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
|
// Checks whether patch present
|
||||||
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
|
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
|
||||||
{
|
{
|
||||||
@ -211,29 +309,20 @@ int main(int argc, char *argv[])
|
|||||||
polyTopoChanger stitcher(mesh);
|
polyTopoChanger stitcher(mesh);
|
||||||
stitcher.setSize(1);
|
stitcher.setSize(1);
|
||||||
|
|
||||||
DynamicList<pointZone*> pz;
|
mesh.pointZones().clearAddressing();
|
||||||
DynamicList<faceZone*> fz;
|
mesh.faceZones().clearAddressing();
|
||||||
DynamicList<cellZone*> cz;
|
mesh.cellZones().clearAddressing();
|
||||||
|
|
||||||
if (perfectCover)
|
if (perfectCover)
|
||||||
{
|
{
|
||||||
// Add empty zone for resulting internal faces
|
// Add empty zone for resulting internal faces
|
||||||
fz.append
|
label cutZoneID = addFaceZone(mesh, cutZoneName);
|
||||||
(
|
|
||||||
new faceZone
|
|
||||||
(
|
|
||||||
cutZoneName,
|
|
||||||
isf,
|
|
||||||
boolList(masterPatch.size(), false),
|
|
||||||
0,
|
|
||||||
mesh.faceZones()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Note: make sure to add the zones BEFORE constructing polyMeshModifier
|
mesh.faceZones()[cutZoneID].resetAddressing
|
||||||
// (since looks up various zones at construction time)
|
(
|
||||||
Info<< "Adding point and face zones" << endl;
|
isf,
|
||||||
mesh.addZones(pz.shrink(), fz.shrink(), cz.shrink());
|
boolList(masterPatch.size(), false)
|
||||||
|
);
|
||||||
|
|
||||||
// Add the perfect interface mesh modifier
|
// Add the perfect interface mesh modifier
|
||||||
stitcher.set
|
stitcher.set
|
||||||
@ -252,27 +341,15 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pz.append
|
label pointZoneID = addPointZone(mesh, mergePatchName + "CutPointZone");
|
||||||
(
|
mesh.pointZones()[pointZoneID] = labelList(0);
|
||||||
new pointZone
|
|
||||||
(
|
|
||||||
mergePatchName + "CutPointZone",
|
|
||||||
labelList(0),
|
|
||||||
0,
|
|
||||||
mesh.pointZones()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
fz.append
|
label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone");
|
||||||
|
|
||||||
|
mesh.faceZones()[masterZoneID].resetAddressing
|
||||||
(
|
(
|
||||||
new faceZone
|
isf,
|
||||||
(
|
boolList(masterPatch.size(), false)
|
||||||
mergePatchName + "MasterZone",
|
|
||||||
isf,
|
|
||||||
boolList(masterPatch.size(), false),
|
|
||||||
0,
|
|
||||||
mesh.faceZones()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Slave patch
|
// Slave patch
|
||||||
@ -284,42 +361,27 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
labelList osf(slavePatch.size());
|
labelList osf(slavePatch.size());
|
||||||
|
|
||||||
forAll(osf, i)
|
forAll (osf, i)
|
||||||
{
|
{
|
||||||
osf[i] = slavePatch.start() + i;
|
osf[i] = slavePatch.start() + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
fz.append
|
label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone");
|
||||||
|
mesh.faceZones()[slaveZoneID].resetAddressing
|
||||||
(
|
(
|
||||||
new faceZone
|
osf,
|
||||||
(
|
boolList(slavePatch.size(), false)
|
||||||
mergePatchName + "SlaveZone",
|
|
||||||
osf,
|
|
||||||
boolList(slavePatch.size(), false),
|
|
||||||
1,
|
|
||||||
mesh.faceZones()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add empty zone for cut faces
|
// Add empty zone for cut faces
|
||||||
fz.append
|
label cutZoneID = addFaceZone(mesh, cutZoneName);
|
||||||
|
mesh.faceZones()[cutZoneID].resetAddressing
|
||||||
(
|
(
|
||||||
new faceZone
|
labelList(0),
|
||||||
(
|
boolList(0, false)
|
||||||
cutZoneName,
|
|
||||||
labelList(0),
|
|
||||||
boolList(0, false),
|
|
||||||
2,
|
|
||||||
mesh.faceZones()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// 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
|
// Add the sliding interface mesh modifier
|
||||||
stitcher.set
|
stitcher.set
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user