ENH: Changed behaviour of surfaces with zones.

- if allowFreeStanding = false it also disables faceZones on boundaries.
- can have surfaces with faceZone but no cellZone.
This commit is contained in:
mattijs
2010-03-30 21:50:40 +01:00
parent d8c1aa3afd
commit 0b1fc8e0cd
3 changed files with 85 additions and 63 deletions

View File

@ -246,27 +246,8 @@ void Foam::meshRefinement::getBafflePatches
const pointField& cellCentres = mesh_.cellCentres(); const pointField& cellCentres = mesh_.cellCentres();
// Build list of surfaces that are not to be baffled. // Surfaces that need to be baffled
const wordList& cellZoneNames = surfaces_.cellZoneNames(); const labelList surfacesToBaffle(surfaces_.getUnnamedSurfaces());
labelList surfacesToBaffle(cellZoneNames.size());
label baffleI = 0;
forAll(cellZoneNames, surfI)
{
if (cellZoneNames[surfI].size())
{
if (debug)
{
Pout<< "getBafflePatches : Not baffling surface "
<< surfaces_.names()[surfI] << endl;
}
}
else
{
surfacesToBaffle[baffleI++] = surfI;
}
}
surfacesToBaffle.setSize(baffleI);
ownPatch.setSize(mesh_.nFaces()); ownPatch.setSize(mesh_.nFaces());
ownPatch = -1; ownPatch = -1;
@ -1254,7 +1235,7 @@ void Foam::meshRefinement::findCellZoneTopo
{ {
label surfI = namedSurfaceIndex[faceI]; label surfI = namedSurfaceIndex[faceI];
if (surfI != -1) if (surfI != -1 && surfaceToCellZone[surfI] != -1)
{ {
// Calculate region to zone from cellRegions on either side // Calculate region to zone from cellRegions on either side
// of internal face. // of internal face.
@ -1306,7 +1287,7 @@ void Foam::meshRefinement::findCellZoneTopo
label surfI = namedSurfaceIndex[faceI]; label surfI = namedSurfaceIndex[faceI];
if (surfI != -1) if (surfI != -1 && surfaceToCellZone[surfI] != -1)
{ {
bool changedCell = calcRegionToZone bool changedCell = calcRegionToZone
( (
@ -1440,6 +1421,15 @@ void Foam::meshRefinement::makeConsistentFaceIndex
} }
} }
} }
else
{
// Unzonify boundary faces
forAll(pp, i)
{
label faceI = pp.start()+i;
namedSurfaceIndex[faceI] = -1;
}
}
} }
} }
@ -2043,14 +2033,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
labelList namedSurfaces(surfaces_.getNamedSurfaces()); labelList namedSurfaces(surfaces_.getNamedSurfaces());
boolList isNamedSurface(cellZoneNames.size(), false);
forAll(namedSurfaces, i) forAll(namedSurfaces, i)
{ {
label surfI = namedSurfaces[i]; label surfI = namedSurfaces[i];
isNamedSurface[surfI] = true;
Info<< "Surface : " << surfaces_.names()[surfI] << nl Info<< "Surface : " << surfaces_.names()[surfI] << nl
<< " faceZone : " << faceZoneNames[surfI] << nl << " faceZone : " << faceZoneNames[surfI] << nl
<< " cellZone : " << cellZoneNames[surfI] << endl; << " cellZone : " << cellZoneNames[surfI] << endl;
@ -2126,31 +2112,34 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
{ {
label surfI = namedSurfaces[i]; label surfI = namedSurfaces[i];
label zoneI = cellZones.findZoneID(cellZoneNames[surfI]); if (cellZoneNames[surfI] != word::null)
if (zoneI == -1)
{ {
zoneI = cellZones.size(); label zoneI = cellZones.findZoneID(cellZoneNames[surfI]);
cellZones.setSize(zoneI+1);
cellZones.set if (zoneI == -1)
( {
zoneI, zoneI = cellZones.size();
new cellZone cellZones.setSize(zoneI+1);
cellZones.set
( (
cellZoneNames[surfI], //name zoneI,
labelList(0), //addressing new cellZone
zoneI, //index (
cellZones //cellZoneMesh cellZoneNames[surfI], //name
) labelList(0), //addressing
); zoneI, //index
} cellZones //cellZoneMesh
)
);
}
if (debug) if (debug)
{ {
Pout<< "Cells inside " << surfaces_.names()[surfI] Pout<< "Cells inside " << surfaces_.names()[surfI]
<< " will go into cellZone " << zoneI << endl; << " will go into cellZone " << zoneI << endl;
}
surfaceToCellZone[surfI] = zoneI;
} }
surfaceToCellZone[surfI] = zoneI;
} }
// Check they are synced // Check they are synced
@ -2322,6 +2311,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
if (closedNamedSurfaces.size()) if (closedNamedSurfaces.size())
{ {
Info<< "Found " << closedNamedSurfaces.size()
<< " closed, named surfaces. Assigning cells in/outside"
<< " these surfaces to the corresponding cellZone."
<< nl << endl;
findCellZoneGeometric findCellZoneGeometric
( (
closedNamedSurfaces, // indices of closed surfaces closedNamedSurfaces, // indices of closed surfaces
@ -2334,8 +2328,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
// Set using walking // Set using walking
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
//if (returnReduce(nSet, sumOp<label>()) < mesh_.globalData().nTotalCells()) if (!allowFreeStandingZoneFaces)
{ {
Info<< "Walking to assign cellZones." << nl << endl;
// Topological walk // Topological walk
findCellZoneTopo findCellZoneTopo
( (
@ -2350,6 +2346,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
// Make sure namedSurfaceIndex is unset inbetween same cell cell zones. // Make sure namedSurfaceIndex is unset inbetween same cell cell zones.
if (!allowFreeStandingZoneFaces) if (!allowFreeStandingZoneFaces)
{ {
Info<< "Only keeping zone faces inbetween different cellZones."
<< nl << endl;
makeConsistentFaceIndex(cellToZone, namedSurfaceIndex); makeConsistentFaceIndex(cellToZone, namedSurfaceIndex);
} }

View File

@ -78,8 +78,18 @@ Foam::refinementSurfaces::refinementSurfaces
if (dict.found("faceZone")) if (dict.found("faceZone"))
{ {
dict.lookup("faceZone") >> faceZoneNames_[surfI]; dict.lookup("faceZone") >> faceZoneNames_[surfI];
dict.lookup("cellZone") >> cellZoneNames_[surfI]; if (dict.readIfPresent("cellZone", cellZoneNames_[surfI]))
dict.lookup("zoneInside") >> zoneInside_[surfI]; {
dict.lookup("zoneInside") >> zoneInside_[surfI];
}
else if (dict.found("zoneInside"))
{
IOWarningIn("refinementSurfaces::refinementSurfaces(..)", dict)
<< "Unused entry zoneInside for faceZone "
<< faceZoneNames_[surfI]
<< " since no cellZone specified."
<< endl;
}
} }
// Global perpendicular angle // Global perpendicular angle
@ -315,8 +325,21 @@ Foam::refinementSurfaces::refinementSurfaces
if (dict.found("faceZone")) if (dict.found("faceZone"))
{ {
dict.lookup("faceZone") >> faceZoneNames_[surfI]; dict.lookup("faceZone") >> faceZoneNames_[surfI];
dict.lookup("cellZone") >> cellZoneNames_[surfI]; if (dict.readIfPresent("cellZone", cellZoneNames_[surfI]))
dict.lookup("zoneInside") >> zoneInside_[surfI]; {
dict.lookup("zoneInside") >> zoneInside_[surfI];
}
else if (dict.found("zoneInside"))
{
IOWarningIn
(
"refinementSurfaces::refinementSurfaces(..)",
dict
) << "Unused entry zoneInside for faceZone "
<< faceZoneNames_[surfI]
<< " since no cellZone specified."
<< endl;
}
} }
// Global perpendicular angle // Global perpendicular angle
@ -476,18 +499,17 @@ Foam::labelList Foam::refinementSurfaces::getNamedSurfaces() const
// Get indices of closed named surfaces // Get indices of closed named surfaces
Foam::labelList Foam::refinementSurfaces::getClosedNamedSurfaces() const Foam::labelList Foam::refinementSurfaces::getClosedNamedSurfaces() const
{ {
labelList named(getNamedSurfaces()); labelList closed(cellZoneNames_.size());
labelList closed(named.size());
label closedI = 0; label closedI = 0;
forAll(cellZoneNames_, surfI)
forAll(named, i)
{ {
label surfI = named[i]; if (cellZoneNames_[surfI].size())
if (allGeometry_[surfaces_[surfI]].hasVolumeType())
{ {
closed[closedI++] = surfI; if (allGeometry_[surfaces_[surfI]].hasVolumeType())
{
closed[closedI++] = surfI;
}
} }
} }
closed.setSize(closedI); closed.setSize(closedI);

View File

@ -147,7 +147,8 @@ public:
return faceZoneNames_; return faceZoneNames_;
} }
//- Per 'interface' surface : name of cellZone to put cells into //- Per 'interface' surface : empty or name of cellZone to put
// cells into
const wordList& cellZoneNames() const const wordList& cellZoneNames() const
{ {
return cellZoneNames_; return cellZoneNames_;
@ -159,7 +160,7 @@ public:
//- Get indices of named surfaces (surfaces with faceZoneName) //- Get indices of named surfaces (surfaces with faceZoneName)
labelList getNamedSurfaces() const; labelList getNamedSurfaces() const;
//- Get indices of closed named surfaces //- Get indices of closed surfaces with a cellZone
labelList getClosedNamedSurfaces() const; labelList getClosedNamedSurfaces() const;
//- From local region number to global region number //- From local region number to global region number