mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Reuse existing zones.
This commit is contained in:
@ -68,6 +68,104 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
label addPointZone(const polyMesh& mesh, const word& name)
|
||||
{
|
||||
label zoneID = mesh.pointZones().findZoneID(name);
|
||||
|
||||
if (zoneID != -1)
|
||||
{
|
||||
Info<< "Reusing existing pointZone "
|
||||
<< mesh.pointZones()[zoneID].name()
|
||||
<< " at index " << zoneID << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh).pointZones();
|
||||
zoneID = pointZones.size();
|
||||
Info<< "Adding pointZone " << name << " at index " << zoneID << endl;
|
||||
|
||||
pointZones.setSize(zoneID+1);
|
||||
pointZones.set
|
||||
(
|
||||
zoneID,
|
||||
new pointZone
|
||||
(
|
||||
name,
|
||||
labelList(0),
|
||||
zoneID,
|
||||
pointZones
|
||||
)
|
||||
);
|
||||
}
|
||||
return zoneID;
|
||||
}
|
||||
|
||||
|
||||
label addFaceZone(const polyMesh& mesh, const word& name)
|
||||
{
|
||||
label zoneID = mesh.faceZones().findZoneID(name);
|
||||
|
||||
if (zoneID != -1)
|
||||
{
|
||||
Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name()
|
||||
<< " at index " << zoneID << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh).faceZones();
|
||||
zoneID = faceZones.size();
|
||||
Info<< "Adding faceZone " << name << " at index " << zoneID << endl;
|
||||
|
||||
faceZones.setSize(zoneID+1);
|
||||
faceZones.set
|
||||
(
|
||||
zoneID,
|
||||
new faceZone
|
||||
(
|
||||
name,
|
||||
labelList(0),
|
||||
boolList(),
|
||||
zoneID,
|
||||
faceZones
|
||||
)
|
||||
);
|
||||
}
|
||||
return zoneID;
|
||||
}
|
||||
|
||||
|
||||
label addCellZone(const polyMesh& mesh, const word& name)
|
||||
{
|
||||
label zoneID = mesh.cellZones().findZoneID(name);
|
||||
|
||||
if (zoneID != -1)
|
||||
{
|
||||
Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name()
|
||||
<< " at index " << zoneID << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh).cellZones();
|
||||
zoneID = cellZones.size();
|
||||
Info<< "Adding cellZone " << name << " at index " << zoneID << endl;
|
||||
|
||||
cellZones.setSize(zoneID+1);
|
||||
cellZones.set
|
||||
(
|
||||
zoneID,
|
||||
new cellZone
|
||||
(
|
||||
name,
|
||||
labelList(0),
|
||||
zoneID,
|
||||
cellZones
|
||||
)
|
||||
);
|
||||
}
|
||||
return zoneID;
|
||||
}
|
||||
|
||||
|
||||
// Checks whether patch present
|
||||
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
|
||||
{
|
||||
@ -211,29 +309,20 @@ int main(int argc, char *argv[])
|
||||
polyTopoChanger stitcher(mesh);
|
||||
stitcher.setSize(1);
|
||||
|
||||
DynamicList<pointZone*> pz;
|
||||
DynamicList<faceZone*> fz;
|
||||
DynamicList<cellZone*> cz;
|
||||
mesh.pointZones().clearAddressing();
|
||||
mesh.faceZones().clearAddressing();
|
||||
mesh.cellZones().clearAddressing();
|
||||
|
||||
if (perfectCover)
|
||||
{
|
||||
// Add empty zone for resulting internal faces
|
||||
fz.append
|
||||
(
|
||||
new faceZone
|
||||
(
|
||||
cutZoneName,
|
||||
isf,
|
||||
boolList(masterPatch.size(), false),
|
||||
0,
|
||||
mesh.faceZones()
|
||||
)
|
||||
);
|
||||
label cutZoneID = addFaceZone(mesh, cutZoneName);
|
||||
|
||||
// Note: make sure to add the zones BEFORE constructing polyMeshModifier
|
||||
// (since looks up various zones at construction time)
|
||||
Info<< "Adding point and face zones" << endl;
|
||||
mesh.addZones(pz.shrink(), fz.shrink(), cz.shrink());
|
||||
mesh.faceZones()[cutZoneID].resetAddressing
|
||||
(
|
||||
isf,
|
||||
boolList(masterPatch.size(), false)
|
||||
);
|
||||
|
||||
// Add the perfect interface mesh modifier
|
||||
stitcher.set
|
||||
@ -252,27 +341,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
pz.append
|
||||
(
|
||||
new pointZone
|
||||
(
|
||||
mergePatchName + "CutPointZone",
|
||||
labelList(0),
|
||||
0,
|
||||
mesh.pointZones()
|
||||
)
|
||||
);
|
||||
label pointZoneID = addPointZone(mesh, mergePatchName + "CutPointZone");
|
||||
mesh.pointZones()[pointZoneID] = labelList(0);
|
||||
|
||||
fz.append
|
||||
label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone");
|
||||
|
||||
mesh.faceZones()[masterZoneID].resetAddressing
|
||||
(
|
||||
new faceZone
|
||||
(
|
||||
mergePatchName + "MasterZone",
|
||||
isf,
|
||||
boolList(masterPatch.size(), false),
|
||||
0,
|
||||
mesh.faceZones()
|
||||
)
|
||||
isf,
|
||||
boolList(masterPatch.size(), false)
|
||||
);
|
||||
|
||||
// Slave patch
|
||||
@ -284,42 +361,27 @@ int main(int argc, char *argv[])
|
||||
|
||||
labelList osf(slavePatch.size());
|
||||
|
||||
forAll(osf, i)
|
||||
forAll (osf, i)
|
||||
{
|
||||
osf[i] = slavePatch.start() + i;
|
||||
}
|
||||
|
||||
fz.append
|
||||
label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone");
|
||||
mesh.faceZones()[slaveZoneID].resetAddressing
|
||||
(
|
||||
new faceZone
|
||||
(
|
||||
mergePatchName + "SlaveZone",
|
||||
osf,
|
||||
boolList(slavePatch.size(), false),
|
||||
1,
|
||||
mesh.faceZones()
|
||||
)
|
||||
osf,
|
||||
boolList(slavePatch.size(), false)
|
||||
);
|
||||
|
||||
// Add empty zone for cut faces
|
||||
fz.append
|
||||
label cutZoneID = addFaceZone(mesh, cutZoneName);
|
||||
mesh.faceZones()[cutZoneID].resetAddressing
|
||||
(
|
||||
new faceZone
|
||||
(
|
||||
cutZoneName,
|
||||
labelList(0),
|
||||
boolList(0, false),
|
||||
2,
|
||||
mesh.faceZones()
|
||||
)
|
||||
labelList(0),
|
||||
boolList(0, false)
|
||||
);
|
||||
|
||||
|
||||
// Note: make sure to add the zones BEFORE constructing polyMeshModifier
|
||||
// (since looks up various zones at construction time)
|
||||
Info<< "Adding point and face zones" << endl;
|
||||
mesh.addZones(pz.shrink(), fz.shrink(), cz.shrink());
|
||||
|
||||
// Add the sliding interface mesh modifier
|
||||
stitcher.set
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user