extrudeToRegionMesh: Added options to set the name and type of the generated patches

e.g. in extrudeToRegionMeshDict:

// Generate the region named film
region          film;

// from the patch extrudeWall
patches         (extrudeWall);

// generating mapped patches for the extruded region
adaptMesh       yes;

// New options:

// Set the type of the mapped patch on the existing mesh to mappedWall ...
patchTypes      (mappedWall);

// ... and name to wall
patchNames      (wall);

// Set the type of the mapped patch on the region mesh to mappedFilmWall ...
regionPatchTypes   (mappedFilmWall);

// ... and name to wall
regionPatchNames   (wall);

// Set the type of the opposite patch on the region mesh to empty ...
regionOppositePatchTypes    (empty);

// ... and name to empty
regionOppositePatchNames    (empty);

All the above entries are optional and if not present the previous behaviour is
reproduced.
This commit is contained in:
Henry Weller
2023-02-28 15:43:37 +00:00
parent ea8a922ee8
commit c7c8c0fa46

View File

@ -146,11 +146,11 @@ label findPatchID(const List<polyPatch*>& newPatches, const word& name)
} }
template<class PatchType>
label addPatch label addPatch
( (
const polyBoundaryMesh& patches, const polyBoundaryMesh& patches,
const word& patchName, const word& patchName,
const word& patchType,
const dictionary& dict, const dictionary& dict,
DynamicList<polyPatch*>& newPatches DynamicList<polyPatch*>& newPatches
) )
@ -159,7 +159,7 @@ label addPatch
if (patchi != -1) if (patchi != -1)
{ {
if (isA<PatchType>(*newPatches[patchi])) if (newPatches[patchi]->type() == patchType)
{ {
return patchi; return patchi;
} }
@ -182,7 +182,7 @@ label addPatch
} }
dictionary patchDict(dict); dictionary patchDict(dict);
patchDict.set("type", PatchType::typeName); patchDict.set("type", patchType);
patchDict.set("nFaces", 0); patchDict.set("nFaces", 0);
patchDict.set("startFace", startFacei); patchDict.set("startFace", startFacei);
@ -541,6 +541,7 @@ void addCouplingPatches
const wordList& zoneNames, const wordList& zoneNames,
const wordList& zoneShadowNames, const wordList& zoneShadowNames,
const boolList& zoneIsInternal, const boolList& zoneIsInternal,
const dictionary& dict,
DynamicList<polyPatch*>& newPatches, DynamicList<polyPatch*>& newPatches,
labelList& zoneTopPatch, labelList& zoneTopPatch,
labelList& zoneBottomPatch labelList& zoneBottomPatch
@ -551,6 +552,42 @@ void addCouplingPatches
<< "-------\t-----\t----" << "-------\t-----\t----"
<< endl; << endl;
const wordList patchNames
(
dict.lookupOrDefault("patchNames", wordList())
);
const wordList patchTypes
(
isShellMesh
? dict.lookupOrDefault
(
"regionPatchTypes",
wordList(zoneNames.size(), mappedWallPolyPatch::typeName)
)
: dict.lookupOrDefault
(
"patchTypes",
wordList(zoneNames.size(), mappedWallPolyPatch::typeName)
)
);
const wordList regionPatchNames
(
dict.lookupOrDefault("regionPatchNames", wordList())
);
const wordList regionOppositePatchTypes
(
dict.lookupOrDefault("regionOppositePatchTypes", wordList())
);
const wordList regionOppositePatchNames
(
dict.lookupOrDefault("regionOppositePatchNames", wordList())
);
zoneTopPatch.setSize(zoneNames.size(), -1); zoneTopPatch.setSize(zoneNames.size(), -1);
zoneBottomPatch.setSize(zoneNames.size(), -1); zoneBottomPatch.setSize(zoneNames.size(), -1);
@ -562,11 +599,15 @@ void addCouplingPatches
{ {
const word patchNamePrefix = const word patchNamePrefix =
regionName + "_to_" + nbrRegionName + '_'; regionName + "_to_" + nbrRegionName + '_';
const word nbrPatchNamePrefix = const word nbrPatchNamePrefix =
nbrRegionName + "_to_" + regionName + '_'; nbrRegionName + "_to_" + regionName + '_';
word bottomPatchName, bottomNbrPatchName; word bottomPatchName;
word topPatchName, topNbrPatchName; word bottomNbrPatchName;
word topPatchName;
word topNbrPatchName;
if (zoneIsInternal[zonei]) if (zoneIsInternal[zonei])
{ {
bottomPatchName = patchNamePrefix + zoneNames[zonei] + "_bottom"; bottomPatchName = patchNamePrefix + zoneNames[zonei] + "_bottom";
@ -584,22 +625,41 @@ void addCouplingPatches
} }
else else
{ {
bottomPatchName = patchNamePrefix + zoneNames[zonei]; if (patchNames.size())
bottomNbrPatchName = nbrPatchNamePrefix + zoneNames[zonei]; {
topPatchName = zoneNames[zonei] + "_top"; bottomPatchName = patchNames[zonei];
}
else
{
bottomPatchName = patchNamePrefix + zoneNames[zonei];
}
if (regionPatchNames.size())
{
bottomNbrPatchName = regionPatchNames[zonei];
}
else
{
bottomNbrPatchName = nbrPatchNamePrefix + zoneNames[zonei];
}
topPatchName =
regionOppositePatchNames.size()
? regionOppositePatchNames[zonei]
: word(zoneNames[zonei] + "_top");
} }
dictionary bottomPatchDict(patchDict); dictionary bottomPatchDict(patchDict);
bottomPatchDict.add("neighbourPatch", bottomNbrPatchName); bottomPatchDict.add("neighbourPatch", bottomNbrPatchName);
zoneBottomPatch[zonei] = zoneBottomPatch[zonei] = addPatch
addPatch<mappedWallPolyPatch> (
( mesh.boundaryMesh(),
mesh.boundaryMesh(), bottomPatchName,
bottomPatchName, patchTypes[zonei],
bottomPatchDict, bottomPatchDict,
newPatches newPatches
); );
Pout<< zoneBottomPatch[zonei] Pout<< zoneBottomPatch[zonei]
<< '\t' << newPatches[zoneBottomPatch[zonei]]->name() << '\t' << newPatches[zoneBottomPatch[zonei]]->name()
@ -615,25 +675,27 @@ void addCouplingPatches
topPatchDict.add("bottomPatch", bottomPatchName); topPatchDict.add("bottomPatch", bottomPatchName);
} }
zoneTopPatch[zonei] = zoneTopPatch[zonei] = addPatch
addPatch<mappedExtrudedWallPolyPatch> (
( mesh.boundaryMesh(),
mesh.boundaryMesh(), topPatchName,
topPatchName, mappedExtrudedWallPolyPatch::typeName,
topPatchDict, topPatchDict,
newPatches newPatches
); );
} }
else else
{ {
zoneTopPatch[zonei] = zoneTopPatch[zonei] = addPatch
addPatch<polyPatch> (
( mesh.boundaryMesh(),
mesh.boundaryMesh(), topPatchName,
topPatchName, regionOppositePatchTypes.size()
dictionary(), ? regionOppositePatchTypes[zonei]
newPatches : polyPatch::typeName,
); dictionary(),
newPatches
);
} }
Pout<< zoneTopPatch[zonei] Pout<< zoneTopPatch[zonei]
@ -734,10 +796,11 @@ labelList addZoneSidePatches
if (oneDPolyPatchType == "empty") if (oneDPolyPatchType == "empty")
{ {
patchName = "oneDEmptyPatch"; patchName = "oneDEmptyPatch";
zoneSidePatches[zoneI] = addPatch<emptyPolyPatch> zoneSidePatches[zoneI] = addPatch
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
patchName, patchName,
emptyPolyPatch::typeName,
dictionary(), dictionary(),
newPatches newPatches
); );
@ -745,10 +808,11 @@ labelList addZoneSidePatches
else if (oneDPolyPatchType == "wedge") else if (oneDPolyPatchType == "wedge")
{ {
patchName = "oneDWedgePatch"; patchName = "oneDWedgePatch";
zoneSidePatches[zoneI] = addPatch<wedgePolyPatch> zoneSidePatches[zoneI] = addPatch
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
patchName, patchName,
wedgePolyPatch::typeName,
dictionary(), dictionary(),
newPatches newPatches
); );
@ -771,10 +835,11 @@ labelList addZoneSidePatches
{ {
word patchName = zoneNames[zoneI] + "_" + "side"; word patchName = zoneNames[zoneI] + "_" + "side";
zoneSidePatches[zoneI] = addPatch<polyPatch> zoneSidePatches[zoneI] = addPatch
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
patchName, patchName,
polyPatch::typeName,
dictionary(), dictionary(),
newPatches newPatches
); );
@ -910,10 +975,11 @@ labelList addExtrudeEdgeSidePatches
patchDict.add("myProcNo", Pstream::myProcNo()); patchDict.add("myProcNo", Pstream::myProcNo());
patchDict.add("neighbProcNo", nbrProci); patchDict.add("neighbProcNo", nbrProci);
extrudeEdgeSidePatches[edgeI] = addPatch<processorPolyPatch> extrudeEdgeSidePatches[edgeI] = addPatch
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
name, name,
processorPolyPatch::typeName,
patchDict, patchDict,
newPatches newPatches
); );
@ -990,7 +1056,7 @@ int main(int argc, char *argv[])
zoneShadowNames.append zoneShadowNames.append
( (
dict.lookupOrDefault<wordList> dict.lookupOrDefault
( (
keyword + "Shadow", keyword + "Shadow",
wordList wordList
@ -1344,6 +1410,7 @@ int main(int argc, char *argv[])
zoneNames, zoneNames,
zoneShadowNames, zoneShadowNames,
zoneIsInternal, zoneIsInternal,
dict,
regionPatches, regionPatches,
zoneTopPatch, zoneTopPatch,
zoneBottomPatch zoneBottomPatch
@ -1376,6 +1443,7 @@ int main(int argc, char *argv[])
zoneNames, zoneNames,
zoneShadowNames, zoneShadowNames,
zoneIsInternal, zoneIsInternal,
dict,
newPatches, newPatches,
interMeshTopPatch, interMeshTopPatch,
interMeshBottomPatch interMeshBottomPatch