mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: redistributePar support for finiteArea (#2436)
This commit is contained in:
committed by
Andrew Heather
parent
6644cf8ddb
commit
cc1e6c12bb
@ -1,7 +1,10 @@
|
||||
passivePositionParticleCloud.C
|
||||
|
||||
parLagrangianDistributor.C
|
||||
parLagrangianDistributorFields.C
|
||||
|
||||
parPointFieldDistributor.C
|
||||
parFaFieldDistributorCache.C
|
||||
parFvFieldDistributor.C
|
||||
parFvFieldDistributorFields.C
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "loadOrCreateMesh.H"
|
||||
#include "faMesh.H"
|
||||
#include "Pstream.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
@ -66,6 +67,26 @@ Foam::boolList Foam::haveMeshFile
|
||||
}
|
||||
|
||||
|
||||
void Foam::removeProcAddressing(const faMesh& mesh)
|
||||
{
|
||||
IOobject ioAddr
|
||||
(
|
||||
"procAddressing",
|
||||
mesh.facesInstance(),
|
||||
faMesh::meshSubDir,
|
||||
mesh.thisDb()
|
||||
);
|
||||
|
||||
for (const auto prefix : {"boundary", "edge", "face", "point"})
|
||||
{
|
||||
ioAddr.rename(prefix + word("ProcAddressing"));
|
||||
|
||||
const fileName procFile(ioAddr.objectPath());
|
||||
Foam::rm(procFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::removeProcAddressing(const polyMesh& mesh)
|
||||
{
|
||||
IOobject ioAddr
|
||||
|
||||
@ -45,6 +45,9 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class faMesh;
|
||||
|
||||
//- Check for availability of specified mesh file (default: "faces")
|
||||
boolList haveMeshFile
|
||||
(
|
||||
@ -55,6 +58,9 @@ boolList haveMeshFile
|
||||
);
|
||||
|
||||
|
||||
//- Remove procAddressing
|
||||
void removeProcAddressing(const faMesh& mesh);
|
||||
|
||||
//- Remove procAddressing
|
||||
void removeProcAddressing(const polyMesh& mesh);
|
||||
|
||||
|
||||
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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 "parFaFieldDistributorCache.H"
|
||||
|
||||
#include "areaFields.H"
|
||||
#include "edgeFields.H"
|
||||
#include "fieldsDistributor.H"
|
||||
#include "faMeshDistributor.H"
|
||||
#include "faMeshSubset.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::parFaFieldDistributorCache::redistributeAndWrite
|
||||
(
|
||||
const faMeshDistributor& distributor,
|
||||
PtrList<GeoField>& fields,
|
||||
const bool isWriteProc
|
||||
)
|
||||
{
|
||||
for (GeoField& fld : fields)
|
||||
{
|
||||
tmp<GeoField> tfld = distributor.distributeField(fld);
|
||||
|
||||
if (isWriteProc)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::parFaFieldDistributorCache::read
|
||||
(
|
||||
const Time& baseRunTime,
|
||||
const fileName& proc0CaseName,
|
||||
const bool decompose, // i.e. read from undecomposed case
|
||||
|
||||
const boolList& areaMeshOnProc,
|
||||
const fileName& areaMeshInstance,
|
||||
faMesh& mesh
|
||||
)
|
||||
{
|
||||
Time& runTime = const_cast<Time&>(mesh.time());
|
||||
const bool oldProcCase = runTime.processorCase();
|
||||
|
||||
autoPtr<faMeshSubset> subsetterPtr;
|
||||
|
||||
// Missing an area mesh somewhere?
|
||||
if (areaMeshOnProc.found(false))
|
||||
{
|
||||
// A zero-sized mesh with boundaries.
|
||||
// This is used to create zero-sized fields.
|
||||
subsetterPtr.reset(new faMeshSubset(mesh, zero{}));
|
||||
|
||||
// Deregister from polyMesh ...
|
||||
auto& obr = const_cast<objectRegistry&>
|
||||
(
|
||||
subsetterPtr->subMesh().thisDb()
|
||||
);
|
||||
|
||||
obr.checkOut(faMesh::typeName);
|
||||
obr.checkOut("faBoundaryMesh");
|
||||
obr.checkOut("faSchemes");
|
||||
obr.checkOut("faSolution");
|
||||
}
|
||||
|
||||
|
||||
// Get original objects (before incrementing time!)
|
||||
if (Pstream::master() && decompose)
|
||||
{
|
||||
runTime.caseName() = baseRunTime.caseName();
|
||||
runTime.processorCase(false);
|
||||
}
|
||||
IOobjectList objects(mesh.mesh(), runTime.timeName());
|
||||
if (Pstream::master() && decompose)
|
||||
{
|
||||
runTime.caseName() = proc0CaseName;
|
||||
runTime.processorCase(oldProcCase);
|
||||
}
|
||||
|
||||
Info<< "From time " << runTime.timeName()
|
||||
<< " mesh:" << mesh.mesh().objectRegistry::objectRelPath()
|
||||
<< " have objects:" << objects.names() << endl;
|
||||
|
||||
if (Pstream::master() && decompose)
|
||||
{
|
||||
runTime.caseName() = baseRunTime.caseName();
|
||||
runTime.processorCase(false);
|
||||
}
|
||||
|
||||
#undef doFieldReading
|
||||
#define doFieldReading(Storage) \
|
||||
fieldsDistributor::readFields \
|
||||
( \
|
||||
areaMeshOnProc, mesh, subsetterPtr, objects, Storage, \
|
||||
true /* (deregister field) */ \
|
||||
);
|
||||
|
||||
// areaFields
|
||||
doFieldReading(scalarAreaFields_);
|
||||
doFieldReading(vectorAreaFields_);
|
||||
doFieldReading(sphericalTensorAreaFields_);
|
||||
doFieldReading(symmTensorAreaFields_);
|
||||
doFieldReading(tensorAreaFields_);
|
||||
|
||||
// edgeFields
|
||||
doFieldReading(scalarEdgeFields_);
|
||||
doFieldReading(vectorEdgeFields_);
|
||||
doFieldReading(tensorEdgeFields_);
|
||||
doFieldReading(sphericalTensorEdgeFields_);
|
||||
doFieldReading(symmTensorEdgeFields_);
|
||||
#undef doFieldReading
|
||||
}
|
||||
|
||||
|
||||
void Foam::parFaFieldDistributorCache::redistributeAndWrite
|
||||
(
|
||||
const faMeshDistributor& distributor,
|
||||
const bool isWriteProc
|
||||
)
|
||||
{
|
||||
redistributeAndWrite(distributor, scalarAreaFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, vectorAreaFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, sphericalTensorAreaFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, symmTensorAreaFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, tensorAreaFields_, isWriteProc);
|
||||
|
||||
redistributeAndWrite(distributor, scalarEdgeFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, vectorEdgeFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, sphericalTensorEdgeFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, symmTensorEdgeFields_, isWriteProc);
|
||||
redistributeAndWrite(distributor, tensorEdgeFields_, isWriteProc);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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/>.
|
||||
|
||||
Class
|
||||
Foam::parFaFieldDistributorCache
|
||||
|
||||
Description
|
||||
Simple container to manage read/write, redistribute finiteArea fields.
|
||||
|
||||
SourceFiles
|
||||
parFaFieldDistributorCache.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_parFaFieldDistributorCache_H
|
||||
#define Foam_parFaFieldDistributorCache_H
|
||||
|
||||
#include "faMesh.H"
|
||||
#include "faMeshDistributor.H"
|
||||
#include "areaFieldsFwd.H"
|
||||
#include "edgeFieldsFwd.H"
|
||||
#include "PtrList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class parFaFieldDistributorCache Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class parFaFieldDistributorCache
|
||||
{
|
||||
// Private Data
|
||||
|
||||
#undef declareField
|
||||
#define declareField(Type) \
|
||||
PtrList<GeometricField<Type, faPatchField, areaMesh>> Type##AreaFields_; \
|
||||
PtrList<GeometricField<Type, faePatchField, edgeMesh>> Type##EdgeFields_;
|
||||
|
||||
declareField(scalar);
|
||||
declareField(vector);
|
||||
declareField(sphericalTensor);
|
||||
declareField(symmTensor);
|
||||
declareField(tensor);
|
||||
#undef declareField
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Redistribute and write fields of given type (file-scope use)
|
||||
template<class GeoField>
|
||||
static void redistributeAndWrite
|
||||
(
|
||||
const faMeshDistributor& distributor,
|
||||
PtrList<GeoField>& fields,
|
||||
const bool isWriteProc
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- No copy construct
|
||||
parFaFieldDistributorCache(const parFaFieldDistributorCache&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const parFaFieldDistributorCache&) = delete;
|
||||
|
||||
//- Default construct
|
||||
parFaFieldDistributorCache() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read distributed fields
|
||||
void read
|
||||
(
|
||||
const Time& baseRunTime,
|
||||
const fileName& proc0CaseName,
|
||||
const bool decompose, // i.e. read from undecomposed case
|
||||
|
||||
const boolList& areaMeshOnProc,
|
||||
const fileName& areaMeshInstance,
|
||||
faMesh& mesh
|
||||
);
|
||||
|
||||
void redistributeAndWrite
|
||||
(
|
||||
const faMeshDistributor& distributor,
|
||||
const bool isWriteProc
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user