Commit eaad256f authored by laurence's avatar laurence
Browse files

face/cell zoning: Create new class surfaceZonesInfo

parent 298724b0
......@@ -265,6 +265,7 @@ Foam::conformationSurfaces::conformationSurfaces
allGeometryToSurfaces_(),
normalVolumeTypes_(),
patchNames_(),
surfZones_(),
regionOffset_(),
patchInfo_(),
globalBounds_(),
......@@ -275,157 +276,198 @@ 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());
allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
surfaces_[surfI] = geomI;
Info<< nl << " " << surfaceName << endl;
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
const wordList& regionNames =
allGeometry_.regionNames()[surfaces_[surfI]];
// Surface zones
if (dict.found("faceZone"))
{
surfZones_.set(surfI, new surfaceZonesInfo(surface, dict));
}
patchNames_.append(regionNames);
allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
Info<< nl << " " << geomName << endl;
globalVolumeTypes[surfI] =
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
surfaceSubDict.lookupOrDefault<word>("meshableSide", "inside")
]
);
const wordList& regionNames =
allGeometry_.regionNames()[surfaces_[surfI]];
if (!globalVolumeTypes[surfI])
{
if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
patchNames_.append(regionNames);
globalVolumeTypes[surfI] =
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>
(
"meshableSide",
"inside"
)
]
);
if (!globalVolumeTypes[surfI])
{
WarningIn("conformationSurfaces::conformationSurfaces(..)")
<< "Non-baffle surface "
<< allGeometry_[surfaces_[surfI]].name()
<< " does not allow inside/outside queries."
<< " This usually is an error." << endl;
if (!surface.hasVolumeType())
{
WarningIn("conformationSurfaces::conformationSurfaces(..)")
<< "Non-baffle surface "
<< surface.name()
<< " does not allow inside/outside queries."
<< " This usually is an error." << endl;
}
}
}
// Load patch info
if (surfaceSubDict.found("patchInfo"))
{
globalPatchInfo.set
// Load patch info
if (dict.found("patchInfo"))
{
globalPatchInfo.set
(
surfI,
dict.subDict("patchInfo").clone()
);
}
readFeatures
(
surfI,
surfaceSubDict.subDict("patchInfo").clone()
dict,
geomName,
featureI
);
}
readFeatures
(
surfI,
surfaceSubDict,
surfaceName,
featureI
);
const wordList& rNames = allGeometry_[surfaces_[surfI]].regions();
const wordList& rNames = surface.regions();
if (surfaceSubDict.found("regions"))
{
const dictionary& regionsDict = surfaceSubDict.subDict("regions");
forAll(rNames, regionI)
if (dict.found("regions"))
{
const word& regionName = rNames[regionI];
const dictionary& regionsDict = dict.subDict("regions");
if (regionsDict.found(regionName))
forAll(rNames, regionI)
{
Info<< " region " << regionName << endl;
const word& regionName = rNames[regionI];
// Get the dictionary for region
const dictionary& regionDict = regionsDict.subDict
(
regionName
);
if (regionDict.found("patchInfo"))
if (regionsDict.found(regionName))
{
regionPatchInfo[surfI].insert
Info<< " region " << regionName << endl;
// Get the dictionary for region
const dictionary& regionDict = regionsDict.subDict
(
regionName
);
if (regionDict.found("patchInfo"))
{
regionPatchInfo[surfI].insert
(
regionI,
regionDict.subDict("patchInfo").clone()
);
}
regionVolumeTypes[surfI].insert
(
regionI,
regionDict.subDict("patchInfo").clone()
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
regionDict.lookupOrDefault<word>
(
"meshableSide",
"inside"
)
]
);
}
regionVolumeTypes[surfI].insert
(
regionI,
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
regionDict.lookupOrDefault<word>
(
"meshableSide",
"inside"
)
]
);
readFeatures(regionDict, regionName, featureI);
readFeatures(regionDict, regionName, featureI);
}
}
}
surfI++;
}
}
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;
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]];
......
......@@ -40,6 +40,7 @@ SourceFiles
#include "extendedFeatureEdgeMesh.H"
#include "boolList.H"
#include "volumeType.H"
#include "surfaceZonesInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -47,7 +48,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class conformationSurfaces Declaration
Class conformationSurfaces Declaration
\*---------------------------------------------------------------------------*/
class conformationSurfaces
......@@ -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;
......
......@@ -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
{
......
......@@ -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 (