ENH: collect and cleanup decompose and reconstruct methods (#2084)

- new faDecompose and faReconstruct libraries

- provide common readFields in the faDecompose library
This commit is contained in:
Mark Olesen
2021-05-05 10:52:15 +02:00
parent 830a217353
commit 0ae17908a2
38 changed files with 661 additions and 591 deletions

View File

@ -1,4 +1,5 @@
decomposePar.C
domainDecomposition.C
domainDecompositionMesh.C
domainDecompositionDistribute.C
@ -7,10 +8,6 @@ domainDecompositionWrite.C
domainDecompositionDryRun.C
domainDecompositionDryRunWrite.C
dimFieldDecomposer.C
pointFieldDecomposer.C
faMeshDecomposition.C
faFieldDecomposer.C
lagrangianFieldDecomposer.C
EXE = $(FOAM_APPBIN)/decomposePar

View File

@ -6,7 +6,8 @@ EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/decompose/faDecompose/lnInclude
EXE_LIBS = \
-lfiniteArea \
@ -18,5 +19,6 @@ EXE_LIBS = \
-lgenericPatchFields \
-ldecompositionMethods \
-ldecompose \
-lfaDecompose \
-L$(FOAM_LIBBIN)/dummy \
-lkahipDecomp -lmetisDecomp -lscotchDecomp

View File

@ -162,7 +162,6 @@ Usage
#include "regionProperties.H"
#include "readFields.H"
#include "dimFieldDecomposer.H"
#include "fvFieldDecomposer.H"
#include "pointFieldDecomposer.H"
#include "lagrangianFieldDecomposer.H"
@ -173,11 +172,52 @@ Usage
#include "faMeshDecomposition.H"
#include "faFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Read proc addressing at specific instance.
// Uses polyMesh/fvMesh meshSubDir by default
autoPtr<labelIOList> procAddressing
(
const fvMesh& procMesh,
const word& name,
const word& instance,
const word& local = fvMesh::meshSubDir
)
{
return autoPtr<labelIOList>::New
(
IOobject
(
name,
instance,
local,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false // do not register
)
);
}
// Read proc addressing at specific instance.
// Uses the finiteArea meshSubDir
autoPtr<labelIOList> faProcAddressing
(
const fvMesh& procMesh,
const word& name,
const word& instance,
const word& local = faMesh::meshSubDir
)
{
return procAddressing(procMesh, name, instance, local);
}
// Return cached or read proc addressing from facesInstance
const labelIOList& procAddressing
(
const PtrList<fvMesh>& procMeshList,
@ -193,19 +233,7 @@ const labelIOList& procAddressing
procAddressingList.set
(
proci,
new labelIOList
(
IOobject
(
name,
procMesh.facesInstance(),
procMesh.meshSubDir,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
)
procAddressing(procMesh, name, procMesh.facesInstance())
);
}
return procAddressingList[proci];
@ -275,7 +303,7 @@ void decomposeUniform
}
}
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -682,7 +710,6 @@ int main(int argc, char *argv[])
PtrList<labelIOList> cellProcAddressingList(mesh.nProcs());
PtrList<labelIOList> boundaryProcAddressingList(mesh.nProcs());
PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
PtrList<dimFieldDecomposer> dimFieldDecomposerList(mesh.nProcs());
PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
PtrList<pointFieldDecomposer> pointFieldDecomposerList
(
@ -1047,7 +1074,6 @@ int main(int argc, char *argv[])
{
Info<< "Processor " << proci << ": field transfer" << endl;
// open the database
if (!processorDbList.set(proci))
{
@ -1112,7 +1138,7 @@ int main(int argc, char *argv[])
);
// FV fields
// FV fields: volume, surface, internal
{
if (!fieldDecomposerList.set(proci))
{
@ -1132,6 +1158,7 @@ int main(int argc, char *argv[])
const fvFieldDecomposer& fieldDecomposer =
fieldDecomposerList[proci];
// vol fields
fieldDecomposer.decomposeFields(volScalarFields);
fieldDecomposer.decomposeFields(volVectorFields);
fieldDecomposer.decomposeFields
@ -1141,6 +1168,7 @@ int main(int argc, char *argv[])
fieldDecomposer.decomposeFields(volSymmTensorFields);
fieldDecomposer.decomposeFields(volTensorFields);
// surface fields
fieldDecomposer.decomposeFields(surfaceScalarFields);
fieldDecomposer.decomposeFields(surfaceVectorFields);
fieldDecomposer.decomposeFields
@ -1153,6 +1181,13 @@ int main(int argc, char *argv[])
);
fieldDecomposer.decomposeFields(surfaceTensorFields);
// internal fields
fieldDecomposer.decomposeFields(dimScalarFields);
fieldDecomposer.decomposeFields(dimVectorFields);
fieldDecomposer.decomposeFields(dimSphericalTensorFields);
fieldDecomposer.decomposeFields(dimSymmTensorFields);
fieldDecomposer.decomposeFields(dimTensorFields);
if (times.size() == 1)
{
// Clear cached decomposer
@ -1160,37 +1195,6 @@ int main(int argc, char *argv[])
}
}
// Dimensioned fields
{
if (!dimFieldDecomposerList.set(proci))
{
dimFieldDecomposerList.set
(
proci,
new dimFieldDecomposer
(
mesh,
procMesh,
faceProcAddressing,
cellProcAddressing
)
);
}
const dimFieldDecomposer& dimDecomposer =
dimFieldDecomposerList[proci];
dimDecomposer.decomposeFields(dimScalarFields);
dimDecomposer.decomposeFields(dimVectorFields);
dimDecomposer.decomposeFields(dimSphericalTensorFields);
dimDecomposer.decomposeFields(dimSymmTensorFields);
dimDecomposer.decomposeFields(dimTensorFields);
if (times.size() == 1)
{
dimFieldDecomposerList.set(proci, nullptr);
}
}
// Point fields
if
@ -1366,18 +1370,24 @@ int main(int argc, char *argv[])
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
IOobject::NO_WRITE,
false // not registered
);
if (faMeshBoundaryIOobj.typeHeaderOk<faBoundaryMesh>(true))
{
Info << "\nFinite area mesh decomposition" << endl;
Info<< "\nFinite area mesh decomposition" << endl;
faMeshDecomposition aMesh(mesh);
// Always based on the volume decomposition!
faMeshDecomposition aMesh
(
mesh,
mesh.nProcs(),
mesh.model()
);
aMesh.decomposeMesh();
aMesh.writeDecomposition();
@ -1404,13 +1414,29 @@ int main(int argc, char *argv[])
PtrList<edgeScalarField> edgeScalarFields;
readFields(aMesh, objects, edgeScalarFields);
Info << endl;
const label nAreaFields =
(
areaScalarFields.size()
+ areaVectorFields.size()
+ areaSphericalTensorFields.size()
+ areaSymmTensorFields.size()
+ areaTensorFields.size()
+ edgeScalarFields.size()
);
Info<< endl;
Info<< "Finite area field transfer: "
<< nAreaFields << " fields" << endl;
// Split the fields over processors
for (label procI = 0; procI < mesh.nProcs(); procI++)
for
(
label proci = 0;
nAreaFields && proci < mesh.nProcs();
++proci
)
{
Info<< "Processor " << procI
<< ": finite area field transfer" << endl;
Info<< " Processor " << proci << endl;
// open the database
Time processorDb
@ -1418,7 +1444,7 @@ int main(int argc, char *argv[])
Time::controlDictName,
args.rootPath(),
args.caseName()
/ ("processor" + Foam::name(procI))
/ ("processor" + Foam::name(proci))
);
processorDb.setTime(runTime);
@ -1441,7 +1467,7 @@ int main(int argc, char *argv[])
// procAddressing
// (
// procMeshList,
// procI,
// proci,
// "faceProcAddressing",
// faceProcAddressingList
// );
@ -1450,84 +1476,59 @@ int main(int argc, char *argv[])
// procAddressing
// (
// procMeshList,
// procI,
// proci,
// "boundaryProcAddressing",
// boundaryProcAddressingList
// );
labelIOList faceProcAddressing
(
IOobject
// Addressing from faMesh (not polyMesh) meshSubDir
autoPtr<labelIOList> tfaceProcAddr =
faProcAddressing
(
procFvMesh,
"faceProcAddressing",
"constant",
procMesh.meshSubDir,
procFvMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
runTime.constant()
);
auto& faceProcAddressing = *tfaceProcAddr;
labelIOList boundaryProcAddressing
(
IOobject
autoPtr<labelIOList> tboundaryProcAddr =
faProcAddressing
(
procFvMesh,
"boundaryProcAddressing",
"constant",
procMesh.meshSubDir,
runTime.constant()
);
auto& boundaryProcAddressing = *tboundaryProcAddr;
autoPtr<labelIOList> tedgeProcAddr =
faProcAddressing
(
procFvMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
"edgeProcAddressing",
runTime.constant()
);
const auto& edgeProcAddressing = *tedgeProcAddr;
faFieldDecomposer fieldDecomposer
(
aMesh,
procMesh,
edgeProcAddressing,
faceProcAddressing,
boundaryProcAddressing
);
// FA fields
if
fieldDecomposer.decomposeFields(areaScalarFields);
fieldDecomposer.decomposeFields(areaVectorFields);
fieldDecomposer.decomposeFields
(
areaScalarFields.size()
|| areaVectorFields.size()
|| areaSphericalTensorFields.size()
|| areaSymmTensorFields.size()
|| areaTensorFields.size()
|| edgeScalarFields.size()
)
{
labelIOList edgeProcAddressing
(
IOobject
(
"edgeProcAddressing",
"constant",
procMesh.meshSubDir,
procFvMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
areaSphericalTensorFields
);
fieldDecomposer.decomposeFields(areaSymmTensorFields);
fieldDecomposer.decomposeFields(areaTensorFields);
faFieldDecomposer fieldDecomposer
(
aMesh,
procMesh,
edgeProcAddressing,
faceProcAddressing,
boundaryProcAddressing
);
fieldDecomposer.decomposeFields(areaScalarFields);
fieldDecomposer.decomposeFields(areaVectorFields);
fieldDecomposer.decomposeFields
(
areaSphericalTensorFields
);
fieldDecomposer.decomposeFields
(
areaSymmTensorFields
);
fieldDecomposer.decomposeFields(areaTensorFields);
fieldDecomposer.decomposeFields(edgeScalarFields);
}
fieldDecomposer.decomposeFields(edgeScalarFields);
}
}
}

View File

@ -120,16 +120,27 @@ Foam::domainDecomposition::domainDecomposition
procProcessorPatchSubPatchIDs_(nProcs_),
procProcessorPatchSubPatchStarts_(nProcs_)
{
decompositionModel::New
(
*this,
decompDictFile
).readIfPresent("distributed", distributed_);
updateParameters(this->model());
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::decompositionModel& Foam::domainDecomposition::model() const
{
return decompositionModel::New(*this, decompDictFile_);
}
void Foam::domainDecomposition::updateParameters
(
const dictionary& params
)
{
params.readIfPresent("distributed", distributed_);
}
bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
{
Info<< "\nConstructing processor meshes" << endl;
@ -408,10 +419,9 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
nInterProcPatches += curSubPatchIDs[procPatchi].size();
}
List<polyPatch*> procPatches
PtrList<polyPatch> procPatches
(
curPatchSizes.size() + nInterProcPatches,
reinterpret_cast<polyPatch*>(0)
curPatchSizes.size() + nInterProcPatches
);
label nPatches = 0;
@ -434,13 +444,17 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
);
// Map existing patches
procPatches[nPatches] = meshPatch.clone
procPatches.set
(
procMesh.boundaryMesh(),
nPatches,
patchMapper.directAddressing(),
curPatchStarts[patchi]
).ptr();
meshPatch.clone
(
procMesh.boundaryMesh(),
nPatches,
patchMapper.directAddressing(),
curPatchStarts[patchi]
)
);
nPatches++;
}
@ -464,7 +478,9 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
if (subPatchID[i] == -1)
{
// From internal faces
procPatches[nPatches] =
procPatches.set
(
nPatches,
new processorPolyPatch
(
size,
@ -473,7 +489,8 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
procMesh.boundaryMesh(),
proci,
curNeighbourProcessors[procPatchi]
);
)
);
}
else
{
@ -483,7 +500,9 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
boundaryMesh()[subPatchID[i]]
);
procPatches[nPatches] =
procPatches.set
(
nPatches,
new processorCyclicPolyPatch
(
size,
@ -494,12 +513,12 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
curNeighbourProcessors[procPatchi],
pcPatch.name(),
pcPatch.transform()
);
)
);
}
curStart += size;
nPatches++;
++nPatches;
}
}

View File

@ -26,12 +26,8 @@ License
\*---------------------------------------------------------------------------*/
#include "domainDecomposition.H"
#include "decompositionMethod.H"
#include "cpuTime.H"
#include "cellSet.H"
#include "regionSplit.H"
#include "Tuple2.H"
#include "faceSet.H"
#include "decompositionMethod.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,7 +31,7 @@ Description
SourceFiles
lagrangianFieldDecomposer.C
lagrangianFieldDecomposerDecomposeFields.C
lagrangianFieldDecomposerFields.C
\*---------------------------------------------------------------------------*/
@ -84,7 +84,7 @@ public:
//- Construct from components
lagrangianFieldDecomposer
(
const polyMesh& mesh,
const polyMesh& mesh, //<! unused
const polyMesh& procMesh,
const labelList& faceProcAddressing,
const labelList& cellProcAddressing,
@ -156,7 +156,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "lagrangianFieldDecomposerDecomposeFields.C"
#include "lagrangianFieldDecomposerFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -42,7 +42,7 @@ void Foam::readFields
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
// Search list of objects for fields of type GeoField
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
IOobjectList fieldObjects(objects.lookupClass<GeoField>());
// Remove the cellDist field
auto iter = fieldObjects.find("cellDist");
@ -51,12 +51,12 @@ void Foam::readFields
fieldObjects.erase(iter);
}
// Get sorted set of names (different processors might read objects in
// different order)
// Use sorted set of names
// (different processors might read objects in different order)
const wordList masterNames(fieldObjects.sortedNames());
// Construct the fields
fields.setSize(masterNames.size());
fields.resize(masterNames.size());
forAll(masterNames, i)
{
@ -76,17 +76,14 @@ void Foam::readFields
)
{
// Search list of objects for fields of type GeomField
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
IOobjectList fieldObjects(objects.lookupClass<GeoField>());
// Construct the fields
fields.setSize(fieldObjects.size());
// Get sorted set of names (different processors might read objects in
// different order)
// Use sorted set of names
// (different processors might read objects in different order)
const wordList masterNames(fieldObjects.sortedNames());
// Construct the fields
fields.setSize(masterNames.size());
fields.resize(masterNames.size());
forAll(masterNames, i)
{

View File

@ -1,5 +1,3 @@
processorFaMeshes.C
faFieldReconstructor.C
reconstructPar.C
EXE = $(FOAM_APPBIN)/reconstructPar

View File

@ -4,7 +4,8 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude
-I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \
-I$(LIB_SRC)/parallel/reconstruct/faReconstruct/lnInclude
EXE_LIBS = \
-lfiniteArea \
@ -13,4 +14,5 @@ EXE_LIBS = \
-llagrangian \
-lgenericPatchFields \
-ldynamicMesh \
-lreconstruct
-lreconstruct \
-lfaReconstruct

View File

@ -8,6 +8,7 @@ wclean kahipDecomp
wclean scotchDecomp
wclean decompositionMethods
wclean decompose
wclean faDecompose
./Allwclean-mpi

View File

@ -12,6 +12,7 @@ export FOAM_EXT_LIBBIN
wmake $targetType decompositionMethods
wmake $targetType decompose
wmake $targetType faDecompose
if have_kahip
then

View File

@ -1,5 +1,8 @@
decompositionInformation.C
decompositionModel.C
dimFieldDecomposer.C
fvFieldDecomposer.C
pointFieldDecomposer.C
LIB = $(FOAM_LIBBIN)/libdecompose

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,9 +28,19 @@ License
#include "dimFieldDecomposer.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dimFieldDecomposer::dimFieldDecomposer
(
const fvMesh& procMesh,
const labelList& cellAddressing
)
:
procMesh_(procMesh),
cellAddressing_(cellAddressing)
{}
Foam::dimFieldDecomposer::dimFieldDecomposer
(
const fvMesh& completeMesh,
@ -38,17 +49,11 @@ Foam::dimFieldDecomposer::dimFieldDecomposer
const labelList& cellAddressing
)
:
completeMesh_(completeMesh),
//UNUSED: completeMesh_(completeMesh),
procMesh_(procMesh),
faceAddressing_(faceAddressing),
//UNUSED: faceAddressing_(faceAddressing),
cellAddressing_(cellAddressing)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::dimFieldDecomposer::~dimFieldDecomposer()
{}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +32,7 @@ Description
SourceFiles
dimFieldDecomposer.C
dimFieldDecomposerDecomposeFields.C
dimFieldDecomposerFields.C
\*---------------------------------------------------------------------------*/
@ -46,69 +47,68 @@ SourceFiles
namespace Foam
{
class IOobjectList;
/*---------------------------------------------------------------------------*\
Class fvFieldDecomposer Declaration
\*---------------------------------------------------------------------------*/
class dimFieldDecomposer
{
private:
// Private data
//- Reference to complete mesh
const fvMesh& completeMesh_;
// Private Data
//- Reference to processor mesh
const fvMesh& procMesh_;
//- Reference to face addressing
const labelList& faceAddressing_;
//UNUSED: const labelList& faceAddressing_;
//- Reference to cell addressing
const labelList& cellAddressing_;
// Private Member Functions
//- No copy construct
dimFieldDecomposer(const dimFieldDecomposer&) = delete;
//- No copy assignment
void operator=(const dimFieldDecomposer&) = delete;
public:
//- No copy construct
dimFieldDecomposer(const dimFieldDecomposer&) = delete;
//- No copy assignment
void operator=(const dimFieldDecomposer&) = delete;
// Constructors
//- Construct from components
//- Construct from minimal components
dimFieldDecomposer
(
const fvMesh& completeMesh,
const fvMesh& procMesh,
const labelList& faceAddressing,
const labelList& cellAddressing
);
//- Construct from components with API as per fvFieldDecomposer
dimFieldDecomposer
(
const fvMesh& completeMesh, //!< unused
const fvMesh& procMesh,
const labelList& faceAddressing, //!< unused
const labelList& cellAddressing
);
//- Destructor
~dimFieldDecomposer();
~dimFieldDecomposer() = default;
// Member Functions
//- Decompose field
template<class Type>
tmp<DimensionedField<Type, volMesh>> decomposeField
tmp<DimensionedField<Type, volMesh>>
decomposeField
(
const DimensionedField<Type, volMesh>& field
) const;
//- Decompose llist of fields
//- Decompose list of fields
template<class GeoField>
void decomposeFields(const PtrList<GeoField>& fields) const;
};
@ -121,7 +121,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "dimFieldDecomposerDecomposeFields.C"
#include "dimFieldDecomposerFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,9 +41,8 @@ Foam::dimFieldDecomposer::decomposeField
Field<Type> mappedField(field, cellAddressing_);
// Create the field for the processor
return tmp<DimensionedField<Type, volMesh>>
(
new DimensionedField<Type, volMesh>
return
tmp<DimensionedField<Type, volMesh>>::New
(
IOobject
(
@ -55,9 +55,8 @@ Foam::dimFieldDecomposer::decomposeField
),
procMesh_,
field.dimensions(),
mappedField
)
);
std::move(mappedField)
);
}

View File

@ -27,7 +27,6 @@ License
#include "fvFieldDecomposer.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
@ -135,11 +134,12 @@ Foam::fvFieldDecomposer::fvFieldDecomposer
{
forAll(boundaryAddressing_, patchi)
{
const label oldPatchi = boundaryAddressing_[patchi];
const fvPatch& fvp = procMesh_.boundary()[patchi];
if
(
boundaryAddressing_[patchi] >= 0
oldPatchi >= 0
&& !isA<processorLduInterface>(procMesh.boundary()[patchi])
)
{
@ -149,10 +149,7 @@ Foam::fvFieldDecomposer::fvFieldDecomposer
new patchFieldDecomposer
(
fvp.patchSlice(faceAddressing_),
completeMesh_.boundaryMesh()
[
boundaryAddressing_[patchi]
].start()
completeMesh_.boundaryMesh()[oldPatchi].start()
)
);
}
@ -202,10 +199,4 @@ Foam::fvFieldDecomposer::fvFieldDecomposer
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fvFieldDecomposer::~fvFieldDecomposer()
{}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +32,7 @@ Description
SourceFiles
fvFieldDecomposer.C
fvFieldDecomposerDecomposeFields.C
fvFieldDecomposerFields.C
\*---------------------------------------------------------------------------*/
@ -47,8 +48,6 @@ SourceFiles
namespace Foam
{
class IOobjectList;
/*---------------------------------------------------------------------------*\
Class fvFieldDecomposer Declaration
\*---------------------------------------------------------------------------*/
@ -62,7 +61,7 @@ public:
:
public fvPatchFieldMapper
{
// Private data
// Private Data
labelList directAddressing_;
@ -78,7 +77,7 @@ public:
);
// Member functions
// Member Functions
label size() const
{
@ -110,7 +109,7 @@ public:
:
public fvPatchFieldMapper
{
// Private data
// Private Data
labelList directAddressing_;
@ -124,7 +123,7 @@ public:
);
// Member functions
// Member Functions
label size() const
{
@ -199,7 +198,7 @@ public:
private:
// Private data
// Private Data
//- Reference to complete mesh
const fvMesh& completeMesh_;
@ -225,21 +224,18 @@ private:
PtrList<processorSurfacePatchFieldDecomposer>
processorSurfacePatchFieldDecomposerPtrs_;
PtrList<scalarField> faceSign_;
// Private Member Functions
//- No copy construct
fvFieldDecomposer(const fvFieldDecomposer&) = delete;
//- No copy assignment
void operator=(const fvFieldDecomposer&) = delete;
public:
//- No copy construct
fvFieldDecomposer(const fvFieldDecomposer&) = delete;
//- No copy assignment
void operator=(const fvFieldDecomposer&) = delete;
// Constructors
//- Construct from components
@ -254,11 +250,19 @@ public:
//- Destructor
~fvFieldDecomposer();
~fvFieldDecomposer() = default;
// Member Functions
//- Decompose internal field
template<class Type>
tmp<DimensionedField<Type, volMesh>>
decomposeField
(
const DimensionedField<Type, volMesh>& field
) const;
//- Decompose volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
@ -276,6 +280,7 @@ public:
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
) const;
//- Decompose list of fields
template<class GeoField>
void decomposeFields(const PtrList<GeoField>& fields) const;
};
@ -288,7 +293,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fvFieldDecomposerDecomposeFields.C"
#include "fvFieldDecomposerFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,6 +35,36 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>>
Foam::fvFieldDecomposer::decomposeField
(
const DimensionedField<Type, volMesh>& field
) const
{
// Create and map the internal field values
Field<Type> mappedField(field, cellAddressing_);
// Create the field for the processor
return
tmp<DimensionedField<Type, volMesh>>::New
(
IOobject
(
field.name(),
procMesh_.time().timeName(),
procMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
procMesh_,
field.dimensions(),
std::move(mappedField)
);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvFieldDecomposer::decomposeField

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -88,41 +89,28 @@ Foam::pointFieldDecomposer::pointFieldDecomposer
procMesh_(procMesh),
pointAddressing_(pointAddressing),
boundaryAddressing_(boundaryAddressing),
patchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<patchFieldDecomposer*>(nullptr)
)
patchFieldDecomposerPtrs_(procMesh_.boundary().size())
{
forAll(boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
const label oldPatchi = boundaryAddressing_[patchi];
if (oldPatchi >= 0)
{
patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
patchFieldDecomposerPtrs_.set
(
completeMesh_.boundary()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
pointAddressing_
patchi,
new patchFieldDecomposer
(
completeMesh_.boundary()[oldPatchi],
procMesh_.boundary()[patchi],
pointAddressing_
)
);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointFieldDecomposer::~pointFieldDecomposer()
{
forAll(patchFieldDecomposerPtrs_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
delete patchFieldDecomposerPtrs_[patchi];
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +32,7 @@ Description
SourceFiles
pointFieldDecomposer.C
pointFieldDecomposerDecomposeFields.C
pointFieldDecomposerFields.C
\*---------------------------------------------------------------------------*/
@ -53,7 +54,6 @@ namespace Foam
class pointFieldDecomposer
{
public:
//- Point patch field decomposer class
@ -107,7 +107,7 @@ public:
private:
// Private data
// Private Data
//- Reference to complete mesh
const pointMesh& completeMesh_;
@ -122,20 +122,18 @@ private:
const labelList& boundaryAddressing_;
//- List of patch field decomposers
List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
// Private Member Functions
//- No copy construct
pointFieldDecomposer(const pointFieldDecomposer&) = delete;
//- No copy assignment
void operator=(const pointFieldDecomposer&) = delete;
PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
public:
//- No copy construct
pointFieldDecomposer(const pointFieldDecomposer&) = delete;
//- No copy assignment
void operator=(const pointFieldDecomposer&) = delete;
// Constructors
//- Construct from components
@ -149,7 +147,7 @@ public:
//- Destructor
~pointFieldDecomposer();
~pointFieldDecomposer() = default;
// Member Functions
@ -174,7 +172,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "pointFieldDecomposerDecomposeFields.C"
#include "pointFieldDecomposerFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -46,7 +47,7 @@ Foam::pointFieldDecomposer::decomposeField
// Create and map the patch field values
forAll(boundaryAddressing_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
if (patchFieldDecomposerPtrs_.set(patchi))
{
patchFields.set
(
@ -56,7 +57,7 @@ Foam::pointFieldDecomposer::decomposeField
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
DimensionedField<Type, pointMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
patchFieldDecomposerPtrs_[patchi]
)
);
}
@ -75,9 +76,8 @@ Foam::pointFieldDecomposer::decomposeField
}
// Create the field for the processor
return tmp<GeometricField<Type, pointPatchField, pointMesh>>
(
new GeometricField<Type, pointPatchField, pointMesh>
return
tmp<GeometricField<Type, pointPatchField, pointMesh>>::New
(
IOobject
(
@ -92,8 +92,7 @@ Foam::pointFieldDecomposer::decomposeField
field.dimensions(),
internalField,
patchFields
)
);
);
}

View File

@ -0,0 +1,4 @@
faFieldDecomposer.C
faMeshDecomposition.C
LIB = $(FOAM_LIBBIN)/libfaDecompose

View File

@ -0,0 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
LIB_LIBS = \
-lfiniteVolume \
-lfiniteArea \
-lmeshTools

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,14 +28,9 @@ License
#include "faFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
Foam::faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
(
const label sizeBeforeMapping,
const labelUList& addressingSlice,
@ -54,7 +50,7 @@ faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
}
faFieldDecomposer::processorAreaPatchFieldDecomposer::
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::
processorAreaPatchFieldDecomposer
(
const faMesh& mesh,
@ -108,7 +104,7 @@ processorAreaPatchFieldDecomposer
}
faFieldDecomposer::processorEdgePatchFieldDecomposer::
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::
processorEdgePatchFieldDecomposer
(
label sizeBeforeMapping,
@ -130,7 +126,7 @@ processorEdgePatchFieldDecomposer
}
faFieldDecomposer::faFieldDecomposer
Foam::faFieldDecomposer::faFieldDecomposer
(
const faMesh& completeMesh,
const faMesh& procMesh,
@ -144,47 +140,43 @@ faFieldDecomposer::faFieldDecomposer
edgeAddressing_(edgeAddressing),
faceAddressing_(faceAddressing),
boundaryAddressing_(boundaryAddressing),
patchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<patchFieldDecomposer*>(NULL)
),
processorAreaPatchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<processorAreaPatchFieldDecomposer*>(NULL)
),
processorEdgePatchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<processorEdgePatchFieldDecomposer*>(NULL)
)
patchFieldDecomposerPtrs_(procMesh_.boundary().size()),
processorAreaPatchFieldDecomposerPtrs_(procMesh_.boundary().size()),
processorEdgePatchFieldDecomposerPtrs_(procMesh_.boundary().size())
{
forAll(boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
const label oldPatchi = boundaryAddressing_[patchi];
if (oldPatchi >= 0)
{
patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
patchFieldDecomposerPtrs_.set
(
completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
// completeMesh_.boundaryMesh()
completeMesh_.boundary()
[
boundaryAddressing_[patchi]
].start()
patchi,
new patchFieldDecomposer
(
completeMesh_.boundary()[oldPatchi].size(),
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
completeMesh_.boundary()[oldPatchi].start()
)
);
}
else
{
processorAreaPatchFieldDecomposerPtrs_[patchi] =
processorAreaPatchFieldDecomposerPtrs_.set
(
patchi,
new processorAreaPatchFieldDecomposer
(
completeMesh_,
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_)
);
)
);
processorEdgePatchFieldDecomposerPtrs_[patchi] =
processorEdgePatchFieldDecomposerPtrs_.set
(
patchi,
new processorEdgePatchFieldDecomposer
(
procMesh_.boundary()[patchi].size(),
@ -195,44 +187,11 @@ faFieldDecomposer::faFieldDecomposer
edgeAddressing_
)
)
);
)
);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
faFieldDecomposer::~faFieldDecomposer()
{
forAll(patchFieldDecomposerPtrs_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
delete patchFieldDecomposerPtrs_[patchi];
}
}
forAll(processorAreaPatchFieldDecomposerPtrs_, patchi)
{
if (processorAreaPatchFieldDecomposerPtrs_[patchi])
{
delete processorAreaPatchFieldDecomposerPtrs_[patchi];
}
}
forAll(processorEdgePatchFieldDecomposerPtrs_, patchi)
{
if (processorEdgePatchFieldDecomposerPtrs_[patchi])
{
delete processorEdgePatchFieldDecomposerPtrs_[patchi];
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +36,7 @@ Author
SourceFiles
faFieldDecomposer.C
faFieldDecomposerDecomposeFields.C
faFieldDecomposerFields.C
\*---------------------------------------------------------------------------*/
@ -51,6 +52,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class IOobjectList;
/*---------------------------------------------------------------------------*\
@ -66,7 +68,7 @@ public:
:
public faPatchFieldMapper
{
// Private data
// Private Data
label sizeBeforeMapping_;
labelList directAddressing_;
@ -241,12 +243,12 @@ private:
const labelList& boundaryAddressing_;
//- List of patch field decomposers
List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
List<processorAreaPatchFieldDecomposer*>
PtrList<processorAreaPatchFieldDecomposer>
processorAreaPatchFieldDecomposerPtrs_;
List<processorEdgePatchFieldDecomposer*>
PtrList<processorEdgePatchFieldDecomposer>
processorEdgePatchFieldDecomposerPtrs_;
@ -275,8 +277,7 @@ public:
// Destructor
~faFieldDecomposer();
~faFieldDecomposer() = default;
// Member Functions
@ -299,6 +300,33 @@ public:
template<class GeoField>
void decomposeFields(const PtrList<GeoField>& fields) const;
// Reading helpers
//- Read the fields and hold on the pointer list
template
<
class Type,
template<class> class PatchField,
class GeoMesh
>
static void readFields
(
const typename GeoMesh::Mesh& mesh,
const IOobjectList& objects,
PtrList<GeometricField<Type, PatchField, GeoMesh>>& fields,
const bool readOldTime
);
//- Read fields and hold on the pointer list
template<class Mesh, class GeoField>
static void readFields
(
const Mesh& mesh,
const IOobjectList& objects,
PtrList<GeoField>& fields
);
};
@ -309,7 +337,8 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faFieldDecomposerDecomposeFields.C"
#include "faFieldDecomposerFields.C"
#include "faFieldDecomposerReadFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,16 +30,11 @@ License
#include "processorFaPatchField.H"
#include "processorFaePatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
tmp<GeometricField<Type, faPatchField, areaMesh>>
faFieldDecomposer::decomposeField
Foam::tmp<Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh>>
Foam::faFieldDecomposer::decomposeField
(
const GeometricField<Type, faPatchField, areaMesh>& field
) const
@ -51,17 +47,19 @@ faFieldDecomposer::decomposeField
forAll(boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
const label oldPatchi = boundaryAddressing_[patchi];
if (oldPatchi >= 0)
{
patchFields.set
(
patchi,
faPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
field.boundaryField()[oldPatchi],
procMesh_.boundary()[patchi],
DimensionedField<Type, areaMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
patchFieldDecomposerPtrs_[patchi]
)
);
}
@ -77,7 +75,7 @@ faFieldDecomposer::decomposeField
Field<Type>
(
field.internalField(),
*processorAreaPatchFieldDecomposerPtrs_[patchi]
processorAreaPatchFieldDecomposerPtrs_[patchi]
)
)
);
@ -85,9 +83,8 @@ faFieldDecomposer::decomposeField
}
// Create the field for the processor
return tmp<GeometricField<Type, faPatchField, areaMesh>>
(
new GeometricField<Type, faPatchField, areaMesh>
return
tmp<GeometricField<Type, faPatchField, areaMesh>>::New
(
IOobject
(
@ -101,14 +98,13 @@ faFieldDecomposer::decomposeField
field.dimensions(),
internalField,
patchFields
)
);
);
}
template<class Type>
tmp<GeometricField<Type, faePatchField, edgeMesh>>
faFieldDecomposer::decomposeField
Foam::tmp<Foam::GeometricField<Type, Foam::faePatchField, Foam::edgeMesh>>
Foam::faFieldDecomposer::decomposeField
(
const GeometricField<Type, faePatchField, edgeMesh>& field
) const
@ -147,7 +143,7 @@ faFieldDecomposer::decomposeField
forAll(field.boundaryField(), patchi)
{
const Field<Type> & p = field.boundaryField()[patchi];
const Field<Type>& p = field.boundaryField()[patchi];
const label patchStart = field.mesh().boundary()[patchi].start();
@ -162,17 +158,19 @@ faFieldDecomposer::decomposeField
forAll(boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
const label oldPatchi = boundaryAddressing_[patchi];
if (oldPatchi >= 0)
{
patchFields.set
(
patchi,
faePatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
field.boundaryField()[oldPatchi],
procMesh_.boundary()[patchi],
DimensionedField<Type, edgeMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
patchFieldDecomposerPtrs_[patchi]
)
);
}
@ -188,7 +186,7 @@ faFieldDecomposer::decomposeField
Field<Type>
(
allEdgeField,
*processorEdgePatchFieldDecomposerPtrs_[patchi]
processorEdgePatchFieldDecomposerPtrs_[patchi]
)
)
);
@ -196,9 +194,8 @@ faFieldDecomposer::decomposeField
}
// Create the field for the processor
return tmp<GeometricField<Type, faePatchField, edgeMesh>>
(
new GeometricField<Type, faePatchField, edgeMesh>
return
tmp<GeometricField<Type, faePatchField, edgeMesh>>::New
(
IOobject
(
@ -212,13 +209,12 @@ faFieldDecomposer::decomposeField
field.dimensions(),
internalField,
patchFields
)
);
);
}
template<class GeoField>
void faFieldDecomposer::decomposeFields
void Foam::faFieldDecomposer::decomposeFields
(
const PtrList<GeoField>& fields
) const
@ -230,8 +226,4 @@ void faFieldDecomposer::decomposeFields
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
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 "faFieldDecomposer.H"
#include "GeometricField.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::faFieldDecomposer::readFields
(
const typename GeoMesh::Mesh& mesh,
const IOobjectList& objects,
PtrList<GeometricField<Type, PatchField, GeoMesh>>& fields,
const bool readOldTime
)
{
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
// Search list of objects for fields of type GeoField
IOobjectList fieldObjects(objects.lookupClass<GeoField>());
/// // Remove the cellDist field
/// auto iter = fieldObjects.find("cellDist");
/// if (iter.found())
/// {
/// fieldObjects.erase(iter);
/// }
// Use sorted set of names
// (different processors might read objects in different order)
const wordList masterNames(fieldObjects.sortedNames());
// Construct the fields
fields.resize(masterNames.size());
forAll(masterNames, i)
{
const IOobject& io = *fieldObjects[masterNames[i]];
fields.set(i, new GeoField(io, mesh, readOldTime));
}
}
template<class Mesh, class GeoField>
void Foam::faFieldDecomposer::readFields
(
const Mesh& mesh,
const IOobjectList& objects,
PtrList<GeoField>& fields
)
{
// Search list of objects for fields of type GeomField
IOobjectList fieldObjects(objects.lookupClass<GeoField>());
// Use sorted set of names
// (different processors might read objects in different order)
const wordList masterNames(fieldObjects.sortedNames());
// Construct the fields
fields.resize(masterNames.size());
forAll(masterNames, i)
{
const IOobject& io = *fieldObjects[masterNames[i]];
fields.set(i, new GeoField(io, mesh));
}
}
// ************************************************************************* //

View File

@ -34,8 +34,8 @@ License
#include "faMesh.H"
#include "OSspecific.H"
#include "Map.H"
#include "SLList.H"
#include "globalMeshData.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -43,7 +43,7 @@ void Foam::faMeshDecomposition::distributeFaces()
{
const word& polyMeshRegionName = mesh().name();
Info<< "\nCalculating distribution of faces" << endl;
Info<< "\nCalculating distribution of finiteArea faces" << endl;
cpuTime decompositionTime;
@ -162,22 +162,12 @@ void Foam::faMeshDecomposition::distributeFaces()
Foam::faMeshDecomposition::faMeshDecomposition
(
const fvMesh& mesh,
const fileName& decompDictFile
const label nProcessors,
const dictionary& params
)
:
faMesh(mesh),
decompDictFile_(decompDictFile),
nProcs_
(
decompositionMethod::nDomains
(
decompositionModel::New
(
mesh,
decompDictFile
)
)
),
nProcs_(nProcessors),
distributed_(false),
hasGlobalFaceZones_(false),
faceToProc_(nFaces()),
@ -195,22 +185,28 @@ Foam::faMeshDecomposition::faMeshDecomposition
procNeighbourProcessors_(nProcs_),
procProcessorPatchSize_(nProcs_),
procProcessorPatchStartIndex_(nProcs_),
globallySharedPoints_(0),
globallySharedPoints_(),
cyclicParallel_(false)
{
const decompositionModel& model = decompositionModel::New
(
mesh,
decompDictFile
);
model.readIfPresent("distributed", distributed_);
hasGlobalFaceZones_ = model.found("globalFaceZones");
updateParameters(params);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faMeshDecomposition::updateParameters
(
const dictionary& params
)
{
params.readIfPresent("distributed", distributed_);
if (params.found("globalFaceZones"))
{
hasGlobalFaceZones_ = true;
}
}
void Foam::faMeshDecomposition::decomposeMesh()
{
// Decide which cell goes to which processor
@ -220,30 +216,42 @@ void Foam::faMeshDecomposition::decomposeMesh()
Info<< "\nDistributing faces to processors" << endl;
// Memory management
labelList nLocalFaces(nProcs_, Zero);
// Pass 1: determine local sizes, sanity check
forAll(faceToProc_, facei)
{
List<SLList<label>> procFaceList(nProcs());
const label proci = faceToProc_[facei];
forAll(faceToProc_, faceI)
if (proci < 0 || proci >= nProcs_)
{
if (faceToProc_[faceI] >= nProcs())
{
FatalErrorInFunction
<< "Impossible processor label " << faceToProc_[faceI]
<< "for face " << faceI << nl
<< abort(FatalError);
}
else
{
procFaceList[faceToProc_[faceI]].append(faceI);
}
FatalErrorInFunction
<< "Invalid processor label " << proci
<< " for face " << facei << nl
<< abort(FatalError);
}
else
{
++nLocalFaces[proci];
}
}
// Convert linked lists into normal lists
forAll(procFaceList, procI)
{
procFaceAddressing_[procI] = procFaceList[procI];
}
// Adjust lengths
forAll(nLocalFaces, proci)
{
procFaceAddressing_[proci].resize(nLocalFaces[proci]);
nLocalFaces[proci] = 0; // restart list
}
// Pass 2: fill in local lists
forAll(faceToProc_, facei)
{
const label proci = faceToProc_[facei];
const label localFacei = nLocalFaces[proci];
++nLocalFaces[proci];
procFaceAddressing_[proci][localFacei] = facei;
}
@ -1081,12 +1089,11 @@ void Foam::faMeshDecomposition::decomposeMesh()
procProcessorPatchSize_[procI];
labelListList& curPatchEdgeLabels = procPatchEdgeLabels_[procI];
curPatchEdgeLabels =
labelListList
(
curPatchSize.size()
+ curProcessorPatchSize.size()
);
curPatchEdgeLabels.resize
(
curPatchSize.size()
+ curProcessorPatchSize.size()
);
forAll(curPatchSize, patchI)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -44,7 +45,6 @@ SourceFiles
#include "fvMesh.H"
#include "faMesh.H"
#include "labelList.H"
#include "SLList.H"
#include "PtrList.H"
#include "point.H"
@ -59,10 +59,7 @@ class faMeshDecomposition
:
public faMesh
{
// Private data
//- Optional non-standard file for decomposeParDict
const fileName decompDictFile_;
// Private Data
//- Number of processors in decomposition
label nProcs_;
@ -86,7 +83,7 @@ class faMeshDecomposition
labelList procNInternalEdges_;
//- Edge labels for patches of processor meshes
List<List<List<label>>> procPatchEdgeLabels_;
List<labelListList> procPatchEdgeLabels_;
//- Labels of points for each processor
labelListList procPatchPointAddressing_;
@ -131,18 +128,21 @@ class faMeshDecomposition
void distributeFaces();
public:
// Constructors
//- Construct from components.
//- Values will come from the volume decomposition
// \param mesh the fvMesh
// \param decompDictFile optional non-standard location for the
// decomposeParDict file
// \param nProcessors the number of processors
// \param params additional parameters, sent to updateParameters
faMeshDecomposition
(
const fvMesh& mesh,
const fileName& decompDictFile = ""
const label nProcessors,
const dictionary& params = dictionary::null
);
@ -152,29 +152,63 @@ public:
// Member Functions
// Settings
//- Number of processor in decomposition
label nProcs() const
{
return nProcs_;
}
//- Is the decomposition data to be distributed for each processor
//- Is decomposition data to be distributed for each processor
bool distributed() const
{
return distributed_;
}
//- Change distributed flag
bool distributed(const bool on)
{
bool old(distributed_);
distributed_ = on;
return old;
}
//- Are global face zones used
bool useGlobalFaceZones() const
{
return distributed_;
}
//- Change global face zones flag
bool useGlobalFaceZones(const bool on)
{
bool old(hasGlobalFaceZones_);
hasGlobalFaceZones_ = on;
return old;
}
//- Update flags based on the decomposition model settings
// Sets "distributed", detects presence of "globalFaceZones"
void updateParameters(const dictionary& params);
// Mappings
//- Face-processor decomposition labels
const labelList& faceToProc() const noexcept
{
return faceToProc_;
}
// Decompose
//- Decompose mesh
void decomposeMesh();
//- Write decomposition
bool writeDecomposition();
//- Cell-processor decomposition labels
const labelList& faceToProc() const
{
return faceToProc_;
}
};

View File

@ -5,5 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wmake $targetType reconstruct
wmake $targetType faReconstruct
#------------------------------------------------------------------------------

View File

@ -0,0 +1,4 @@
processorFaMeshes.C
faFieldReconstructor.C
LIB = $(FOAM_LIBBIN)/libfaReconstruct

View File

@ -0,0 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lfiniteVolume \
-lmeshTools

View File

@ -35,7 +35,7 @@ Author
SourceFiles
faFieldReconstructor.C
faFieldReconstructorReconstructFields.C
faFieldReconstructorFields.C
\*---------------------------------------------------------------------------*/
@ -194,7 +194,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "faFieldReconstructorReconstructFields.C"
# include "faFieldReconstructorFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -145,116 +145,4 @@ Foam::processorFaMeshes::processorFaMeshes
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Foam::fvMesh::readUpdateState Foam::processorFaMeshes::readUpdate()
// {
// fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
// forAll(databases_, procI)
// {
// // Check if any new meshes need to be read.
// fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
// /*
// if (procStat != fvMesh::UNCHANGED)
// {
// Info<< "Processor " << procI
// << " at time " << databases_[procI].timeName()
// << " detected mesh change " << procStat
// << endl;
// }
// */
// // Combine into overall mesh change status
// if (stat == fvMesh::UNCHANGED)
// {
// stat = procStat;
// }
// else
// {
// if (stat != procStat)
// {
// FatalErrorIn("processorFaMeshes::readUpdate()")
// << "Processor " << procI
// << " has a different polyMesh at time "
// << databases_[procI].timeName()
// << " compared to any previous processors." << nl
// << "Please check time " << databases_[procI].timeName()
// << " directories on all processors for consistent"
// << " mesh files."
// << exit(FatalError);
// }
// }
// }
// if
// (
// stat == fvMesh::TOPO_CHANGE
// || stat == fvMesh::TOPO_PATCH_CHANGE
// )
// {
// // Reread all meshes and addressing
// read();
// }
// return stat;
// }
// void Foam::processorFaMeshes::reconstructPoints(fvMesh& mesh)
// {
// // Read the field for all the processors
// PtrList<pointIOField> procsPoints(meshes_.size());
// forAll(meshes_, procI)
// {
// procsPoints.set
// (
// procI,
// new pointIOField
// (
// IOobject
// (
// "points",
// meshes_[procI].time().timeName(),
// polyMesh::meshSubDir,
// meshes_[procI],
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// )
// )
// );
// }
// // Create the new points
// vectorField newPoints(mesh.nPoints());
// forAll(meshes_, procI)
// {
// const vectorField& procPoints = procsPoints[procI];
// // Set the cell values in the reconstructed field
// const labelList& pointProcAddressingI = pointProcAddressing_[procI];
// if (pointProcAddressingI.size() != procPoints.size())
// {
// FatalErrorIn("processorFaMeshes")
// << "problem :"
// << " pointProcAddressingI:" << pointProcAddressingI.size()
// << " procPoints:" << procPoints.size()
// << abort(FatalError);
// }
// forAll(pointProcAddressingI, pointI)
// {
// newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
// }
// }
// mesh.movePoints(newPoints);
// mesh.write();
// }
// ************************************************************************* //

View File

@ -27,7 +27,7 @@ Class
Foam::processorFaMeshes
Description
Container for processor mesh addressing.
Container for finite-area processor mesh addressing.
Author
Zeljko Tukovic, FSB Zagreb
@ -41,8 +41,8 @@ SourceFiles
#define processorFaMeshes_H
#include "PtrList.H"
#include "fvMesh.H"
#include "faMesh.H"
#include "fvMesh.H"
#include "IOobjectList.H"
#include "labelIOList.H"
@ -100,29 +100,31 @@ public:
// Member Functions
//- Update the meshes based on the mesh files saved in
// time directories
// fvMesh::readUpdateState readUpdate();
//- Reconstruct point position after motion in parallel
// void reconstructPoints(faMesh& mesh);
const PtrList<faMesh>& meshes() const
{
return meshes_;
}
PtrList<faMesh>& meshes()
{
return meshes_;
}
const PtrList<labelIOList>& pointProcAddressing() const
{
return pointProcAddressing_;
}
PtrList<labelIOList>& edgeProcAddressing()
{
return edgeProcAddressing_;
}
const PtrList<labelIOList>& faceProcAddressing() const
{
return faceProcAddressing_;
}
const PtrList<labelIOList>& boundaryProcAddressing() const
{
return boundaryProcAddressing_;