mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: expose decomposePar -dry-run options -domains, -method
- can now drop older Test-decomposePar for exploration purposes and simply use -dry-run with the -domains and -method options. - write VTK file instead of volScalarField in combination with -dry-run and -cellDist. Avoids adding any OpenFOAM fields and is usually faster to load. Also easier to rename than a volScalarField would be when exploring multiple decompositions.
This commit is contained in:
@ -1,3 +0,0 @@
|
|||||||
Test-decomposePar.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-decomposePar
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
EXE_INC = \
|
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
|
||||||
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
|
|
||||||
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude
|
|
||||||
|
|
||||||
EXE_LIBS = \
|
|
||||||
-lfiniteVolume \
|
|
||||||
-lmeshTools \
|
|
||||||
-ldecompose \
|
|
||||||
-ldecompositionMethods \
|
|
||||||
-L$(FOAM_LIBBIN)/dummy \
|
|
||||||
-lkahipDecomp -lmetisDecomp -lscotchDecomp
|
|
||||||
@ -1,308 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | www.openfoam.com
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Application
|
|
||||||
Test-decomposePar
|
|
||||||
|
|
||||||
Group
|
|
||||||
grpParallelUtilities
|
|
||||||
|
|
||||||
Description
|
|
||||||
Like decomposePar -dry-run, but with additional options
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "OSspecific.H"
|
|
||||||
#include "fvCFD.H"
|
|
||||||
#include "cpuTime.H"
|
|
||||||
#include "volFields.H"
|
|
||||||
#include "IOobjectList.H"
|
|
||||||
#include "regionProperties.H"
|
|
||||||
#include "decompositionInformation.H"
|
|
||||||
#include "decompositionModel.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
argList::addNote
|
|
||||||
(
|
|
||||||
"Special-purpose version of decomposePar with additional"
|
|
||||||
" -domain and -method options."
|
|
||||||
" The '-dry-run' and '-cellDist' are implicit.\n"
|
|
||||||
"NB: The -domain/-method overrides may not work very well with regions"
|
|
||||||
);
|
|
||||||
|
|
||||||
argList::noParallel();
|
|
||||||
argList::addOption
|
|
||||||
(
|
|
||||||
"decomposeParDict",
|
|
||||||
"file",
|
|
||||||
"Use specified file for decomposePar dictionary"
|
|
||||||
);
|
|
||||||
|
|
||||||
#include "addAllRegionOptions.H"
|
|
||||||
|
|
||||||
argList::addBoolOption
|
|
||||||
(
|
|
||||||
"verbose",
|
|
||||||
"Additional verbosity"
|
|
||||||
);
|
|
||||||
argList::addOption
|
|
||||||
(
|
|
||||||
"domains",
|
|
||||||
"N",
|
|
||||||
"Override numberOfSubdomains"
|
|
||||||
);
|
|
||||||
|
|
||||||
argList::addOption
|
|
||||||
(
|
|
||||||
"method",
|
|
||||||
"name",
|
|
||||||
"Override decomposition method"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// These are implicit so just ignore them
|
|
||||||
argList::ignoreOptionCompat({"dry-run", 0}, false);
|
|
||||||
argList::addBoolOption
|
|
||||||
(
|
|
||||||
"cellDist",
|
|
||||||
"Write cell distribution as volScalarField for visualization"
|
|
||||||
);
|
|
||||||
argList::addBoolOption
|
|
||||||
(
|
|
||||||
"cellDist-internal",
|
|
||||||
"Write cell distribution (internal field) for visualization"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Include explicit constant options, have zero from time range
|
|
||||||
timeSelector::addOptions(true, false);
|
|
||||||
|
|
||||||
#include "setRootCase.H"
|
|
||||||
|
|
||||||
const bool optRegion = args.found("region");
|
|
||||||
const bool verbose = args.found("verbose");
|
|
||||||
|
|
||||||
const label numSubdomains = args.getOrDefault<label>("domains", 0);
|
|
||||||
const word methodName = args.getOrDefault<word>("method", word::null);
|
|
||||||
|
|
||||||
// Set time from database
|
|
||||||
#include "createTime.H"
|
|
||||||
// Allow override of time
|
|
||||||
instantList times = timeSelector::selectIfPresent(runTime, args);
|
|
||||||
|
|
||||||
// Allow override of decomposeParDict location
|
|
||||||
const fileName decompDictFile =
|
|
||||||
args.getOrDefault<fileName>("decomposeParDict", "");
|
|
||||||
|
|
||||||
// Get region names
|
|
||||||
#include "getAllRegionOptions.H"
|
|
||||||
|
|
||||||
Info<< "Decomposing regions: "
|
|
||||||
<< flatOutput(regionNames) << nl << endl;
|
|
||||||
|
|
||||||
|
|
||||||
forAll(regionNames, regioni)
|
|
||||||
{
|
|
||||||
const word& regionName = regionNames[regioni];
|
|
||||||
const word& regionDir =
|
|
||||||
(
|
|
||||||
regionName == polyMesh::defaultRegion ? word::null : regionName
|
|
||||||
);
|
|
||||||
|
|
||||||
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
|
|
||||||
Info<< "Create mesh..." << flush;
|
|
||||||
|
|
||||||
fvMesh mesh
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
regionName,
|
|
||||||
runTime.timeName(),
|
|
||||||
runTime,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
Info<< " nCells = " << mesh.nCells() << endl;
|
|
||||||
|
|
||||||
Info<< "\nCalculating distribution of cells" << endl;
|
|
||||||
cpuTime decompositionTime;
|
|
||||||
|
|
||||||
const decompositionModel& model = decompositionModel::New
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
decompDictFile
|
|
||||||
);
|
|
||||||
|
|
||||||
// Allow command-line override for quick testing
|
|
||||||
|
|
||||||
dictionary& modelDict = const_cast<decompositionModel&>(model);
|
|
||||||
|
|
||||||
if (numSubdomains)
|
|
||||||
{
|
|
||||||
modelDict.add
|
|
||||||
(
|
|
||||||
word("numberOfSubdomains"),
|
|
||||||
numSubdomains,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!methodName.empty())
|
|
||||||
{
|
|
||||||
modelDict.add
|
|
||||||
(
|
|
||||||
word("method"),
|
|
||||||
methodName,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalarField cellWeights;
|
|
||||||
word weightName;
|
|
||||||
if (model.readIfPresent("weightField", weightName))
|
|
||||||
{
|
|
||||||
volScalarField weights
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
weightName,
|
|
||||||
mesh.time().timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
),
|
|
||||||
mesh
|
|
||||||
);
|
|
||||||
cellWeights = weights.primitiveField();
|
|
||||||
}
|
|
||||||
|
|
||||||
decompositionMethod& method = model.decomposer();
|
|
||||||
|
|
||||||
CompactListList<label> cellCells;
|
|
||||||
decompositionMethod::calcCellCells
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
identity(mesh.nCells()),
|
|
||||||
mesh.nCells(),
|
|
||||||
false,
|
|
||||||
cellCells
|
|
||||||
);
|
|
||||||
|
|
||||||
labelList cellToProc = method.decompose(mesh, cellWeights);
|
|
||||||
|
|
||||||
Info<< "\nFinished decomposition into "
|
|
||||||
<< method.nDomains() << " domains in "
|
|
||||||
<< decompositionTime.elapsedCpuTime()
|
|
||||||
<< " s" << nl << endl;
|
|
||||||
|
|
||||||
decompositionInformation info
|
|
||||||
(
|
|
||||||
cellCells,
|
|
||||||
cellToProc,
|
|
||||||
method.nDomains()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
info.printDetails(Info);
|
|
||||||
Info<< nl;
|
|
||||||
}
|
|
||||||
info.printSummary(Info);
|
|
||||||
|
|
||||||
|
|
||||||
if (args.found("cellDist-internal"))
|
|
||||||
{
|
|
||||||
volScalarField::Internal cellDist
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"cellDist",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh,
|
|
||||||
dimensionedScalar("cellDist", dimless, -1)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(cellToProc, celli)
|
|
||||||
{
|
|
||||||
cellDist[celli] = cellToProc[celli];
|
|
||||||
}
|
|
||||||
|
|
||||||
cellDist.write();
|
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition as volScalarField::Internal to "
|
|
||||||
<< cellDist.name() << " for visualization."
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
fileHandler().flush();
|
|
||||||
}
|
|
||||||
else if (args.found("cellDist"))
|
|
||||||
{
|
|
||||||
volScalarField cellDist
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"cellDist",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh,
|
|
||||||
dimensionedScalar("cellDist", dimless, -1),
|
|
||||||
zeroGradientFvPatchScalarField::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(cellToProc, celli)
|
|
||||||
{
|
|
||||||
cellDist[celli] = cellToProc[celli];
|
|
||||||
}
|
|
||||||
|
|
||||||
cellDist.correctBoundaryConditions();
|
|
||||||
cellDist.write();
|
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition as volScalarField to "
|
|
||||||
<< cellDist.name() << " for visualization."
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
fileHandler().flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,11 @@ decomposePar.C
|
|||||||
domainDecomposition.C
|
domainDecomposition.C
|
||||||
domainDecompositionMesh.C
|
domainDecompositionMesh.C
|
||||||
domainDecompositionDistribute.C
|
domainDecompositionDistribute.C
|
||||||
|
domainDecompositionWrite.C
|
||||||
|
|
||||||
domainDecompositionDryRun.C
|
domainDecompositionDryRun.C
|
||||||
|
domainDecompositionDryRunWrite.C
|
||||||
|
|
||||||
dimFieldDecomposer.C
|
dimFieldDecomposer.C
|
||||||
pointFieldDecomposer.C
|
pointFieldDecomposer.C
|
||||||
faMeshDecomposition.C
|
faMeshDecomposition.C
|
||||||
|
|||||||
@ -1,20 +1,22 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/fileFormats/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)/dynamicMesh/lnInclude \
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
|
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||||
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude
|
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lfiniteArea \
|
-lfiniteArea \
|
||||||
-lfiniteVolume \
|
-lfiniteVolume \
|
||||||
|
-lfileFormats \
|
||||||
-lmeshTools \
|
-lmeshTools \
|
||||||
-llagrangian \
|
-llagrangian \
|
||||||
-ldynamicMesh \
|
-ldynamicMesh \
|
||||||
-lgenericPatchFields \
|
-lgenericPatchFields \
|
||||||
-ldecompose \
|
|
||||||
-ldecompositionMethods \
|
-ldecompositionMethods \
|
||||||
|
-ldecompose \
|
||||||
-L$(FOAM_LIBBIN)/dummy \
|
-L$(FOAM_LIBBIN)/dummy \
|
||||||
-lkahipDecomp -lmetisDecomp -lscotchDecomp
|
-lkahipDecomp -lmetisDecomp -lscotchDecomp
|
||||||
|
|||||||
@ -47,7 +47,7 @@ Usage
|
|||||||
|
|
||||||
- \par -cellDist
|
- \par -cellDist
|
||||||
Write the cell distribution as a labelList, for use with 'manual'
|
Write the cell distribution as a labelList, for use with 'manual'
|
||||||
decomposition method and as a volScalarField for visualization.
|
decomposition method and as a VTK or volScalarField for visualization.
|
||||||
|
|
||||||
- \par -constant
|
- \par -constant
|
||||||
Include the 'constant/' dir in the times list.
|
Include the 'constant/' dir in the times list.
|
||||||
@ -67,7 +67,7 @@ Usage
|
|||||||
|
|
||||||
- \par -dry-run
|
- \par -dry-run
|
||||||
Test without writing the decomposition. Changes -cellDist to
|
Test without writing the decomposition. Changes -cellDist to
|
||||||
only write volScalarField.
|
only write VTK output.
|
||||||
|
|
||||||
- \par -fields
|
- \par -fields
|
||||||
Use existing geometry decomposition and convert fields only.
|
Use existing geometry decomposition and convert fields only.
|
||||||
@ -301,13 +301,28 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
"dry-run",
|
"dry-run",
|
||||||
"Test without writing the decomposition. "
|
"Test without writing the decomposition. "
|
||||||
"Changes -cellDist to only write volScalarField."
|
"Changes -cellDist to only write VTK output."
|
||||||
);
|
);
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"verbose",
|
"verbose",
|
||||||
"Additional verbosity"
|
"Additional verbosity"
|
||||||
);
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"domains",
|
||||||
|
"N",
|
||||||
|
"Override numberOfSubdomains (-dry-run only)",
|
||||||
|
true // Advanced option
|
||||||
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"method",
|
||||||
|
"name",
|
||||||
|
"Override decomposition method (-dry-run only)",
|
||||||
|
true // Advanced option
|
||||||
|
);
|
||||||
|
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"cellDist",
|
"cellDist",
|
||||||
@ -421,7 +436,9 @@ int main(int argc, char *argv[])
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
decompDictFile
|
decompDictFile,
|
||||||
|
args.getOrDefault<label>("domains", 0),
|
||||||
|
args.getOrDefault<word>("method", word::null)
|
||||||
);
|
);
|
||||||
|
|
||||||
decompTest.execute(writeCellDist, verbose);
|
decompTest.execute(writeCellDist, verbose);
|
||||||
@ -580,33 +597,9 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
const labelList& procIds = mesh.cellToProc();
|
const labelList& procIds = mesh.cellToProc();
|
||||||
|
|
||||||
// Write decomposition as volScalarField for visualization
|
// Write decomposition for visualization
|
||||||
volScalarField cellDist
|
mesh.writeVolField("cellDist");
|
||||||
(
|
//TBD: mesh.writeVTK("cellDist");
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"cellDist",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh,
|
|
||||||
dimensionedScalar("cellDist", dimless, -1),
|
|
||||||
zeroGradientFvPatchScalarField::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(procIds, celli)
|
|
||||||
{
|
|
||||||
cellDist[celli] = procIds[celli];
|
|
||||||
}
|
|
||||||
|
|
||||||
cellDist.correctBoundaryConditions();
|
|
||||||
cellDist.write();
|
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition as volScalarField to "
|
|
||||||
<< cellDist.name() << " for visualization."
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
// Write decomposition as labelList for use with 'manual'
|
// Write decomposition as labelList for use with 'manual'
|
||||||
// decomposition method.
|
// decomposition method.
|
||||||
@ -626,7 +619,7 @@ int main(int argc, char *argv[])
|
|||||||
cellDecomposition.write();
|
cellDecomposition.write();
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition to "
|
Info<< nl << "Wrote decomposition to "
|
||||||
<< cellDecomposition.objectPath()
|
<< runTime.relativePath(cellDecomposition.objectPath())
|
||||||
<< " for use in manual decomposition." << endl;
|
<< " for use in manual decomposition." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,7 +32,8 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
domainDecomposition.C
|
domainDecomposition.C
|
||||||
decomposeMesh.C
|
domainDecompositionDistribute.C
|
||||||
|
domainDecompositionMesh.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -40,16 +42,16 @@ SourceFiles
|
|||||||
|
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "SLList.H"
|
|
||||||
#include "PtrList.H"
|
|
||||||
#include "point.H"
|
#include "point.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class decompositionModel;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class domainDecomposition Declaration
|
Class domainDecomposition Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -58,7 +60,7 @@ class domainDecomposition
|
|||||||
:
|
:
|
||||||
public fvMesh
|
public fvMesh
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Optional: points at the facesInstance
|
//- Optional: points at the facesInstance
|
||||||
autoPtr<pointIOField> facesInstancePointsPtr_;
|
autoPtr<pointIOField> facesInstancePointsPtr_;
|
||||||
@ -117,6 +119,7 @@ class domainDecomposition
|
|||||||
//- Sub patch sizes for inter-processor patches
|
//- Sub patch sizes for inter-processor patches
|
||||||
List<labelListList> procProcessorPatchSubPatchStarts_;
|
List<labelListList> procProcessorPatchSubPatchStarts_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
void distributeCells();
|
void distributeCells();
|
||||||
@ -165,7 +168,7 @@ public:
|
|||||||
// \param io the IOobject for mesh
|
// \param io the IOobject for mesh
|
||||||
// \param decompDictFile optional non-standard location for the
|
// \param decompDictFile optional non-standard location for the
|
||||||
// decomposeParDict file
|
// decomposeParDict file
|
||||||
domainDecomposition
|
explicit domainDecomposition
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const fileName& decompDictFile = ""
|
const fileName& decompDictFile = ""
|
||||||
@ -178,29 +181,68 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The mesh
|
||||||
|
const fvMesh& mesh() const noexcept
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
|
||||||
//- Number of processor in decomposition
|
//- Number of processor in decomposition
|
||||||
label nProcs() const
|
label nProcs() const noexcept
|
||||||
{
|
{
|
||||||
return nProcs_;
|
return nProcs_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Is the decomposition data to be distributed for each processor
|
//- Is decomposition data to be distributed for each processor
|
||||||
bool distributed() const
|
bool distributed() const noexcept
|
||||||
{
|
{
|
||||||
return distributed_;
|
return distributed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Change distributed flag
|
||||||
|
bool distributed(const bool on) noexcept
|
||||||
|
{
|
||||||
|
bool old(distributed_);
|
||||||
|
distributed_ = on;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return decomposition model used
|
||||||
|
const decompositionModel& model() const;
|
||||||
|
|
||||||
|
//- Update flags based on the decomposition model settings
|
||||||
|
// Sets "distributed"
|
||||||
|
void updateParameters(const dictionary& params);
|
||||||
|
|
||||||
|
|
||||||
|
// Mappings
|
||||||
|
|
||||||
|
//- Cell-processor decomposition labels
|
||||||
|
const labelList& cellToProc() const noexcept
|
||||||
|
{
|
||||||
|
return cellToProc_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Decompose
|
||||||
|
|
||||||
//- Decompose mesh
|
//- Decompose mesh
|
||||||
void decomposeMesh();
|
void decomposeMesh();
|
||||||
|
|
||||||
//- Write decomposition
|
//- Write decomposition
|
||||||
bool writeDecomposition(const bool decomposeSets);
|
bool writeDecomposition(const bool decomposeSets);
|
||||||
|
|
||||||
//- Cell-processor decomposition labels
|
|
||||||
const labelList& cellToProc() const
|
// Write
|
||||||
{
|
|
||||||
return cellToProc_;
|
//- Write decomposition as volScalarField for visualization
|
||||||
}
|
void writeVolField(const word& timeName) const;
|
||||||
|
|
||||||
|
//- Write cell distribution as VTU file (binary)
|
||||||
|
void writeVTK(const fileName& file) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,7 +29,6 @@ License
|
|||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "decompositionModel.H"
|
#include "decompositionModel.H"
|
||||||
#include "decompositionInformation.H"
|
#include "decompositionInformation.H"
|
||||||
#include "zeroGradientFvPatchFields.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -137,32 +136,9 @@ void Foam::domainDecompositionDryRun::execute
|
|||||||
|
|
||||||
if (writeCellDist)
|
if (writeCellDist)
|
||||||
{
|
{
|
||||||
// Write decomposition as volScalarField for visualization
|
// Write decomposition for visualization
|
||||||
volScalarField cellDist
|
// - write as VTU to avoid any impact
|
||||||
(
|
writeVTK("cellDist", cellToProc);
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"cellDist",
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
mesh_,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh_,
|
|
||||||
dimensionedScalar("cellDist", dimless, -1),
|
|
||||||
zeroGradientFvPatchScalarField::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(cellToProc, celli)
|
|
||||||
{
|
|
||||||
cellDist[celli] = cellToProc[celli];
|
|
||||||
}
|
|
||||||
|
|
||||||
cellDist.correctBoundaryConditions();
|
|
||||||
cellDist.write();
|
|
||||||
|
|
||||||
Info<< "Wrote decomposition as volScalarField for visualization:"
|
|
||||||
<< nl << cellDist.objectPath() << nl;
|
|
||||||
|
|
||||||
// Less likely that this is actually required, but may be useful...
|
// Less likely that this is actually required, but may be useful...
|
||||||
//
|
//
|
||||||
@ -183,9 +159,9 @@ void Foam::domainDecompositionDryRun::execute
|
|||||||
// );
|
// );
|
||||||
// cellDecomposition.write();
|
// cellDecomposition.write();
|
||||||
//
|
//
|
||||||
// Info<< "Wrote decomposition for use in manual decomposition:"
|
// Info<< nl << "Wrote decomposition to "
|
||||||
// << nl << cellDecomposition.objectPath() << nl;
|
// << runTime.relativePath(cellDecomposition.objectPath())
|
||||||
// #endif
|
// << " for use in manual decomposition." << endl;
|
||||||
|
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -63,6 +63,23 @@ class domainDecompositionDryRun
|
|||||||
const word methodNameOverride_;
|
const word methodNameOverride_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Members
|
||||||
|
|
||||||
|
//- Write decomposition as volScalarField for visualization
|
||||||
|
void writeVolField
|
||||||
|
(
|
||||||
|
const word& timeName,
|
||||||
|
const labelUList& cellToProc
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write cell distribution as VTU file (binary)
|
||||||
|
void writeVTK
|
||||||
|
(
|
||||||
|
const fileName& file,
|
||||||
|
const labelUList& cellToProc
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -88,6 +105,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The mesh
|
||||||
|
const fvMesh& mesh() const noexcept
|
||||||
|
{
|
||||||
|
return mesh_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Perform dry-run
|
//- Perform dry-run
|
||||||
void execute(const bool writeCellDist, const bool verbose = false);
|
void execute(const bool writeCellDist, const bool verbose = false);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,95 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "domainDecompositionDryRun.H"
|
||||||
|
#include "foamVtkInternalMeshWriter.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "zeroGradientFvPatchFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::domainDecompositionDryRun::writeVolField
|
||||||
|
(
|
||||||
|
const word& timeName,
|
||||||
|
const labelUList& procIds
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Write decomposition as volScalarField for visualization
|
||||||
|
volScalarField cellDist
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"cellDist",
|
||||||
|
timeName,
|
||||||
|
this->mesh(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
this->mesh(),
|
||||||
|
dimensionedScalar("cellDist", dimless, -1),
|
||||||
|
zeroGradientFvPatchScalarField::typeName
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(procIds, celli)
|
||||||
|
{
|
||||||
|
cellDist[celli] = procIds[celli];
|
||||||
|
}
|
||||||
|
|
||||||
|
cellDist.correctBoundaryConditions();
|
||||||
|
cellDist.write();
|
||||||
|
|
||||||
|
Info<< nl << "Wrote decomposition to "
|
||||||
|
<< this->mesh().time().relativePath(cellDist.objectPath())
|
||||||
|
<< " (volScalarField) for visualization."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::domainDecompositionDryRun::writeVTK
|
||||||
|
(
|
||||||
|
const fileName& file,
|
||||||
|
const labelUList& cellToProc
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const vtk::vtuCells cells(this->mesh());
|
||||||
|
|
||||||
|
// not parallel
|
||||||
|
vtk::internalMeshWriter writer(this->mesh(), cells, file, false);
|
||||||
|
|
||||||
|
writer.writeGeometry();
|
||||||
|
writer.beginCellData();
|
||||||
|
writer.writeCellData("procID", cellToProc);
|
||||||
|
|
||||||
|
Info<< "Wrote decomposition to "
|
||||||
|
<< this->mesh().time().relativePath(writer.output())
|
||||||
|
<< " for visualization."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,92 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "domainDecomposition.H"
|
||||||
|
#include "foamVtkInternalMeshWriter.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "zeroGradientFvPatchFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::domainDecomposition::writeVolField
|
||||||
|
(
|
||||||
|
const word& timeName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const labelList& procIds = this->cellToProc();
|
||||||
|
|
||||||
|
// Write decomposition as volScalarField for visualization
|
||||||
|
volScalarField cellDist
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"cellDist",
|
||||||
|
timeName,
|
||||||
|
this->mesh(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
this->mesh(),
|
||||||
|
dimensionedScalar("cellDist", dimless, -1),
|
||||||
|
zeroGradientFvPatchScalarField::typeName
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(procIds, celli)
|
||||||
|
{
|
||||||
|
cellDist[celli] = procIds[celli];
|
||||||
|
}
|
||||||
|
|
||||||
|
cellDist.correctBoundaryConditions();
|
||||||
|
cellDist.write();
|
||||||
|
|
||||||
|
Info<< nl << "Wrote decomposition to "
|
||||||
|
<< this->mesh().time().relativePath(cellDist.objectPath())
|
||||||
|
<< " (volScalarField) for visualization."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::domainDecomposition::writeVTK(const fileName& file) const
|
||||||
|
{
|
||||||
|
const vtk::vtuCells cells(this->mesh());
|
||||||
|
|
||||||
|
// not parallel
|
||||||
|
vtk::internalMeshWriter writer(this->mesh(), cells, file, false);
|
||||||
|
|
||||||
|
writer.writeGeometry();
|
||||||
|
writer.beginCellData();
|
||||||
|
writer.writeCellData("procID", cellToProc());
|
||||||
|
|
||||||
|
Info<< "Wrote decomposition to "
|
||||||
|
<< this->mesh().time().relativePath(writer.output())
|
||||||
|
<< " for visualization."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user