149 using namespace Foam;
169 for (
const polyPatch* ppPtr : newPatches)
172 os <<
" name:" <<
pp.name() <<
" index:" <<
pp.index()
173 <<
" start:" <<
pp.start() <<
" size:" <<
pp.size()
174 <<
" type:" <<
pp.type() <<
nl;
180 template<
class PatchType>
184 const word& patchName,
188 label patchi = findPatchID(newPatches, patchName);
192 if (isA<PatchType>(*newPatches[patchi]))
200 <<
"Already have patch " << patchName
201 <<
" but of type " << newPatches[patchi]->type()
207 patchi = newPatches.
size();
209 label startFacei = 0;
213 startFacei =
pp.start()+
pp.size();
217 Pout<<
"addPatch : starting newPatches:" 218 <<
" patch:" << patchi <<
" startFace:" << startFacei <<
nl;
219 printPatches(
Pout, newPatches);
220 Pout<<
"*** end of addPatch:" <<
endl;
240 template<
class PatchType>
244 const word& patchName,
249 label patchi = findPatchID(newPatches, patchName);
253 if (isA<PatchType>(*newPatches[patchi]))
261 <<
"Already have patch " << patchName
262 <<
" but of type " << newPatches[patchi]->type()
268 patchi = newPatches.
size();
270 label startFacei = 0;
274 startFacei =
pp.start()+
pp.size();
279 Pout<<
"addPatch : starting newPatches:" 280 <<
" patch:" << patchi <<
" startFace:" << startFacei <<
nl;
281 printPatches(
Pout, newPatches);
282 Pout<<
"*** end of addPatch:" <<
endl;
287 patchDict.
set(
"type", PatchType::typeName);
288 patchDict.
set(
"nFaces", 0);
289 patchDict.
set(
"startFace", startFacei);
324 forAll(masterNames, masterI)
330 if (isA<processorPolyPatch>(
patches[patchi]))
335 Pout<<
"Deleting processor patch " << patchi
338 oldToNew[patchi] = --notUsedI;
342 oldToNew[patchi] = usedI++;
350 Pout<<
"Deleting patch " << patchi
353 oldToNew[patchi] = --notUsedI;
357 oldToNew[patchi] = usedI++;
366 if (oldToNew[patchi] == -1)
372 Pout<<
"Deleting processor patch " << patchi
375 oldToNew[patchi] = --notUsedI;
379 oldToNew[patchi] = usedI++;
402 Info<<
"Zone " << zoneNames[i] <<
" has internal faces" <<
endl;
406 Info<<
"Zone " << zoneNames[i] <<
" has boundary faces" <<
endl;
410 forAll(extrudeMeshFaces, i)
412 label facei = extrudeMeshFaces[i];
413 label zoneI = zoneID[i];
417 <<
"Zone " << zoneNames[zoneI]
418 <<
" is not consistently all internal or all boundary faces." 420 <<
" is the first occurrence." 444 globalEdgeFaces[edgeI] = globalFaces.
toGlobal(edgeFaces[edgeI]);
457 return globalEdgeFaces;
462 label findUncoveredPatchFace
466 const label meshEdgeI
471 extrudeFaceSet.
insert(extrudeMeshFaces);
477 label facei = eFaces[i];
484 && !extrudeFaceSet.found(facei)
496 label findUncoveredCyclicPatchFace
500 const label meshEdgeI
505 extrudeFaceSet.
insert(extrudeMeshFaces);
511 label facei = eFaces[i];
517 && isA<cyclicPolyPatch>(
pbm[patchi])
518 && !extrudeFaceSet.found(facei)
530 void calcEdgeMinMaxZone
551 forAll(extrudeEdgeGlobalFaces, edgeI)
553 const labelList& eFaces = extrudeEdgeGlobalFaces[edgeI];
558 label zoneI = mappedZoneID[eFaces[i]];
559 minZoneID[edgeI] =
min(minZoneID[edgeI], zoneI);
560 maxZoneID[edgeI] =
max(maxZoneID[edgeI], zoneI);
588 void countExtrudePatches
613 if (eFaces.
size() == 2)
616 if (minZoneID[edgeI] != maxZoneID[edgeI])
618 zoneZonePatch[minZoneID[edgeI]*nZones+maxZoneID[edgeI]]++;
624 && extrudeEdgeGlobalFaces[edgeI].
size() == 2
628 if (minZoneID[edgeI] != maxZoneID[edgeI])
635 <<
" is a coupled edge and inbetween two different zones " 636 << minZoneID[edgeI] <<
" and " << maxZoneID[edgeI] <<
endl 637 <<
" This is currently not supported." <<
endl;
639 zoneZonePatch[minZoneID[edgeI]*nZones+maxZoneID[edgeI]]++;
649 label facei = findUncoveredPatchFace
653 extrudeMeshEdges[edgeI]
658 zoneSidePatch[minZoneID[edgeI]]++;
669 void addCouplingPatches
673 const word& shellRegionName,
684 Pout<<
"Adding coupling patches:" <<
nl <<
nl 685 <<
"patchID\tpatch\ttype" <<
nl 686 <<
"-------\t-----\t----" 690 interRegionBottomPatch.
setSize(zoneNames.
size(), -1);
692 label nOldPatches = newPatches.
size();
704 if (isInternal[zoneI])
706 interRegionTopPatch[zoneI] = addPatch<mappedWallPolyPatch>
712 Pout<< interRegionTopPatch[zoneI]
713 <<
'\t' << newPatches[interRegionTopPatch[zoneI]]->name()
714 <<
'\t' << newPatches[interRegionTopPatch[zoneI]]->type()
717 interRegionBottomPatch[zoneI] = addPatch<mappedWallPolyPatch>
720 interName +
"_bottom",
723 Pout<< interRegionBottomPatch[zoneI]
724 <<
'\t' << newPatches[interRegionBottomPatch[zoneI]]->name()
725 <<
'\t' << newPatches[interRegionBottomPatch[zoneI]]->type()
728 else if (zoneShadowNames.
size() == 0)
730 interRegionTopPatch[zoneI] = addPatch<polyPatch>
733 zoneNames[zoneI] +
"_top",
736 Pout<< interRegionTopPatch[zoneI]
737 <<
'\t' << newPatches[interRegionTopPatch[zoneI]]->name()
738 <<
'\t' << newPatches[interRegionTopPatch[zoneI]]->type()
741 interRegionBottomPatch[zoneI] = addPatch<mappedWallPolyPatch>
747 Pout<< interRegionBottomPatch[zoneI]
748 <<
'\t' << newPatches[interRegionBottomPatch[zoneI]]->name()
749 <<
'\t' << newPatches[interRegionBottomPatch[zoneI]]->type()
754 interRegionTopPatch[zoneI] = addPatch<mappedWallPolyPatch>
757 zoneShadowNames[zoneI] +
"_top",
760 Pout<< interRegionTopPatch[zoneI]
761 <<
'\t' << newPatches[interRegionTopPatch[zoneI]]->name()
762 <<
'\t' << newPatches[interRegionTopPatch[zoneI]]->type()
765 interRegionBottomPatch[zoneI] = addPatch<mappedWallPolyPatch>
771 Pout<< interRegionBottomPatch[zoneI]
772 <<
'\t' << newPatches[interRegionBottomPatch[zoneI]]->name()
773 <<
'\t' << newPatches[interRegionBottomPatch[zoneI]]->type()
777 Pout<<
"Added " << newPatches.
size()-nOldPatches
778 <<
" inter-region patches." <<
nl 785 void addCoupledPatches
808 forAll(extrudeEdgeGlobalFaces, edgeI)
810 const labelList& eFaces = extrudeEdgeGlobalFaces[edgeI];
815 label proci = procID[eFaces[i]];
816 minProcID[edgeI] =
min(minProcID[edgeI], proci);
817 maxProcID[edgeI] =
max(maxProcID[edgeI], proci);
838 Pout<<
"Adding processor or cyclic patches:" <<
nl <<
nl 839 <<
"patchID\tpatch" <<
nl 843 label nOldPatches = newPatches.
size();
853 && extrudeEdgeGlobalFaces[edgeI].
size() == 2
857 label nbrProci = minProcID[edgeI];
860 nbrProci = maxProcID[edgeI];
869 label facei = findUncoveredCyclicPatchFace
873 extrudeMeshEdges[edgeI]
880 label newPatchi = findPatchID
886 sidePatchID[edgeI] = newPatchi;
891 <<
"Unable to determine coupled patch addressing" 903 sidePatchID[edgeI] = findPatchID(newPatches,
name);
905 if (sidePatchID[edgeI] == -1)
909 patchDict.
add(
"neighbProcNo", nbrProci);
911 sidePatchID[edgeI] = addPatch<processorPolyPatch>
919 Pout<< sidePatchID[edgeI] <<
'\t' <<
name 925 Pout<<
"Added " << newPatches.
size()-nOldPatches
926 <<
" coupled patches." <<
nl 931 void addZoneSidePatches
935 const word& oneDPolyPatchType,
941 Pout<<
"Adding patches for sides on zones:" <<
nl <<
nl 942 <<
"patchID\tpatch" <<
nl 946 label nOldPatches = newPatches.
size();
948 forAll(zoneSidePatch, zoneI)
950 if (!oneDPolyPatchType.empty())
954 if (oneDPolyPatchType ==
"empty")
956 patchName =
"oneDEmptyPatch";
957 zoneSidePatch[zoneI] = addPatch<emptyPolyPatch>
964 else if (oneDPolyPatchType ==
"wedge")
966 patchName =
"oneDWedgePatch";
967 zoneSidePatch[zoneI] = addPatch<wedgePolyPatch>
977 <<
"Type " << oneDPolyPatchType <<
" does not exist " 981 Pout<< zoneSidePatch[zoneI] <<
'\t' << patchName <<
nl;
983 else if (zoneSidePatch[zoneI] > 0)
985 word patchName = zoneNames[zoneI] +
"_" +
"side";
987 zoneSidePatch[zoneI] = addPatch<polyPatch>
994 Pout<< zoneSidePatch[zoneI] <<
'\t' << patchName <<
nl;
997 Pout<<
"Added " << newPatches.
size()-nOldPatches <<
" zone-side patches." 1002 void addInterZonePatches
1013 Pout<<
"Adding inter-zone patches:" <<
nl <<
nl 1014 <<
"patchID\tpatch" <<
nl 1025 label nOldPatches = newPatches.
size();
1029 forAll(zoneZonePatch_min, minZone)
1031 for (label maxZone = minZone; maxZone < zoneNames.
size(); maxZone++)
1033 label index = minZone*zoneNames.
size()+maxZone;
1035 if (zoneZonePatch_min[index] > 0)
1040 + zoneNames[maxZone];
1044 + zoneNames[minZone];
1047 transformDict.
set(
"neighbourPatch", maxToMin);
1048 zoneZonePatch_min[index] =
1049 addPatch<nonuniformTransformCyclicPolyPatch>
1056 Pout<< zoneZonePatch_min[index] <<
'\t' << minToMax
1060 transformDict.
set(
"neighbourPatch", minToMax);
1061 zoneZonePatch_max[index] =
1062 addPatch<nonuniformTransformCyclicPolyPatch>
1069 Pout<< zoneZonePatch_max[index] <<
'\t' << maxToMin
1077 Pout<<
"Added " << newPatches.
size()-nOldPatches <<
" inter-zone patches." 1096 label meshFacei =
pp.start()+i;
1098 point patchFc = extrudePatch[patchFacei].centre
1102 offsets[i] = patchFc - fc[i];
1108 void setCouplingInfo
1112 const word& sampleRegion,
1125 forAll(zoneToPatch, zoneI)
1127 const label patchi = zoneToPatch[zoneI];
1133 if (isA<mappedWallPolyPatch>(
pp))
1137 const scalar mergeSqrDist =
1155 Info<<
"Adding on " <<
mesh.
name() <<
" coupling patch " 1156 <<
pp.name() <<
" with ";
1160 if (mergeSqrDist <
magSqr(10*SMALL*bb.span()))
1162 Info<<
"uniform offset " << avgOffset <<
endl;
1166 Info<<
"non-uniform offset" <<
endl;
1168 (*mappedPtr).setOffset(offsets[zoneI]);
1171 newPatches[patchi] = mappedPtr.release();
1176 forAll(newPatches, patchi)
1178 if (!newPatches[patchi])
1187 Pout<<
"*** setCouplingInfo addFvPAtches:" <<
nl;
1188 printPatches(
Pout, newPatches);
1189 Pout<<
"*** setCouplingInfo end of addFvPAtches:" <<
endl;
1198 void extrudeGeometricProperties
1243 bitSet sameEdgeOrientation;
1291 label celli = regionMesh.faceOwner()[facei];
1292 if (regionMesh.isInternalFace(facei))
1294 celli =
max(celli, regionMesh.faceNeighbour()[facei]);
1298 label layerI = (celli % model.
nLayers());
1302 !regionMesh.isInternalFace(facei)
1312 faceCentres[facei] = model
1314 patchFaceCentres[patchFacei],
1325 regionMesh.faceOwner()[facei]
1332 patchEdgeCentres[patchEdgeI],
1333 patchEdgeNormals[patchEdgeI],
1339 patchEdgeCentres[patchEdgeI],
1340 patchEdgeNormals[patchEdgeI],
1345 faceCentres[facei] = 0.5*(pt0+pt1);
1354 regionMesh.pointsInstance(),
1369 label layerI = (celli % model.
nLayers());
1374 patchFaceCentres[patchFacei],
1380 patchFaceCentres[patchFacei],
1386 cellCentres[celli] = 0.5*(pt0+pt1);
1393 OBJstream faceStr(regionMesh.time().path()/
"faceCentres.obj");
1394 OBJstream cellStr(regionMesh.time().path()/
"cellCentres.obj");
1396 forAll(faceCentres, facei)
1398 Pout<<
"Model :" << faceCentres[facei] <<
endl 1399 <<
"regionMesh:" << regionMesh.faceCentres()[facei] <<
endl;
1403 regionMesh.faceCentres()[facei]
1406 forAll(cellCentres, celli)
1408 Pout<<
"Model :" << cellCentres[celli] <<
endl 1409 <<
"regionMesh:" << regionMesh.cellCentres()[celli] <<
endl;
1413 regionMesh.cellCentres()[celli]
1420 Info<<
"Writing geometric properties for mesh " << regionMesh.name()
1421 <<
" to " << regionMesh.pointsInstance() <<
nl 1424 bool ok = faceCentres.
write() && cellCentres.write();
1429 <<
"Failed writing " << faceCentres.objectPath()
1430 <<
" and " << cellCentres.objectPath()
1436 int main(
int argc,
char *argv[])
1440 "Create region mesh by extruding a faceZone or faceSet" 1448 "dict",
"file",
"Alternative extrudeToRegionMeshDict" 1462 <<
"Patches are not synchronised on all processors." 1463 <<
" Per processor patches " << allNames
1469 const bool overwrite =
args.
found(
"overwrite");
1487 const bool hasZones =
dict.
found(
"faceZones");
1497 <<
"Please supply faces to extrude either through 'faceZones'" 1498 <<
" or 'faceSets' entry. Found both." 1512 const bool oneD(
dict.
get<
bool>(
"oneD"));
1513 bool oneDNonManifoldEdges(
false);
1514 word oneDPatchType(emptyPolyPatch::typeName);
1518 oneDPatchType =
dict.
get<
word>(
"oneDPolyPatchType");
1521 const bool adaptMesh(
dict.
get<
bool>(
"adaptMesh"));
1525 Info<<
"Extruding zones " << zoneNames
1527 <<
" into shell mesh " << shellRegionName
1532 Info<<
"Extruding faceSets " << zoneNames
1534 <<
" into shell mesh " << shellRegionName
1541 <<
"Cannot extrude into same region as mesh." <<
endl 1543 <<
"Shell region : " << shellRegionName
1550 if (oneDNonManifoldEdges)
1552 Info<<
"Extruding as 1D columns with sides in patch type " 1554 <<
" and connected points (except on non-manifold areas)." 1559 Info<<
"Extruding as 1D columns with sides in patch type " 1561 <<
" and duplicated points (overlapping volumes)." 1628 meshInstance = oldInstance;
1630 Info<<
"Writing meshes to " << meshInstance <<
nl <<
endl;
1663 meshZoneID[i] = faceZones.
findZoneID(zoneNames[i]);
1664 if (meshZoneID[i] == -1)
1667 <<
"Cannot find zone " << zoneNames[i] <<
endl 1668 <<
"Valid zones are " << faceZones.
names()
1673 label nExtrudeFaces = 0;
1676 nExtrudeFaces += faceZones[meshZoneID[i]].
size();
1678 extrudeMeshFaces.setSize(nExtrudeFaces);
1679 zoneFaces.
setSize(nExtrudeFaces);
1680 zoneID.
setSize(nExtrudeFaces);
1681 zoneFlipMap.
setSize(nExtrudeFaces);
1685 const faceZone& fz = faceZones[meshZoneID[i]];
1689 extrudeMeshFaces[nExtrudeFaces] = fz[j];
1690 zoneFaces[nExtrudeFaces] = fzp[j];
1691 zoneID[nExtrudeFaces] = i;
1692 zoneFlipMap[nExtrudeFaces] = fz.
flipMap()[j];
1697 isInternal[i] =
true;
1705 if (zoneShadowNames.
size())
1708 forAll(zoneShadowNames, i)
1710 zoneShadowIDs[i] = faceZones.
findZoneID(zoneShadowNames[i]);
1711 if (zoneShadowIDs[i] == -1)
1714 <<
"Cannot find zone " << zoneShadowNames[i] <<
endl 1715 <<
"Valid zones are " << faceZones.
names()
1720 label nShadowFaces = 0;
1723 nShadowFaces += faceZones[zoneShadowIDs[i]].
size();
1726 extrudeMeshShadowFaces.
setSize(nShadowFaces);
1727 zoneShadowFlipMap.
setSize(nShadowFaces);
1728 zoneShadowID.
setSize(nShadowFaces);
1733 const faceZone& fz = faceZones[zoneShadowIDs[i]];
1736 extrudeMeshShadowFaces[nShadowFaces] = fz[j];
1737 zoneShadowFlipMap[nShadowFaces] = fz.
flipMap()[j];
1738 zoneShadowID[nShadowFaces] = i;
1751 Info<<
"Loading faceSet " << zoneNames[i] <<
endl;
1757 label nExtrudeFaces = 0;
1760 nExtrudeFaces += zones[i].size();
1762 extrudeMeshFaces.setSize(nExtrudeFaces);
1763 zoneFaces.
setSize(nExtrudeFaces);
1764 zoneID.
setSize(nExtrudeFaces);
1765 zoneFlipMap.
setSize(nExtrudeFaces);
1771 for (
const label facei : fz)
1776 <<
"faceSet " << fz.name()
1777 <<
"contains internal faces." 1778 <<
" This is not permitted." 1781 extrudeMeshFaces[nExtrudeFaces] = facei;
1782 zoneFaces[nExtrudeFaces] =
mesh.
faces()[facei];
1783 zoneID[nExtrudeFaces] = i;
1784 zoneFlipMap[nExtrudeFaces] =
false;
1789 isInternal[i] =
true;
1799 if (zoneShadowNames.
size())
1801 zoneShadowIDs.
setSize(zoneShadowNames.
size(), -1);
1802 forAll(zoneShadowNames, i)
1804 shadowZones.set(i,
new faceSet(
mesh, zoneShadowNames[i]));
1807 label nShadowFaces = 0;
1808 for (
const faceSet& fz : shadowZones)
1810 nShadowFaces += fz.size();
1813 if (nExtrudeFaces != nShadowFaces)
1816 <<
"Extruded faces " << nExtrudeFaces <<
endl 1817 <<
"is different from shadow faces. " << nShadowFaces
1818 <<
"This is not permitted " <<
endl 1822 extrudeMeshShadowFaces.
setSize(nShadowFaces);
1823 zoneShadowFlipMap.
setSize(nShadowFaces);
1824 zoneShadowID.
setSize(nShadowFaces);
1829 const faceSet& fz = shadowZones[i];
1830 for (
const label facei : fz)
1835 <<
"faceSet " << fz.name()
1836 <<
"contains internal faces." 1837 <<
" This is not permitted." 1840 extrudeMeshShadowFaces[nShadowFaces] = facei;
1841 zoneShadowFlipMap[nShadowFaces] =
false;
1842 zoneShadowID[nShadowFaces] = i;
1854 checkZoneInside(
mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal);
1862 Info<<
"extrudePatch :" 1863 <<
" faces:" << extrudePatch.size()
1864 <<
" points:" << extrudePatch.
nPoints()
1865 <<
" edges:" << extrudePatch.
nEdges()
1883 const globalIndex globalExtrudeFaces(extrudePatch.size());
1900 extrudeEdgeGlobalFaces,
1914 extrudeEdgeFacesMap,
1915 extrudeEdgeGlobalFaces,
1929 if (!isA<processorPolyPatch>(
patches[patchi]))
1931 label newPatchi = regionPatches.size();
1932 regionPatches.append
1964 interRegionTopPatch,
1965 interRegionBottomPatch
1981 if (!isA<processorPolyPatch>(
patches[patchi]))
1984 clonedPatch->index() = newPatches.
size();
1985 newPatches.
append(clonedPatch.ptr());
2002 interMeshBottomPatch
2008 if (isA<processorPolyPatch>(
patches[patchi]))
2011 clonedPatch->index() = newPatches.
size();
2012 newPatches.
append(clonedPatch.ptr());
2018 Pout<<
"*** adaptMesh : addFvPAtches:" <<
nl;
2019 printPatches(
Pout, newPatches);
2020 Pout<<
"*** end of adaptMesh : addFvPAtches:" <<
endl;
2034 labelList extrudeTopPatchID(extrudePatch.size());
2035 labelList extrudeBottomPatchID(extrudePatch.size());
2039 extrudeTopPatchID[facei] = interRegionTopPatch[zoneID[facei]];
2040 extrudeBottomPatchID[facei] = interRegionBottomPatch[zoneID[facei]];
2063 extrudeEdgeGlobalFaces,
2110 extrudeEdgeFacesMap,
2111 extrudeEdgeGlobalFaces,
2161 const labelList& eFaces = edgeFaces[edgeI];
2163 labelList& ePatches = extrudeEdgePatches[edgeI];
2170 ePatches[i] = zoneSidePatch[zoneID[eFaces[i]]];
2173 if (oneDNonManifoldEdges)
2178 if (eFaces.
size() != 2)
2180 nonManifoldEdge.
set(edgeI);
2185 nonManifoldEdge.set(edgeI);
2188 else if (eFaces.
size() == 2)
2190 label zone0 = zoneID[eFaces[0]];
2191 label zone1 = zoneID[eFaces[1]];
2195 label minZone =
min(zone0,zone1);
2196 label maxZone =
max(zone0,zone1);
2197 label index = minZone*zoneNames.
size()+maxZone;
2199 ePatches.
setSize(eFaces.size());
2201 if (zone0 == minZone)
2203 ePatches[0] = zoneZonePatch_min[index];
2204 ePatches[1] = zoneZonePatch_max[index];
2208 ePatches[0] = zoneZonePatch_max[index];
2209 ePatches[1] = zoneZonePatch_min[index];
2212 nonManifoldEdge.
set(edgeI);
2215 else if (sidePatchID[edgeI] != -1)
2218 ePatches.
setSize(eFaces.size());
2221 ePatches[i] = sidePatchID[edgeI];
2226 label facei = findUncoveredPatchFace
2230 extrudeMeshEdges[edgeI]
2235 label newPatchi = findPatchID
2240 ePatches.
setSize(eFaces.size(), newPatchi);
2244 ePatches.
setSize(eFaces.size());
2247 ePatches[i] = zoneSidePatch[zoneID[eFaces[i]]];
2250 nonManifoldEdge.
set(edgeI);
2278 forAll(pointLocalRegions, facei)
2281 const face& pRegions = pointLocalRegions[facei];
2284 localRegionPoints[pRegions[fp]] =
f[fp];
2293 forAll(pointLocalRegions, facei)
2295 const face& pRegions = pointLocalRegions[facei];
2298 label localRegionI = pRegions[fp];
2299 localSum[localRegionI] += extrudePatch.
faceNormals()[facei];
2305 forAll(localSum, localRegionI)
2307 label globalRegionI = localToGlobalRegion[localRegionI];
2308 globalSum.insert(globalRegionI, localSum[localRegionI]);
2314 forAll(localToGlobalRegion, localRegionI)
2316 label globalRegionI = localToGlobalRegion[localRegionI];
2317 localRegionNormals[localRegionI] = globalSum[globalRegionI];
2319 localRegionNormals /=
mag(localRegionNormals);
2331 forAll(pointLocalRegions, facei)
2333 const face&
f = extrudeFaces[facei];
2337 label region = pointLocalRegions[facei][fp];
2338 const point& pt = extrudePoints[
f[fp]];
2345 pt+thickness*localRegionNormals[region]
2348 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
2356 forAll(firstDisp, regionI)
2363 localRegionPoints[regionI]
2366 const vector&
n = localRegionNormals[regionI];
2367 firstDisp[regionI] = model()(regionPt,
n, 1) - regionPt;
2399 forAll(regionPatches, patchi)
2401 polyPatch* ppPtr = regionPatches[patchi];
2402 regionPatches[patchi] = ppPtr->
clone(regionMesh.boundaryMesh()).ptr();
2407 Pout<<
"*** regionPatches : regionPatches:" <<
nl;
2408 printPatches(
Pout, regionPatches);
2409 Pout<<
"*** end of regionPatches : regionPatches:" <<
endl;
2413 regionMesh.clearOut();
2414 regionMesh.removeFvBoundary();
2415 regionMesh.addFvPatches(regionPatches,
true);
2423 model().expansionRatio(),
2426 extrudeBottomPatchID,
2439 label meshPointi = extrudePatch.
localPoints().size();
2440 forAll(localRegionPoints, regionI)
2442 label pointi = localRegionPoints[regionI];
2444 const vector&
n = localRegionNormals[regionI];
2446 for (label layerI = 1; layerI <= model().
nLayers(); layerI++)
2448 newPoints[meshPointi++] = model()(pt,
n, layerI);
2452 shellMap = meshMod.changeMesh
2460 regionMesh.setInstance(meshInstance);
2473 forAll(regionMesh.boundaryMesh(), patchi)
2475 const polyPatch&
pp = regionMesh.boundaryMesh()[patchi];
2477 if (isA<mappedWallPolyPatch>(
pp))
2479 if (interRegionTopPatch.
found(patchi))
2481 label zoneI = interRegionTopPatch.
find(patchi);
2482 topOffsets[zoneI] = calcOffset(extrudePatch, extruder,
pp);
2484 else if (interRegionBottomPatch.
found(patchi))
2486 label zoneI = interRegionBottomPatch.
find(patchi);
2487 bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder,
pp);
2501 interRegionTopPatch,
2511 interRegionBottomPatch,
2518 deleteEmptyPatches(regionMesh);
2540 interMeshBottomPatch,
2556 "cellToPatchFaceAddressing",
2557 regionMesh.facesInstance(),
2566 cellToPatchFaceAddressing.
note() =
"cell to patch face addressing";
2572 "faceToPatchFaceAddressing",
2573 regionMesh.facesInstance(),
2582 faceToPatchFaceAddressing.
note() =
2583 "front/back face + turning index to patch face addressing";
2589 "faceToPatchEdgeAddressing",
2590 regionMesh.facesInstance(),
2599 faceToPatchEdgeAddressing.
note() =
2600 "side face to patch edge addressing";
2606 "pointToPatchPointAddressing",
2607 regionMesh.facesInstance(),
2616 pointToPatchPointAddressing.
note() =
2617 "point to patch point addressing";
2620 Info<<
"Writing mesh " << regionMesh.name()
2621 <<
" to " << regionMesh.facesInstance() <<
nl 2626 && cellToPatchFaceAddressing.write()
2627 && faceToPatchFaceAddressing.write()
2628 && faceToPatchEdgeAddressing.write()
2629 && pointToPatchPointAddressing.write();
2634 <<
"Failed writing mesh " << regionMesh.name()
2635 <<
" at location " << regionMesh.facesInstance()
2657 Info<<
"Reading patch face,edge centres : " 2658 <<
io.
name() <<
" and patchEdgeCentres" <<
endl;
2660 extrudeGeometricProperties
2684 forAll(extrudeMeshFaces, zoneFacei)
2686 label meshFacei = extrudeMeshFaces[zoneFacei];
2687 label zoneI = zoneID[zoneFacei];
2688 bool flip = zoneFlipMap[zoneFacei];
2700 interMeshBottomPatch[zoneI],
2714 interMeshBottomPatch[zoneI],
2721 if (zoneShadowNames.
size() > 0)
2723 forAll(extrudeMeshFaces, zoneFacei)
2725 label meshFacei = extrudeMeshShadowFaces[zoneFacei];
2726 label zoneI = zoneShadowID[zoneFacei];
2727 bool flip = zoneShadowFlipMap[zoneFacei];
2739 interMeshTopPatch[zoneI],
2753 interMeshTopPatch[zoneI],
2763 forAll(extrudeMeshFaces, zoneFacei)
2765 label meshFacei = extrudeMeshFaces[zoneFacei];
2766 label zoneI = zoneID[zoneFacei];
2767 bool flip = zoneFlipMap[zoneFacei];
2783 interMeshTopPatch[zoneI],
2800 interMeshTopPatch[zoneI],
2809 addBafflesMap = meshMod.changeMesh(
mesh,
false);
2820 if (addBafflesMap().hasMotionPoints())
2828 deleteEmptyPatches(
mesh);
2837 <<
"Failed writing mesh " <<
mesh.
name()
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
const polyBoundaryMesh & pbm
static const Enum< transformType > transformTypeNames
void clearOut()
Clear all geometry and addressing.
label nPoints() const
Number of points supporting patch faces.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
const labelIOList & zoneIDs
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to these fvPatches.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute List data using default commsType, default flip/negate operator.
const word & name() const noexcept
Return the object name.
const labelListList & pointEdges() const
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
Output to file stream, using an OSstream.
constexpr char nl
The newline '\n' character (0x0a)
UIndirectList< label > labelUIndList
UIndirectList of labels.
const word dictName("faMeshDefinition")
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch ("procBoundary..") constructed from the pair of processor IDs...
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
const string & note() const noexcept
Return the optional note.
A bounding box defined in terms of min/max extrema points.
const labelList & faceToEdgeMap() const
From region side-face to patch edge. -1 for non-edge faces.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Ignore writing from objectRegistry::writeObject()
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
SubField is a Field obtained as a section of another Field, without its own allocation. SubField is derived from a SubList rather than a List.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
Top level extrusion model class.
static void allGatherList(List< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses linear/tree communication. ...
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
const fileName & pointsInstance() const
Return the current instance directory for points.
void setSize(const label n)
Alias for resize()
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const labelList & cellToFaceMap() const
From region cell to patch face. Consecutively added so.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
List helper to append y unique elements onto the end of x.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
const Field< point_type > & faceCentres() const
Return face centres for patch.
label nLayers() const
Return the number of layers.
virtual const labelList & faceOwner() const
Return face owner.
const labelList & faceToFaceMap() const
From region face to patch face. Contains turning index:
Creates mesh by extruding a patch.
static const word null
An empty word.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
const labelListList & edgeFaces() const
Return edge-face addressing.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & points() const noexcept
Return reference to global points.
void append(const T &val)
Copy append an element to the end of this list.
virtual const faceList & faces() const
Return raw faces.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Construct and return a clone, setting faceCells.
label size() const noexcept
The number of elements in the list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label find(const T &val) const
Find index of the first occurrence of the value.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
static void calcPointRegions(const globalMeshData &globalData, const primitiveFacePatch &patch, const bitSet &nonManifoldEdge, const bool syncNonCollocated, faceList &pointGlobalRegions, faceList &pointLocalRegions, labelList &localToGlobalRegion)
Helper: calculate point regions. The point region is the.
static const Enum< sampleMode > sampleModeNames_
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
label nEdges() const
Number of edges in patch.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
void updateMesh(const mapPolyMesh &)
Update any locally stored mesh information.
Type gMax(const FieldField< Field, Type > &f)
OBJstream os(runTime.globalPath()/outputName)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
void addFvPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
scalar sumThickness(const label layer) const
Helper: calculate cumulative relative thickness for layer.
static autoPtr< extrudeModel > New(const dictionary &dict)
Select null constructed.
T & last()
Access last element of the list, position [size()-1].
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
const vectorField & faceCentres() const
Class containing processor-to-processor mapping information.
label toGlobal(const label proci, const label i) const
From local to global on proci.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
const word & name() const
Return reference to name.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Type gAverage(const FieldField< Field, Type > &f)
const labelList & pointToPointMap() const
From region point to patch point.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using cell addressing.
Mesh data needed to do the Finite Volume discretisation.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Direct mesh changes based on v1.3 polyTopoChange syntax.
sampleMode
Mesh items to sample.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
const boolList & flipMap() const noexcept
Return face flip map.
wordList names() const
A list of the zone names.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
void setRefinement(const pointField &firstLayerThickness, const scalar expansionRatio, const label nLayers, const labelList &topPatchID, const labelList &bottomPatchID, const labelListList &extrudeEdgePatches, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layer mesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
A subset of mesh faces organised as a primitive patch.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A patch is a list of labels that address the faces in the global face list.
static void mapCombineReduce(Container &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine map values from different processo...
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
A primitive field of type <T> with automated input and output.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
const labelListList & edgeFaces() const
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
bool found(const word &optName) const
Return true if the named option is found.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A HashTable to objects of type <T> with a label key.
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)