ENH: polyTopoChange: handle meshes without patches

This commit is contained in:
mattijs
2013-09-03 14:40:49 +01:00
parent 72f8324383
commit cadaee82b7
2 changed files with 36 additions and 36 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,11 +26,8 @@ License
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "polyMesh.H" #include "polyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::mapPolyMesh::mapPolyMesh Foam::mapPolyMesh::mapPolyMesh
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -115,7 +112,6 @@ Foam::mapPolyMesh::mapPolyMesh
} }
// Construct from components and optionally reuse storage
Foam::mapPolyMesh::mapPolyMesh Foam::mapPolyMesh::mapPolyMesh
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -177,31 +173,32 @@ Foam::mapPolyMesh::mapPolyMesh
oldPatchStarts_(oldPatchStarts, reUse), oldPatchStarts_(oldPatchStarts, reUse),
oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse) oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse)
{ {
// Calculate old patch sizes if (oldPatchStarts_.size() > 0)
for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
{ {
oldPatchSizes_[patchI] = // Calculate old patch sizes
oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI]; for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
}
// Set the last one by hand
const label lastPatchID = oldPatchStarts_.size() - 1;
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
if (polyMesh::debug)
{
if (min(oldPatchSizes_) < 0)
{ {
FatalErrorIn("mapPolyMesh::mapPolyMesh(...)") oldPatchSizes_[patchI] =
<< "Calculated negative old patch size. Error in mapping data" oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
<< abort(FatalError); }
// Set the last one by hand
const label lastPatchID = oldPatchStarts_.size() - 1;
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
if (polyMesh::debug)
{
if (min(oldPatchSizes_) < 0)
{
FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
<< "Calculated negative old patch size."
<< " Error in mapping data"
<< abort(FatalError);
}
} }
} }
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* // // ************************************************************************* //

View File

@ -818,22 +818,25 @@ void Foam::polyTopoChange::getFaceOrder
patchSizes.setSize(nPatches_); patchSizes.setSize(nPatches_);
patchSizes = 0; patchSizes = 0;
patchStarts[0] = newFaceI; if (nPatches_ > 0)
for (label faceI = 0; faceI < nActiveFaces; faceI++)
{ {
if (region_[faceI] >= 0) patchStarts[0] = newFaceI;
for (label faceI = 0; faceI < nActiveFaces; faceI++)
{ {
patchSizes[region_[faceI]]++; if (region_[faceI] >= 0)
{
patchSizes[region_[faceI]]++;
}
} }
}
label faceI = patchStarts[0]; label faceI = patchStarts[0];
forAll(patchStarts, patchI) forAll(patchStarts, patchI)
{ {
patchStarts[patchI] = faceI; patchStarts[patchI] = faceI;
faceI += patchSizes[patchI]; faceI += patchSizes[patchI];
}
} }
//if (debug) //if (debug)