ENH: autoHexMesh: allow location-in-mesh to be made into a cellZone

Normally the location-in-mesh is equivalent to a cellZone -1. This can
now be overridden by a surface-specified cellZone as before.
This commit is contained in:
mattijs
2015-12-10 11:50:42 +00:00
parent 3e48a99c5f
commit 0bb501b69a
4 changed files with 101 additions and 6 deletions

View File

@ -58,6 +58,7 @@ Description
#include "globalIndex.H"
#include "IOmanip.H"
#include "decompositionModel.H"
#include "fvMeshTools.H"
using namespace Foam;
@ -813,6 +814,7 @@ int main(int argc, char *argv[])
readScalar(meshDict.lookup("mergeTolerance"))
);
const Switch keepPatches(meshDict.lookupOrDefault("keepPatches", false));
// Read decomposePar dictionary
@ -1517,6 +1519,12 @@ int main(int argc, char *argv[])
motionDict
);
// Remove zero sized patches originating from faceZones
if (!keepPatches && !wantSnap && !wantLayers)
{
fvMeshTools::removeEmptyPatches(mesh, true);
}
writeMesh
(
"Refined mesh",
@ -1559,6 +1567,12 @@ int main(int argc, char *argv[])
snapParams
);
// Remove zero sized patches originating from faceZones
if (!keepPatches && !wantLayers)
{
fvMeshTools::removeEmptyPatches(mesh, true);
}
writeMesh
(
"Snapped mesh",
@ -1609,6 +1623,12 @@ int main(int argc, char *argv[])
distributor
);
// Remove zero sized patches originating from faceZones
if (!keepPatches)
{
fvMeshTools::removeEmptyPatches(mesh, true);
}
writeMesh
(
"Layer mesh",
@ -1622,6 +1642,7 @@ int main(int argc, char *argv[])
}
{
// Check final mesh
Info<< "Checking final mesh ..." << endl;

View File

@ -355,6 +355,69 @@ void Foam::fvMeshTools::reorderPatches
}
Foam::labelList Foam::fvMeshTools::removeEmptyPatches
(
fvMesh& mesh,
const bool validBoundary
)
{
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
labelList newToOld(pbm.size());
labelList oldToNew(pbm.size(), -1);
label newI = 0;
// Assumes all non-coupled boundaries are on all processors!
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (!isA<processorPolyPatch>(pp))
{
label nFaces = pp.size();
if (validBoundary)
{
reduce(nFaces, sumOp<label>());
}
if (nFaces > 0)
{
newToOld[newI] = patchI;
oldToNew[patchI] = newI++;
}
}
}
// Same for processor patches (but need no reduction)
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (isA<processorPolyPatch>(pp) && pp.size())
{
newToOld[newI] = patchI;
oldToNew[patchI] = newI++;
}
}
newToOld.setSize(newI);
// Move all deleteable patches to the end
forAll(oldToNew, patchI)
{
if (oldToNew[patchI] == -1)
{
oldToNew[patchI] = newI++;
}
}
reorderPatches(mesh, oldToNew, newToOld.size(), validBoundary);
return newToOld;
}
Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
(
const IOobject& io,

View File

@ -113,7 +113,7 @@ public:
static void zeroPatchFields(fvMesh& mesh, const label patchI);
//- Reorder and remove trailing patches. If validBoundary call is parallel
// synced and all add the same patch with same settings
// synced
static void reorderPatches
(
fvMesh&,
@ -122,6 +122,11 @@ public:
const bool validBoundary
);
//- Remove zero sized patches. All but processor patches are
// assumed to be present on all processors (so size will be reduced
// if validBoundary). Return map from new
// to old patches
static labelList removeEmptyPatches(fvMesh&, const bool validBoundary);
//- Read mesh or create dummy mesh (0 cells, >0 patches). Works in two
// modes according to masterOnlyReading:
@ -133,7 +138,6 @@ public:
const IOobject& io,
const bool masterOnlyReading
);
};

View File

@ -1390,14 +1390,21 @@ void Foam::meshRefinement::findCellZoneGeometric
forAll(insideSurfaces, cellI)
{
if (cellToZone[cellI] == -2)
{
label surfI = insideSurfaces[cellI];
label surfI = insideSurfaces[cellI];
if (surfI != -1)
if (surfI != -1)
{
if (cellToZone[cellI] == -2)
{
cellToZone[cellI] = surfaceToCellZone[surfI];
}
else if (cellToZone[cellI] == -1)
{
// ? Allow named surface to override background zone (-1)
// This is used in the multiRegionHeater tutorial where the
// locationInMesh is inside a named surface.
cellToZone[cellI] = surfaceToCellZone[surfI];
}
}
}