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