decomposePar: Added 'copyZero' option
Using decomposePar -copyZero The mesh is decomposed as usual but the '0' directory is recursively copied to the 'processor.*' directories rather than decomposing the fields. This is a convenient option to handle cases where the initial field files are generic and can be used for serial or parallel running. See for example the incompressible/simpleFoam/motorBike tutorial case.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,6 +43,9 @@ Usage
|
||||
Decompose all regions in regionProperties. Does not check for
|
||||
existence of processor*.
|
||||
|
||||
- \par -copyZero \n
|
||||
Copy \a 0 directory to processor* rather than decompose the fields.
|
||||
|
||||
- \par -copyUniform \n
|
||||
Copy any \a uniform directories too.
|
||||
|
||||
@ -215,6 +218,11 @@ int main(int argc, char *argv[])
|
||||
"decomposition method or as a volScalarField for post-processing."
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"copyZero",
|
||||
"Copy \a 0 directory to processor* rather than decompose the fields"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"copyUniform",
|
||||
"copy any uniform/ directories too"
|
||||
@ -247,6 +255,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool allRegions = args.optionFound("allRegions");
|
||||
bool writeCellDist = args.optionFound("cellDist");
|
||||
bool copyZero = args.optionFound("copyZero");
|
||||
bool copyUniform = args.optionFound("copyUniform");
|
||||
bool decomposeFieldsOnly = args.optionFound("fields");
|
||||
bool decomposeSets = !args.optionFound("noSets");
|
||||
@ -476,11 +485,36 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
if (copyZero)
|
||||
{
|
||||
// Link the 0 directory into each of the processor directories
|
||||
for (label proci = 0; proci < mesh.nProcs(); proci++)
|
||||
{
|
||||
Time processorDb
|
||||
(
|
||||
Time::controlDictName,
|
||||
args.rootPath(),
|
||||
args.caseName()/fileName(word("processor") + name(proci))
|
||||
);
|
||||
processorDb.setTime(runTime);
|
||||
|
||||
// Caches
|
||||
// ~~~~~~
|
||||
// Cached processor meshes and maps. These are only preserved if running
|
||||
// with multiple times.
|
||||
if (isDir(runTime.timePath()))
|
||||
{
|
||||
const fileName timePath = processorDb.timePath();
|
||||
|
||||
Info<< "Processor " << proci
|
||||
<< ": linking " << runTime.timePath() << nl
|
||||
<< " to " << processorDb.timePath() << endl;
|
||||
cp(runTime.timePath(), processorDb.timePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Decompose the field files
|
||||
|
||||
// Cached processor meshes and maps. These are only preserved if
|
||||
// running with multiple times.
|
||||
PtrList<Time> processorDbList(mesh.nProcs());
|
||||
PtrList<fvMesh> procMeshList(mesh.nProcs());
|
||||
PtrList<labelIOList> faceProcAddressingList(mesh.nProcs());
|
||||
@ -489,8 +523,10 @@ int main(int argc, char *argv[])
|
||||
PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
|
||||
PtrList<dimFieldDecomposer> dimFieldDecomposerList(mesh.nProcs());
|
||||
PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
|
||||
PtrList<pointFieldDecomposer> pointFieldDecomposerList(mesh.nProcs());
|
||||
|
||||
PtrList<pointFieldDecomposer> pointFieldDecomposerList
|
||||
(
|
||||
mesh.nProcs()
|
||||
);
|
||||
|
||||
|
||||
// Loop over all times
|
||||
@ -527,7 +563,8 @@ int main(int argc, char *argv[])
|
||||
PtrList<DimensionedField<sphericalTensor, volMesh>>
|
||||
dimSphericalTensorFields;
|
||||
readFields(mesh, objects, dimSphericalTensorFields);
|
||||
PtrList<DimensionedField<symmTensor, volMesh>> dimSymmTensorFields;
|
||||
PtrList<DimensionedField<symmTensor, volMesh>>
|
||||
dimSymmTensorFields;
|
||||
readFields(mesh, objects, dimSymmTensorFields);
|
||||
PtrList<DimensionedField<tensor, volMesh>> dimTensorFields;
|
||||
readFields(mesh, objects, dimTensorFields);
|
||||
@ -539,7 +576,8 @@ int main(int argc, char *argv[])
|
||||
readFields(mesh, objects, surfaceScalarFields);
|
||||
PtrList<surfaceVectorField> surfaceVectorFields;
|
||||
readFields(mesh, objects, surfaceVectorFields);
|
||||
PtrList<surfaceSphericalTensorField> surfaceSphericalTensorFields;
|
||||
PtrList<surfaceSphericalTensorField>
|
||||
surfaceSphericalTensorFields;
|
||||
readFields(mesh, objects, surfaceSphericalTensorFields);
|
||||
PtrList<surfaceSymmTensorField> surfaceSymmTensorFields;
|
||||
readFields(mesh, objects, surfaceSymmTensorFields);
|
||||
@ -568,7 +606,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
fileNameList cloudDirs
|
||||
(
|
||||
readDir(runTime.timePath()/cloud::prefix, fileName::DIRECTORY)
|
||||
readDir
|
||||
(
|
||||
runTime.timePath()/cloud::prefix, fileName::DIRECTORY
|
||||
)
|
||||
);
|
||||
|
||||
// Particles
|
||||
@ -649,15 +690,18 @@ int main(int argc, char *argv[])
|
||||
false
|
||||
);
|
||||
|
||||
IOobject* positionsPtr = sprayObjs.lookup(word("positions"));
|
||||
IOobject* positionsPtr = sprayObjs.lookup
|
||||
(
|
||||
word("positions")
|
||||
);
|
||||
|
||||
if (positionsPtr)
|
||||
{
|
||||
// Read lagrangian particles
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Info<< "Identified lagrangian data set: " << cloudDirs[i]
|
||||
<< endl;
|
||||
Info<< "Identified lagrangian data set: "
|
||||
<< cloudDirs[i] << endl;
|
||||
|
||||
lagrangianPositions.set
|
||||
(
|
||||
@ -702,8 +746,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Illegal cell number " << celli
|
||||
<< " for particle with index " << iter().index()
|
||||
<< " at position " << iter().position() << nl
|
||||
<< " for particle with index "
|
||||
<< iter().index()
|
||||
<< " at position "
|
||||
<< iter().position() << nl
|
||||
<< "Cell number should be between 0 and "
|
||||
<< mesh.nCells()-1 << nl
|
||||
<< "On this mesh the particle should"
|
||||
@ -931,7 +977,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
fieldDecomposer.decomposeFields(volScalarFields);
|
||||
fieldDecomposer.decomposeFields(volVectorFields);
|
||||
fieldDecomposer.decomposeFields(volSphericalTensorFields);
|
||||
fieldDecomposer.decomposeFields
|
||||
(
|
||||
volSphericalTensorFields
|
||||
);
|
||||
fieldDecomposer.decomposeFields(volSymmTensorFields);
|
||||
fieldDecomposer.decomposeFields(volTensorFields);
|
||||
|
||||
@ -941,7 +990,10 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
surfaceSphericalTensorFields
|
||||
);
|
||||
fieldDecomposer.decomposeFields(surfaceSymmTensorFields);
|
||||
fieldDecomposer.decomposeFields
|
||||
(
|
||||
surfaceSymmTensorFields
|
||||
);
|
||||
fieldDecomposer.decomposeFields(surfaceTensorFields);
|
||||
|
||||
if (times.size() == 1)
|
||||
@ -1022,7 +1074,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
pointDecomposer.decomposeFields(pointScalarFields);
|
||||
pointDecomposer.decomposeFields(pointVectorFields);
|
||||
pointDecomposer.decomposeFields(pointSphericalTensorFields);
|
||||
pointDecomposer.decomposeFields
|
||||
(
|
||||
pointSphericalTensorFields
|
||||
);
|
||||
pointDecomposer.decomposeFields(pointSymmTensorFields);
|
||||
pointDecomposer.decomposeFields(pointTensorFields);
|
||||
|
||||
@ -1129,8 +1184,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// We have cached all the constant mesh data for the current
|
||||
// processor. This is only important if running with multiple
|
||||
// times, otherwise it is just extra storage.
|
||||
// processor. This is only important if running with
|
||||
// multiple times, otherwise it is just extra storage.
|
||||
if (times.size() == 1)
|
||||
{
|
||||
boundaryProcAddressingList.set(proci, nullptr);
|
||||
@ -1142,6 +1197,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
|
||||
@ -135,8 +135,12 @@ void Foam::timeSelector::addOptions
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noZero",
|
||||
"exclude the '0/' dir from the times list, "
|
||||
"has precedence over the -withZero option"
|
||||
string("exclude the '0/' dir from the times list")
|
||||
+ (
|
||||
withZero
|
||||
? ", has precedence over the -withZero option"
|
||||
: ""
|
||||
)
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source tutorial clean functions
|
||||
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
|
||||
|
||||
# remove surface and features
|
||||
# Remove surface and features
|
||||
rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1
|
||||
rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
|
||||
rm -f constant/triSurface/motorBike.eMesh > /dev/null 2>&1
|
||||
@ -11,3 +12,5 @@ rm -f constant/triSurface/motorBike.eMesh > /dev/null 2>&1
|
||||
rm -rf 0 > /dev/null 2>&1
|
||||
|
||||
cleanCase
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -4,22 +4,17 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Source tutorial run functions
|
||||
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
||||
|
||||
# copy motorbike surface from resources directory
|
||||
# Copy motorbike surface from resources directory
|
||||
cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/
|
||||
runApplication surfaceFeatureExtract
|
||||
|
||||
runApplication blockMesh
|
||||
|
||||
runApplication decomposePar
|
||||
[ ! -d 0 ] && cp -r 0.orig 0
|
||||
|
||||
runApplication decomposePar -copyZero
|
||||
runParallel snappyHexMesh -overwrite
|
||||
|
||||
#- For non-parallel running
|
||||
#cp -r 0.orig 0 > /dev/null 2>&1
|
||||
|
||||
#- For parallel running
|
||||
ls -d processor* | xargs -I {} rm -rf ./{}/0
|
||||
ls -d processor* | xargs -I {} cp -r 0.orig ./{}/0
|
||||
|
||||
runParallel patchSummary
|
||||
runParallel potentialFoam
|
||||
runParallel $(getApplication)
|
||||
|
||||
Reference in New Issue
Block a user