diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C index f892a0d7c8..faf2922955 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,11 +26,8 @@ License #include "mapPolyMesh.H" #include "polyMesh.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::mapPolyMesh::mapPolyMesh ( const polyMesh& mesh, @@ -115,7 +112,6 @@ Foam::mapPolyMesh::mapPolyMesh } -// Construct from components and optionally reuse storage Foam::mapPolyMesh::mapPolyMesh ( const polyMesh& mesh, @@ -177,31 +173,32 @@ Foam::mapPolyMesh::mapPolyMesh oldPatchStarts_(oldPatchStarts, reUse), oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse) { - // Calculate old patch sizes - for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++) + if (oldPatchStarts_.size() > 0) { - oldPatchSizes_[patchI] = - oldPatchStarts_[patchI + 1] - oldPatchStarts_[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) + // Calculate old patch sizes + for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++) { - FatalErrorIn("mapPolyMesh::mapPolyMesh(...)") - << "Calculated negative old patch size. Error in mapping data" - << abort(FatalError); + oldPatchSizes_[patchI] = + oldPatchStarts_[patchI + 1] - oldPatchStarts_[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(...)") + << "Calculated negative old patch size." + << " Error in mapping data" + << abort(FatalError); + } } } } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 49ee1a445e..23e39f203d 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -818,22 +818,25 @@ void Foam::polyTopoChange::getFaceOrder patchSizes.setSize(nPatches_); patchSizes = 0; - patchStarts[0] = newFaceI; - - for (label faceI = 0; faceI < nActiveFaces; faceI++) + if (nPatches_ > 0) { - 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) - { - patchStarts[patchI] = faceI; - faceI += patchSizes[patchI]; + forAll(patchStarts, patchI) + { + patchStarts[patchI] = faceI; + faceI += patchSizes[patchI]; + } } //if (debug)