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;
180template<
class PatchType>
184 const word& patchName,
188 label patchi = findPatchID(newPatches, patchName);
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;
240template<
class PatchType>
244 const word& patchName,
249 label patchi = findPatchID(newPatches, patchName);
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);
321 label notUsedI =
patches.size();
324 forAll(masterNames, masterI)
326 label patchi =
patches.findPatchID(masterNames[masterI]);
335 Pout<<
"Deleting processor patch " << patchi
336 <<
" name:" <<
patches[patchi].name()
338 oldToNew[patchi] = --notUsedI;
342 oldToNew[patchi] = usedI++;
350 Pout<<
"Deleting patch " << patchi
351 <<
" name:" <<
patches[patchi].name()
353 oldToNew[patchi] = --notUsedI;
357 oldToNew[patchi] = usedI++;
366 if (oldToNew[patchi] == -1)
372 Pout<<
"Deleting processor patch " << patchi
373 <<
" name:" <<
patches[patchi].name()
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];
414 if (isInternal[zoneI] !=
mesh.isInternalFace(facei))
417 <<
"Zone " << zoneNames[zoneI]
418 <<
" is not consistently all internal or all boundary faces."
419 <<
" Face " << facei <<
" at " <<
mesh.faceCentres()[facei]
420 <<
" is the first occurrence."
444 globalEdgeFaces[edgeI] = globalFaces.
toGlobal(edgeFaces[edgeI]);
457 return globalEdgeFaces;
462label findUncoveredPatchFace
466 const label meshEdgeI
471 extrudeFaceSet.insert(extrudeMeshFaces);
477 label facei = eFaces[i];
478 label patchi =
pbm.whichPatch(facei);
484 && !extrudeFaceSet.found(facei)
496label findUncoveredCyclicPatchFace
500 const label meshEdgeI
505 extrudeFaceSet.insert(extrudeMeshFaces);
511 label facei = eFaces[i];
512 label patchi =
pbm.whichPatch(facei);
518 && !extrudeFaceSet.found(facei)
530void calcEdgeMinMaxZone
551 forAll(extrudeEdgeGlobalFaces, edgeI)
553 const labelList& eFaces = extrudeEdgeGlobalFaces[edgeI];
558 label zoneI = mappedZoneID[eFaces[i]];
559 minZoneID[edgeI] =
Foam::min(minZoneID[edgeI], zoneI);
560 maxZoneID[edgeI] =
Foam::max(maxZoneID[edgeI], zoneI);
588void 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]]++;
669void 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
785void addCoupledPatches
808 forAll(extrudeEdgeGlobalFaces, edgeI)
810 const labelList& eFaces = extrudeEdgeGlobalFaces[edgeI];
815 label proci = procID[eFaces[i]];
816 minProcID[edgeI] =
Foam::min(minProcID[edgeI], proci);
817 maxProcID[edgeI] =
Foam::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
931void 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."
1002void 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>
1051 mesh.boundaryMesh(),
1056 Pout<< zoneZonePatch_min[index] <<
'\t' << minToMax
1060 transformDict.
set(
"neighbourPatch", minToMax);
1061 zoneZonePatch_max[index] =
1062 addPatch<nonuniformTransformCyclicPolyPatch>
1064 mesh.boundaryMesh(),
1069 Pout<< zoneZonePatch_max[index] <<
'\t' << maxToMin
1077 Pout<<
"Added " << newPatches.
size()-nOldPatches <<
" inter-zone patches."
1092 auto& offsets = toffsets.ref();
1096 label meshFacei =
pp.start()+i;
1098 point patchFc = extrudePatch[patchFacei].centre
1102 offsets[i] = patchFc - fc[i];
1112 const word& sampleRegion,
1114 const List<pointField>& offsets,
1115 const List<boundBox>& bbs
1120 List<polyPatch*> newPatches
1126 forAll(zoneToPatch, zoneI)
1128 const label patchi = zoneToPatch[zoneI];
1137 const scalar mergeSqrDist =
1155 Info<<
"Adding on " <<
mesh.name() <<
" coupling patch "
1156 <<
pp.name() <<
" with ";
1160 if (mergeSqrDist <
magSqr(10*SMALL*bbs[zoneI].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;
1192 mesh.removeFvBoundary();
1193 mesh.addFvPatches(newPatches,
true);
1198void extrudeGeometricProperties
1212 mesh.pointsInstance(),
1224 mesh.pointsInstance(),
1243 bitSet sameEdgeOrientation;
1247 mesh.globalData().coupledPatch(),
1291 label celli = regionMesh.
faceOwner()[facei];
1298 label layerI = (celli % model.
nLayers());
1312 faceCentres[facei] = model
1314 patchFaceCentres[patchFacei],
1332 patchEdgeCentres[patchEdgeI],
1333 patchEdgeNormals[patchEdgeI],
1339 patchEdgeCentres[patchEdgeI],
1340 patchEdgeNormals[patchEdgeI],
1345 faceCentres[facei] = 0.5*(pt0+pt1);
1369 label layerI = (celli % model.
nLayers());
1374 patchFaceCentres[patchFacei],
1380 patchFaceCentres[patchFacei],
1386 cellCentres[celli] = 0.5*(pt0+pt1);
1396 forAll(faceCentres, facei)
1398 Pout<<
"Model :" << faceCentres[facei] <<
endl
1406 forAll(cellCentres, celli)
1408 Pout<<
"Model :" << cellCentres[celli] <<
endl
1420 Info<<
"Writing geometric properties for mesh " << regionMesh.
name()
1424 bool ok = faceCentres.write() && cellCentres.write();
1429 <<
"Failed writing " << faceCentres.objectPath()
1430 <<
" and " << cellCentres.objectPath()
1436int main(
int argc,
char *argv[])
1440 "Create region mesh by extruding a faceZone or faceSet"
1448 "dict",
"file",
"Alternative extrudeToRegionMeshDict"
1455 if (
mesh.boundaryMesh().checkParallelSync(
true))
1462 <<
"Patches are not synchronised on all processors."
1463 <<
" Per processor patches " << allNames
1468 const word oldInstance =
mesh.pointsInstance();
1469 const bool overwrite =
args.found(
"overwrite");
1487 const bool hasZones =
dict.found(
"faceZones");
1490 dict.readEntry(
"faceZones", zoneNames);
1491 dict.readIfPresent(
"faceZonesShadow", zoneShadowNames);
1494 if (
dict.found(
"faceSets"))
1497 <<
"Please supply faces to extrude either through 'faceZones'"
1498 <<
" or 'faceSets' entry. Found both."
1504 dict.readEntry(
"faceSets", zoneNames);
1505 dict.readIfPresent(
"faceSetsShadow", zoneShadowNames);
1512 const bool oneD(
dict.get<
bool>(
"oneD"));
1513 bool oneDNonManifoldEdges(
false);
1514 word oneDPatchType(emptyPolyPatch::typeName);
1517 oneDNonManifoldEdges =
dict.getOrDefault(
"nonManifold",
false);
1518 oneDPatchType =
dict.get<
word>(
"oneDPolyPatchType");
1521 const bool adaptMesh(
dict.get<
bool>(
"adaptMesh"));
1523 const bool addSidePatches(
dict.getOrDefault<
bool>(
"addSidePatches",
true));
1529 Info<<
"Extruding zones " << zoneNames
1531 <<
" into shell mesh " << shellRegionName
1536 Info<<
"Extruding faceSets " << zoneNames
1538 <<
" into shell mesh " << shellRegionName
1545 <<
"Cannot extrude into same region as mesh." <<
endl
1547 <<
"Shell region : " << shellRegionName
1554 if (oneDNonManifoldEdges)
1556 Info<<
"Extruding as 1D columns with sides in patch type "
1558 <<
" and connected points (except on non-manifold areas)."
1563 Info<<
"Extruding as 1D columns with sides in patch type "
1565 <<
" and duplicated points (overlapping volumes)."
1571 if (addSidePatches && zoneNames.
size() > 1)
1573 Info<<
"Extruding edges on more than one faceZone into boundary faces"
1578 Info<<
"Extruding internal edges into internal faces" <<
endl;
1637 meshInstance =
runTime.timeName();
1641 meshInstance = oldInstance;
1643 Info<<
"Writing meshes to " << meshInstance <<
nl <<
endl;
1676 meshZoneID[i] = faceZones.
findZoneID(zoneNames[i]);
1677 if (meshZoneID[i] == -1)
1680 <<
"Cannot find zone " << zoneNames[i] <<
endl
1681 <<
"Valid zones are " << faceZones.
names()
1686 label nExtrudeFaces = 0;
1689 nExtrudeFaces += faceZones[meshZoneID[i]].
size();
1691 extrudeMeshFaces.
setSize(nExtrudeFaces);
1692 zoneFaces.
setSize(nExtrudeFaces);
1693 zoneID.
setSize(nExtrudeFaces);
1694 zoneFlipMap.
setSize(nExtrudeFaces);
1698 const faceZone& fz = faceZones[meshZoneID[i]];
1702 extrudeMeshFaces[nExtrudeFaces] = fz[j];
1703 zoneFaces[nExtrudeFaces] = fzp[j];
1704 zoneID[nExtrudeFaces] = i;
1705 zoneFlipMap[nExtrudeFaces] = fz.
flipMap()[j];
1708 if (
mesh.isInternalFace(fz[j]))
1710 isInternal[i] =
true;
1718 if (zoneShadowNames.
size())
1721 forAll(zoneShadowNames, i)
1723 zoneShadowIDs[i] = faceZones.
findZoneID(zoneShadowNames[i]);
1724 if (zoneShadowIDs[i] == -1)
1727 <<
"Cannot find zone " << zoneShadowNames[i] <<
endl
1728 <<
"Valid zones are " << faceZones.
names()
1733 label nShadowFaces = 0;
1736 nShadowFaces += faceZones[zoneShadowIDs[i]].
size();
1739 extrudeMeshShadowFaces.
setSize(nShadowFaces);
1740 zoneShadowFlipMap.
setSize(nShadowFaces);
1741 zoneShadowID.
setSize(nShadowFaces);
1746 const faceZone& fz = faceZones[zoneShadowIDs[i]];
1749 extrudeMeshShadowFaces[nShadowFaces] = fz[j];
1750 zoneShadowFlipMap[nShadowFaces] = fz.
flipMap()[j];
1751 zoneShadowID[nShadowFaces] = i;
1759 meshZoneID.setSize(zoneNames.
size(), -1);
1764 Info<<
"Loading faceSet " << zoneNames[i] <<
endl;
1770 label nExtrudeFaces = 0;
1773 nExtrudeFaces += zones[i].
size();
1775 extrudeMeshFaces.
setSize(nExtrudeFaces);
1776 zoneFaces.
setSize(nExtrudeFaces);
1777 zoneID.
setSize(nExtrudeFaces);
1778 zoneFlipMap.
setSize(nExtrudeFaces);
1784 for (
const label facei : fz)
1786 if (
mesh.isInternalFace(facei))
1789 <<
"faceSet " << fz.name()
1790 <<
"contains internal faces."
1791 <<
" This is not permitted."
1794 extrudeMeshFaces[nExtrudeFaces] = facei;
1795 zoneFaces[nExtrudeFaces] =
mesh.faces()[facei];
1796 zoneID[nExtrudeFaces] = i;
1797 zoneFlipMap[nExtrudeFaces] =
false;
1800 if (
mesh.isInternalFace(facei))
1802 isInternal[i] =
true;
1812 if (zoneShadowNames.
size())
1814 zoneShadowIDs.
setSize(zoneShadowNames.
size(), -1);
1815 forAll(zoneShadowNames, i)
1817 shadowZones.set(i,
new faceSet(
mesh, zoneShadowNames[i]));
1820 label nShadowFaces = 0;
1821 for (
const faceSet& fz : shadowZones)
1823 nShadowFaces += fz.size();
1826 if (nExtrudeFaces != nShadowFaces)
1829 <<
"Extruded faces " << nExtrudeFaces <<
endl
1830 <<
"is different from shadow faces. " << nShadowFaces
1831 <<
"This is not permitted " <<
endl
1835 extrudeMeshShadowFaces.
setSize(nShadowFaces);
1836 zoneShadowFlipMap.
setSize(nShadowFaces);
1837 zoneShadowID.
setSize(nShadowFaces);
1842 const faceSet& fz = shadowZones[i];
1843 for (
const label facei : fz)
1845 if (
mesh.isInternalFace(facei))
1848 <<
"faceSet " << fz.name()
1849 <<
"contains internal faces."
1850 <<
" This is not permitted."
1853 extrudeMeshShadowFaces[nShadowFaces] = facei;
1854 zoneShadowFlipMap[nShadowFaces] =
false;
1855 zoneShadowID[nShadowFaces] = i;
1867 checkZoneInside(
mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal);
1875 Info<<
"extrudePatch :"
1876 <<
" faces:" << extrudePatch.
size()
1877 <<
" points:" << extrudePatch.
nPoints()
1878 <<
" edges:" << extrudePatch.
nEdges()
1909 List<Map<label>> compactMap;
1913 extrudeEdgeGlobalFaces,
1927 extrudeEdgeFacesMap,
1928 extrudeEdgeGlobalFaces,
1934 if (!addSidePatches)
1938 edgeMaxZoneID = edgeMinZoneID;
1949 label newPatchi = regionPatches.size();
1950 regionPatches.append
1982 interRegionTopPatch,
1983 interRegionBottomPatch
2002 clonedPatch->index() = newPatches.
size();
2003 newPatches.
append(clonedPatch.ptr());
2020 interMeshBottomPatch
2029 clonedPatch->index() = newPatches.
size();
2030 newPatches.
append(clonedPatch.ptr());
2036 Pout<<
"*** adaptMesh : addFvPAtches:" <<
nl;
2037 printPatches(
Pout, newPatches);
2038 Pout<<
"*** end of adaptMesh : addFvPAtches:" <<
endl;
2044 mesh.removeFvBoundary();
2045 mesh.addFvPatches(newPatches,
true);
2057 extrudeTopPatchID[facei] = interRegionTopPatch[zoneID[facei]];
2058 extrudeBottomPatchID[facei] = interRegionBottomPatch[zoneID[facei]];
2081 extrudeEdgeGlobalFaces,
2128 extrudeEdgeFacesMap,
2129 extrudeEdgeGlobalFaces,
2174 bitSet nonManifoldEdge(extrudePatch.
nEdges());
2179 const labelList& eFaces = edgeFaces[edgeI];
2181 labelList& ePatches = extrudeEdgePatches[edgeI];
2188 ePatches[i] = zoneSidePatch[zoneID[eFaces[i]]];
2191 if (oneDNonManifoldEdges)
2196 if (eFaces.
size() != 2)
2198 nonManifoldEdge.set(edgeI);
2203 nonManifoldEdge.set(edgeI);
2206 else if (eFaces.
size() == 2)
2208 label zone0 = zoneID[eFaces[0]];
2209 label zone1 = zoneID[eFaces[1]];
2211 if (addSidePatches && (zone0 != zone1))
2215 label index = minZone*zoneNames.
size()+maxZone;
2217 ePatches.
setSize(eFaces.size());
2219 if (zone0 == minZone)
2221 ePatches[0] = zoneZonePatch_min[index];
2222 ePatches[1] = zoneZonePatch_max[index];
2226 ePatches[0] = zoneZonePatch_max[index];
2227 ePatches[1] = zoneZonePatch_min[index];
2230 nonManifoldEdge.set(edgeI);
2233 else if (sidePatchID[edgeI] != -1)
2236 ePatches.
setSize(eFaces.size());
2239 ePatches[i] = sidePatchID[edgeI];
2244 label facei = findUncoveredPatchFace
2248 extrudeMeshEdges[edgeI]
2253 label newPatchi = findPatchID
2258 ePatches.
setSize(eFaces.size(), newPatchi);
2262 ePatches.
setSize(eFaces.size());
2265 ePatches[i] = zoneSidePatch[zoneID[eFaces[i]]];
2268 nonManifoldEdge.
set(edgeI);
2296 forAll(pointLocalRegions, facei)
2299 const face& pRegions = pointLocalRegions[facei];
2302 localRegionPoints[pRegions[fp]] =
f[fp];
2311 forAll(pointLocalRegions, facei)
2313 const face& pRegions = pointLocalRegions[facei];
2316 label localRegionI = pRegions[fp];
2317 localSum[localRegionI] += extrudePatch.
faceNormals()[facei];
2323 forAll(localSum, localRegionI)
2325 label globalRegionI = localToGlobalRegion[localRegionI];
2326 globalSum.insert(globalRegionI, localSum[localRegionI]);
2332 forAll(localToGlobalRegion, localRegionI)
2334 label globalRegionI = localToGlobalRegion[localRegionI];
2335 localRegionNormals[localRegionI] = globalSum[globalRegionI];
2337 localRegionNormals /=
mag(localRegionNormals);
2349 forAll(pointLocalRegions, facei)
2351 const face&
f = extrudeFaces[facei];
2355 label region = pointLocalRegions[facei][fp];
2356 const point& pt = extrudePoints[
f[fp]];
2363 pt+thickness*localRegionNormals[region]
2366 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
2374 forAll(firstDisp, regionI)
2381 localRegionPoints[regionI]
2384 const vector&
n = localRegionNormals[regionI];
2385 firstDisp[regionI] = model()(regionPt,
n, 1) - regionPt;
2417 forAll(regionPatches, patchi)
2419 polyPatch* ppPtr = regionPatches[patchi];
2425 Pout<<
"*** regionPatches : regionPatches:" <<
nl;
2426 printPatches(
Pout, regionPatches);
2427 Pout<<
"*** end of regionPatches : regionPatches:" <<
endl;
2432 regionMesh.removeFvBoundary();
2433 regionMesh.addFvPatches(regionPatches,
true);
2441 model().expansionRatio(),
2444 extrudeBottomPatchID,
2457 label meshPointi = extrudePatch.
localPoints().size();
2458 forAll(localRegionPoints, regionI)
2460 label pointi = localRegionPoints[regionI];
2462 const vector&
n = localRegionNormals[regionI];
2464 for (label layerI = 1; layerI <= model().
nLayers(); layerI++)
2466 newPoints[meshPointi++] = model()(pt,
n, layerI);
2470 shellMap = meshMod.changeMesh
2488 List<pointField> topOffsets(zoneNames.
size());
2489 List<boundBox> topBbs(zoneNames.
size());
2491 List<pointField> bottomOffsets(zoneNames.
size());
2492 List<boundBox> bottomBbs(zoneNames.
size());
2500 if (interRegionTopPatch.
found(patchi))
2502 label zoneI = interRegionTopPatch.
find(patchi);
2503 topOffsets[zoneI] = calcOffset(extrudePatch, extruder,
pp);
2504 topBbs[zoneI] =
boundBox(
pp.points(),
pp.meshPoints(),
true);
2506 else if (interRegionBottomPatch.
found(patchi))
2508 label zoneI = interRegionBottomPatch.
find(patchi);
2509 bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder,
pp);
2510 bottomBbs[zoneI] =
boundBox(
pp.points(),
pp.meshPoints(),
true);
2524 interRegionTopPatch,
2535 interRegionBottomPatch,
2543 deleteEmptyPatches(regionMesh);
2566 interMeshBottomPatch,
2583 "cellToPatchFaceAddressing",
2593 cellToPatchFaceAddressing.note() =
"cell to patch face addressing";
2599 "faceToPatchFaceAddressing",
2609 faceToPatchFaceAddressing.note() =
2610 "front/back face + turning index to patch face addressing";
2616 "faceToPatchEdgeAddressing",
2626 faceToPatchEdgeAddressing.note() =
2627 "side face to patch edge addressing";
2633 "pointToPatchPointAddressing",
2643 pointToPatchPointAddressing.note() =
2644 "point to patch point addressing";
2647 Info<<
"Writing mesh " << regionMesh.
name()
2653 && cellToPatchFaceAddressing.write()
2654 && faceToPatchFaceAddressing.write()
2655 && faceToPatchEdgeAddressing.write()
2656 && pointToPatchPointAddressing.write();
2661 <<
"Failed writing mesh " << regionMesh.
name()
2676 mesh.pointsInstance(),
2684 Info<<
"Reading patch face,edge centres : "
2685 <<
io.name() <<
" and patchEdgeCentres" <<
endl;
2687 extrudeGeometricProperties
2711 forAll(extrudeMeshFaces, zoneFacei)
2713 label meshFacei = extrudeMeshFaces[zoneFacei];
2714 label zoneI = zoneID[zoneFacei];
2715 bool flip = zoneFlipMap[zoneFacei];
2716 const face&
f =
mesh.faces()[meshFacei];
2724 mesh.faceOwner()[meshFacei],
2727 interMeshBottomPatch[zoneI],
2732 else if (
mesh.isInternalFace(meshFacei))
2738 mesh.faceNeighbour()[meshFacei],
2741 interMeshBottomPatch[zoneI],
2748 if (zoneShadowNames.
size() > 0)
2750 forAll(extrudeMeshFaces, zoneFacei)
2752 label meshFacei = extrudeMeshShadowFaces[zoneFacei];
2753 label zoneI = zoneShadowID[zoneFacei];
2754 bool flip = zoneShadowFlipMap[zoneFacei];
2755 const face&
f =
mesh.faces()[meshFacei];
2763 mesh.faceOwner()[meshFacei],
2766 interMeshTopPatch[zoneI],
2771 else if (
mesh.isInternalFace(meshFacei))
2777 mesh.faceNeighbour()[meshFacei],
2780 interMeshTopPatch[zoneI],
2790 forAll(extrudeMeshFaces, zoneFacei)
2792 label meshFacei = extrudeMeshFaces[zoneFacei];
2793 label zoneI = zoneID[zoneFacei];
2794 bool flip = zoneFlipMap[zoneFacei];
2795 const face&
f =
mesh.faces()[meshFacei];
2799 if (
mesh.isInternalFace(meshFacei))
2804 mesh.faceNeighbour()[meshFacei],
2810 interMeshTopPatch[zoneI],
2821 mesh.faceOwner()[meshFacei],
2827 interMeshTopPatch[zoneI],
2836 addBafflesMap = meshMod.changeMesh(
mesh,
false);
2839 mesh.updateMesh(addBafflesMap());
2847 if (addBafflesMap().hasMotionPoints())
2849 mesh.movePoints(addBafflesMap().preMotionPoints());
2852 mesh.setInstance(meshInstance);
2855 deleteEmptyPatches(
mesh);
2857 Info<<
"Writing mesh " <<
mesh.name()
2858 <<
" to " <<
mesh.facesInstance() <<
nl
2864 <<
"Failed writing mesh " <<
mesh.name()
2865 <<
" at location " <<
mesh.facesInstance()
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
SubField< vector > subField
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
label size() const noexcept
The number of elements in the list.
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void setSize(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label nEdges() const
Number of edges in patch.
label nPoints() const
Number of points supporting patch faces.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
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.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
static void mapCombineReduce(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::mapReduce with an in-place cop.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
static void listCombineReduce(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listReduce with an in-place cop.
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
fileName path() const
The path for the case = rootPath/caseName.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool found(const T &val, label pos=0) const
Same as contains().
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
label find(const T &val) const
Find index of the first occurrence of the value.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
label size() const noexcept
The number of entries in the list.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
wordList names() const
A list of the zone names.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A bounding box defined in terms of min/max extrema points.
static const Enum< transformType > transformTypeNames
Creates mesh by extruding a patch.
const labelList & faceToEdgeMap() const
From region side-face to patch edge. -1 for non-edge faces.
const labelList & pointToPointMap() const
From region point to patch point.
const labelList & faceToFaceMap() const
From region face to patch face. Contains turning index:
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.
const labelList & cellToFaceMap() const
From region cell to patch face. Consecutively added so.
void updateMesh(const mapPolyMesh &)
Update any locally stored mesh information.
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Top level extrusion model class.
static autoPtr< extrudeModel > New(const dictionary &dict)
Select null constructed.
label nLayers() const
Return the number of layers.
scalar sumThickness(const label layer) const
Helper: calculate cumulative relative thickness for layer.
A subset of mesh faces organised as a primitive patch.
const boolList & flipMap() const noexcept
Return face flip map.
A face is a list of labels corresponding to mesh vertices.
Mesh data needed to do the Finite Volume discretisation.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
label toGlobal(const label proci, const label i) const
From local to global on proci.
Class containing processor-to-processor mapping information.
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.
sampleMode
Mesh items to sample.
static const Enum< sampleMode > sampleModeNames_
const Time & time() const noexcept
Return time registry.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
const fileName & facesInstance() const
Return the current instance directory for faces.
virtual const labelList & faceOwner() const
Return face owner.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual const labelList & faceNeighbour() const
Return face neighbour.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
void clearOut(const bool isMeshUpdate=false)
Clear all geometry and addressing.
A patch is a list of labels that address the faces in the global face list.
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.
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Construct and return a clone, setting faceCells.
Direct mesh changes based on v1.3 polyTopoChange syntax.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
const vectorField & faceCentres() const
const vectorField & cellCentres() const
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch ("procBoundary..") constructed from the pair of processor IDs...
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
static const word null
An empty word.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
const polyBoundaryMesh & patches
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const word dictName("faMeshDefinition")
const labelIOList & zoneIDs
#define WarningInFunction
Report a warning using Foam::Warning.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
UIndirectList< label > labelUIndList
UIndirectList of labels.
IOList< label > labelIOList
IO for a List of label.
messageStream Info
Information stream (stdout output on master, null elsewhere).
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
List< face > faceList
List of faces.
vectorIOField pointIOField
pointIOField is a vectorIOField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
vector point
Point is a vector.
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gMax(const FieldField< Field, Type > &f)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
List helper to append y unique elements onto the end of x.