mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: redistributePar: allow nDomains 1 in decomposeParDict. Fixes #924.
Note: this removes the option to reconstruct by setting nDomains to 1.
You now have to explicitly use -reconstruct to reconstruct.
This commit is contained in:
@ -4,6 +4,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/mesh/snappyHexMesh/lnInclude
|
||||
|
||||
@ -17,4 +18,5 @@ EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-llagrangian \
|
||||
-ldynamicMesh \
|
||||
-lregionModels \
|
||||
-lsnappyHexMesh
|
||||
|
||||
@ -34,27 +34,38 @@ Description
|
||||
Must be run on maximum number of source and destination processors.
|
||||
Balances mesh and writes new mesh to new time directory.
|
||||
|
||||
Can optionally run in decompose/reconstruct mode to decompose/reconstruct
|
||||
mesh and fields.
|
||||
|
||||
Usage
|
||||
\b redistributePar [OPTION]
|
||||
|
||||
- redistributePar [OPTION]
|
||||
|
||||
\param -region regionName \n
|
||||
Distribute named region.
|
||||
|
||||
\param -decompose \n
|
||||
Options:
|
||||
- \par -decompose
|
||||
Remove any existing \a processor subdirectories and decomposes the
|
||||
geometry. Equivalent to running without processor subdirectories.
|
||||
mesh. Equivalent to running without processor subdirectories.
|
||||
|
||||
\param -reconstruct \n
|
||||
Reconstruct geometry (like reconstructParMesh). Equivalent to setting
|
||||
numberOfSubdomains 1 in the decomposeParDict.
|
||||
- \par -reconstruct
|
||||
Reconstruct mesh and fields (like reconstructParMesh+reconstructPar).
|
||||
|
||||
\param -newTimes \n
|
||||
- \par -newTimes
|
||||
(in combination with -reconstruct) reconstruct only new times.
|
||||
|
||||
\param -cellDist \n
|
||||
Write the cell distribution as a labelList, for use with 'manual'
|
||||
decomposition method or as a volScalarField for post-processing.
|
||||
- \par -dry-run
|
||||
(not in combination with -reconstruct) Test without actually
|
||||
decomposing.
|
||||
|
||||
- \par -cellDist
|
||||
not in combination with -reconstruct) Write the cell distribution
|
||||
as a labelList, for use with 'manual'
|
||||
decomposition method and as a volScalarField for visualization.
|
||||
|
||||
- \par -region \<regionName\>
|
||||
Distribute named region.
|
||||
|
||||
- \par -allRegions
|
||||
Distribute all regions in regionProperties. Does not check for
|
||||
existence of processor*.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -77,6 +88,7 @@ Usage
|
||||
#include "processorFvPatchField.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "topoSet.H"
|
||||
#include "regionProperties.H"
|
||||
|
||||
#include "parFvFieldReconstructor.H"
|
||||
#include "parLagrangianRedistributor.H"
|
||||
@ -502,7 +514,7 @@ void writeProcAddressing
|
||||
UPstream::msgType()
|
||||
);
|
||||
}
|
||||
else // if (nDestProcs == 1)
|
||||
else // reconstruct
|
||||
{
|
||||
cellMap = identity(mesh.nCells());
|
||||
map.cellMap().reverseDistribute(map.nOldCells(), cellMap);
|
||||
@ -821,6 +833,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
|
||||
const fileName& meshSubDir,
|
||||
const bool doReadFields,
|
||||
const bool decompose, // decompose, i.e. read from undecomposed case
|
||||
const bool reconstruct,
|
||||
const bool overwrite,
|
||||
const fileName& proc0CaseName,
|
||||
const label nDestProcs,
|
||||
@ -1173,7 +1186,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
|
||||
map.transfer(rawMap());
|
||||
|
||||
|
||||
if (nDestProcs == 1)
|
||||
if (reconstruct)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
@ -1224,7 +1237,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
|
||||
<< endl;
|
||||
|
||||
|
||||
if (decompose || nDestProcs == 1)
|
||||
if (decompose || reconstruct)
|
||||
{
|
||||
// Decompose (1 -> N) or reconstruct (N -> 1)
|
||||
// so {boundary,cell,face,point}ProcAddressing have meaning
|
||||
@ -1275,7 +1288,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
|
||||
// Now we've read refinement data we can remove it
|
||||
meshRefinement::removeFiles(mesh);
|
||||
|
||||
if (nDestProcs == 1)
|
||||
if (reconstruct)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
@ -1318,7 +1331,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
|
||||
// cellSets[i].distribute(map);
|
||||
// }
|
||||
//
|
||||
// if (nDestProcs == 1)
|
||||
// if (reconstruct)
|
||||
// {
|
||||
// if (Pstream::master())
|
||||
// {
|
||||
@ -2256,9 +2269,20 @@ int main(int argc, char *argv[])
|
||||
// enable -zeroTime to prevent accidentally trashing the initial fields
|
||||
timeSelector::addOptions(true, true);
|
||||
#include "addRegionOption.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
"allRegions",
|
||||
"operate on all regions in regionProperties"
|
||||
);
|
||||
#include "addOverwriteOption.H"
|
||||
argList::addBoolOption("decompose", "Decompose case");
|
||||
argList::addBoolOption("reconstruct", "Reconstruct case");
|
||||
argList::addBoolOption
|
||||
(
|
||||
"dry-run",
|
||||
"Test without writing the decomposition. "
|
||||
"Changes -cellDist to only write volScalarField."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"mergeTol",
|
||||
@ -2285,6 +2309,7 @@ int main(int argc, char *argv[])
|
||||
Foam::argList args(argc, argv);
|
||||
const bool reconstruct = args.found("reconstruct");
|
||||
const bool writeCellDist = args.found("cellDist");
|
||||
const bool dryrun = args.found("dry-run");
|
||||
const bool newTimes = args.found("newTimes");
|
||||
|
||||
bool decompose = args.found("decompose");
|
||||
@ -2466,20 +2491,31 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
// Determine any region
|
||||
word regionName = polyMesh::defaultRegion;
|
||||
fileName meshSubDir = polyMesh::meshSubDir;
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
meshSubDir = regionName/polyMesh::meshSubDir;
|
||||
}
|
||||
Info<< "Using mesh subdirectory " << meshSubDir << nl << endl;
|
||||
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
fileName decompDictFile;
|
||||
args.readIfPresent("decomposeParDict", decompDictFile);
|
||||
|
||||
// Get all region names
|
||||
wordList regionNames;
|
||||
if (args.found("allRegions"))
|
||||
{
|
||||
Info<< "Decomposing all regions in regionProperties" << nl << endl;
|
||||
regionProperties rp(runTime);
|
||||
|
||||
wordHashSet names;
|
||||
forAllConstIters(rp, iter)
|
||||
{
|
||||
names.insert(iter.object());
|
||||
}
|
||||
|
||||
regionNames = names.sortedToc();
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames = {fvMesh::defaultRegion};
|
||||
args.readIfPresent("region", regionNames[0]);
|
||||
}
|
||||
|
||||
|
||||
// Demand driven lagrangian mapper
|
||||
autoPtr<parLagrangianRedistributor> lagrangianReconstructorPtr;
|
||||
@ -2507,6 +2543,19 @@ int main(int argc, char *argv[])
|
||||
Info<< nl
|
||||
<< "Pass1 : reconstructing mesh and addressing" << nl << endl;
|
||||
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
const fileName meshSubDir
|
||||
(
|
||||
regionName == fvMesh::defaultRegion
|
||||
? fileName(polyMesh::meshSubDir)
|
||||
: regionNames[regioni]/polyMesh::meshSubDir
|
||||
);
|
||||
|
||||
Info<< "\n\nReconstructing mesh " << regionName << nl << endl;
|
||||
|
||||
// Loop over all times
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
@ -2548,8 +2597,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Note: filePath searches up on processors that don't have
|
||||
// processor if instance = constant so explicitly check found
|
||||
// filename.
|
||||
// processor if instance = constant so explicitly check
|
||||
// found filename.
|
||||
bool haveAddressing = false;
|
||||
if (haveMesh[Pstream::myProcNo()])
|
||||
{
|
||||
@ -2621,7 +2670,8 @@ int main(int argc, char *argv[])
|
||||
// Determine decomposition
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Info<< "Reconstructing mesh for time " << facesInstance << endl;
|
||||
Info<< "Reconstructing mesh for time " << facesInstance
|
||||
<< endl;
|
||||
|
||||
label nDestProcs = 1;
|
||||
labelList finalDecomp = labelList(mesh.nCells(), 0);
|
||||
@ -2633,7 +2683,8 @@ int main(int argc, char *argv[])
|
||||
haveMesh,
|
||||
meshSubDir,
|
||||
false, // do not read fields
|
||||
false, // do not read undecomposed case on processor0
|
||||
false, // do not read undecomposed case on proc0
|
||||
true, // write redistributed files to proc0
|
||||
overwrite,
|
||||
proc0CaseName,
|
||||
nDestProcs,
|
||||
@ -2746,8 +2797,8 @@ int main(int argc, char *argv[])
|
||||
|| procStat == fvMesh::TOPO_PATCH_CHANGE
|
||||
)
|
||||
{
|
||||
Info<< " Detected topology change; reconstructing addressing"
|
||||
<< nl << endl;
|
||||
Info<< " Detected topology change;"
|
||||
<< " reconstructing addressing" << nl << endl;
|
||||
|
||||
if (baseMeshPtr.valid())
|
||||
{
|
||||
@ -2822,6 +2873,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Time coming from processor0 (or undecomposed if no processor0)
|
||||
@ -2850,6 +2902,27 @@ int main(int argc, char *argv[])
|
||||
runTime.setTime(masterTime, 0);
|
||||
|
||||
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
const fileName meshSubDir
|
||||
(
|
||||
regionName == fvMesh::defaultRegion
|
||||
? fileName(polyMesh::meshSubDir)
|
||||
: regionNames[regioni]/polyMesh::meshSubDir
|
||||
);
|
||||
|
||||
if (decompose)
|
||||
{
|
||||
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "\n\nRedistributing mesh " << regionName << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// Get time instance directory
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// At this point we should be able to read at least a mesh on
|
||||
@ -2956,6 +3029,21 @@ int main(int argc, char *argv[])
|
||||
finalDecomp
|
||||
);
|
||||
|
||||
if (dryrun)
|
||||
{
|
||||
if (!Pstream::master() && !haveMesh[Pstream::myProcNo()])
|
||||
{
|
||||
// Remove dummy mesh created by loadOrCreateMesh
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
mesh.removeFiles();
|
||||
rmDir(mesh.objectRegistry::objectPath());
|
||||
Pstream::parRun() = oldParRun;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wordList cloudNames;
|
||||
List<wordList> fieldNames;
|
||||
@ -2973,7 +3061,10 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
// Read lagrangian fields and store on cloud (objectRegistry)
|
||||
PtrList<unmappedPassivePositionParticleCloud> clouds(cloudNames.size());
|
||||
PtrList<unmappedPassivePositionParticleCloud> clouds
|
||||
(
|
||||
cloudNames.size()
|
||||
);
|
||||
readLagrangian
|
||||
(
|
||||
mesh,
|
||||
@ -2997,6 +3088,7 @@ int main(int argc, char *argv[])
|
||||
meshSubDir,
|
||||
true, // read fields
|
||||
decompose, // decompose, i.e. read from undecomposed case
|
||||
false, // no reconstruction
|
||||
overwrite,
|
||||
proc0CaseName,
|
||||
nDestProcs,
|
||||
@ -3030,6 +3122,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
Reference in New Issue
Block a user