Merge branch 'feature_shm_zoning' into develop

Conflicts:
	src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/refinementParameters/refinementParameters.C
	src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H
	src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C
This commit is contained in:
mattijs
2015-12-15 20:10:10 +00:00
9 changed files with 902 additions and 706 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

@ -296,8 +296,18 @@ castellatedMeshControls
locationInMesh (5 0.28 0.43);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
// are only on the boundary of corresponding cellZones.
// Not used if there are no faceZones. The behaviour has changed
// with respect to previous versions:
// true : all intersections with surface are put in faceZone
// (same behaviour as before)
// false : depending on the type of surface intersected:
// - if intersecting surface has faceZone only (so no cellZone)
// leave in faceZone (so behave as if set to true) (= changed
// behaviour)
// - if intersecting surface has faceZone and cellZone
// remove if inbetween same cellZone or if on boundary
// (same behaviour as before)
allowFreeStandingZoneFaces true;

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

@ -74,14 +74,7 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
if (dict.readIfPresent("locationInMesh", locationInMesh))
{
locationsInMesh_.append(locationInMesh);
zonesInMesh_.append("noneIfNotSet");// special name for no cellZone
if (dict.found("locationsInMesh"))
{
FatalIOErrorInFunction(dict)
<< "Cannot both specify 'locationInMesh' and 'locationsInMesh'"
<< exit(FatalIOError);
}
zonesInMesh_.append("none"); // special name for no cellZone
}
List<Tuple2<point, word> > pointsToZone;
@ -95,6 +88,10 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
{
locationsInMesh_[nZones] = pointsToZone[i].first();
zonesInMesh_[nZones] = pointsToZone[i].second();
if (zonesInMesh_[nZones] == word::null)
{
zonesInMesh_[nZones] = "none";
}
nZones++;
}
}
@ -152,12 +149,7 @@ Foam::labelList Foam::refinementParameters::addCellZonesToMesh
labelList zoneIDs(zonesInMesh_.size(), -1);
forAll(zonesInMesh_, i)
{
if
(
zonesInMesh_[i] != word::null
&& zonesInMesh_[i] != "none"
&& zonesInMesh_[i] != "noneIfNotSet"
)
if (zonesInMesh_[i] != word::null && zonesInMesh_[i] != "none")
{
zoneIDs[i] = surfaceZonesInfo::addCellZone
(
@ -242,8 +234,8 @@ Foam::labelList Foam::refinementParameters::zonedLocations
{
if
(
zonesInMesh[i] == word::null
|| zonesInMesh[i] != "noneIfNotSet"
zonesInMesh[i] != word::null
&& zonesInMesh[i] != "none"
)
{
indices.append(i);
@ -264,8 +256,8 @@ Foam::labelList Foam::refinementParameters::unzonedLocations
{
if
(
zonesInMesh[i] != word::null
&& zonesInMesh[i] == "noneIfNotSet"
zonesInMesh[i] == word::null
|| zonesInMesh[i] == "none"
)
{
indices.append(i);

View File

@ -507,7 +507,6 @@ private:
void getIntersections
(
const labelList& surfacesToTest,
const labelList& neiLevel,
const pointField& neiCc,
const labelList& testFaces,
@ -515,7 +514,19 @@ private:
labelList& globalRegion2
) const;
//- Determine patches for baffles on all intersected unnamed faces
//- Calculate intersections on zoned faces. Return per face -1
// or the index of the surface and the orientation w.r.t. surface
void getIntersections
(
const labelList& surfacesToTest,
const pointField& neiCc,
const labelList& testFaces,
labelList& namedSurfaceIndex,
PackedBoolList& posOrientation
) const;
//- Determine patches for baffles
void getBafflePatches
(
const labelList& globalToMasterPatch,
@ -635,13 +646,13 @@ private:
labelList& cellToZone
) const;
//- Finds zone per cell for cells inside named surfaces that have
// an inside point specified.
//- Finds zone per cell for cells inside region for which name
// is specified.
void findCellZoneInsideWalk
(
const labelList& locationSurfaces,
const labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone,
const pointField& locationsInMesh,
const labelList& zonesInMesh,
const labelList& blockedFace, // per face -1 or some index >= 0
labelList& cellToZone
) const;
@ -650,8 +661,8 @@ private:
void findCellZoneInsideWalk
(
const pointField& locationsInMesh,
const wordList& regionsInMesh,
const labelList& blockedFace, // per face -1 or some index >= 0
const wordList& zoneNamesInMesh,
const labelList& faceToZone, // per face -1 or some index >= 0
labelList& cellToZone
) const;
@ -670,6 +681,7 @@ private:
void findCellZoneTopo
(
const pointField& locationsInMesh,
const labelList& allSurfaceIndex,
const labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone,
labelList& cellToZone
@ -679,10 +691,23 @@ private:
// - clear out any blocked faces inbetween same cell zone.
void makeConsistentFaceIndex
(
const labelList& zoneToNamedSurface,
const labelList& cellToZone,
labelList& namedSurfaceIndex
) const;
//- Calculate cellZone allocation
void zonify
(
const bool allowFreeStandingZoneFaces,
const pointField& locationsInMesh,
const wordList& zonesInMesh,
labelList& cellToZone,
labelList& namedSurfaceIndex,
PackedBoolList& posOrientation
) const;
//- Put cells into cellZone, faces into faceZone
void zonify
(

View File

@ -226,6 +226,32 @@ Foam::labelList Foam::surfaceZonesInfo::getNamedSurfaces
}
Foam::labelList Foam::surfaceZonesInfo::getStandaloneNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
)
{
labelList namedSurfaces(surfList.size());
label namedI = 0;
forAll(surfList, surfI)
{
if
(
surfList.set(surfI)
&& surfList[surfI].faceZoneName().size()
&& !surfList[surfI].cellZoneName().size()
)
{
namedSurfaces[namedI++] = surfI;
}
}
namedSurfaces.setSize(namedI);
return namedSurfaces;
}
Foam::labelList Foam::surfaceZonesInfo::getClosedNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList,

View File

@ -191,6 +191,12 @@ public:
const PtrList<surfaceZonesInfo>& surfList
);
//- Get indices of named surfaces without a cellZone
static labelList getStandaloneNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
);
//- Get indices of surfaces with a cellZone that are closed and
// have 'inside' or 'outside' selection.
static labelList getClosedNamedSurfaces