extrudeToRegionMesh: Added option to extrude patches

This greatly simplifies most setups in which it is a patch (or patches)
of the original mesh which are extruded. It prevents the need for a
topoSet configuration to convert the patch into a zone or set.
This commit is contained in:
Will Bainbridge
2022-08-30 09:49:55 +01:00
parent 94cf816b9d
commit b07feb9858
43 changed files with 378 additions and 559 deletions

View File

@ -672,7 +672,7 @@ void addCouplingPatches
patchDict.add("sampleRegion", sampleRegionName); patchDict.add("sampleRegion", sampleRegionName);
label nOldPatches = newPatches.size(); label nOldPatches = newPatches.size();
forAll(zoneNames, zoneI) forAll(zoneNames, zonei)
{ {
const word patchNamePrefix = const word patchNamePrefix =
regionName + "_to_" + sampleRegionName + '_'; regionName + "_to_" + sampleRegionName + '_';
@ -681,33 +681,33 @@ void addCouplingPatches
word bottomPatchName, bottomSamplePatchName; word bottomPatchName, bottomSamplePatchName;
word topPatchName, topSamplePatchName; word topPatchName, topSamplePatchName;
if (zoneIsInternal[zoneI]) if (zoneIsInternal[zonei])
{ {
bottomPatchName = patchNamePrefix + zoneNames[zoneI] + "_bottom"; bottomPatchName = patchNamePrefix + zoneNames[zonei] + "_bottom";
bottomSamplePatchName = bottomSamplePatchName =
samplePatchNamePrefix + zoneNames[zoneI] + "_bottom"; samplePatchNamePrefix + zoneNames[zonei] + "_bottom";
topPatchName = patchNamePrefix + zoneNames[zoneI] + "_top"; topPatchName = patchNamePrefix + zoneNames[zonei] + "_top";
topSamplePatchName = topSamplePatchName =
samplePatchNamePrefix + zoneNames[zoneI] + "_top"; samplePatchNamePrefix + zoneNames[zonei] + "_top";
} }
else if (!zoneShadowNames.empty()) else if (!zoneShadowNames[zonei].empty())
{ {
bottomPatchName = patchNamePrefix + zoneNames[zoneI]; bottomPatchName = patchNamePrefix + zoneNames[zonei];
bottomSamplePatchName = samplePatchNamePrefix + zoneNames[zoneI]; bottomSamplePatchName = samplePatchNamePrefix + zoneNames[zonei];
topPatchName = patchNamePrefix + zoneShadowNames[zoneI]; topPatchName = patchNamePrefix + zoneShadowNames[zonei];
topSamplePatchName = samplePatchNamePrefix + zoneShadowNames[zoneI]; topSamplePatchName = samplePatchNamePrefix + zoneShadowNames[zonei];
} }
else else
{ {
bottomPatchName = patchNamePrefix + zoneNames[zoneI]; bottomPatchName = patchNamePrefix + zoneNames[zonei];
bottomSamplePatchName = samplePatchNamePrefix + zoneNames[zoneI]; bottomSamplePatchName = samplePatchNamePrefix + zoneNames[zonei];
topPatchName = zoneNames[zoneI] + "_top"; topPatchName = zoneNames[zonei] + "_top";
} }
dictionary bottomPatchDict(patchDict); dictionary bottomPatchDict(patchDict);
bottomPatchDict.add("samplePatch", bottomSamplePatchName); bottomPatchDict.add("samplePatch", bottomSamplePatchName);
zoneBottomPatch[zoneI] = zoneBottomPatch[zonei] =
addPatch<mappedWallPolyPatch> addPatch<mappedWallPolyPatch>
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
@ -716,12 +716,12 @@ void addCouplingPatches
newPatches newPatches
); );
Pout<< zoneBottomPatch[zoneI] Pout<< zoneBottomPatch[zonei]
<< '\t' << newPatches[zoneBottomPatch[zoneI]]->name() << '\t' << newPatches[zoneBottomPatch[zonei]]->name()
<< '\t' << newPatches[zoneBottomPatch[zoneI]]->type() << '\t' << newPatches[zoneBottomPatch[zonei]]->type()
<< nl; << nl;
if (zoneIsInternal[zoneI] || !zoneShadowNames.empty()) if (zoneIsInternal[zonei] || !zoneShadowNames[zonei].empty())
{ {
dictionary topPatchDict(patchDict); dictionary topPatchDict(patchDict);
topPatchDict.add("samplePatch", topSamplePatchName); topPatchDict.add("samplePatch", topSamplePatchName);
@ -730,7 +730,7 @@ void addCouplingPatches
topPatchDict.add("bottomPatch", bottomPatchName); topPatchDict.add("bottomPatch", bottomPatchName);
} }
zoneTopPatch[zoneI] = zoneTopPatch[zonei] =
addPatch<mappedExtrudedWallPolyPatch> addPatch<mappedExtrudedWallPolyPatch>
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
@ -741,7 +741,7 @@ void addCouplingPatches
} }
else else
{ {
zoneTopPatch[zoneI] = zoneTopPatch[zonei] =
addPatch<polyPatch> addPatch<polyPatch>
( (
mesh.boundaryMesh(), mesh.boundaryMesh(),
@ -751,9 +751,9 @@ void addCouplingPatches
); );
} }
Pout<< zoneTopPatch[zoneI] Pout<< zoneTopPatch[zonei]
<< '\t' << newPatches[zoneTopPatch[zoneI]]->name() << '\t' << newPatches[zoneTopPatch[zonei]]->name()
<< '\t' << newPatches[zoneTopPatch[zoneI]]->type() << '\t' << newPatches[zoneTopPatch[zonei]]->type()
<< nl; << nl;
} }
@ -1068,38 +1068,75 @@ int main(int argc, char *argv[])
bool overwrite = args.optionFound("overwrite"); bool overwrite = args.optionFound("overwrite");
const word oldInstance = mesh.pointsInstance();
const dictionary dict(systemDict("extrudeToRegionMeshDict", args, mesh)); const dictionary dict(systemDict("extrudeToRegionMeshDict", args, mesh));
// Point generator // Region to extrude from
autoPtr<extrudeModel> model(extrudeModel::New(dict));
// Region
const word shellRegionName(dict.lookup("region")); const word shellRegionName(dict.lookup("region"));
// Faces to extrude - either faceZones or faceSets (boundary faces only) if (shellRegionName == regionName)
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Cannot extrude into same region as mesh." << endl
<< "Mesh region : " << regionName << endl
<< "Shell region : " << shellRegionName
<< exit(FatalIOError);
}
// Select faces to extrude
enum class zoneSourceType { zone, set, patch };
static const wordList zoneSourceTypeNames =
{"faceZone", "faceSet", "patch" };
static const wordList zoneSourcesTypeNames =
{"faceZones", "faceSets", "patches" };
wordList zoneNames; wordList zoneNames;
wordList zoneShadowNames; wordList zoneShadowNames;
bool hasZones = dict.found("faceZones"); List<zoneSourceType> zoneSourceTypes;
if (hasZones) auto lookupZones = [&](const zoneSourceType& type)
{ {
dict.lookup("faceZones") >> zoneNames; const word& keyword = zoneSourcesTypeNames[unsigned(type)];
dict.readIfPresent("faceZonesShadow", zoneShadowNames);
if (dict.found("faceSets")) if (dict.found(keyword))
{ {
FatalIOErrorIn(args.executable().c_str(), dict) zoneNames.append(dict.lookup<wordList>(keyword));
<< "Please supply faces to extrude either through 'faceZones'"
<< " or 'faceSets' entry. Found both." zoneShadowNames.append
<< exit(FatalIOError); (
dict.lookupOrDefault<wordList>
(
keyword + "Shadow",
wordList
(
zoneNames.size() - zoneShadowNames.size(),
word::null
)
)
);
zoneSourceTypes.setSize(zoneNames.size(), type);
}
};
lookupZones(zoneSourceType::zone);
lookupZones(zoneSourceType::set);
lookupZones(zoneSourceType::patch);
Info<< nl << "Extruding:" << nl << incrIndent;
forAll(zoneNames, zonei)
{
const unsigned typei = unsigned(zoneSourceTypes[zonei]);
if (zoneShadowNames[zonei].empty())
{
Info<< indent << "From " << zoneSourceTypeNames[typei] << " \""
<< zoneNames[zonei] << "\"" << nl;
}
else
{
Info<< indent << "Between " << zoneSourcesTypeNames[typei] << " \""
<< zoneNames[zonei] << "\" and \"" << zoneShadowNames[zonei]
<< "\"" << nl;
} }
} }
else Info<< endl << decrIndent;
{
dict.lookup("faceSets") >> zoneNames;
dict.readIfPresent("faceSetsShadow", zoneShadowNames);
}
// One-dimensional extrusion settings // One-dimensional extrusion settings
const Switch oneD(dict.lookupOrDefault("oneD", false)); const Switch oneD(dict.lookupOrDefault("oneD", false));
@ -1111,33 +1148,6 @@ int main(int argc, char *argv[])
dict.lookup("oneDPolyPatchType") >> oneDPatchType; dict.lookup("oneDPolyPatchType") >> oneDPatchType;
} }
// Change the primary mesh?
const Switch adaptMesh(dict.lookup("adaptMesh"));
if (hasZones)
{
Info<< "Extruding zones " << zoneNames
<< " on mesh " << regionName
<< " into shell mesh " << shellRegionName
<< endl;
}
else
{
Info<< "Extruding faceSets " << zoneNames
<< " on mesh " << regionName
<< " into shell mesh " << shellRegionName
<< endl;
}
if (shellRegionName == regionName)
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Cannot extrude into same region as mesh." << endl
<< "Mesh region : " << regionName << endl
<< "Shell region : " << shellRegionName
<< exit(FatalIOError);
}
if (oneD) if (oneD)
{ {
if (oneDNonManifoldEdges) if (oneDNonManifoldEdges)
@ -1156,7 +1166,14 @@ int main(int argc, char *argv[])
} }
} }
// Construct the point generator
autoPtr<extrudeModel> model(extrudeModel::New(dict));
// Change the primary mesh?
const Switch adaptMesh(dict.lookup("adaptMesh"));
// Determine output instance
word meshInstance; word meshInstance;
if (!overwrite) if (!overwrite)
{ {
@ -1165,222 +1182,185 @@ int main(int argc, char *argv[])
} }
else else
{ {
meshInstance = oldInstance; meshInstance = mesh.pointsInstance();
} }
Info<< "Writing meshes to " << meshInstance << nl << endl; Info<< "Writing meshes to " << meshInstance << nl << endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Map from extrude zone to mesh zone, or -1 if not a mesh zone
labelList zoneMeshZoneID(zoneNames.size(), -1);
labelList shadowZoneMeshZoneID(zoneNames.size(), -1);
forAll(zoneNames, zonei)
{
if (zoneSourceTypes[zonei] != zoneSourceType::zone) continue;
zoneMeshZoneID[zonei] =
mesh.faceZones().findZoneID(zoneNames[zonei]);
if (zoneMeshZoneID[zonei] == -1)
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Cannot find zone " << zoneNames[zonei]
<< endl << "Valid zones are " << mesh.faceZones().names()
<< exit(FatalIOError);
}
if (!zoneShadowNames[zonei].empty())
{
shadowZoneMeshZoneID[zonei] =
mesh.faceZones().findZoneID(zoneShadowNames[zonei]);
if (shadowZoneMeshZoneID[zonei] == -1)
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Cannot find shadow zone " << zoneShadowNames[zonei]
<< endl << "Valid zones are " << mesh.faceZones().names()
<< exit(FatalIOError);
}
}
}
// Extract faces to extrude // Extract faces to extrude
// ~~~~~~~~~~~~~~~~~~~~~~~~ labelList extrudeFaces, shadowExtrudeFaces;
labelList extrudeFaceZoneIDs, shadowExtrudeFaceZoneIDs;
// From extrude zone to mesh zone (or -1 if extruding faceSets) boolList extrudeFaceFlips, shadowExtrudeFaceFlips;
labelList zoneMeshZoneID;
labelList shadowZoneMeshZoneID;
// Primary
labelList extrudeFaces;
labelList extrudeFaceZoneIDs;
boolList extrudeFaceFlips;
// Shadow
labelList shadowExtrudeFaces;
labelList shadowExtrudeFaceZoneIDs;
boolList shadowExtrudeFaceFlips;
if (hasZones)
{ {
const meshFaceZones& faceZones = mesh.faceZones(); // Load any faceSets that we need
PtrList<faceSet> zoneSets(zoneNames.size());
zoneMeshZoneID.setSize(zoneNames.size()); PtrList<faceSet> zoneShadowSets(zoneNames.size());
forAll(zoneNames, i) forAll(zoneNames, zonei)
{ {
zoneMeshZoneID[i] = if (zoneSourceTypes[zonei] == zoneSourceType::set)
faceZones.findZoneID(zoneNames[i]);
if (zoneMeshZoneID[i] == -1)
{ {
FatalIOErrorIn(args.executable().c_str(), dict) zoneSets.set(zonei, new faceSet(mesh, zoneNames[zonei]));
<< "Cannot find zone " << zoneNames[i] << endl if (!zoneShadowNames.empty())
<< "Valid zones are " << faceZones.names()
<< exit(FatalIOError);
}
}
label nExtrudeFaces = 0;
forAll(zoneMeshZoneID, i)
{
nExtrudeFaces += faceZones[zoneMeshZoneID[i]].size();
}
extrudeFaces.setSize(nExtrudeFaces);
extrudeFaceZoneIDs.setSize(nExtrudeFaces);
extrudeFaceFlips.setSize(nExtrudeFaces);
nExtrudeFaces = 0;
forAll(zoneMeshZoneID, i)
{
const faceZone& fz = faceZones[zoneMeshZoneID[i]];
forAll(fz, j)
{
extrudeFaces[nExtrudeFaces] = fz[j];
extrudeFaceZoneIDs[nExtrudeFaces] = i;
extrudeFaceFlips[nExtrudeFaces] = fz.flipMap()[j];
nExtrudeFaces++;
}
}
// Shadow zones
if (zoneShadowNames.size())
{
shadowZoneMeshZoneID.setSize(zoneShadowNames.size());
forAll(zoneShadowNames, i)
{
shadowZoneMeshZoneID[i] =
faceZones.findZoneID(zoneShadowNames[i]);
if (shadowZoneMeshZoneID[i] == -1)
{ {
FatalIOErrorIn(args.executable().c_str(), dict) zoneShadowSets.set
<< "Cannot find zone " << zoneShadowNames[i] << endl (
<< "Valid zones are " << faceZones.names() zonei,
<< exit(FatalIOError); new faceSet(mesh, zoneShadowNames[zonei])
} );
}
label nShadowFaces = 0;
forAll(shadowZoneMeshZoneID, i)
{
nShadowFaces += faceZones[shadowZoneMeshZoneID[i]].size();
}
if (nExtrudeFaces != nShadowFaces)
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Extruded faces " << nExtrudeFaces << endl
<< "is different from shadow faces. " << nShadowFaces
<< "This is not permitted " << endl
<< exit(FatalIOError);
}
shadowExtrudeFaces.setSize(nShadowFaces);
shadowExtrudeFaceZoneIDs.setSize(nShadowFaces);
shadowExtrudeFaceFlips.setSize(nShadowFaces);
nShadowFaces = 0;
forAll(shadowZoneMeshZoneID, i)
{
const faceZone& fz = faceZones[shadowZoneMeshZoneID[i]];
forAll(fz, j)
{
shadowExtrudeFaces[nShadowFaces] = fz[j];
shadowExtrudeFaceZoneIDs[nShadowFaces] = i;
shadowExtrudeFaceFlips[nShadowFaces] = fz.flipMap()[j];
nShadowFaces++;
} }
} }
} }
}
else
{
zoneMeshZoneID.setSize(zoneNames.size(), -1);
// Load faceSets // Create dynamic face lists
PtrList<faceSet> zones(zoneNames.size()); DynamicList<label> facesDyn, sdwFacesDyn;
forAll(zoneNames, i) DynamicList<label> zoneIDsDyn, sdwZoneIDsDyn;
DynamicList<bool> flipsDyn, sdwFlipsDyn;
forAll(zoneNames, zonei)
{ {
Info<< "Loading faceSet " << zoneNames[i] << endl; switch (zoneSourceTypes[zonei])
zones.set(i, new faceSet(mesh, zoneNames[i]));
}
label nExtrudeFaces = 0;
forAll(zones, i)
{
nExtrudeFaces += zones[i].size();
}
extrudeFaces.setSize(nExtrudeFaces);
extrudeFaceZoneIDs.setSize(nExtrudeFaces);
extrudeFaceFlips.setSize(nExtrudeFaces);
nExtrudeFaces = 0;
forAll(zones, i)
{
const faceSet& fz = zones[i];
forAllConstIter(faceSet, fz, iter)
{ {
label facei = iter.key(); case zoneSourceType::zone:
if (mesh.isInternalFace(facei))
{ {
FatalIOErrorIn(args.executable().c_str(), dict) const faceZone& fz =
<< "faceSet " << fz.name() mesh.faceZones()[zoneMeshZoneID[zonei]];
<< "contains internal faces." facesDyn.append(fz);
<< " This is not permitted." zoneIDsDyn.append(labelList(fz.size(), zonei));
<< exit(FatalIOError); flipsDyn.append(fz.flipMap());
}
extrudeFaces[nExtrudeFaces] = facei;
extrudeFaceZoneIDs[nExtrudeFaces] = i;
extrudeFaceFlips[nExtrudeFaces] = false;
nExtrudeFaces++;
}
}
// Shadow sets if (!zoneShadowNames[zonei].empty())
if (zoneShadowNames.size())
{
shadowZoneMeshZoneID.setSize(zoneShadowNames.size(), -1);
// Load faceSets
PtrList<faceSet> shadowZones(zoneShadowNames.size());
forAll(zoneShadowNames, i)
{
shadowZones.set(i, new faceSet(mesh, zoneShadowNames[i]));
}
label nShadowFaces = 0;
forAll(shadowZones, i)
{
nShadowFaces += shadowZones[i].size();
}
if (nExtrudeFaces != nShadowFaces)
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Extruded faces " << nExtrudeFaces << endl
<< "is different from shadow faces. " << nShadowFaces
<< "This is not permitted " << endl
<< exit(FatalIOError);
}
shadowExtrudeFaces.setSize(nShadowFaces);
shadowExtrudeFaceFlips.setSize(nShadowFaces);
shadowExtrudeFaceZoneIDs.setSize(nShadowFaces);
nShadowFaces = 0;
forAll(shadowZones, i)
{
const faceSet& fz = shadowZones[i];
forAllConstIter(faceSet, fz, iter)
{
label facei = iter.key();
if (mesh.isInternalFace(facei))
{ {
FatalIOErrorIn(args.executable().c_str(), dict) const faceZone& sfz =
<< "faceSet " << fz.name() mesh.faceZones()[shadowZoneMeshZoneID[zonei]];
<< "contains internal faces." if (sfz.size() != fz.size())
<< " This is not permitted." {
<< exit(FatalIOError); FatalIOErrorIn(args.executable().c_str(), dict)
<< "Shadow zone " << zoneShadowNames[zonei]
<< "is a different size from it's "
<< "corresponding zone " << zoneNames[zonei]
<< exit(FatalIOError);
}
sdwFacesDyn.append(sfz);
sdwZoneIDsDyn.append(labelList(sfz.size(), zonei));
sdwFlipsDyn.append(sfz.flipMap());
} }
shadowExtrudeFaces[nShadowFaces] = facei; else
shadowExtrudeFaceFlips[nShadowFaces] = false; {
shadowExtrudeFaceZoneIDs[nShadowFaces] = i; sdwFacesDyn.append(labelList(fz.size(), -1));
nShadowFaces++; sdwZoneIDsDyn.append(labelList(fz.size(), -1));
sdwFlipsDyn.append(boolList(fz.size(), false));
}
break;
}
case zoneSourceType::set:
{
const faceSet& fs = zoneSets[zonei];
facesDyn.append(fs.toc());
zoneIDsDyn.append(labelList(fs.size(), zonei));
flipsDyn.append(boolList(fs.size(), false));
if (!zoneShadowNames[zonei].empty())
{
const faceSet& sfs = zoneShadowSets[zonei];
if (sfs.size() != fs.size())
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Shadow set " << zoneShadowNames[zonei]
<< "is a different size from it's "
<< "corresponding zone " << zoneNames[zonei]
<< exit(FatalIOError);
}
sdwFacesDyn.append(sfs.toc());
sdwZoneIDsDyn.append(labelList(sfs.size(), zonei));
sdwFlipsDyn.append(boolList(sfs.size(), false));
}
else
{
sdwFacesDyn.append(labelList(fs.size(), -1));
sdwZoneIDsDyn.append(labelList(fs.size(), -1));
sdwFlipsDyn.append(boolList(fs.size(), false));
}
break;
}
case zoneSourceType::patch:
{
const polyPatch& pp =
mesh.boundaryMesh()[zoneNames[zonei]];
facesDyn.append(pp.start() + identity(pp.size()));
zoneIDsDyn.append(labelList(pp.size(), zonei));
flipsDyn.append(boolList(pp.size(), false));
if (!zoneShadowNames[zonei].empty())
{
const polyPatch& spp =
mesh.boundaryMesh()[zoneShadowNames[zonei]];
if (spp.size() != pp.size())
{
FatalIOErrorIn(args.executable().c_str(), dict)
<< "Shadow patch " << zoneShadowNames[zonei]
<< "is a different size from it's "
<< "corresponding zone " << zoneNames[zonei]
<< exit(FatalIOError);
}
sdwFacesDyn.append(spp.start() + identity(spp.size()));
sdwZoneIDsDyn.append(labelList(spp.size(), zonei));
sdwFlipsDyn.append(boolList(spp.size(), false));
}
else
{
sdwFacesDyn.append(labelList(pp.size(), -1));
sdwZoneIDsDyn.append(labelList(pp.size(), -1));
sdwFlipsDyn.append(boolList(pp.size(), false));
}
break;
} }
} }
} }
// Transfer to non-dynamic storage
extrudeFaces.transfer(facesDyn);
extrudeFaceZoneIDs.transfer(zoneIDsDyn);
extrudeFaceFlips.transfer(flipsDyn);
shadowExtrudeFaces.transfer(sdwFacesDyn);
shadowExtrudeFaceZoneIDs.transfer(sdwZoneIDsDyn);
shadowExtrudeFaceFlips.transfer(sdwFlipsDyn);
} }
// Create a primitive patch of the extruded faces
const primitiveFacePatch extrudePatch const primitiveFacePatch extrudePatch
( (
faceList(UIndirectList<face>(mesh.faces(), extrudeFaces)), faceList(UIndirectList<face>(mesh.faces(), extrudeFaces)),
@ -1454,16 +1434,16 @@ int main(int argc, char *argv[])
// Copy all non-local patches since these are used on boundary edges of // Copy all non-local patches since these are used on boundary edges of
// the extrusion // the extrusion
DynamicList<polyPatch*> regionPatches(patches.size()); DynamicList<polyPatch*> regionPatches(mesh.boundaryMesh().size());
forAll(patches, patchi) forAll(mesh.boundaryMesh(), patchi)
{ {
if (!isA<processorPolyPatch>(patches[patchi])) if (!isA<processorPolyPatch>(mesh.boundaryMesh()[patchi]))
{ {
regionPatches.append regionPatches.append
( (
patches[patchi].clone mesh.boundaryMesh()[patchi].clone
( (
patches, mesh.boundaryMesh(),
regionPatches.size(), regionPatches.size(),
0, // size 0, // size
0 // start 0 // start
@ -1497,6 +1477,8 @@ int main(int argc, char *argv[])
labelList interMeshBottomPatch; labelList interMeshBottomPatch;
if (adaptMesh) if (adaptMesh)
{ {
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Clone existing non-processor patches // Clone existing non-processor patches
DynamicList<polyPatch*> newPatches(patches.size()); DynamicList<polyPatch*> newPatches(patches.size());
forAll(patches, patchi) forAll(patches, patchi)
@ -1670,11 +1652,15 @@ int main(int argc, char *argv[])
if (facei != -1) if (facei != -1)
{ {
label newPatchi = findPatchID const label newPatchi =
( findPatchID
regionPatches, (
patches[patches.whichPatch(facei)].name() regionPatches,
); mesh.boundaryMesh()
[
mesh.boundaryMesh().whichPatch(facei)
].name()
);
ePatches.setSize(eFaces.size(), newPatchi); ePatches.setSize(eFaces.size(), newPatchi);
} }
else else
@ -1872,11 +1858,11 @@ int main(int argc, char *argv[])
polyTopoChange meshMod(mesh); polyTopoChange meshMod(mesh);
// Modify faces to be in bottom (= always coupled) patch // Modify faces to be in bottom (= always coupled) patch
forAll(extrudeFaces, zoneFacei) forAll(extrudeFaces, facei)
{ {
label meshFacei = extrudeFaces[zoneFacei]; const label meshFacei = extrudeFaces[facei];
label zoneI = extrudeFaceZoneIDs[zoneFacei]; const label zonei = extrudeFaceZoneIDs[facei];
bool flip = extrudeFaceFlips[zoneFacei]; const bool flip = extrudeFaceFlips[facei];
const face& f = mesh.faces()[meshFacei]; const face& f = mesh.faces()[meshFacei];
if (!flip) if (!flip)
@ -1888,8 +1874,8 @@ int main(int argc, char *argv[])
mesh.faceOwner()[meshFacei],// owner mesh.faceOwner()[meshFacei],// owner
-1, // neighbour -1, // neighbour
false, // face flip false, // face flip
interMeshBottomPatch[zoneI],// patch for face interMeshBottomPatch[zonei],// patch for face
zoneMeshZoneID[zoneI], // zone for face zoneMeshZoneID[zonei], // zone for face
flip // face flip in zone flip // face flip in zone
); );
} }
@ -1902,20 +1888,20 @@ int main(int argc, char *argv[])
mesh.faceNeighbour()[meshFacei],// owner mesh.faceNeighbour()[meshFacei],// owner
-1, // neighbour -1, // neighbour
true, // face flip true, // face flip
interMeshBottomPatch[zoneI], // patch for face interMeshBottomPatch[zonei], // patch for face
zoneMeshZoneID[zoneI], // zone for face zoneMeshZoneID[zonei], // zone for face
!flip // face flip in zone !flip // face flip in zone
); );
} }
} }
if (zoneShadowNames.size() > 0) // if there is a top faceZone specified forAll(extrudeFaces, facei)
{ {
forAll(extrudeFaces, zoneFacei) if (shadowExtrudeFaces[facei] != -1)
{ {
label meshFacei = shadowExtrudeFaces[zoneFacei]; const label meshFacei = shadowExtrudeFaces[facei];
label zoneI = shadowExtrudeFaceZoneIDs[zoneFacei]; const label zonei = shadowExtrudeFaceZoneIDs[facei];
bool flip = shadowExtrudeFaceFlips[zoneFacei]; bool flip = shadowExtrudeFaceFlips[facei];
const face& f = mesh.faces()[meshFacei]; const face& f = mesh.faces()[meshFacei];
if (!flip) if (!flip)
@ -1927,8 +1913,8 @@ int main(int argc, char *argv[])
mesh.faceOwner()[meshFacei],// owner mesh.faceOwner()[meshFacei],// owner
-1, // neighbour -1, // neighbour
false, // face flip false, // face flip
interMeshTopPatch[zoneI], // patch for face interMeshTopPatch[zonei], // patch for face
zoneMeshZoneID[zoneI], // zone for face zoneMeshZoneID[zonei], // zone for face
flip // face flip in zone flip // face flip in zone
); );
} }
@ -1941,21 +1927,17 @@ int main(int argc, char *argv[])
mesh.faceNeighbour()[meshFacei],// owner mesh.faceNeighbour()[meshFacei],// owner
-1, // neighbour -1, // neighbour
true, // face flip true, // face flip
interMeshTopPatch[zoneI], // patch for face interMeshTopPatch[zonei], // patch for face
zoneMeshZoneID[zoneI], // zone for face zoneMeshZoneID[zonei], // zone for face
!flip // face flip in zone !flip // face flip in zone
); );
} }
} }
} else
else
{
// Add faces (using same points) to be in top patch
forAll(extrudeFaces, zoneFacei)
{ {
label meshFacei = extrudeFaces[zoneFacei]; const label meshFacei = extrudeFaces[facei];
label zoneI = extrudeFaceZoneIDs[zoneFacei]; const label zonei = extrudeFaceZoneIDs[facei];
bool flip = extrudeFaceFlips[zoneFacei]; const bool flip = extrudeFaceFlips[facei];
const face& f = mesh.faces()[meshFacei]; const face& f = mesh.faces()[meshFacei];
if (!flip) if (!flip)
@ -1971,7 +1953,7 @@ int main(int argc, char *argv[])
-1, // master edge -1, // master edge
meshFacei, // master face meshFacei, // master face
true, // flip flux true, // flip flux
interMeshTopPatch[zoneI], // patch for face interMeshTopPatch[zonei], // patch for face
-1, // zone for face -1, // zone for face
false // face flip in zone false // face flip in zone
); );
@ -1988,7 +1970,7 @@ int main(int argc, char *argv[])
-1, // master edge -1, // master edge
meshFacei, // master face meshFacei, // master face
false, // flip flux false, // flip flux
interMeshTopPatch[zoneI], // patch for face interMeshTopPatch[zonei], // patch for face
-1, // zone for face -1, // zone for face
false // zone flip false // zone flip
); );

View File

@ -0,0 +1,22 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh -region fluid
# Create the 3D baffle
runApplication -s extrudeFromPatches createBaffles -region fluid -overwrite \
-dict system/fluid/createBafflesDict.extrudeFromPatches
runApplication extrudeToRegionMesh -region fluid -overwrite \
-dict system/fluid/extrudeToRegionMeshDict.extrudeFromPatches
# Create the 1D baffle
runApplication createBaffles -region fluid -overwrite
runApplication $(getApplication)
paraFoam -touchAll
#------------------------------------------------------------------------------

View File

@ -9,28 +9,35 @@ FoamFile
{ {
format ascii; format ascii;
class dictionary; class dictionary;
object topoSetDict; object createBafflesDict.baffle3D;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions internalFacesOnly true;
(
fields false;
baffles
{
baffle3D
{ {
name plateFaceSet; type searchableSurface;
type faceSet; surface triSurfaceMesh;
action new; name baffle3D.stl;
source patchToFace;
patch plate; owner
{
name baffle3D0;
type wall;
}
neighbour
{
name baffle3D1;
type wall;
}
} }
{ }
name plateFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet plateFaceSet;
}
);
// ************************************************************************* // // ************************************************************************* //

View File

@ -9,27 +9,26 @@ FoamFile
{ {
format ascii; format ascii;
class dictionary; class dictionary;
object topoSetDict; object extrudeToRegionMeshDict;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions region baffle3D;
(
{ patches (baffle3D0);
name walls; patchesShadow (baffle3D1);
type faceSet;
action new; extrudeModel linearNormal;
source patchToFace;
patch walls; nLayers 50;
}
{ expansionRatio 1;
name walls;
type faceZoneSet; adaptMesh yes; // apply mapped to both regions
action new;
source setToFaceZone; linearNormalCoeffs
faceSet walls; {
} thickness 0.02;
); }
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ boundaryField
{ {
#includeEtc "caseDicts/setConstraintTypes" #includeEtc "caseDicts/setConstraintTypes"
"(sides|frontAndBack|wallFilmFaces_top|cylinderFilmFaces_top)" "(sides|frontAndBack|walls_top|cylinder_top)"
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -22,7 +22,7 @@ boundaryField
{ {
#includeEtc "caseDicts/setConstraintTypes" #includeEtc "caseDicts/setConstraintTypes"
"(wallFilmFaces_top|cylinderFilmFaces_top)" "(walls_top|cylinder_top)"
{ {
type slip; type slip;
} }

View File

@ -22,7 +22,7 @@ boundaryField
{ {
#includeEtc "caseDicts/setConstraintTypes" #includeEtc "caseDicts/setConstraintTypes"
"(sides|frontAndBack|wallFilmFaces_top|cylinderFilmFaces_top)" "(sides|frontAndBack|walls_top|cylinder_top)"
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh runApplication blockMesh
runApplication topoSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
runApplication $(getApplication) runApplication $(getApplication)

View File

@ -5,7 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory
runApplication blockMesh runApplication blockMesh
runApplication decomposePar -noFields runApplication decomposePar -noFields
runParallel topoSet
runParallel extrudeToRegionMesh -overwrite runParallel extrudeToRegionMesh -overwrite
runApplication -s fields decomposePar -fields -copyZero runApplication -s fields decomposePar -fields -copyZero

View File

@ -15,7 +15,7 @@ FoamFile
region wallFilm; region wallFilm;
faceZones (wallFilmFaces cylinderFilmFaces); patches (walls cylinder);
extrudeModel linearNormal; extrudeModel linearNormal;

View File

@ -1,49 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name wallFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch walls;
}
{
name wallFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet wallFilmFaceSet;
}
{
name cylinderFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch cylinder;
}
{
name cylinderFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet cylinderFilmFaceSet;
}
);
// ************************************************************************* //

View File

@ -14,9 +14,6 @@ runParallel topoSet
# Create the boxes and add their surfaces to the boxes patch # Create the boxes and add their surfaces to the boxes patch
runParallel subsetMesh notBoxes -patch boxes -overwrite -noFields runParallel subsetMesh notBoxes -patch boxes -overwrite -noFields
# Create zones from the floor and the boxes
runParallel -s wallFilm topoSet -dict topoSetDict.wallFilm
# Create the film mesh # Create the film mesh
runParallel extrudeToRegionMesh -overwrite runParallel extrudeToRegionMesh -overwrite

View File

@ -15,7 +15,7 @@ FoamFile
region wallFilm; region wallFilm;
faceZones (floorFilmFaces boxesFilmFaces); patches (floor boxes);
extrudeModel linearNormal; extrudeModel linearNormal;

View File

@ -1,49 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name floorFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch floor;
}
{
name floorFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet floorFilmFaceSet;
}
{
name boxesFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch boxes;
}
{
name boxesFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet boxesFilmFaceSet;
}
);
// ************************************************************************* //

View File

@ -39,7 +39,7 @@ boundaryField
type zeroGradient; type zeroGradient;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -39,7 +39,7 @@ boundaryField
type zeroGradient; type zeroGradient;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -39,7 +39,7 @@ boundaryField
type zeroGradient; type zeroGradient;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -40,7 +40,7 @@ boundaryField
value $internalField; value $internalField;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type fixedValue; type fixedValue;
value $internalField; value $internalField;

View File

@ -37,7 +37,7 @@ boundaryField
type noSlip; type noSlip;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type noSlip; type noSlip;
} }

View File

@ -38,7 +38,7 @@ boundaryField
value $internalField; value $internalField;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type calculated; type calculated;
value $internalField; value $internalField;

View File

@ -37,7 +37,7 @@ boundaryField
type fixedFluxPressure; type fixedFluxPressure;
} }
region0_to_wallFilm_wallFilmFaces region0_to_wallFilm_walls
{ {
type fixedFluxPressure; type fixedFluxPressure;
} }

View File

@ -36,12 +36,12 @@ boundaryField
type zeroGradient; type zeroGradient;
} }
wallFilmFaces_top walls_top
{ {
type zeroGradient; type zeroGradient;
} }
wallFilm_to_region0_wallFilmFaces wallFilm_to_region0_walls
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -36,12 +36,12 @@ boundaryField
type noSlip; type noSlip;
} }
wallFilmFaces_top walls_top
{ {
type slip; type slip;
} }
wallFilm_to_region0_wallFilmFaces wallFilm_to_region0_walls
{ {
type noSlip; type noSlip;
} }

View File

@ -36,12 +36,12 @@ boundaryField
type zeroGradient; type zeroGradient;
} }
wallFilmFaces_top walls_top
{ {
type zeroGradient; type zeroGradient;
} }
wallFilm_to_region0_wallFilmFaces wallFilm_to_region0_walls
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh runApplication blockMesh
runApplication topoSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
paraFoam -touchAll paraFoam -touchAll

View File

@ -82,7 +82,7 @@ boundary
); );
} }
filmWalls walls
{ {
type wall; type wall;
faces faces

View File

@ -15,7 +15,7 @@ FoamFile
region wallFilm; region wallFilm;
faceZones (wallFilmFaces); patches (walls);
extrudeModel linearNormal; extrudeModel linearNormal;

View File

@ -1,35 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name wallFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch filmWalls;
}
{
name wallFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet wallFilmFaceSet;
}
);
// ************************************************************************* //

View File

@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh runApplication blockMesh
runApplication topoSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
paraFoam -touchAll paraFoam -touchAll

View File

@ -15,7 +15,7 @@ FoamFile
region wallFilm; region wallFilm;
faceZones (walls); patches (walls);
extrudeModel linearNormal; extrudeModel linearNormal;

View File

@ -5,7 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh runApplication blockMesh
runApplication topoSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
runApplication $(getApplication) runApplication $(getApplication)

View File

@ -15,7 +15,7 @@ FoamFile
region wallFilm; region wallFilm;
faceZones (wallFilmFaces cylinderFilmFaces); patches (walls cylinder);
extrudeModel linearNormal; extrudeModel linearNormal;

View File

@ -1,49 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name wallFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch walls;
}
{
name wallFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet wallFilmFaceSet;
}
{
name cylinderFilmFaceSet;
type faceSet;
action new;
source patchToFace;
patch cylinder;
}
{
name cylinderFilmFaces;
type faceZoneSet;
action new;
source setToFaceZone;
faceSet cylinderFilmFaceSet;
}
);
// ************************************************************************* //

View File

@ -19,7 +19,7 @@ internalField uniform 300;
boundaryField boundaryField
{ {
region0_to_plate_plateFaces region0_to_plate_plate
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -20,7 +20,7 @@ internalField uniform (0 0 0);
boundaryField boundaryField
{ {
region0_to_plate_plateFaces region0_to_plate_plate
{ {
type noSlip; type noSlip;
} }

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField boundaryField
{ {
region0_to_plate_plateFaces region0_to_plate_plate
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -19,7 +19,7 @@ internalField uniform 1e5;
boundaryField boundaryField
{ {
region0_to_plate_plateFaces region0_to_plate_plate
{ {
type calculated; type calculated;
value $internalField; value $internalField;

View File

@ -19,7 +19,7 @@ internalField uniform 1e5;
boundaryField boundaryField
{ {
region0_to_plate_plateFaces region0_to_plate_plate
{ {
type fixedFluxPressure; type fixedFluxPressure;
value $internalField; value $internalField;

View File

@ -22,12 +22,12 @@ boundaryField
{ {
#includeEtc "caseDicts/setConstraintTypes" #includeEtc "caseDicts/setConstraintTypes"
plateFaces_top plate_top
{ {
type zeroGradient; type zeroGradient;
} }
plate_to_region0_plateFaces plate_to_region0_plate
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -22,12 +22,12 @@ boundaryField
{ {
#includeEtc "caseDicts/setConstraintTypes" #includeEtc "caseDicts/setConstraintTypes"
plateFaces_top plate_top
{ {
type slip; type slip;
} }
plate_to_region0_plateFaces plate_to_region0_plate
{ {
type noSlip; type noSlip;
} }

View File

@ -22,12 +22,12 @@ boundaryField
{ {
#includeEtc "caseDicts/setConstraintTypes" #includeEtc "caseDicts/setConstraintTypes"
plateFaces_top plate_top
{ {
type zeroGradient; type zeroGradient;
} }
plate_to_region0_plateFaces plate_to_region0_plate
{ {
type zeroGradient; type zeroGradient;
} }

View File

@ -5,7 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh runApplication blockMesh
runApplication topoSet
runApplication extrudeToRegionMesh -overwrite runApplication extrudeToRegionMesh -overwrite
runApplication setFields runApplication setFields

View File

@ -15,7 +15,7 @@ FoamFile
region plate; region plate;
faceZones (plateFaces); patches (plate);
extrudeModel linearNormal; extrudeModel linearNormal;