diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C index 4c9f81432fc4d0956c8f87f1ba18ca90f6889d1a..37c98e6aa48374be6a930c8a5ee20c2aef93c89f 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C @@ -381,70 +381,82 @@ Foam::labelList Foam::meshRefinement::nearestPatch { const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - // Count number of faces in adaptPatchIDs - label nFaces = 0; - forAll(adaptPatchIDs, i) - { - const polyPatch& pp = patches[adaptPatchIDs[i]]; - nFaces += pp.size(); - } - - // Field on cells and faces. - List<topoDistanceData> cellData(mesh_.nCells()); - List<topoDistanceData> faceData(mesh_.nFaces()); + labelList nearestAdaptPatch; - // Start of changes - labelList patchFaces(nFaces); - List<topoDistanceData> patchData(nFaces); - nFaces = 0; - forAll(adaptPatchIDs, i) + if (adaptPatchIDs.size()) { - label patchI = adaptPatchIDs[i]; - const polyPatch& pp = patches[patchI]; + nearestAdaptPatch.setSize(mesh_.nFaces(), adaptPatchIDs[0]); - forAll(pp, i) + + // Count number of faces in adaptPatchIDs + label nFaces = 0; + forAll(adaptPatchIDs, i) { - patchFaces[nFaces] = pp.start()+i; - patchData[nFaces] = topoDistanceData(patchI, 0); - nFaces++; + const polyPatch& pp = patches[adaptPatchIDs[i]]; + nFaces += pp.size(); } - } - // Propagate information inwards - FaceCellWave<topoDistanceData> deltaCalc - ( - mesh_, - patchFaces, - patchData, - faceData, - cellData, - mesh_.globalData().nTotalCells()+1 - ); - - // And extract - labelList nearestAdaptPatch(mesh_.nFaces(), adaptPatchIDs[0]); + // Field on cells and faces. + List<topoDistanceData> cellData(mesh_.nCells()); + List<topoDistanceData> faceData(mesh_.nFaces()); - bool haveWarned = false; - forAll(faceData, faceI) - { - if (!faceData[faceI].valid(deltaCalc.data())) + // Start of changes + labelList patchFaces(nFaces); + List<topoDistanceData> patchData(nFaces); + nFaces = 0; + forAll(adaptPatchIDs, i) { - if (!haveWarned) + label patchI = adaptPatchIDs[i]; + const polyPatch& pp = patches[patchI]; + + forAll(pp, i) { - WarningIn("meshRefinement::nearestPatch(..)") - << "Did not visit some faces, e.g. face " << faceI - << " at " << mesh_.faceCentres()[faceI] << endl - << "Assigning these cells to patch " - << adaptPatchIDs[0] - << endl; - haveWarned = true; + patchFaces[nFaces] = pp.start()+i; + patchData[nFaces] = topoDistanceData(patchI, 0); + nFaces++; } } - else + + // Propagate information inwards + FaceCellWave<topoDistanceData> deltaCalc + ( + mesh_, + patchFaces, + patchData, + faceData, + cellData, + mesh_.globalData().nTotalCells()+1 + ); + + // And extract + + bool haveWarned = false; + forAll(faceData, faceI) { - nearestAdaptPatch[faceI] = faceData[faceI].data(); + if (!faceData[faceI].valid(deltaCalc.data())) + { + if (!haveWarned) + { + WarningIn("meshRefinement::nearestPatch(..)") + << "Did not visit some faces, e.g. face " << faceI + << " at " << mesh_.faceCentres()[faceI] << endl + << "Assigning these cells to patch " + << adaptPatchIDs[0] + << endl; + haveWarned = true; + } + } + else + { + nearestAdaptPatch[faceI] = faceData[faceI].data(); + } } } + else + { + // Use patch 0 + nearestAdaptPatch.setSize(mesh_.nFaces(), 0); + } return nearestAdaptPatch; }