157 if (newPatches[i]->
name() == name)
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);
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;
240template<
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);
312 if (Pstream::master())
316 Pstream::broadcast(masterNames);
321 label notUsedI =
patches.size();
324 forAll(masterNames, masterI)
326 label patchi =
patches.findPatchID(masterNames[masterI]);
330 if (isA<processorPolyPatch>(
patches[patchi]))
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++;
384 fvMeshTools::reorderPatches(
mesh, oldToNew, usedI,
true);
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];
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]);
448 syncTools::syncEdgeList
457 return globalEdgeFaces;
462label findUncoveredPatchFace
466 const label meshEdgeI
471 extrudeFaceSet.insert(extrudeMeshFaces);
477 label facei = eFaces[i];
484 && !extrudeFaceSet.found(facei)
496label findUncoveredCyclicPatchFace
500 const label meshEdgeI
505 extrudeFaceSet.insert(extrudeMeshFaces);
511 label facei = eFaces[i];
517 && isA<cyclicPolyPatch>(pbm[patchi])
518 && !extrudeFaceSet.found(facei)
530void calcEdgeMinMaxZone
548 minZoneID.
setSize(extrudeEdgeGlobalFaces.
size(), labelMax);
549 maxZoneID.
setSize(extrudeEdgeGlobalFaces.
size(), labelMin);
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);
564 syncTools::syncEdgeList
572 syncTools::syncEdgeList
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])
634 <<
"at " << pts[
e[0]] << pts[
e[1]]
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
802 labelList procID(extrudeEdgeGlobalFaces.
size(), Pstream::myProcNo());
805 labelList minProcID(extrudeEdgeGlobalFaces.
size(), labelMax);
806 labelList maxProcID(extrudeEdgeGlobalFaces.
size(), labelMin);
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);
821 syncTools::syncEdgeList
829 syncTools::syncEdgeList
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];
858 if (nbrProci == Pstream::myProcNo())
860 nbrProci = maxProcID[edgeI];
864 if (nbrProci == Pstream::myProcNo())
869 label facei = findUncoveredCyclicPatchFace
873 extrudeMeshEdges[edgeI]
880 label newPatchi = findPatchID
886 sidePatchID[edgeI] = newPatchi;
891 <<
"Unable to determine coupled patch addressing"
892 <<
abort(FatalError);
900 processorPolyPatch::newName(Pstream::myProcNo(), nbrProci)
903 sidePatchID[edgeI] = findPatchID(newPatches, name);
905 if (sidePatchID[edgeI] == -1)
908 patchDict.
add(
"myProcNo", Pstream::myProcNo());
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)
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
1022 cyclicPolyPatch::transformTypeNames[cyclicPolyPatch::NOORDERING]
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."
1096 label meshFacei = pp.
start()+i;
1098 point patchFc = extrudePatch[patchFacei].centre
1102 offsets[i] = patchFc - fc[i];
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;
1192 mesh.removeFvBoundary();
1193 mesh.addFvPatches(newPatches,
true);
1198void extrudeGeometricProperties
1212 mesh.pointsInstance(),
1224 mesh.pointsInstance(),
1243 bitSet sameEdgeOrientation;
1244 PatchTools::matchEdges
1247 mesh.globalData().coupledPatch(),
1255 PatchTools::edgeNormals
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
1409 forAll(cellCentres, celli)
1411 Pout<<
"Model :" << cellCentres[celli] <<
endl
1426 Info<<
"Writing geometric properties for mesh " << regionMesh.
name()
1430 bool ok = faceCentres.
write() && cellCentres.write();
1435 <<
"Failed writing " << faceCentres.objectPath()
1436 <<
" and " << cellCentres.objectPath()
1437 <<
exit(FatalError);
1442int main(
int argc,
char *argv[])
1446 "Create region mesh by extruding a faceZone or faceSet"
1454 "dict",
"file",
"Alternative extrudeToRegionMeshDict"
1461 if (
mesh.boundaryMesh().checkParallelSync(
true))
1464 allNames[Pstream::myProcNo()] =
mesh.boundaryMesh().names();
1465 Pstream::allGatherList(allNames);
1468 <<
"Patches are not synchronised on all processors."
1469 <<
" Per processor patches " << allNames
1470 <<
exit(FatalError);
1474 const word oldInstance =
mesh.pointsInstance();
1475 const bool overwrite =
args.
found(
"overwrite");
1493 const bool hasZones =
dict.found(
"faceZones");
1496 dict.readEntry(
"faceZones", zoneNames);
1497 dict.readIfPresent(
"faceZonesShadow", zoneShadowNames);
1500 if (
dict.found(
"faceSets"))
1503 <<
"Please supply faces to extrude either through 'faceZones'"
1504 <<
" or 'faceSets' entry. Found both."
1505 <<
exit(FatalIOError);
1510 dict.readEntry(
"faceSets", zoneNames);
1511 dict.readIfPresent(
"faceSetsShadow", zoneShadowNames);
1516 mappedPatchBase::sampleModeNames_.get(
"sampleMode",
dict);
1518 const bool oneD(
dict.get<
bool>(
"oneD"));
1519 bool oneDNonManifoldEdges(
false);
1520 word oneDPatchType(emptyPolyPatch::typeName);
1523 oneDNonManifoldEdges =
dict.getOrDefault(
"nonManifold",
false);
1524 oneDPatchType =
dict.get<
word>(
"oneDPolyPatchType");
1527 const bool adaptMesh(
dict.get<
bool>(
"adaptMesh"));
1531 Info<<
"Extruding zones " << zoneNames
1533 <<
" into shell mesh " << shellRegionName
1538 Info<<
"Extruding faceSets " << zoneNames
1540 <<
" into shell mesh " << shellRegionName
1547 <<
"Cannot extrude into same region as mesh." <<
endl
1549 <<
"Shell region : " << shellRegionName
1550 <<
exit(FatalIOError);
1556 if (oneDNonManifoldEdges)
1558 Info<<
"Extruding as 1D columns with sides in patch type "
1560 <<
" and connected points (except on non-manifold areas)."
1565 Info<<
"Extruding as 1D columns with sides in patch type "
1567 <<
" and duplicated points (overlapping volumes)."
1623 fvMeshTools::createDummyFvMeshFiles(
mesh, shellRegionName,
true);
1630 meshInstance =
runTime.timeName();
1634 meshInstance = oldInstance;
1636 Info<<
"Writing meshes to " << meshInstance <<
nl <<
endl;
1669 meshZoneID[i] = faceZones.
findZoneID(zoneNames[i]);
1670 if (meshZoneID[i] == -1)
1673 <<
"Cannot find zone " << zoneNames[i] <<
endl
1674 <<
"Valid zones are " << faceZones.
names()
1675 <<
exit(FatalIOError);
1679 label nExtrudeFaces = 0;
1682 nExtrudeFaces += faceZones[meshZoneID[i]].
size();
1684 extrudeMeshFaces.
setSize(nExtrudeFaces);
1685 zoneFaces.
setSize(nExtrudeFaces);
1686 zoneID.setSize(nExtrudeFaces);
1687 zoneFlipMap.
setSize(nExtrudeFaces);
1691 const faceZone& fz = faceZones[meshZoneID[i]];
1695 extrudeMeshFaces[nExtrudeFaces] = fz[j];
1696 zoneFaces[nExtrudeFaces] = fzp[j];
1697 zoneID[nExtrudeFaces] = i;
1698 zoneFlipMap[nExtrudeFaces] = fz.
flipMap()[j];
1701 if (
mesh.isInternalFace(fz[j]))
1703 isInternal[i] =
true;
1711 if (zoneShadowNames.
size())
1714 forAll(zoneShadowNames, i)
1716 zoneShadowIDs[i] = faceZones.
findZoneID(zoneShadowNames[i]);
1717 if (zoneShadowIDs[i] == -1)
1720 <<
"Cannot find zone " << zoneShadowNames[i] <<
endl
1721 <<
"Valid zones are " << faceZones.
names()
1722 <<
exit(FatalIOError);
1726 label nShadowFaces = 0;
1729 nShadowFaces += faceZones[zoneShadowIDs[i]].
size();
1732 extrudeMeshShadowFaces.
setSize(nShadowFaces);
1733 zoneShadowFlipMap.
setSize(nShadowFaces);
1734 zoneShadowID.
setSize(nShadowFaces);
1739 const faceZone& fz = faceZones[zoneShadowIDs[i]];
1742 extrudeMeshShadowFaces[nShadowFaces] = fz[j];
1743 zoneShadowFlipMap[nShadowFaces] = fz.
flipMap()[j];
1744 zoneShadowID[nShadowFaces] = i;
1757 Info<<
"Loading faceSet " << zoneNames[i] <<
endl;
1763 label nExtrudeFaces = 0;
1766 nExtrudeFaces += zones[i].size();
1768 extrudeMeshFaces.
setSize(nExtrudeFaces);
1769 zoneFaces.
setSize(nExtrudeFaces);
1770 zoneID.setSize(nExtrudeFaces);
1771 zoneFlipMap.
setSize(nExtrudeFaces);
1777 for (
const label facei : fz)
1779 if (
mesh.isInternalFace(facei))
1782 <<
"faceSet " << fz.name()
1783 <<
"contains internal faces."
1784 <<
" This is not permitted."
1785 <<
exit(FatalIOError);
1787 extrudeMeshFaces[nExtrudeFaces] = facei;
1788 zoneFaces[nExtrudeFaces] =
mesh.faces()[facei];
1789 zoneID[nExtrudeFaces] = i;
1790 zoneFlipMap[nExtrudeFaces] =
false;
1793 if (
mesh.isInternalFace(facei))
1795 isInternal[i] =
true;
1805 if (zoneShadowNames.
size())
1807 zoneShadowIDs.
setSize(zoneShadowNames.
size(), -1);
1808 forAll(zoneShadowNames, i)
1810 shadowZones.set(i,
new faceSet(
mesh, zoneShadowNames[i]));
1813 label nShadowFaces = 0;
1814 for (
const faceSet& fz : shadowZones)
1816 nShadowFaces += fz.size();
1819 if (nExtrudeFaces != nShadowFaces)
1822 <<
"Extruded faces " << nExtrudeFaces <<
endl
1823 <<
"is different from shadow faces. " << nShadowFaces
1824 <<
"This is not permitted " <<
endl
1825 <<
exit(FatalIOError);
1828 extrudeMeshShadowFaces.
setSize(nShadowFaces);
1829 zoneShadowFlipMap.
setSize(nShadowFaces);
1830 zoneShadowID.
setSize(nShadowFaces);
1835 const faceSet& fz = shadowZones[i];
1836 for (
const label facei : fz)
1838 if (
mesh.isInternalFace(facei))
1841 <<
"faceSet " << fz.name()
1842 <<
"contains internal faces."
1843 <<
" This is not permitted."
1844 <<
exit(FatalIOError);
1846 extrudeMeshShadowFaces[nShadowFaces] = facei;
1847 zoneShadowFlipMap[nShadowFaces] =
false;
1848 zoneShadowID[nShadowFaces] = i;
1857 Pstream::listCombineAllGather(isInternal,
orEqOp<bool>());
1860 checkZoneInside(
mesh, zoneNames,
zoneID, extrudeMeshFaces, isInternal);
1868 Info<<
"extrudePatch :"
1869 <<
" faces:" << extrudePatch.size()
1870 <<
" points:" << extrudePatch.
nPoints()
1871 <<
" edges:" << extrudePatch.
nEdges()
1889 const globalIndex globalExtrudeFaces(extrudePatch.size());
1906 extrudeEdgeGlobalFaces,
1920 extrudeEdgeFacesMap,
1921 extrudeEdgeGlobalFaces,
1935 if (!isA<processorPolyPatch>(
patches[patchi]))
1937 label newPatchi = regionPatches.size();
1938 regionPatches.append
1970 interRegionTopPatch,
1971 interRegionBottomPatch
1987 if (!isA<processorPolyPatch>(
patches[patchi]))
1990 clonedPatch->index() = newPatches.
size();
1991 newPatches.
append(clonedPatch.ptr());
2008 interMeshBottomPatch
2014 if (isA<processorPolyPatch>(
patches[patchi]))
2017 clonedPatch->index() = newPatches.
size();
2018 newPatches.
append(clonedPatch.ptr());
2024 Pout<<
"*** adaptMesh : addFvPAtches:" <<
nl;
2025 printPatches(Pout, newPatches);
2026 Pout<<
"*** end of adaptMesh : addFvPAtches:" <<
endl;
2032 mesh.removeFvBoundary();
2033 mesh.addFvPatches(newPatches,
true);
2040 labelList extrudeTopPatchID(extrudePatch.size());
2041 labelList extrudeBottomPatchID(extrudePatch.size());
2045 extrudeTopPatchID[facei] = interRegionTopPatch[
zoneID[facei]];
2046 extrudeBottomPatchID[facei] = interRegionBottomPatch[
zoneID[facei]];
2069 extrudeEdgeGlobalFaces,
2116 extrudeEdgeFacesMap,
2117 extrudeEdgeGlobalFaces,
2167 const labelList& eFaces = edgeFaces[edgeI];
2169 labelList& ePatches = extrudeEdgePatches[edgeI];
2176 ePatches[i] = zoneSidePatch[
zoneID[eFaces[i]]];
2179 if (oneDNonManifoldEdges)
2184 if (eFaces.
size() != 2)
2186 nonManifoldEdge.
set(edgeI);
2191 nonManifoldEdge.set(edgeI);
2194 else if (eFaces.
size() == 2)
2196 label zone0 =
zoneID[eFaces[0]];
2197 label zone1 =
zoneID[eFaces[1]];
2201 label minZone =
min(zone0,zone1);
2202 label maxZone =
max(zone0,zone1);
2203 label index = minZone*zoneNames.
size()+maxZone;
2205 ePatches.
setSize(eFaces.size());
2207 if (zone0 == minZone)
2209 ePatches[0] = zoneZonePatch_min[index];
2210 ePatches[1] = zoneZonePatch_max[index];
2214 ePatches[0] = zoneZonePatch_max[index];
2215 ePatches[1] = zoneZonePatch_min[index];
2218 nonManifoldEdge.
set(edgeI);
2221 else if (sidePatchID[edgeI] != -1)
2224 ePatches.
setSize(eFaces.size());
2227 ePatches[i] = sidePatchID[edgeI];
2232 label facei = findUncoveredPatchFace
2236 extrudeMeshEdges[edgeI]
2241 label newPatchi = findPatchID
2246 ePatches.
setSize(eFaces.size(), newPatchi);
2250 ePatches.
setSize(eFaces.size());
2253 ePatches[i] = zoneSidePatch[
zoneID[eFaces[i]]];
2256 nonManifoldEdge.
set(edgeI);
2270 createShellMesh::calcPointRegions
2284 forAll(pointLocalRegions, facei)
2287 const face& pRegions = pointLocalRegions[facei];
2290 localRegionPoints[pRegions[fp]] =
f[fp];
2299 forAll(pointLocalRegions, facei)
2301 const face& pRegions = pointLocalRegions[facei];
2304 label localRegionI = pRegions[fp];
2305 localSum[localRegionI] += extrudePatch.
faceNormals()[facei];
2311 forAll(localSum, localRegionI)
2313 label globalRegionI = localToGlobalRegion[localRegionI];
2314 globalSum.insert(globalRegionI, localSum[localRegionI]);
2320 forAll(localToGlobalRegion, localRegionI)
2322 label globalRegionI = localToGlobalRegion[localRegionI];
2323 localRegionNormals[localRegionI] = globalSum[globalRegionI];
2325 localRegionNormals /=
mag(localRegionNormals);
2337 forAll(pointLocalRegions, facei)
2339 const face&
f = extrudeFaces[facei];
2343 label region = pointLocalRegions[facei][fp];
2344 const point& pt = extrudePoints[
f[fp]];
2346 meshTools::writeOBJ(str, pt);
2351 pt+thickness*localRegionNormals[region]
2354 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
2362 forAll(firstDisp, regionI)
2369 localRegionPoints[regionI]
2372 const vector&
n = localRegionNormals[regionI];
2373 firstDisp[regionI] = model()(regionPt,
n, 1) - regionPt;
2397 IOobject::AUTO_WRITE,
2405 forAll(regionPatches, patchi)
2407 polyPatch* ppPtr = regionPatches[patchi];
2413 Pout<<
"*** regionPatches : regionPatches:" <<
nl;
2414 printPatches(Pout, regionPatches);
2415 Pout<<
"*** end of regionPatches : regionPatches:" <<
endl;
2420 regionMesh.removeFvBoundary();
2421 regionMesh.addFvPatches(regionPatches,
true);
2429 model().expansionRatio(),
2432 extrudeBottomPatchID,
2445 label meshPointi = extrudePatch.
localPoints().size();
2446 forAll(localRegionPoints, regionI)
2448 label pointi = localRegionPoints[regionI];
2450 const vector&
n = localRegionNormals[regionI];
2452 for (label layerI = 1; layerI <= model().
nLayers(); layerI++)
2454 newPoints[meshPointi++] = model()(pt,
n, layerI);
2458 shellMap = meshMod.changeMesh
2483 if (isA<mappedWallPolyPatch>(pp))
2485 if (interRegionTopPatch.
found(patchi))
2487 label zoneI = interRegionTopPatch.
find(patchi);
2488 topOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp);
2490 else if (interRegionBottomPatch.
found(patchi))
2492 label zoneI = interRegionBottomPatch.
find(patchi);
2493 bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp);
2507 interRegionTopPatch,
2517 interRegionBottomPatch,
2524 deleteEmptyPatches(regionMesh);
2546 interMeshBottomPatch,
2562 "cellToPatchFaceAddressing",
2572 cellToPatchFaceAddressing.note() =
"cell to patch face addressing";
2578 "faceToPatchFaceAddressing",
2588 faceToPatchFaceAddressing.note() =
2589 "front/back face + turning index to patch face addressing";
2595 "faceToPatchEdgeAddressing",
2605 faceToPatchEdgeAddressing.note() =
2606 "side face to patch edge addressing";
2612 "pointToPatchPointAddressing",
2622 pointToPatchPointAddressing.note() =
2623 "point to patch point addressing";
2626 Info<<
"Writing mesh " << regionMesh.
name()
2632 && cellToPatchFaceAddressing.write()
2633 && faceToPatchFaceAddressing.write()
2634 && faceToPatchEdgeAddressing.write()
2635 && pointToPatchPointAddressing.write();
2640 <<
"Failed writing mesh " << regionMesh.
name()
2642 <<
exit(FatalError);
2644 topoSet::removeFiles(regionMesh);
2645 processorMeshes::removeFiles(regionMesh);
2655 mesh.pointsInstance(),
2663 Info<<
"Reading patch face,edge centres : "
2664 <<
io.name() <<
" and patchEdgeCentres" <<
endl;
2666 extrudeGeometricProperties
2690 forAll(extrudeMeshFaces, zoneFacei)
2692 label meshFacei = extrudeMeshFaces[zoneFacei];
2693 label zoneI =
zoneID[zoneFacei];
2694 bool flip = zoneFlipMap[zoneFacei];
2695 const face&
f =
mesh.faces()[meshFacei];
2703 mesh.faceOwner()[meshFacei],
2706 interMeshBottomPatch[zoneI],
2711 else if (
mesh.isInternalFace(meshFacei))
2717 mesh.faceNeighbour()[meshFacei],
2720 interMeshBottomPatch[zoneI],
2727 if (zoneShadowNames.
size() > 0)
2729 forAll(extrudeMeshFaces, zoneFacei)
2731 label meshFacei = extrudeMeshShadowFaces[zoneFacei];
2732 label zoneI = zoneShadowID[zoneFacei];
2733 bool flip = zoneShadowFlipMap[zoneFacei];
2734 const face&
f =
mesh.faces()[meshFacei];
2742 mesh.faceOwner()[meshFacei],
2745 interMeshTopPatch[zoneI],
2750 else if (
mesh.isInternalFace(meshFacei))
2756 mesh.faceNeighbour()[meshFacei],
2759 interMeshTopPatch[zoneI],
2769 forAll(extrudeMeshFaces, zoneFacei)
2771 label meshFacei = extrudeMeshFaces[zoneFacei];
2772 label zoneI =
zoneID[zoneFacei];
2773 bool flip = zoneFlipMap[zoneFacei];
2774 const face&
f =
mesh.faces()[meshFacei];
2778 if (
mesh.isInternalFace(meshFacei))
2783 mesh.faceNeighbour()[meshFacei],
2789 interMeshTopPatch[zoneI],
2800 mesh.faceOwner()[meshFacei],
2806 interMeshTopPatch[zoneI],
2815 addBafflesMap = meshMod.changeMesh(
mesh,
false);
2818 mesh.updateMesh(addBafflesMap());
2826 if (addBafflesMap().hasMotionPoints())
2828 mesh.movePoints(addBafflesMap().preMotionPoints());
2831 mesh.setInstance(meshInstance);
2834 deleteEmptyPatches(
mesh);
2836 Info<<
"Writing mesh " <<
mesh.name()
2837 <<
" to " <<
mesh.facesInstance() <<
nl
2843 <<
"Failed writing mesh " <<
mesh.name()
2844 <<
" at location " <<
mesh.facesInstance()
2845 <<
exit(FatalError);
2847 topoSet::removeFiles(
mesh);
2848 processorMeshes::removeFiles(
mesh);
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.
A primitive field of type <T> with automated input and output.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
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.
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.
void setSize(const label n)
Alias for resize()
A HashTable to objects of type <T> with a label key.
OFstream that keeps track of vertices.
Output to file stream, using an OSstream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of faces which address into the list of points.
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
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.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
SubField is a Field obtained as a section of another Field, without its own allocation....
fileName path() const
Return path.
A List with indirect addressing. Like IndirectList but does not store addressing.
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
True if the value if found in the list.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
label size() const noexcept
The number of elements 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.
bool found(const word &optName) const
Return true if the named option is found.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A bounding box defined in terms of min/max extrema points.
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:
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 point labels. The functionality it provides supports the discretisation on a...
Top level extrusion model class.
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 unique integer (label so might not have enough room - 2G max) for processor + local inde...
label toGlobal(const label i) const
From local to global index.
Class containing processor-to-processor mapping information.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
sampleMode
Mesh items to sample.
const Time & time() const noexcept
Return time registry.
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
void setInstance(const fileName &instance, const IOobject::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.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
A patch is a list of labels that address the faces in the global face list.
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Construct and return a clone, setting faceCells.
label start() const
Return start label of this patch in the polyMesh face list.
const vectorField::subField faceCentres() const
Return face centres.
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.
virtual bool write(const bool valid=true) const
Write using setting from DB.
A class for managing temporary objects.
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.
const polyBoundaryMesh & patches
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
Foam::word regionName(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
const labelIOList & zoneID
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
Type gAverage(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
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.