Merge branch 'feature/foamyHexMesh-baffles'

This commit is contained in:
laurence
2013-09-03 11:25:14 +01:00
15 changed files with 1023 additions and 720 deletions

View File

@ -265,6 +265,7 @@ Foam::conformationSurfaces::conformationSurfaces
allGeometryToSurfaces_(),
normalVolumeTypes_(),
patchNames_(),
surfZones_(),
regionOffset_(),
patchInfo_(),
globalBounds_(),
@ -275,105 +276,129 @@ Foam::conformationSurfaces::conformationSurfaces
surfaceConformationDict.subDict("geometryToConformTo")
);
const label nSurf = surfacesDict.size();
const dictionary& additionalFeaturesDict
(
surfaceConformationDict.subDict("additionalFeatures")
);
// Wildcard specification : loop over all surface, all regions
// and try to find a match.
// Count number of surfaces.
label surfI = 0;
forAll(allGeometry.names(), geomI)
{
const word& geomName = allGeometry_.names()[geomI];
if (surfacesDict.found(geomName))
{
surfI++;
}
}
const label nAddFeat = additionalFeaturesDict.size();
Info<< nl << "Reading geometryToConformTo" << endl;
surfaces_.setSize(nSurf, -1);
allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
normalVolumeTypes_.setSize(nSurf);
normalVolumeTypes_.setSize(surfI);
surfaces_.setSize(surfI);
surfZones_.setSize(surfI);
// Features may be attached to host surfaces or independent
features_.setSize(nSurf + nAddFeat);
features_.setSize(surfI + nAddFeat);
label featureI = 0;
regionOffset_.setSize(nSurf, 0);
regionOffset_.setSize(surfI, 0);
PtrList<dictionary> globalPatchInfo(nSurf);
List<Map<autoPtr<dictionary> > > regionPatchInfo(nSurf);
List<sideVolumeType> globalVolumeTypes(nSurf);
List<Map<sideVolumeType> > regionVolumeTypes(nSurf);
PtrList<dictionary> globalPatchInfo(surfI);
List<Map<autoPtr<dictionary> > > regionPatchInfo(surfI);
List<sideVolumeType> globalVolumeTypes(surfI);
List<Map<sideVolumeType> > regionVolumeTypes(surfI);
label surfI = 0;
HashSet<word> unmatchedKeys(surfacesDict.toc());
forAllConstIter(dictionary, surfacesDict, iter)
surfI = 0;
forAll(allGeometry_.names(), geomI)
{
word surfaceName = iter().keyword();
const word& geomName = allGeometry_.names()[geomI];
surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName);
const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
if (surfaces_[surfI] < 0)
if (ePtr)
{
FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces")
<< "No surface " << surfaceName << " found. "
<< "Valid geometry is " << nl << allGeometry_.names()
<< exit(FatalError);
const dictionary& dict = ePtr->dict();
unmatchedKeys.erase(ePtr->keyword());
surfaces_[surfI] = geomI;
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
// Surface zones
if (dict.found("faceZone"))
{
surfZones_.set(surfI, new surfaceZonesInfo(surface, dict));
}
allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
Info<< nl << " " << surfaceName << endl;
Info<< nl << " " << geomName << endl;
const wordList& regionNames =
allGeometry_.regionNames()[surfaces_[surfI]];
patchNames_.append(regionNames);
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
globalVolumeTypes[surfI] =
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
surfaceSubDict.lookupOrDefault<word>("meshableSide", "inside")
dict.lookupOrDefault<word>
(
"meshableSide",
"inside"
)
]
);
if (!globalVolumeTypes[surfI])
{
if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
if (!surface.hasVolumeType())
{
WarningIn("conformationSurfaces::conformationSurfaces(..)")
<< "Non-baffle surface "
<< allGeometry_[surfaces_[surfI]].name()
<< surface.name()
<< " does not allow inside/outside queries."
<< " This usually is an error." << endl;
}
}
// Load patch info
if (surfaceSubDict.found("patchInfo"))
if (dict.found("patchInfo"))
{
globalPatchInfo.set
(
surfI,
surfaceSubDict.subDict("patchInfo").clone()
dict.subDict("patchInfo").clone()
);
}
readFeatures
(
surfI,
surfaceSubDict,
surfaceName,
dict,
geomName,
featureI
);
const wordList& rNames = allGeometry_[surfaces_[surfI]].regions();
const wordList& rNames = surface.regions();
if (surfaceSubDict.found("regions"))
if (dict.found("regions"))
{
const dictionary& regionsDict = surfaceSubDict.subDict("regions");
const dictionary& regionsDict = dict.subDict("regions");
forAll(rNames, regionI)
{
@ -418,6 +443,21 @@ Foam::conformationSurfaces::conformationSurfaces
surfI++;
}
}
if (unmatchedKeys.size() > 0)
{
IOWarningIn
(
"conformationSurfaces::conformationSurfaces(..)",
surfacesDict
) << "Not all entries in conformationSurfaces dictionary were used."
<< " The following entries were not used : "
<< unmatchedKeys.sortedToc()
<< endl;
}
// Calculate local to global region offset
label nRegions = 0;
@ -425,7 +465,9 @@ Foam::conformationSurfaces::conformationSurfaces
forAll(surfaces_, surfI)
{
regionOffset_[surfI] = nRegions;
nRegions += allGeometry_[surfaces_[surfI]].regions().size();
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
nRegions += surface.regions().size();
}
// Rework surface specific information into information per global region
@ -434,7 +476,9 @@ Foam::conformationSurfaces::conformationSurfaces
forAll(surfaces_, surfI)
{
label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
label nRegions = surface.regions().size();
// Initialise to global (i.e. per surface)
for (label i = 0; i < nRegions; i++)
@ -535,6 +579,30 @@ Foam::conformationSurfaces::conformationSurfaces
Info<< features_[fI].name() << endl;
}
}
Info<< "ZONES" << endl;
forAll(surfZones_, surfI)
{
if (surfZones_.set(surfI))
{
const surfaceZonesInfo& sInfo = surfZones_[surfI];
Info<< " " << surfI << nl
<< " faceZoneName = " << sInfo.faceZoneName() << nl
<< " cellZoneName = " << sInfo.cellZoneName() << nl
<< " zoneInside = "
<< surfaceZonesInfo::areaSelectionAlgoNames[sInfo.zoneInside()]
<< nl
<< " zoneInsidePoint = " << sInfo.zoneInsidePoint() << nl
<< " faceType = "
<< surfaceZonesInfo::faceZoneTypeNames[sInfo.faceType()]
<< endl;
}
else
{
Info<< " " << surfI << " EMPTY" << endl;
}
}
}
@ -1165,13 +1233,7 @@ Foam::label Foam::conformationSurfaces::findPatch(const point& pt) const
pointIndexHit surfHit;
label hitSurface;
findSurfaceNearest
(
pt,
sqr(GREAT),
surfHit,
hitSurface
);
findSurfaceNearest(pt, sqr(GREAT), surfHit, hitSurface);
return getPatchID(hitSurface, surfHit);
}
@ -1229,11 +1291,7 @@ void Foam::conformationSurfaces::getNormal
vectorField& normal
) const
{
allGeometry_[hitSurface].getNormal
(
surfHit,
normal
);
allGeometry_[hitSurface].getNormal(surfHit, normal);
const label patchID = regionOffset_[allGeometryToSurfaces_[hitSurface]];

View File

@ -40,6 +40,7 @@ SourceFiles
#include "extendedFeatureEdgeMesh.H"
#include "boolList.H"
#include "volumeType.H"
#include "surfaceZonesInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -86,6 +87,9 @@ class conformationSurfaces
// surfaces to be reproduced in the meshed geometry
List<word> patchNames_;
//- List of surface zone (face and cell zone) information
PtrList<surfaceZonesInfo> surfZones_;
//- The offset between the patch indices of the individual surface and
// the entry in the overall patch list
labelList regionOffset_;
@ -170,6 +174,9 @@ public:
//- Return the patch names
inline const List<word>& patchNames() const;
//- Return the surfaceZonesInfo
inline const PtrList<surfaceZonesInfo>& surfZones() const;
//- Return the patch info
inline const PtrList<dictionary>& patchInfo() const;

View File

@ -56,6 +56,13 @@ const Foam::List<Foam::word>& Foam::conformationSurfaces::patchNames() const
}
const Foam::PtrList<Foam::surfaceZonesInfo>&
Foam::conformationSurfaces::surfZones() const
{
return surfZones_;
}
const Foam::PtrList<Foam::dictionary>&
Foam::conformationSurfaces::patchInfo() const
{

View File

@ -98,19 +98,8 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
labelList surfaces(surfI);
wordList names(surfI);
wordList faceZoneNames(surfI);
wordList cellZoneNames(surfI);
List<refinementSurfaces::areaSelectionAlgo> zoneInside
(
surfI,
refinementSurfaces::NONE
);
pointField zoneInsidePoints(surfI);
List<refinementSurfaces::faceZoneType> faceType
(
surfI,
refinementSurfaces::INTERNAL
);
PtrList<surfaceZonesInfo> surfZones(surfI);
labelList regionOffset(surfI);
labelList globalMinLevel(surfI, 0);
@ -123,21 +112,24 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
List<Map<scalar> > regionAngle(surfI);
List<Map<autoPtr<dictionary> > > regionPatchInfo(surfI);
HashSet<word> unmatchedKeys(surfacesDict.toc());
surfI = 0;
forAll(allGeometry.names(), geomI)
{
const word& geomName = allGeometry.names()[geomI];
const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
// Definition of surfaces to conform to
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (surfacesDict.found(geomName))
if (ePtr)
{
const dictionary& shapeDict = ePtr->dict();
unmatchedKeys.erase(ePtr->keyword());
names[surfI] = geomName;
surfaces[surfI] = geomI;
const dictionary& shapeDict = shapeControlDict.subDict(geomName);
const searchableSurface& surface = allGeometry[geomI];
// Find the index in shapeControlDict
// Invert surfaceCellSize to get the refinementLevel
@ -160,107 +152,26 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
globalMaxLevel[surfI] = refLevel;
globalLevelIncr[surfI] = gapLevelIncrement;
const dictionary& dict = surfacesDict.subDict(geomName);
// Global zone names per surface
if (dict.readIfPresent("faceZone", faceZoneNames[surfI]))
{
// Read optional entry to determine inside of faceZone
word method;
bool hasSide = dict.readIfPresent("cellZoneInside", method);
if (hasSide)
{
zoneInside[surfI] =
refinementSurfaces::areaSelectionAlgoNames[method];
if (zoneInside[surfI] == refinementSurfaces::INSIDEPOINT)
{
dict.lookup("insidePoint") >> zoneInsidePoints[surfI];
}
}
else
{
// Check old syntax
bool inside;
if (dict.readIfPresent("zoneInside", inside))
{
hasSide = true;
zoneInside[surfI] =
(
inside
? refinementSurfaces::INSIDE
: refinementSurfaces::OUTSIDE
);
}
}
// Read optional cellZone name
if (dict.readIfPresent("cellZone", cellZoneNames[surfI]))
{
if
(
(
zoneInside[surfI] == refinementSurfaces::INSIDE
|| zoneInside[surfI] == refinementSurfaces::OUTSIDE
)
&& !allGeometry[surfaces[surfI]].hasVolumeType()
)
{
IOWarningIn
(
"createRefinementSurfaces(..)",
dict
) << "Illegal entry zoneInside "
<< refinementSurfaces::areaSelectionAlgoNames
[
zoneInside[surfI]
]
<< " for faceZone "
<< faceZoneNames[surfI]
<< " since surface " << names[surfI]
<< " is not closed." << endl;
}
}
else if (hasSide)
{
IOWarningIn
(
"createRefinementSurfaces(..)",
dict
) << "Unused entry zoneInside for faceZone "
<< faceZoneNames[surfI]
<< " since no cellZone specified."
<< endl;
}
// How to handle faces on faceZone
word faceTypeMethod;
if (dict.readIfPresent("faceType", faceTypeMethod))
{
faceType[surfI] =
refinementSurfaces::faceZoneTypeNames[faceTypeMethod];
}
}
// Surface zones
surfZones.set(surfI, new surfaceZonesInfo(surface, shapeDict));
// Global perpendicular angle
if (dict.found("patchInfo"))
if (shapeDict.found("patchInfo"))
{
globalPatchInfo.set
(
surfI,
dict.subDict("patchInfo").clone()
shapeDict.subDict("patchInfo").clone()
);
}
// Per region override of patchInfo
if (dict.found("regions"))
if (shapeDict.found("regions"))
{
const dictionary& regionsDict = dict.subDict("regions");
const dictionary& regionsDict = shapeDict.subDict("regions");
const wordList& regionNames =
allGeometry[surfaces[surfI]].regions();
@ -333,6 +244,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
}
}
}
surfI++;
}
}
@ -403,11 +315,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
allGeometry,
surfaces,
names,
faceZoneNames,
cellZoneNames,
zoneInside,
zoneInsidePoints,
faceType,
surfZones,
regionOffset,
minLevel,
maxLevel,
@ -1188,7 +1096,7 @@ int main(int argc, char *argv[])
Info<< surfaces.names()[surfI] << ':' << nl << nl;
if (surfaces.faceZoneNames()[surfI].empty())
if (surfaces.surfZones()[surfI].faceZoneName().empty())
{
// 'Normal' surface
forAll(regNames, i)

View File

@ -18,6 +18,7 @@ $(autoHexMesh)/meshRefinement/meshRefinementMerge.C
$(autoHexMesh)/meshRefinement/meshRefinementProblemCells.C
$(autoHexMesh)/meshRefinement/meshRefinementRefine.C
$(autoHexMesh)/refinementFeatures/refinementFeatures.C
$(autoHexMesh)/refinementSurfaces/surfaceZonesInfo.C
$(autoHexMesh)/refinementSurfaces/refinementSurfaces.C
$(autoHexMesh)/shellSurfaces/shellSurfaces.C
$(autoHexMesh)/trackedParticle/trackedParticle.C

View File

@ -927,7 +927,10 @@ void Foam::autoRefineDriver::zonify
// into that surface's faceZone. All cells inside faceZone get given the
// same cellZone.
if (meshRefiner_.surfaces().getNamedSurfaces().size())
const labelList namedSurfaces =
surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones());
if (namedSurfaces.size())
{
Info<< nl
<< "Introducing zones for interfaces" << nl

View File

@ -590,7 +590,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::mergeZoneBaffles
const List<labelPair>& baffles
)
{
labelList zonedSurfaces = meshRefiner_.surfaces().getNamedSurfaces();
labelList zonedSurfaces =
surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones());
autoPtr<mapPolyMesh> map;
@ -815,9 +816,15 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
// Divide surfaces into zoned and unzoned
labelList zonedSurfaces =
meshRefiner.surfaces().getNamedSurfaces();
surfaceZonesInfo::getNamedSurfaces
(
meshRefiner.surfaces().surfZones()
);
labelList unzonedSurfaces =
meshRefiner.surfaces().getUnnamedSurfaces();
surfaceZonesInfo::getUnnamedSurfaces
(
meshRefiner.surfaces().surfZones()
);
// 1. All points to non-interface surfaces
@ -854,7 +861,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Surfaces with zone information
const wordList& faceZoneNames = surfaces.faceZoneNames();
const PtrList<surfaceZonesInfo>& surfZones = surfaces.surfZones();
// Current best snap distance
scalarField minSnapDist(snapDist);
@ -863,6 +870,8 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
{
label zoneSurfI = zonedSurfaces[i];
const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
const labelList surfacesToTest(1, zoneSurfI);
// Get indices of points both on faceZone and on pp.
@ -872,7 +881,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
(
mesh,
pp,
faceZoneNames[zoneSurfI]
faceZoneName
)
);
@ -1369,8 +1378,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface
indirectPrimitivePatch& pp = ppPtr();
// Divide surfaces into zoned and unzoned
labelList zonedSurfaces = surfaces.getNamedSurfaces();
labelList unzonedSurfaces = surfaces.getUnnamedSurfaces();
labelList zonedSurfaces =
surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones());
labelList unzonedSurfaces =
surfaceZonesInfo::getUnnamedSurfaces(surfaces.surfZones());
// Faces that do not move
@ -1386,13 +1397,13 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface
}
// 2. All faces on zoned surfaces
const wordList& faceZoneNames = surfaces.faceZoneNames();
const PtrList<surfaceZonesInfo>& surfZones = surfaces.surfZones();
const faceZoneMesh& fZones = mesh.faceZones();
forAll(zonedSurfaces, i)
{
const label zoneSurfI = zonedSurfaces[i];
const faceZone& fZone = fZones[faceZoneNames[zoneSurfI]];
const faceZone& fZone = fZones[surfZones[zoneSurfI].faceZoneName()];
forAll(fZone, i)
{
@ -1557,9 +1568,7 @@ void Foam::autoSnapDriver::doSnap
{
const faceZoneMesh& fZones = mesh.faceZones();
const refinementSurfaces& surfaces = meshRefiner_.surfaces();
const wordList& faceZoneNames = surfaces.faceZoneNames();
const List<refinementSurfaces::faceZoneType>& faceType =
surfaces.faceType();
const PtrList<surfaceZonesInfo>& surfZones = surfaces.surfZones();
// Determine which
// - faces to remove from list of baffles (so not merge)
@ -1568,18 +1577,23 @@ void Foam::autoSnapDriver::doSnap
label nFilterFaces = 0;
PackedBoolList duplicatePoint(mesh.nPoints());
label nDuplicatePoints = 0;
forAll(faceZoneNames, surfI)
forAll(surfZones, surfI)
{
const word& faceZoneName = surfZones[surfI].faceZoneName();
const surfaceZonesInfo::faceZoneType& faceType =
surfZones[surfI].faceType();
if
(
faceType[surfI] == refinementSurfaces::BAFFLE
|| faceType[surfI] == refinementSurfaces::BOUNDARY
faceType == surfaceZonesInfo::BAFFLE
|| faceType == surfaceZonesInfo::BOUNDARY
)
{
if (faceZoneNames[surfI].size())
if (faceZoneName.size())
{
// Filter out all faces for this zone.
label zoneI = fZones.findZoneID(faceZoneNames[surfI]);
label zoneI = fZones.findZoneID(faceZoneName);
const faceZone& fZone = fZones[zoneI];
forAll(fZone, i)
{
@ -1588,7 +1602,7 @@ void Foam::autoSnapDriver::doSnap
nFilterFaces++;
}
if (faceType[surfI] == refinementSurfaces::BOUNDARY)
if (faceType == surfaceZonesInfo::BOUNDARY)
{
forAll(fZone, i)
{

View File

@ -337,8 +337,10 @@ void Foam::autoSnapDriver::calcNearestFace
faceSurfaceGlobalRegion = -1;
// Divide surfaces into zoned and unzoned
labelList zonedSurfaces = surfaces.getNamedSurfaces();
labelList unzonedSurfaces = surfaces.getUnnamedSurfaces();
const labelList zonedSurfaces =
surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones());
const labelList unzonedSurfaces =
surfaceZonesInfo::getUnnamedSurfaces(surfaces.surfZones());
// Per pp face the current surface snapped to
labelList snapSurf(pp.size(), -1);
@ -349,20 +351,22 @@ void Foam::autoSnapDriver::calcNearestFace
// Zoned faces only attract to corresponding surface
// Extract faces per zone
const wordList& faceZoneNames = surfaces.faceZoneNames();
const PtrList<surfaceZonesInfo>& surfZones = surfaces.surfZones();
forAll(zonedSurfaces, i)
{
label zoneSurfI = zonedSurfaces[i];
const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
// Get indices of faces on pp that are also in zone
label zoneI = mesh.faceZones().findZoneID(faceZoneNames[zoneSurfI]);
label zoneI = mesh.faceZones().findZoneID(faceZoneName);
if (zoneI == -1)
{
FatalErrorIn
(
"autoSnapDriver::calcNearestFace(..)"
) << "Problem. Cannot find zone " << faceZoneNames[zoneSurfI]
) << "Problem. Cannot find zone " << faceZoneName
<< exit(FatalError);
}
const faceZone& fZone = mesh.faceZones()[zoneI];

View File

@ -1235,19 +1235,22 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// keep owner&neighbour of such a surface zone on the same
// processor.
const wordList& fzNames = surfaces().faceZoneNames();
const PtrList<surfaceZonesInfo>& surfZones =
surfaces().surfZones();
const faceZoneMesh& fZones = mesh_.faceZones();
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
// Get faces whose owner and neighbour should stay together,
// i.e. they are not 'blocked'.
forAll(fzNames, surfI)
forAll(surfZones, surfI)
{
if (fzNames[surfI].size())
const word& fzName = surfZones[surfI].faceZoneName();
if (fzName.size())
{
// Get zone
const faceZone& fZone = fZones[fzNames[surfI]];
const faceZone& fZone = fZones[fzName];
forAll(fZone, i)
{

View File

@ -287,7 +287,10 @@ void Foam::meshRefinement::getBafflePatches
const pointField& cellCentres = mesh_.cellCentres();
// Surfaces that need to be baffled
const labelList surfacesToBaffle(surfaces_.getUnnamedSurfaces());
const labelList surfacesToBaffle
(
surfaceZonesInfo::getUnnamedSurfaces(surfaces_.surfZones())
);
ownPatch.setSize(mesh_.nFaces());
ownPatch = -1;
@ -416,15 +419,17 @@ Foam::Map<Foam::labelPair> Foam::meshRefinement::getZoneBafflePatches
{
Map<labelPair> bafflePatch(mesh_.nFaces()/1000);
const wordList& faceZoneNames = surfaces_.faceZoneNames();
const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
const faceZoneMesh& fZones = mesh_.faceZones();
forAll(faceZoneNames, surfI)
forAll(surfZones, surfI)
{
if (faceZoneNames[surfI].size())
const word& faceZoneName = surfZones[surfI].faceZoneName();
if (faceZoneName.size())
{
// Get zone
label zoneI = fZones.findZoneID(faceZoneNames[surfI]);
label zoneI = fZones.findZoneID(faceZoneName);
const faceZone& fZone = fZones[zoneI];
@ -703,7 +708,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createZoneBaffles
List<labelPair>& baffles
)
{
labelList zonedSurfaces = surfaces_.getNamedSurfaces();
const labelList zonedSurfaces
(
surfaceZonesInfo::getNamedSurfaces(surfaces_.surfZones())
);
autoPtr<mapPolyMesh> map;
@ -1434,11 +1442,14 @@ void Foam::meshRefinement::findCellZoneInsideWalk
// Force calculation of face decomposition (used in findCell)
(void)mesh_.tetBasePtIs();
const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
// For all locationSurface find the cell
forAll(locationSurfaces, i)
{
label surfI = locationSurfaces[i];
const point& insidePoint = surfaces_.zoneInsidePoints()[surfI];
const point& insidePoint = surfZones[surfI].zoneInsidePoint();
Info<< "For surface " << surfaces_.names()[surfI]
<< " finding inside point " << insidePoint
@ -2503,143 +2514,36 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
const bool allowFreeStandingZoneFaces
)
{
const wordList& cellZoneNames = surfaces_.cellZoneNames();
const wordList& faceZoneNames = surfaces_.faceZoneNames();
const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
labelList namedSurfaces(surfaces_.getNamedSurfaces());
labelList namedSurfaces(surfaceZonesInfo::getNamedSurfaces(surfZones));
forAll(namedSurfaces, i)
{
label surfI = namedSurfaces[i];
Info<< "Surface : " << surfaces_.names()[surfI] << nl
<< " faceZone : " << faceZoneNames[surfI] << nl
<< " cellZone : " << cellZoneNames[surfI] << endl;
<< " faceZone : " << surfZones[surfI].faceZoneName() << nl
<< " cellZone : " << surfZones[surfI].cellZoneName() << endl;
}
// Add zones to mesh
labelList surfaceToFaceZone(faceZoneNames.size(), -1);
{
faceZoneMesh& faceZones = mesh_.faceZones();
forAll(namedSurfaces, i)
{
label surfI = namedSurfaces[i];
label zoneI = faceZones.findZoneID(faceZoneNames[surfI]);
if (zoneI == -1)
{
zoneI = faceZones.size();
faceZones.setSize(zoneI+1);
faceZones.set
labelList surfaceToFaceZone =
surfaceZonesInfo::addFaceZonesToMesh
(
zoneI,
new faceZone
(
faceZoneNames[surfI], //name
labelList(0), //addressing
boolList(0), //flipmap
zoneI, //index
faceZones //faceZoneMesh
)
surfZones,
namedSurfaces,
mesh_
);
}
if (debug)
{
Pout<< "Faces on " << surfaces_.names()[surfI]
<< " will go into faceZone " << zoneI << endl;
}
surfaceToFaceZone[surfI] = zoneI;
}
// Check they are synced
List<wordList> allFaceZones(Pstream::nProcs());
allFaceZones[Pstream::myProcNo()] = faceZones.names();
Pstream::gatherList(allFaceZones);
Pstream::scatterList(allFaceZones);
for (label procI = 1; procI < allFaceZones.size(); procI++)
{
if (allFaceZones[procI] != allFaceZones[0])
{
FatalErrorIn
labelList surfaceToCellZone =
surfaceZonesInfo::addCellZonesToMesh
(
"meshRefinement::zonify"
"(const label, const point&)"
) << "Zones not synchronised among processors." << nl
<< " Processor0 has faceZones:" << allFaceZones[0]
<< " , processor" << procI
<< " has faceZones:" << allFaceZones[procI]
<< exit(FatalError);
}
}
}
labelList surfaceToCellZone(cellZoneNames.size(), -1);
{
cellZoneMesh& cellZones = mesh_.cellZones();
forAll(namedSurfaces, i)
{
label surfI = namedSurfaces[i];
if (cellZoneNames[surfI] != word::null)
{
label zoneI = cellZones.findZoneID(cellZoneNames[surfI]);
if (zoneI == -1)
{
zoneI = cellZones.size();
cellZones.setSize(zoneI+1);
cellZones.set
(
zoneI,
new cellZone
(
cellZoneNames[surfI], //name
labelList(0), //addressing
zoneI, //index
cellZones //cellZoneMesh
)
surfZones,
namedSurfaces,
mesh_
);
}
if (debug)
{
Pout<< "Cells inside " << surfaces_.names()[surfI]
<< " will go into cellZone " << zoneI << endl;
}
surfaceToCellZone[surfI] = zoneI;
}
}
// Check they are synced
List<wordList> allCellZones(Pstream::nProcs());
allCellZones[Pstream::myProcNo()] = cellZones.names();
Pstream::gatherList(allCellZones);
Pstream::scatterList(allCellZones);
for (label procI = 1; procI < allCellZones.size(); procI++)
{
if (allCellZones[procI] != allCellZones[0])
{
FatalErrorIn
(
"meshRefinement::zonify"
"(const label, const point&)"
) << "Zones not synchronised among processors." << nl
<< " Processor0 has cellZones:" << allCellZones[0]
<< " , processor" << procI
<< " has cellZones:" << allCellZones[procI]
<< exit(FatalError);
}
}
}
const pointField& cellCentres = mesh_.cellCentres();
@ -2663,7 +2567,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
{
// Statistics: number of faces per faceZone
labelList nSurfFaces(faceZoneNames.size(), 0);
labelList nSurfFaces(surfZones.size(), 0);
// Note: for all internal faces? internal + coupled?
// Since zonify is run after baffling the surfaceIndex_ on baffles is
@ -2767,7 +2671,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
}
// surfaceIndex migh have different surfaces on both sides if
// surfaceIndex might have different surfaces on both sides if
// there happen to be a (obviously thin) surface with different
// regions between the cell centres. If one is on a named surface
// and the other is not this might give problems so sync.
@ -2806,7 +2710,15 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Closed surfaces with cellZone specified.
labelList closedNamedSurfaces(surfaces_.getClosedNamedSurfaces());
labelList closedNamedSurfaces
(
surfaceZonesInfo::getClosedNamedSurfaces
(
surfZones,
surfaces_.geometry(),
surfaces_.surfaces()
)
);
if (closedNamedSurfaces.size())
{
@ -2830,7 +2742,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
// Set using provided locations
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelList locationSurfaces(surfaces_.getInsidePointNamedSurfaces());
labelList locationSurfaces
(
surfaceZonesInfo::getInsidePointNamedSurfaces(surfZones)
);
if (locationSurfaces.size())
{
Info<< "Found " << locationSurfaces.size()

View File

@ -568,7 +568,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
labelList hitSurface;
surfaces_.findNearest
(
surfaces_.getUnnamedSurfaces(),
surfaceZonesInfo::getUnnamedSurfaces(surfaces_.surfZones()),
localPoints,
scalarField(localPoints.size(), sqr(GREAT)), // sqr of attraction
hitSurface,

View File

@ -33,45 +33,6 @@ License
#include "UPtrList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::refinementSurfaces::areaSelectionAlgo,
4
>::names[] =
{
"inside",
"outside",
"insidePoint",
"none"
};
}
const Foam::NamedEnum<Foam::refinementSurfaces::areaSelectionAlgo, 4>
Foam::refinementSurfaces::areaSelectionAlgoNames;
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::refinementSurfaces::faceZoneType,
3
>::names[] =
{
"internal",
"baffle",
"boundary"
};
}
const Foam::NamedEnum<Foam::refinementSurfaces::faceZoneType, 3>
Foam::refinementSurfaces::faceZoneTypeNames;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::refinementSurfaces::refinementSurfaces
@ -84,19 +45,15 @@ Foam::refinementSurfaces::refinementSurfaces
allGeometry_(allGeometry),
surfaces_(surfacesDict.size()),
names_(surfacesDict.size()),
faceZoneNames_(surfacesDict.size()),
cellZoneNames_(surfacesDict.size()),
zoneInside_(surfacesDict.size(), NONE),
zoneInsidePoints_(surfacesDict.size()),
faceType_(surfacesDict.size(), INTERNAL),
surfZones_(surfacesDict.size()),
regionOffset_(surfacesDict.size())
{
// Wilcard specification : loop over all surface, all regions
// Wildcard specification : loop over all surface, all regions
// and try to find a match.
// Count number of surfaces.
label surfI = 0;
forAll(allGeometry.names(), geomI)
forAll(allGeometry_.names(), geomI)
{
const word& geomName = allGeometry_.names()[geomI];
@ -109,10 +66,7 @@ Foam::refinementSurfaces::refinementSurfaces
// Size lists
surfaces_.setSize(surfI);
names_.setSize(surfI);
faceZoneNames_.setSize(surfI);
cellZoneNames_.setSize(surfI);
zoneInside_.setSize(surfI, NONE);
faceType_.setSize(surfI, INTERNAL),
surfZones_.setSize(surfI);
regionOffset_.setSize(surfI);
labelList globalMinLevel(surfI, 0);
@ -130,7 +84,7 @@ Foam::refinementSurfaces::refinementSurfaces
HashSet<word> unmatchedKeys(surfacesDict.toc());
surfI = 0;
forAll(allGeometry.names(), geomI)
forAll(allGeometry_.names(), geomI)
{
const word& geomName = allGeometry_.names()[geomI];
@ -173,80 +127,10 @@ Foam::refinementSurfaces::refinementSurfaces
<< exit(FatalIOError);
}
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
// Global zone names per surface
if (dict.readIfPresent("faceZone", faceZoneNames_[surfI]))
{
// Read optional entry to determine inside of faceZone
word method;
bool hasSide = dict.readIfPresent("cellZoneInside", method);
if (hasSide)
{
zoneInside_[surfI] = areaSelectionAlgoNames[method];
if (zoneInside_[surfI] == INSIDEPOINT)
{
dict.lookup("insidePoint") >> zoneInsidePoints_[surfI];
}
}
else
{
// Check old syntax
bool inside;
if (dict.readIfPresent("zoneInside", inside))
{
hasSide = true;
zoneInside_[surfI] = (inside ? INSIDE : OUTSIDE);
}
}
// Read optional cellZone name
if (dict.readIfPresent("cellZone", cellZoneNames_[surfI]))
{
if
(
(
zoneInside_[surfI] == INSIDE
|| zoneInside_[surfI] == OUTSIDE
)
&& !allGeometry_[surfaces_[surfI]].hasVolumeType()
)
{
IOWarningIn
(
"refinementSurfaces::refinementSurfaces(..)",
dict
) << "Illegal entry zoneInside "
<< areaSelectionAlgoNames[zoneInside_[surfI]]
<< " for faceZone "
<< faceZoneNames_[surfI]
<< " since surface " << names_[surfI]
<< " is not closed." << endl;
}
}
else if (hasSide)
{
IOWarningIn
(
"refinementSurfaces::refinementSurfaces(..)",
dict
) << "Unused entry zoneInside for faceZone "
<< faceZoneNames_[surfI]
<< " since no cellZone specified."
<< endl;
}
// How to handle faces on faceZone
word faceTypeMethod;
if (dict.readIfPresent("faceType", faceTypeMethod))
{
faceType_[surfI] = faceZoneTypeNames[faceTypeMethod];
}
}
// Surface zones
surfZones_.set(surfI, new surfaceZonesInfo(surface, dict));
// Global perpendicular angle
if (dict.found("patchInfo"))
@ -262,8 +146,7 @@ Foam::refinementSurfaces::refinementSurfaces
if (dict.found("regions"))
{
const dictionary& regionsDict = dict.subDict("regions");
const wordList& regionNames =
allGeometry_[surfaces_[surfI]].regions();
const wordList& regionNames = surface.regions();
forAll(regionNames, regionI)
{
@ -307,8 +190,6 @@ Foam::refinementSurfaces::refinementSurfaces
<< exit(FatalIOError);
}
if (regionDict.found("perpendicularAngle"))
{
regionAngle[surfI].insert
@ -429,11 +310,7 @@ Foam::refinementSurfaces::refinementSurfaces
const searchableSurfaces& allGeometry,
const labelList& surfaces,
const wordList& names,
const wordList& faceZoneNames,
const wordList& cellZoneNames,
const List<areaSelectionAlgo>& zoneInside,
const pointField& zoneInsidePoints,
const List<faceZoneType>& faceType,
const PtrList<surfaceZonesInfo>& surfZones,
const labelList& regionOffset,
const labelList& minLevel,
const labelList& maxLevel,
@ -445,11 +322,7 @@ Foam::refinementSurfaces::refinementSurfaces
allGeometry_(allGeometry),
surfaces_(surfaces),
names_(names),
faceZoneNames_(faceZoneNames),
cellZoneNames_(cellZoneNames),
zoneInside_(zoneInside),
zoneInsidePoints_(zoneInsidePoints),
faceType_(faceType),
surfZones_(surfZones),
regionOffset_(regionOffset),
minLevel_(minLevel),
maxLevel_(maxLevel),
@ -469,90 +342,6 @@ Foam::refinementSurfaces::refinementSurfaces
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Get indices of unnamed surfaces (surfaces without faceZoneName)
Foam::labelList Foam::refinementSurfaces::getUnnamedSurfaces() const
{
labelList anonymousSurfaces(faceZoneNames_.size());
label i = 0;
forAll(faceZoneNames_, surfI)
{
if (faceZoneNames_[surfI].empty())
{
anonymousSurfaces[i++] = surfI;
}
}
anonymousSurfaces.setSize(i);
return anonymousSurfaces;
}
// Get indices of named surfaces (surfaces with faceZoneName)
Foam::labelList Foam::refinementSurfaces::getNamedSurfaces() const
{
labelList namedSurfaces(faceZoneNames_.size());
label namedI = 0;
forAll(faceZoneNames_, surfI)
{
if (faceZoneNames_[surfI].size())
{
namedSurfaces[namedI++] = surfI;
}
}
namedSurfaces.setSize(namedI);
return namedSurfaces;
}
// Get indices of closed named surfaces
Foam::labelList Foam::refinementSurfaces::getClosedNamedSurfaces() const
{
labelList closed(cellZoneNames_.size());
label closedI = 0;
forAll(cellZoneNames_, surfI)
{
if
(
cellZoneNames_[surfI].size()
&& (
zoneInside_[surfI] == INSIDE
|| zoneInside_[surfI] == OUTSIDE
)
&& allGeometry_[surfaces_[surfI]].hasVolumeType()
)
{
closed[closedI++] = surfI;
}
}
closed.setSize(closedI);
return closed;
}
// Get indices of named surfaces with a
Foam::labelList Foam::refinementSurfaces::getInsidePointNamedSurfaces() const
{
labelList closed(cellZoneNames_.size());
label closedI = 0;
forAll(cellZoneNames_, surfI)
{
if (cellZoneNames_[surfI].size() && zoneInside_[surfI] == INSIDEPOINT)
{
closed[closedI++] = surfI;
}
}
closed.setSize(closedI);
return closed;
}
// // Count number of triangles per surface region
// Foam::labelList Foam::refinementSurfaces::countRegions(const triSurface& s)
// {
@ -843,7 +632,9 @@ void Foam::refinementSurfaces::findAllHigherIntersections
forAll(surfaces_, surfI)
{
allGeometry_[surfaces_[surfI]].findLineAll(start, end, hitInfo);
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
surface.findLineAll(start, end, hitInfo);
// Repack hits for surface into flat list
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -873,8 +664,8 @@ void Foam::refinementSurfaces::findAllHigherIntersections
labelList surfRegion(n);
vectorField surfNormal(n);
allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion);
allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal);
surface.getRegion(surfInfo, surfRegion);
surface.getNormal(surfInfo, surfNormal);
surfInfo.clear();
@ -929,9 +720,11 @@ void Foam::refinementSurfaces::findAllHigherIntersections
labelList pRegions;
vectorField pNormals;
forAll(surfaces_, surfI)
forAll(surfaces(), surfI)
{
allGeometry_[surfaces_[surfI]].findLineAll(start, end, hitInfo);
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
surface.findLineAll(start, end, hitInfo);
// Repack hits for surface into flat list
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -961,8 +754,8 @@ void Foam::refinementSurfaces::findAllHigherIntersections
labelList surfRegion(n);
vectorField surfNormal(n);
allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion);
allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal);
surface.getRegion(surfInfo, surfRegion);
surface.getNormal(surfInfo, surfNormal);
// Extract back into pointwise
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -1023,14 +816,16 @@ void Foam::refinementSurfaces::findNearestIntersection
{
label surfI = surfacesToTest[testI];
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
// See if any intersection between start and current nearest
allGeometry_[surfaces_[surfI]].findLine
surface.findLine
(
start,
nearest,
nearestInfo
);
allGeometry_[surfaces_[surfI]].getRegion
surface.getRegion
(
nearestInfo,
region
@ -1076,14 +871,16 @@ void Foam::refinementSurfaces::findNearestIntersection
{
label surfI = surfacesToTest[testI];
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
// See if any intersection between end and current nearest
allGeometry_[surfaces_[surfI]].findLine
surface.findLine
(
end,
nearest,
nearestInfo
);
allGeometry_[surfaces_[surfI]].getRegion
surface.getRegion
(
nearestInfo,
region
@ -1489,20 +1286,29 @@ void Foam::refinementSurfaces::findInside
{
label surfI = testSurfaces[i];
if (zoneInside_[surfI] != INSIDE && zoneInside_[surfI] != OUTSIDE)
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
const surfaceZonesInfo::areaSelectionAlgo selectionMethod =
surfZones_[surfI].zoneInside();
if
(
selectionMethod != surfaceZonesInfo::INSIDE
&& selectionMethod != surfaceZonesInfo::OUTSIDE
)
{
FatalErrorIn("refinementSurfaces::findInside(..)")
<< "Trying to use surface "
<< allGeometry_[surfaces_[surfI]].name()
<< surface.name()
<< " which has non-geometric inside selection method "
<< areaSelectionAlgoNames[zoneInside_[surfI]]
<< surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod]
<< exit(FatalError);
}
if (allGeometry_[surfaces_[surfI]].hasVolumeType())
if (surface.hasVolumeType())
{
List<volumeType> volType;
allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType);
surface.getVolumeType(pt, volType);
forAll(volType, pointI)
{
@ -1512,11 +1318,11 @@ void Foam::refinementSurfaces::findInside
(
(
volType[pointI] == volumeType::INSIDE
&& zoneInside_[surfI] == INSIDE
&& selectionMethod == surfaceZonesInfo::INSIDE
)
|| (
volType[pointI] == volumeType::OUTSIDE
&& zoneInside_[surfI] == OUTSIDE
&& selectionMethod == surfaceZonesInfo::OUTSIDE
)
)
{

View File

@ -41,6 +41,7 @@ SourceFiles
#include "triSurfaceFields.H"
#include "vectorList.H"
#include "pointIndexHit.H"
#include "surfaceZonesInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,31 +60,6 @@ typedef List<point> pointList;
class refinementSurfaces
{
public:
//- Types of selection of area
enum areaSelectionAlgo
{
INSIDE,
OUTSIDE,
INSIDEPOINT,
NONE
};
static const NamedEnum<areaSelectionAlgo, 4> areaSelectionAlgoNames;
//- What to do with faceZone faces
enum faceZoneType
{
INTERNAL,
BAFFLE,
BOUNDARY
};
static const NamedEnum<faceZoneType, 3> faceZoneTypeNames;
private:
// Private data
//- Reference to all geometry.
@ -95,23 +71,8 @@ private:
//- Surface name (word)
wordList names_;
//- Per 'interface' surface : name of faceZone to put faces into
wordList faceZoneNames_;
//- Per 'interface' surface : name of cellZone to put cells into
wordList cellZoneNames_;
//- Per 'interface' surface : (only used if surface is closed)
// How to select zone cells : surface inside or outside or given
// inside location.
List<areaSelectionAlgo> zoneInside_;
//- If zoneInside=location gives the corresponding inside point
pointField zoneInsidePoints_;
//- Per 'interface' surface :
// What to do with outside
List<faceZoneType> faceType_;
//- List of surface zone (face and cell zone) information
PtrList<surfaceZonesInfo> surfZones_;
//- From local region number to global region number
labelList regionOffset_;
@ -159,11 +120,7 @@ public:
const searchableSurfaces& allGeometry,
const labelList& surfaces,
const wordList& names,
const wordList& faceZoneNames,
const wordList& cellZoneNames,
const List<areaSelectionAlgo>& zoneInside,
const pointField& zoneInsidePoints,
const List<faceZoneType>& faceType,
const PtrList<surfaceZonesInfo>& surfZones,
const labelList& regionOffset,
const labelList& minLevel,
const labelList& maxLevel,
@ -193,44 +150,9 @@ public:
return names_;
}
//- Per 'interface' surface : empty or name of faceZone to put
// faces into
const wordList& faceZoneNames() const
const PtrList<surfaceZonesInfo>& surfZones() const
{
return faceZoneNames_;
}
//- Per 'interface' surface : empty or name of cellZone to put
// cells into
const wordList& cellZoneNames() const
{
return cellZoneNames_;
}
//- Get indices of unnamed surfaces (surfaces without faceZoneName)
labelList getUnnamedSurfaces() const;
//- Get indices of named surfaces (surfaces with faceZoneName)
labelList getNamedSurfaces() const;
//- Get indices of surfaces with a cellZone that are closed and
// have 'inside' or 'outside' selection.
labelList getClosedNamedSurfaces() const;
//- Get indices of surfaces with a cellZone that have 'insidePoint'
// section.
labelList getInsidePointNamedSurfaces() const;
//- Get specified inside locations for surfaces with a cellZone
const pointField& zoneInsidePoints() const
{
return zoneInsidePoints_;
}
//- How to handle face of surfaces with a faceZone
const List<faceZoneType>& faceType() const
{
return faceType_;
return surfZones_;
}
//- From local region number to global region number

View File

@ -0,0 +1,421 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "surfaceZonesInfo.H"
#include "searchableSurface.H"
#include "searchableSurfaces.H"
#include "polyMesh.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::surfaceZonesInfo::areaSelectionAlgo,
4
>::names[] =
{
"inside",
"outside",
"insidePoint",
"none"
};
}
const Foam::NamedEnum<Foam::surfaceZonesInfo::areaSelectionAlgo, 4>
Foam::surfaceZonesInfo::areaSelectionAlgoNames;
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::surfaceZonesInfo::faceZoneType,
3
>::names[] =
{
"internal",
"baffle",
"boundary"
};
}
const Foam::NamedEnum<Foam::surfaceZonesInfo::faceZoneType, 3>
Foam::surfaceZonesInfo::faceZoneTypeNames;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceZonesInfo::surfaceZonesInfo
(
const searchableSurface& surface,
const dictionary& surfacesDict
)
:
faceZoneName_(),
cellZoneName_(),
zoneInside_(NONE),
zoneInsidePoint_(point::min),
faceType_(INTERNAL)
{
// Global zone names per surface
if (surfacesDict.readIfPresent("faceZone", faceZoneName_))
{
// Read optional entry to determine inside of faceZone
word method;
bool hasSide = surfacesDict.readIfPresent("cellZoneInside", method);
if (hasSide)
{
zoneInside_ = areaSelectionAlgoNames[method];
if (zoneInside_ == INSIDEPOINT)
{
surfacesDict.lookup("insidePoint") >> zoneInsidePoint_;
}
}
else
{
// Check old syntax
bool inside;
if (surfacesDict.readIfPresent("zoneInside", inside))
{
hasSide = true;
zoneInside_ = (inside ? INSIDE : OUTSIDE);
}
}
// Read optional cellZone name
if (surfacesDict.readIfPresent("cellZone", cellZoneName_))
{
if
(
(
zoneInside_ == INSIDE
|| zoneInside_ == OUTSIDE
)
&& !surface.hasVolumeType()
)
{
IOWarningIn
(
"refinementSurfaces::refinementSurfaces(..)",
surfacesDict
) << "Illegal entry zoneInside "
<< areaSelectionAlgoNames[zoneInside_]
<< " for faceZone "
<< faceZoneName_
<< " since surface is not closed." << endl;
}
}
else if (hasSide)
{
IOWarningIn
(
"refinementSurfaces::refinementSurfaces(..)",
surfacesDict
) << "Unused entry zoneInside for faceZone "
<< faceZoneName_
<< " since no cellZone specified."
<< endl;
}
// How to handle faces on faceZone
word faceTypeMethod;
if (surfacesDict.readIfPresent("faceType", faceTypeMethod))
{
faceType_ = faceZoneTypeNames[faceTypeMethod];
}
}
}
Foam::surfaceZonesInfo::surfaceZonesInfo
(
const word& faceZoneName,
const word& cellZoneName,
const areaSelectionAlgo& zoneInside,
const point& zoneInsidePoint,
const faceZoneType& faceType
)
:
faceZoneName_(faceZoneName),
cellZoneName_(cellZoneName),
zoneInside_(zoneInside),
zoneInsidePoint_(zoneInsidePoint),
faceType_(faceType)
{}
Foam::surfaceZonesInfo::surfaceZonesInfo(const surfaceZonesInfo& surfZone)
:
faceZoneName_(surfZone.faceZoneName()),
cellZoneName_(surfZone.cellZoneName()),
zoneInside_(surfZone.zoneInside()),
zoneInsidePoint_(surfZone.zoneInsidePoint()),
faceType_(surfZone.faceType())
{}
// Get indices of unnamed surfaces (surfaces without faceZoneName)
Foam::labelList Foam::surfaceZonesInfo::getUnnamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
)
{
labelList anonymousSurfaces(surfList.size());
label i = 0;
forAll(surfList, surfI)
{
if (surfList[surfI].faceZoneName().empty())
{
anonymousSurfaces[i++] = surfI;
}
}
anonymousSurfaces.setSize(i);
return anonymousSurfaces;
}
// Get indices of named surfaces (surfaces with faceZoneName)
Foam::labelList Foam::surfaceZonesInfo::getNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
)
{
labelList namedSurfaces(surfList.size());
label namedI = 0;
forAll(surfList, surfI)
{
if (surfList[surfI].faceZoneName().size())
{
namedSurfaces[namedI++] = surfI;
}
}
namedSurfaces.setSize(namedI);
return namedSurfaces;
}
// Get indices of closed named surfaces
Foam::labelList Foam::surfaceZonesInfo::getClosedNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList,
const searchableSurfaces& allGeometry,
const labelList& surfaces
)
{
labelList closed(surfList.size());
label closedI = 0;
forAll(surfList, surfI)
{
if
(
surfList[surfI].cellZoneName().size()
&& (
surfList[surfI].zoneInside() == surfaceZonesInfo::INSIDE
|| surfList[surfI].zoneInside() == surfaceZonesInfo::OUTSIDE
)
&& allGeometry[surfaces[surfI]].hasVolumeType()
)
{
closed[closedI++] = surfI;
}
}
closed.setSize(closedI);
return closed;
}
// Get indices of named surfaces with a
Foam::labelList Foam::surfaceZonesInfo::getInsidePointNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
)
{
labelList closed(surfList.size());
label closedI = 0;
forAll(surfList, surfI)
{
if
(
surfList[surfI].cellZoneName().size()
&& surfList[surfI].zoneInside() == surfaceZonesInfo::INSIDEPOINT
)
{
closed[closedI++] = surfI;
}
}
closed.setSize(closedI);
return closed;
}
Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
(
const PtrList<surfaceZonesInfo>& surfList,
const labelList& namedSurfaces,
polyMesh& mesh
)
{
labelList surfaceToCellZone(surfList.size(), -1);
cellZoneMesh& cellZones = mesh.cellZones();
forAll(namedSurfaces, i)
{
label surfI = namedSurfaces[i];
const word& cellZoneName = surfList[surfI].cellZoneName();
if (cellZoneName != word::null)
{
label zoneI = cellZones.findZoneID(cellZoneName);
if (zoneI == -1)
{
zoneI = cellZones.size();
cellZones.setSize(zoneI+1);
cellZones.set
(
zoneI,
new cellZone
(
cellZoneName, //name
labelList(0), //addressing
zoneI, //index
cellZones //cellZoneMesh
)
);
}
surfaceToCellZone[surfI] = zoneI;
}
}
// Check they are synced
List<wordList> allCellZones(Pstream::nProcs());
allCellZones[Pstream::myProcNo()] = cellZones.names();
Pstream::gatherList(allCellZones);
Pstream::scatterList(allCellZones);
for (label procI = 1; procI < allCellZones.size(); procI++)
{
if (allCellZones[procI] != allCellZones[0])
{
FatalErrorIn
(
"meshRefinement::zonify"
"(const label, const point&)"
) << "Zones not synchronised among processors." << nl
<< " Processor0 has cellZones:" << allCellZones[0]
<< " , processor" << procI
<< " has cellZones:" << allCellZones[procI]
<< exit(FatalError);
}
}
return surfaceToCellZone;
}
Foam::labelList Foam::surfaceZonesInfo::addFaceZonesToMesh
(
const PtrList<surfaceZonesInfo>& surfList,
const labelList& namedSurfaces,
polyMesh& mesh
)
{
labelList surfaceToFaceZone(surfList.size(), -1);
faceZoneMesh& faceZones = mesh.faceZones();
forAll(namedSurfaces, i)
{
label surfI = namedSurfaces[i];
const word& faceZoneName = surfList[surfI].faceZoneName();
label zoneI = faceZones.findZoneID(faceZoneName);
if (zoneI == -1)
{
zoneI = faceZones.size();
faceZones.setSize(zoneI+1);
faceZones.set
(
zoneI,
new faceZone
(
faceZoneName, //name
labelList(0), //addressing
boolList(0), //flipmap
zoneI, //index
faceZones //faceZoneMesh
)
);
}
surfaceToFaceZone[surfI] = zoneI;
}
// Check they are synced
List<wordList> allFaceZones(Pstream::nProcs());
allFaceZones[Pstream::myProcNo()] = faceZones.names();
Pstream::gatherList(allFaceZones);
Pstream::scatterList(allFaceZones);
for (label procI = 1; procI < allFaceZones.size(); procI++)
{
if (allFaceZones[procI] != allFaceZones[0])
{
FatalErrorIn
(
"meshRefinement::zonify"
"(const label, const point&)"
) << "Zones not synchronised among processors." << nl
<< " Processor0 has faceZones:" << allFaceZones[0]
<< " , processor" << procI
<< " has faceZones:" << allFaceZones[procI]
<< exit(FatalError);
}
}
return surfaceToFaceZone;
}
// ************************************************************************* //

View File

@ -0,0 +1,233 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceZonesInfo
Description
SourceFiles
surfaceZonesInfo.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceZonesInfo_H
#define surfaceZonesInfo_H
#include "NamedEnum.H"
#include "point.H"
#include "word.H"
#include "PtrList.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class searchableSurface;
class searchableSurfaces;
class polyMesh;
class dictionary;
/*---------------------------------------------------------------------------*\
Class surfaceZonesInfo Declaration
\*---------------------------------------------------------------------------*/
class surfaceZonesInfo
{
public:
//- Types of selection of area
enum areaSelectionAlgo
{
INSIDE,
OUTSIDE,
INSIDEPOINT,
NONE
};
static const NamedEnum<areaSelectionAlgo, 4> areaSelectionAlgoNames;
//- What to do with faceZone faces
enum faceZoneType
{
INTERNAL,
BAFFLE,
BOUNDARY
};
static const NamedEnum<faceZoneType, 3> faceZoneTypeNames;
private:
// Private data
//- Per 'interface' surface : name of faceZone to put faces into
word faceZoneName_;
//- Per 'interface' surface : name of cellZone to put cells into
word cellZoneName_;
//- Per 'interface' surface : (only used if surface is closed)
// How to select zone cells : surface inside or outside or given
// inside location.
areaSelectionAlgo zoneInside_;
//- If zoneInside=location gives the corresponding inside point
point zoneInsidePoint_;
//- Per 'interface' surface :
// What to do with outside
faceZoneType faceType_;
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const surfaceZonesInfo&);
public:
// Constructors
//- Construct from surfaces and dictionary
surfaceZonesInfo
(
const searchableSurface& surface,
const dictionary& surfacesDict
);
//- Construct from components
surfaceZonesInfo
(
const word& faceZoneNames,
const word& cellZoneNames,
const areaSelectionAlgo& zoneInside,
const point& zoneInsidePoints,
const faceZoneType& faceType
);
//- Copy constructor
surfaceZonesInfo(const surfaceZonesInfo&);
//- Return clone
autoPtr<surfaceZonesInfo> clone() const
{
return autoPtr<surfaceZonesInfo>(new surfaceZonesInfo(*this));
}
// Member Functions
// Access
//- Per 'interface' surface : empty or name of faceZone to put
// faces into
const word& faceZoneName() const
{
return faceZoneName_;
}
//- Per 'interface' surface : empty or name of cellZone to put
// cells into
const word& cellZoneName() const
{
return cellZoneName_;
}
const areaSelectionAlgo& zoneInside() const
{
return zoneInside_;
}
//- Get specified inside locations for surfaces with a cellZone
const point& zoneInsidePoint() const
{
return zoneInsidePoint_;
}
//- How to handle face of surfaces with a faceZone
const faceZoneType& faceType() const
{
return faceType_;
}
// Query
//- Get indices of unnamed surfaces (surfaces without faceZoneName)
static labelList getUnnamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
);
//- Get indices of named surfaces (surfaces with faceZoneName)
static labelList getNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
);
//- Get indices of surfaces with a cellZone that are closed and
// have 'inside' or 'outside' selection.
static labelList getClosedNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList,
const searchableSurfaces& allGeometry,
const labelList& surfaces
);
//- Get indices of surfaces with a cellZone that have 'insidePoint'
// section.
static labelList getInsidePointNamedSurfaces
(
const PtrList<surfaceZonesInfo>& surfList
);
static labelList addCellZonesToMesh
(
const PtrList<surfaceZonesInfo>& surfList,
const labelList& namedSurfaces,
polyMesh& mesh
);
static labelList addFaceZonesToMesh
(
const PtrList<surfaceZonesInfo>& surfList,
const labelList& namedSurfaces,
polyMesh& mesh
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //