128 if (Pstream::master())
133 masterTimeDirs = localTimeDirs;
135 Pstream::scatter(masterTimeDirs);
141 for (
const instant& t : masterTimeDirs)
143 if (!localTimeDirs.found(t))
156 (void)Time::findTimes(
path,
"constant");
163 const bool decompose,
164 const bool reconstruct,
165 const word& readTimeName,
171 const IOobject readIO(
"uniform", readTimeName, readDb);
182 if (!readPath.empty())
184 Info<<
"Detected additional non-decomposed files in "
213 Pout<<
" readPath :" << readPath <<
endl;
214 Pout<<
" writePath :" << writePath <<
endl;
215 Pout<<
" currentPath:" << currentPath <<
endl;
218 if (readPath == writePath)
223 if (currentPath.empty())
228 fh.
cp(readPath, writePath);
230 else if (reconstruct)
233 if (Pstream::master())
235 const bool oldParRun = Pstream::parRun(
false);
236 fh.
cp(readPath, writePath);
237 Pstream::parRun(oldParRun);
245 if (isA<fileOperations::collatedFileOperation>(fh))
248 if (Pstream::master())
250 const bool oldParRun = Pstream::parRun(
false);
251 fh.
cp(readPath, writePath);
252 Pstream::parRun(oldParRun);
258 fh.
cp(readPath, writePath);
272 const labelList& pPatches =
mesh.globalData().processorPatches();
273 patchNeiProcNo[Pstream::myProcNo()].setSize(pPatches.
size());
274 patchSize[Pstream::myProcNo()].setSize(pPatches.
size());
279 mesh.boundaryMesh()[pPatches[i]]
281 patchNeiProcNo[Pstream::myProcNo()][i] = ppp.
neighbProcNo();
282 patchSize[Pstream::myProcNo()][i] = ppp.size();
284 Pstream::gatherList(patchNeiProcNo);
285 Pstream::gatherList(patchSize);
293 label maxProcCells = 0;
294 label maxProcFaces = 0;
295 label totProcFaces = 0;
296 label maxProcPatches = 0;
297 label totProcPatches = 0;
299 for (
const int proci : Pstream::allProcs())
301 const label nLocalCells = globalCells.localSize(proci);
302 const label nBndFaces = globalBoundaryFaces.localSize(proci);
305 <<
"Processor " << proci;
315 <<
" Number of cells = " << nLocalCells <<
endl;
318 label nProcFaces = 0;
319 const labelList& nei = patchNeiProcNo[proci];
321 forAll(patchNeiProcNo[proci], i)
323 Info<<
" Number of faces shared with processor "
324 << patchNeiProcNo[proci][i] <<
" = "
325 << patchSize[proci][i] <<
nl;
327 nProcFaces += patchSize[proci][i];
331 Info<<
" Number of processor patches = " << nei.
size() <<
nl
332 <<
" Number of processor faces = " << nProcFaces <<
nl
333 <<
" Number of boundary faces = "
334 << nBndFaces-nProcFaces <<
endl;
337 maxProcCells =
max(maxProcCells, nLocalCells);
338 totProcFaces += nProcFaces;
339 totProcPatches += nei.
size();
340 maxProcFaces =
max(maxProcFaces, nProcFaces);
341 maxProcPatches =
max(maxProcPatches, nei.
size());
347 <<
"Number of processor faces = " << (totProcFaces/2) << nl
348 <<
"Max number of cells = " << maxProcCells;
350 if (maxProcCells != globalCells.totalSize())
352 scalar avgValue = scalar(globalCells.totalSize())/Pstream::nProcs();
354 Info<<
" (" << 100.0*(maxProcCells-avgValue)/avgValue
355 <<
"% above average " << avgValue <<
')';
359 Info<<
"Max number of processor patches = " << maxProcPatches;
362 scalar avgValue = scalar(totProcPatches)/Pstream::nProcs();
364 Info<<
" (" << 100.0*(maxProcPatches-avgValue)/avgValue
365 <<
"% above average " << avgValue <<
')';
369 Info<<
"Max number of faces between processors = " << maxProcFaces;
372 scalar avgValue = scalar(totProcFaces)/Pstream::nProcs();
374 Info<<
" (" << 100.0*(maxProcFaces-avgValue)/avgValue
375 <<
"% above average " << avgValue <<
')';
382void writeDecomposition
396 mesh.facesInstance(),
404 cellDecomposition.write();
406 Info<<
"Writing wanted cell distribution to volScalarField " <<
name
407 <<
" for postprocessing purposes." <<
nl <<
endl;
414 mesh.time().timeName(),
427 procCells[celli] = decomp[celli];
430 procCells.correctBoundaryConditions();
435void determineDecomposition
437 const Time& baseRunTime,
439 const bool decompose,
442 const bool writeCellDist,
460 <<
"You have selected decomposition method \""
461 << decomposer.type() <<
"\n"
462 <<
" which does not synchronise decomposition across"
463 " processor patches.\n"
464 " You might want to select a decomposition method"
465 " that is aware of this. Continuing...." <<
endl;
471 if (Pstream::master() && decompose)
474 <<
" to read decomposeParDict" <<
endl;
480 if (method.
found(
"weightField"))
496 cellWeights = weights.internalField();
502 if (Pstream::master() && decompose)
504 Info<<
"Restoring caseName" <<
endl;
515 if (Pstream::master())
517 const bool oldParRun = Pstream::parRun(
false);
520 <<
" to write undecomposed cellDist" <<
endl;
524 writeDecomposition(
"cellDist",
mesh, decomp);
525 Info<<
"Restoring caseName" <<
endl;
529 Pstream::parRun(oldParRun);
534 writeDecomposition(
"cellDist",
mesh, decomp);
542template<
class CoupledPatchType,
class GeoField>
543void correctCoupledBoundaryConditions(
fvMesh&
mesh)
545 for (GeoField&
fld :
mesh.sorted<GeoField>())
547 fld.boundaryFieldRef().template evaluateCoupled<CoupledPatchType>();
556 const Time& baseRunTime,
560 const bool doReadFields,
561 const bool decompose,
562 const bool reconstruct,
563 const bool overwrite,
566 const label nDestProcs,
576 const bool oldProcCase =
runTime.processorCase();
632 if (volMeshOnProc.
found(
false))
641 if (Pstream::master() && decompose)
647 if (Pstream::master() && decompose)
649 runTime.caseName() = proc0CaseName;
650 runTime.processorCase(oldProcCase);
654 <<
" mesh:" <<
mesh.objectRegistry::objectRelPath()
655 <<
" have objects:" << objects.names() <<
endl;
659 auto iter = objects.find(
"cellDist");
666 if (Pstream::master() && decompose)
674 #undef doFieldReading
675 #define doFieldReading(Storage) \
677 fieldsDistributor::readFields \
679 volMeshOnProc, mesh, subsetterPtr, objects, Storage \
684 doFieldReading(volScalarFields);
685 doFieldReading(volVectorFields);
686 doFieldReading(volSphereTensorFields);
687 doFieldReading(volSymmTensorFields);
688 doFieldReading(volTensorFields);
691 doFieldReading(surfScalarFields);
692 doFieldReading(surfVectorFields);
693 doFieldReading(surfSphereTensorFields);
694 doFieldReading(surfSymmTensorFields);
695 doFieldReading(surfTensorFields);
698 doFieldReading(dimScalarFields);
699 doFieldReading(dimVectorFields);
700 doFieldReading(dimSphereTensorFields);
701 doFieldReading(dimSymmTensorFields);
702 doFieldReading(dimTensorFields);
707 #undef doFieldReading
708 #define doFieldReading(Storage) \
710 fieldsDistributor::readFields \
712 volMeshOnProc, oldPointMesh, subsetterPtr, objects, Storage, \
715 nPointFields += Storage.size(); \
718 doFieldReading(pointScalarFields);
719 doFieldReading(pointVectorFields);
720 doFieldReading(pointSphTensorFields);
721 doFieldReading(pointSymmTensorFields);
722 doFieldReading(pointTensorFields);
723 #undef doFieldReading
728 if (Pstream::master() && decompose)
730 runTime.caseName() = proc0CaseName;
731 runTime.processorCase(oldProcCase);
738 pointDistributor.saveMeshPoints();
749 Info<<
"After distribution:" <<
endl;
755 #undef doCorrectCoupled
756 #define doCorrectCoupled(FieldType) \
757 correctCoupledBoundaryConditions<processorFvPatch, FieldType>(mesh);
764 #undef doCorrectCoupled
777 pointDistributor.resetTarget(newPointMesh, distMap());
779 pointDistributor.distributeAndStore(pointScalarFields);
780 pointDistributor.distributeAndStore(pointVectorFields);
781 pointDistributor.distributeAndStore(pointSphTensorFields);
782 pointDistributor.distributeAndStore(pointSymmTensorFields);
783 pointDistributor.distributeAndStore(pointTensorFields);
788 IOstream::defaultPrecision(
max(10u, IOstream::defaultPrecision()));
798 mesh.setInstance(volMeshInstance);
808 mesh.facesInstance(),
809 polyMesh::meshSubDir,
820 if (Pstream::master())
823 <<
" to write reconstructed mesh (and fields)." <<
endl;
825 const bool oldProcCase(
runTime.processorCase(
false));
828 topoSet::removeFiles(
mesh);
831 Info<<
"Restoring caseName" <<
endl;
832 runTime.caseName() = proc0CaseName;
833 runTime.processorCase(oldProcCase);
841 defaultHandler =
fileHandler(std::move(writeHandler));
848 writeHandler =
fileHandler(std::move(defaultHandler));
850 topoSet::removeFiles(
mesh);
852 Info<<
"Written redistributed mesh to "
856 if (decompose || reconstruct)
860 fvMeshTools::writeProcAddressing
865 std::move(writeHandler)
881 if (Pstream::master() && decompose)
889 mesh.facesInstance(),
890 polyMesh::meshSubDir,
892 IOobject::READ_IF_PRESENT,
898 if (Pstream::master() && decompose)
900 runTime.caseName() = proc0CaseName;
901 runTime.processorCase(oldProcCase);
909 refData.distribute(distMap());
913 meshRefinement::removeFiles(
mesh);
917 if (Pstream::master())
919 const bool oldParRun = Pstream::parRun(
false);
922 <<
" to write reconstructed refinement data." <<
endl;
924 const bool oldProcCase(
runTime.processorCase(
false));
929 Info<<
"Restoring caseName" <<
endl;
930 runTime.caseName() = proc0CaseName;
931 runTime.processorCase(oldProcCase);
933 Pstream::parRun(oldParRun);
1004int main(
int argc,
char *argv[])
1008 "Redistribute decomposed mesh and fields according"
1009 " to the decomposeParDict settings.\n"
1010 "Optionally run in decompose/reconstruct mode"
1013 argList::noFunctionObjects();
1017 timeSelector::addOptions(
true,
true);
1022 argList::addBoolOption(
"decompose",
"Decompose case");
1023 argList::addBoolOption(
"reconstruct",
"Reconstruct case");
1024 argList::addVerboseOption(
"Additional verbosity");
1025 argList::addDryRunOption
1027 "Test without writing the decomposition. "
1028 "Changes -cellDist to only write volScalarField."
1030 argList::addVerboseOption(
"Additional verbosity");
1031 argList::addBoolOption
1034 "Write cell distribution as a labelList - for use with 'manual' "
1035 "decomposition method or as a volScalarField for post-processing."
1037 argList::addBoolOption
1040 "Only reconstruct new times (i.e. that do not exist already)"
1042 argList::addVerboseOption
1044 "Additional verbosity. (Can be used multiple times)"
1046 argList::addBoolOption
1049 "Suppress finiteArea mesh/field handling",
1072 != fileOperations::uncollatedFileOperation::typeName
1076 writeHandler =
fileHandler(fileOperation::NewUncollated());
1098 const bool writeCellDist =
args.
found(
"cellDist");
1100 const bool newTimes =
args.
found(
"newTimes");
1103 const bool doFiniteArea = !
args.
found(
"no-finite-area");
1104 bool decompose =
args.
found(
"decompose");
1105 bool overwrite =
args.
found(
"overwrite");
1110 faMeshDistributor::verbose_ = 1;
1111 parPointFieldDistributor::verbose_ = 1;
1126 const wordRes selectedLagrangianFields;
1131 Info<<
"Decomposing case (like decomposePar)" <<
nl <<
endl;
1135 <<
"Cannot specify both -decompose and -reconstruct"
1136 <<
exit(FatalError);
1139 else if (reconstruct)
1141 Info<<
"Reconstructing case (like reconstructParMesh)" <<
nl <<
endl;
1144 if ((decompose || reconstruct) && !overwrite)
1148 <<
"Working in -decompose or -reconstruct mode:"
1149 " automatically implies -overwrite" <<
nl <<
endl;
1152 if (!Pstream::parRun())
1155 <<
": This utility can only be run parallel"
1156 <<
exit(FatalError);
1164 <<
exit(FatalError);
1172 nfs = (roots.size() == 1);
1177 Info<<
"Detected multiple roots i.e. non-nfs running"
1190 Info<<
"Removing existing processor directory" << procDir <<
endl;
1197 if (Pstream::master())
1200 Info<<
"No processor directories; switching on decompose mode"
1205 Pstream::scatter(decompose);
1216 Info<<
"Creating time directories on all processors" <<
nl <<
endl;
1224 runTime.functionObjects().off();
1229 const bool oldProcCase =
runTime.processorCase();
1239 Info<<
"Creating time directories for undecomposed Time"
1240 <<
" on all processors" <<
nl <<
endl;
1245 Info<<
"Create undecomposed database" <<
nl <<
endl;
1261 for (
const instant& t : baseTimeDirs)
1263 masterTimeDirSet.
insert(t.name());
1290 Pstream::scatter(timeDirs);
1292 if (timeDirs.
empty())
1295 <<
"No times selected"
1296 <<
exit(FatalError);
1305 <<
"Reconstructing mesh and addressing" <<
nl <<
endl;
1318 bool areaMeshDetected =
false;
1324 runTime.setTime(timeDirs[timeI], timeI);
1325 baseRunTime.
setTime(timeDirs[timeI], timeI);
1333 volMeshInstance =
runTime.findInstance
1337 IOobject::READ_IF_PRESENT
1342 areaMeshInstance =
runTime.findInstance
1346 IOobject::READ_IF_PRESENT
1352 UPstream::worldComm,
1367 volMeshInstance/volMeshSubDir,
1376 areaMeshInstance/areaMeshSubDir,
1380 areaMeshDetected = areaMeshOnProc.
found(
true);
1392 bool haveVolAddressing =
false;
1393 if (volMeshOnProc[Pstream::myProcNo()])
1413 "faceProcAddressing",
1417 IOobject::READ_IF_PRESENT
1423 faceProcAddressing.headerOk()
1424 && faceProcAddressing.size() == faces.size()
1430 haveVolAddressing =
true;
1433 bool haveAreaAddressing =
false;
1434 if (areaMeshOnProc[Pstream::myProcNo()])
1454 "faceProcAddressing",
1458 IOobject::READ_IF_PRESENT
1462 haveAreaAddressing =
1464 faceProcAddressing.headerOk()
1465 && faceProcAddressing.size() == faceLabels.size()
1468 else if (areaMeshDetected)
1471 haveAreaAddressing =
true;
1479 bool volMeshHaveUndecomposed =
false;
1480 bool areaMeshHaveUndecomposed =
false;
1482 if (Pstream::master())
1485 <<
" for undecomposed volume and area meshes..."
1488 const bool oldParRun = Pstream::parRun(
false);
1504 volMeshHaveUndecomposed = facesIO.headerOk();
1521 areaMeshHaveUndecomposed = labelsIO.headerOk();
1524 Pstream::parRun(oldParRun);
1529 UPstream::worldComm,
1530 volMeshHaveUndecomposed,
1531 areaMeshHaveUndecomposed
1536 Info<<
" volume mesh ["
1537 << volMeshHaveUndecomposed <<
"] : "
1538 << volMeshInstance <<
nl
1540 << areaMeshHaveUndecomposed <<
"] : "
1541 << areaMeshInstance <<
nl
1548 !volMeshHaveUndecomposed
1552 Info<<
"No undecomposed mesh. Creating from: "
1553 << volMeshInstance <<
endl;
1555 if (areaMeshHaveUndecomposed)
1557 areaMeshHaveUndecomposed =
false;
1558 Info<<
"Also ignore any undecomposed area mesh"
1573 fvMeshTools::setBasicGeometry(volMeshPtr());
1580 const label nDestProcs(1);
1583 redistributeAndWrite
1585 std::move(writeHandler),
1613 areaMeshOnProc.
found(
true)
1616 !areaMeshHaveUndecomposed
1621 Info<<
"Loading area mesh from "
1622 << areaMeshInstance <<
endl;
1624 Info<<
" getting volume mesh support" <<
endl;
1637 fvMeshTools::setBasicGeometry(baseMeshPtr());
1644 baseMeshPtr().facesInstance(),
1650 fvMeshTools::setBasicGeometry(volMeshPtr());
1656 fvMeshTools::readProcAddressing(
mesh, baseMeshPtr)
1674 faMeshTools::forceDemandDriven(
areaMesh);
1675 faMeshTools::unregisterMesh(
areaMesh);
1682 faMeshDistributor::distribute
1691 faMeshTools::forceDemandDriven(areaBaseMeshPtr());
1692 faMeshTools::unregisterMesh(areaBaseMeshPtr());
1695 if (Pstream::master())
1697 Info<<
"Setting caseName to " << baseRunTime.
caseName()
1698 <<
" to write reconstructed area mesh." <<
endl;
1700 const bool oldProcCase(
runTime.processorCase(
false));
1702 areaBaseMeshPtr().write();
1705 Info<<
"Restoring caseName" <<
endl;
1706 runTime.caseName() = proc0CaseName;
1707 runTime.processorCase(oldProcCase);
1711 faMeshTools::writeProcAddressing
1716 std::move(writeHandler),
1731 <<
"Reconstructing fields" <<
nl <<
endl;
1733 runTime.setTime(timeDirs[0], 0);
1734 baseRunTime.
setTime(timeDirs[0], 0);
1742 Info<<
"Reading undecomposed mesh (on master)" <<
endl;
1756 fvMeshTools::setBasicGeometry(baseMeshPtr());
1758 Info<<
"Reading local, decomposed mesh" <<
endl;
1764 baseMeshPtr().facesInstance(),
1779 if (areaMeshDetected)
1781 areaBaseMeshPtr = faMeshTools::newMesh
1794 areaMeshPtr = faMeshTools::loadOrCreateMesh
1799 areaBaseMeshPtr().facesInstance(),
1808 faMeshTools::readProcAddressing
1814 faMeshTools::forceDemandDriven(areaMeshPtr());
1828 faMeshDistributor::verbose_ = 1;
1832 if (writeHandler && Pstream::master())
1837 const bool oldParRun = Pstream::parRun(
false);
1839 Pstream::parRun(oldParRun);
1845 distMap = fvMeshTools::readProcAddressing(
mesh, baseMeshPtr);
1848 auto fvDistributorPtr =
1858 const auto& basePointMesh = pointMesh::New(baseMeshPtr());
1859 const auto& procPointMesh = pointMesh::New(
mesh);
1861 auto pointFieldDistributorPtr =
1876 if (
mesh.pointsInstance() !=
mesh.facesInstance())
1878 Info<<
" Detected initial mesh motion;"
1879 <<
" reconstructing points" <<
nl
1881 fvDistributorPtr().reconstructPoints();
1888 if (newTimes && masterTimeDirSet.
found(timeDirs[timeI].name()))
1890 Info<<
"Skipping time " << timeDirs[timeI].name()
1896 runTime.setTime(timeDirs[timeI], timeI);
1897 baseRunTime.
setTime(timeDirs[timeI], timeI);
1905 if (procStat == polyMesh::POINTS_MOVED)
1907 Info<<
" Detected mesh motion; reconstructing points"
1909 fvDistributorPtr().reconstructPoints();
1913 procStat == polyMesh::TOPO_CHANGE
1914 || procStat == polyMesh::TOPO_PATCH_CHANGE
1917 Info<<
" Detected topology change;"
1918 <<
" reconstructing addressing" <<
nl <<
endl;
1925 baseMeshPtr.
clear();
1926 baseMeshPtr = fvMeshTools::newMesh
1941 fvMeshTools::readProcAddressing(
mesh, baseMeshPtr);
1945 fvDistributorPtr.reset
1957 const auto& basePointMesh = pointMesh::New(baseMeshPtr());
1958 const auto& procPointMesh = pointMesh::New(
mesh);
1960 pointFieldDistributorPtr.reset
1972 lagrangianDistributorPtr.
reset();
1976 Info<<
" Discarding finite-area addressing"
1977 <<
" (TODO)" <<
nl <<
endl;
1979 areaBaseMeshPtr.
reset();
1980 areaMeshPtr.
reset();
1981 faDistributor.
reset();
1982 areaDistMap.
clear();
1993 .distributeAllFields(objects, selectedFields);
1997 pointFieldDistributorPtr()
1998 .distributeAllFields(objects, selectedFields);
2004 lagrangianDistributorPtr,
2008 selectedLagrangianFields
2014 .distributeAllFields(objects, selectedFields);
2024 mesh.time().timeName(),
2035 mesh.time().timeName(),
2037 baseMeshPtr().time()
2055 masterTime = timeSelector::selectIfPresent
2063 masterTime = timeSelector::selectIfPresent
2069 Pstream::scatter(masterTime);
2070 Info<<
"Setting time to that of master or undecomposed case : "
2071 << masterTime <<
endl;
2072 runTime.setTime(masterTime, 0);
2073 baseRunTime.
setTime(masterTime, 0);
2087 << (decompose ?
"Decomposing" :
"Redistributing")
2101 bool volMeshHaveUndecomposed =
true;
2102 bool areaMeshHaveUndecomposed = doFiniteArea;
2104 if (Pstream::master())
2108 Info<<
"Checking undecomposed mesh in case: "
2114 const bool oldParRun = Pstream::parRun(
false);
2115 volMeshMasterInstance =
runTime.findInstance
2119 IOobject::READ_IF_PRESENT
2124 areaMeshMasterInstance =
runTime.findInstance
2128 IOobject::READ_IF_PRESENT
2134 if (
"constant" == areaMeshMasterInstance)
2141 areaMeshMasterInstance/areaMeshSubDir,
2147 if (areaMeshOnProc.
empty() || !areaMeshOnProc[0])
2149 areaMeshHaveUndecomposed =
false;
2154 Pstream::parRun(oldParRun);
2158 Info<<
" volume mesh ["
2159 << volMeshHaveUndecomposed <<
"] : "
2160 << volMeshMasterInstance <<
nl
2162 << areaMeshHaveUndecomposed <<
"] : "
2163 << areaMeshMasterInstance <<
nl
2167 runTime.caseName() = proc0CaseName;
2168 runTime.processorCase(oldProcCase);
2174 UPstream::worldComm,
2175 volMeshHaveUndecomposed,
2176 areaMeshHaveUndecomposed,
2177 volMeshMasterInstance,
2178 areaMeshMasterInstance
2190 volMeshMasterInstance/volMeshSubDir,
2199 areaMeshMasterInstance/areaMeshSubDir,
2209 volMeshDir[Pstream::myProcNo()] =
2216 volMeshMasterInstance/volMeshSubDir,
2223 Pstream::allGatherList(volMeshDir);
2225 if (optVerbose && Pstream::master())
2227 Info<<
"Per processor faces dirs:" <<
nl
2230 for (
const int proci : Pstream::allProcs())
2233 <<
runTime.relativePath(volMeshDir[proci]);
2235 if (!volMeshOnProc[proci])
2237 Info<<
" [missing]";
2248 areaMeshDir[Pstream::myProcNo()] =
2255 areaMeshMasterInstance/areaMeshSubDir,
2262 Pstream::allGatherList(areaMeshDir);
2264 if (optVerbose && Pstream::master())
2266 Info<<
"Per processor faceLabels dirs:" <<
nl
2269 for (
const int proci : Pstream::allProcs())
2272 <<
runTime.relativePath(areaMeshDir[proci]);
2274 if (!areaMeshOnProc[proci])
2276 Info<<
" [missing]";
2288 if (Pstream::master() && decompose)
2290 Info<<
"Setting caseName to " << baseRunTime.
caseName()
2291 <<
" to read undecomposed mesh" <<
endl;
2302 volMeshMasterInstance,
2323 ? areaMeshHaveUndecomposed
2324 : areaMeshOnProc.
found(
true)
2328 areaMeshPtr = faMeshTools::loadOrCreateMesh
2333 areaMeshMasterInstance,
2341 faMeshTools::forceDemandDriven(*areaMeshPtr);
2342 faMeshTools::unregisterMesh(*areaMeshPtr);
2351 if (Pstream::master())
2353 const auto myProci = UPstream::myProcNo();
2354 const auto& procs = UPstream::procID
2358 const bool oldParRun = Pstream::parRun(
false);
2359 for (
const auto proci : procs)
2363 !volMeshOnProc[proci]
2364 && volMeshDir[proci] != volMeshDir[myProci]
2367 Info<<
"Deleting mesh dir:"
2368 << volMeshDir[proci] <<
endl;
2374 !areaMeshOnProc[proci]
2375 && areaMeshDir[proci] != areaMeshDir[myProci]
2378 Info<<
"Deleting mesh dir:"
2379 << areaMeshDir[proci] <<
endl;
2387 Pstream::parRun(oldParRun);
2392 if (Pstream::master() && decompose)
2394 Info<<
"Restoring caseName" <<
endl;
2395 runTime.caseName() = proc0CaseName;
2396 runTime.processorCase(oldProcCase);
2399 const label nOldCells =
mesh.nCells();
2413 determineDecomposition
2429 if (!Pstream::master())
2431 if (areaMeshPtr && !areaMeshOnProc[Pstream::myProcNo()])
2434 const bool oldParRun = Pstream::parRun(
false);
2435 areaMeshPtr->removeFiles();
2436 Pstream::parRun(oldParRun);
2439 if (!volMeshOnProc[Pstream::myProcNo()])
2442 const bool oldParRun = Pstream::parRun(
false);
2445 Pstream::parRun(oldParRun);
2462 areaMeshMasterInstance,
2469 if (Pstream::master() && decompose)
2481 selectedLagrangianFields
2485 if (Pstream::master() && decompose)
2487 runTime.caseName() = proc0CaseName;
2488 runTime.processorCase(oldProcCase);
2495 std::move(writeHandler),
2511 volMeshMasterInstance,
2519 lagrangianDistributorPtr,
2534 faDistMap = faMeshDistributor::distribute
2544 faMeshTools::forceDemandDriven(areaProcMeshPtr());
2549 if (Pstream::master())
2551 Info<<
"Setting caseName to " << baseRunTime.
caseName()
2552 <<
" to write reconstructed mesh (and fields)."
2555 const bool oldProcCase(
runTime.processorCase(
false));
2558 areaProcMeshPtr->write();
2561 Info<<
"Restoring caseName" <<
endl;
2562 runTime.caseName() = proc0CaseName;
2563 runTime.processorCase(oldProcCase);
2571 defaultHandler =
fileHandler(std::move(writeHandler));
2579 areaProcMeshPtr->facesInstance(),
2581 areaProcMeshPtr->thisDb(),
2589 areaProcMeshPtr->write();
2593 writeHandler =
fileHandler(std::move(defaultHandler));
2598 faMeshTools::writeProcAddressing
2603 std::move(writeHandler)
2608 Info<<
"Written redistributed mesh to "
2609 << areaProcMeshPtr->facesInstance() <<
nl <<
endl;
2618 areaFields.redistributeAndWrite(distributor,
true);
Inter-processor communication reduction functions.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
bool found(const Key &key) const
Return true if hashed entry is found in table.
A IOmapDistributePolyMesh wrapper for using referenced external data.
List of IOobjects with searching and retrieving facilities.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
instantList times() const
Search the case for valid time directories.
bool processorCase() const noexcept
Return true if this is a processor case.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const fileName & caseName() const
Return case name.
static word timeName(const scalar t, const int precision=precision_)
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
Finite area area (element) fields.
Mesh data needed to do the Finite Area discretisation.
Extract command arguments and options from the supplied argc and argv parameters.
int dryRun() const noexcept
Return the dry-run flag.
int verbose() const noexcept
Return the verbose flag.
const fileName & rootPath() const noexcept
Return root path.
bool found(const word &optName) const
Return true if the named option is found.
fileName path() const
Return the full path to the (processor local) case.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
fileName globalPath() const
Return the full path to the global case.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void clear() noexcept
Same as reset(nullptr)
T * get() noexcept
Return pointer to managed object without nullptr checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Abstract base class for domain decomposition.
static label nDomains(const dictionary &decompDict, const word ®ionName="")
Return region-specific or top-level numberOfSubdomains entry.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
Return the wanted processor number for every coordinate.
virtual bool parallelAware() const =0
Is method parallel aware?
MeshObject wrapper of decompositionMethod.
decompositionMethod & decomposer() const
Return demand-driven decomposition method.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
A class for handling file names.
static std::string path(const std::string &str)
Return directory path name (part before last /)
An encapsulation of filesystem-related operations.
bool distributed() const noexcept
Distributed roots (parallel run)
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
virtual bool rmDir(const fileName &dir, const bool silent=false) const =0
Remove a directory and its contents.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search=true) const =0
Search for a directory. checkGlobal : also check undecomposed.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
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...
Various for reading/decomposing/reconstructing/distributing refinement data.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void clear()
Reset to zero size, only retaining communicator(s)
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
Simple container to manage read/write, redistribute finiteArea fields.
Finite volume reconstructor for volume and surface fields.
Distributor/redistributor for point fields, uses a two (or three) stage construction.
Mesh representing a set of points created from polyMesh.
Mesh consisting of general polyhedral cells.
readUpdateState
Enumeration defining the state of the mesh after a read update.
Neighbour processor patch.
int neighbProcNo() const
Return neighbour processor number.
virtual bool write(const bool valid=true) const
Write using setting from DB.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Foam::word regionName(Foam::polyMesh::defaultRegion)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Miscellaneous file handling for meshes.
#define WarningInFunction
Report a warning using Foam::Warning.
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
int debug
Static debugging option.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
const fileOperation & fileHandler()
Get current file handler.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
void reconstructLagrangian(autoPtr< parLagrangianDistributor > &distributorPtr, const fvMesh &baseMesh, const fvMesh &mesh, const mapDistributePolyMesh &distMap, const wordRes &selectedFields)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
void removeEmptyDirs(const fileName &path)
Remove empty directories from bottom up.
void removeProcAddressing(const faMesh &mesh)
Remove procAddressing.
boolList haveMeshFile(const Time &runTime, const fileName &meshPath, const word &meshFile="faces", const bool verbose=true)
Check for availability of specified mesh file (default: "faces")
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)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
void redistributeLagrangian(autoPtr< parLagrangianDistributor > &distributorPtr, const fvMesh &mesh, const label nOldCells, const mapDistributePolyMesh &distMap, PtrList< unmappedPassivePositionParticleCloud > &clouds)
constexpr char nl
The newline '\n' character (0x0a)
Reading, reconstruct, redistribution of lagrangian fields.
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.
static const char *const typeName
The type name used in ensight case files.