mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add area-name handling for faMesh decompose/reconstruct (#3419)
- using labelUList addressing - support direct handling of pointers (as well as autoPtr)
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
processorFaMeshes.C
|
||||
faFieldReconstructor.C
|
||||
faMeshReconstructor.C
|
||||
processorFaMeshes.cxx
|
||||
faFieldReconstructor.cxx
|
||||
faMeshReconstructor.cxx
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfaReconstruct
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,16 +35,16 @@ Author
|
||||
Hrvoje Jasak, Wikki Ltd.
|
||||
|
||||
SourceFiles
|
||||
faFieldReconstructor.C
|
||||
faFieldReconstructorTemplates.C
|
||||
faFieldReconstructor.cxx
|
||||
faFieldReconstructor.txx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_faFieldReconstructor_H
|
||||
#define Foam_faFieldReconstructor_H
|
||||
|
||||
#include "PtrList.H"
|
||||
#include "faMesh.H"
|
||||
#include "PtrList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "faPatchFieldMapper.H"
|
||||
#include "labelIOList.H"
|
||||
@ -63,19 +63,19 @@ class faFieldReconstructor
|
||||
// Private Data
|
||||
|
||||
//- Reconstructed mesh reference
|
||||
faMesh& mesh_;
|
||||
const faMesh& mesh_;
|
||||
|
||||
//- List of processor meshes
|
||||
const PtrList<faMesh>& procMeshes_;
|
||||
const UPtrList<faMesh>& procMeshes_;
|
||||
|
||||
//- List of processor edge addressing lists
|
||||
const PtrList<labelIOList>& edgeProcAddressing_;
|
||||
const UPtrList<labelIOList>& edgeProcAddressing_;
|
||||
|
||||
//- List of processor face addressing lists
|
||||
const PtrList<labelIOList>& faceProcAddressing_;
|
||||
const UPtrList<labelIOList>& faceProcAddressing_;
|
||||
|
||||
//- List of processor boundary addressing lists
|
||||
const PtrList<labelIOList>& boundaryProcAddressing_;
|
||||
const UPtrList<labelIOList>& boundaryProcAddressing_;
|
||||
|
||||
//- Number of fields reconstructed
|
||||
label nReconstructed_;
|
||||
@ -157,11 +157,11 @@ public:
|
||||
//- Construct from components
|
||||
faFieldReconstructor
|
||||
(
|
||||
faMesh& mesh, // Target mesh
|
||||
const PtrList<faMesh>& procMeshes, // Source meshes
|
||||
const PtrList<labelIOList>& edgeProcAddressing,
|
||||
const PtrList<labelIOList>& faceProcAddressing,
|
||||
const PtrList<labelIOList>& boundaryProcAddressing
|
||||
const faMesh& mesh, // Target mesh
|
||||
const UPtrList<faMesh>& procMeshes, // Source meshes
|
||||
const UPtrList<labelIOList>& edgeProcAddressing,
|
||||
const UPtrList<labelIOList>& faceProcAddressing,
|
||||
const UPtrList<labelIOList>& boundaryProcAddressing
|
||||
);
|
||||
|
||||
|
||||
@ -179,7 +179,7 @@ public:
|
||||
reconstructField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const PtrList<GeometricField<Type, faPatchField, areaMesh>>&
|
||||
const UPtrList<GeometricField<Type, faPatchField, areaMesh>>&
|
||||
) const;
|
||||
|
||||
//- Read and reconstruct area field
|
||||
@ -194,7 +194,7 @@ public:
|
||||
reconstructField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const PtrList<GeometricField<Type, faePatchField, edgeMesh>>&
|
||||
const UPtrList<GeometricField<Type, faePatchField, edgeMesh>>&
|
||||
) const;
|
||||
|
||||
//- Read and reconstruct edge field
|
||||
@ -252,7 +252,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "faFieldReconstructorTemplates.C"
|
||||
# include "faFieldReconstructor.txx"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,11 +39,11 @@ int Foam::faFieldReconstructor::verbose_ = 1;
|
||||
|
||||
Foam::faFieldReconstructor::faFieldReconstructor
|
||||
(
|
||||
faMesh& mesh,
|
||||
const PtrList<faMesh>& procMeshes,
|
||||
const PtrList<labelIOList>& edgeProcAddressing,
|
||||
const PtrList<labelIOList>& faceProcAddressing,
|
||||
const PtrList<labelIOList>& boundaryProcAddressing
|
||||
const faMesh& mesh,
|
||||
const UPtrList<faMesh>& procMeshes,
|
||||
const UPtrList<labelIOList>& edgeProcAddressing,
|
||||
const UPtrList<labelIOList>& faceProcAddressing,
|
||||
const UPtrList<labelIOList>& boundaryProcAddressing
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
@ -28,7 +28,6 @@ License
|
||||
|
||||
#include "faFieldReconstructor.H"
|
||||
#include "Time.H"
|
||||
#include "PtrList.H"
|
||||
#include "emptyFaPatch.H"
|
||||
#include "faPatchFields.H"
|
||||
#include "faePatchFields.H"
|
||||
@ -40,7 +39,7 @@ Foam::tmp<Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh>>
|
||||
Foam::faFieldReconstructor::reconstructField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const PtrList<GeometricField<Type, faPatchField, areaMesh>>& procFields
|
||||
const UPtrList<GeometricField<Type, faPatchField, areaMesh>>& procFields
|
||||
) const
|
||||
{
|
||||
// Create the internalField
|
||||
@ -271,7 +270,7 @@ Foam::tmp<Foam::GeometricField<Type, Foam::faePatchField, Foam::edgeMesh>>
|
||||
Foam::faFieldReconstructor::reconstructField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const PtrList<GeometricField<Type, faePatchField, edgeMesh>>& procFields
|
||||
const UPtrList<GeometricField<Type, faePatchField, edgeMesh>>& procFields
|
||||
) const
|
||||
{
|
||||
// Create the internalField
|
||||
@ -40,7 +40,7 @@ Description
|
||||
but caution should be exercised before attempting large operations.
|
||||
|
||||
SourceFiles
|
||||
faMeshReconstructor.C
|
||||
faMeshReconstructor.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -214,10 +214,10 @@ public:
|
||||
static void writeAddressing
|
||||
(
|
||||
const IOobject& io,
|
||||
const labelList& faBoundaryProcAddr,
|
||||
const labelList& faFaceProcAddr,
|
||||
const labelList& faPointProcAddr,
|
||||
const labelList& faEdgeProcAddr
|
||||
const labelUList& faBoundaryProcAddr,
|
||||
const labelUList& faFaceProcAddr,
|
||||
const labelUList& faPointProcAddr,
|
||||
const labelUList& faEdgeProcAddr
|
||||
);
|
||||
|
||||
//- Write proc addressing at the polyMesh faceInstances time
|
||||
|
||||
@ -56,15 +56,7 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
faBoundaryProcAddr_ = identity(nPatches);
|
||||
|
||||
// Mark processor patches
|
||||
for
|
||||
(
|
||||
label patchi = procMesh_.boundary().nNonProcessor();
|
||||
patchi < nPatches;
|
||||
++patchi
|
||||
)
|
||||
{
|
||||
faBoundaryProcAddr_[patchi] = -1;
|
||||
}
|
||||
faBoundaryProcAddr_.slice(procMesh_.boundary().nNonProcessor()) = -1;
|
||||
|
||||
|
||||
// ------------------
|
||||
@ -112,13 +104,13 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
|
||||
PstreamBuffers pBufs;
|
||||
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
// Determine the respective local portions of the global ordering
|
||||
|
||||
labelList procTargets(globalFaceNum.totalSize());
|
||||
|
||||
for (const label proci : Pstream::allProcs())
|
||||
for (const label proci : UPstream::allProcs())
|
||||
{
|
||||
labelList::subList
|
||||
(
|
||||
@ -139,7 +131,7 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
}
|
||||
|
||||
// Send the local portions
|
||||
for (const int proci : Pstream::subProcs())
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
SubList<label> localOrder
|
||||
(
|
||||
@ -158,11 +150,11 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
|
||||
pBufs.finishedScatters();
|
||||
|
||||
if (!Pstream::master())
|
||||
if (!UPstream::master())
|
||||
{
|
||||
labelList localOrder;
|
||||
|
||||
UIPstream fromProc(Pstream::masterNo(), pBufs);
|
||||
UIPstream fromProc(UPstream::masterNo(), pBufs);
|
||||
fromProc >> localOrder;
|
||||
|
||||
faFaceProcAddr_ = labelList(faFaceProcAddr_, localOrder);
|
||||
@ -235,7 +227,7 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
tmpFaces,
|
||||
singlePatchProcFaces,
|
||||
UPstream::msgType(),
|
||||
Pstream::commsTypes::scheduled
|
||||
UPstream::commsTypes::scheduled
|
||||
);
|
||||
|
||||
globalPointsPtr().gather
|
||||
@ -531,11 +523,11 @@ void Foam::faMeshReconstructor::createMesh()
|
||||
|
||||
// Serial mesh - no parallel communication
|
||||
|
||||
const bool oldParRun = Pstream::parRun(false);
|
||||
const bool oldParRun = UPstream::parRun(false);
|
||||
|
||||
completeMesh.addFaPatches(completePatches);
|
||||
|
||||
Pstream::parRun(oldParRun); // Restore parallel state
|
||||
UPstream::parRun(oldParRun); // Restore parallel state
|
||||
}
|
||||
|
||||
|
||||
@ -550,7 +542,7 @@ Foam::faMeshReconstructor::faMeshReconstructor
|
||||
procMesh_(procMesh),
|
||||
errors_(0)
|
||||
{
|
||||
if (!Pstream::parRun())
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Can only be called in parallel!!" << nl
|
||||
@ -612,7 +604,7 @@ Foam::faMeshReconstructor::faMeshReconstructor
|
||||
procMesh_(procMesh),
|
||||
errors_(0)
|
||||
{
|
||||
if (!Pstream::parRun())
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Can only be called in parallel!!" << nl
|
||||
@ -681,10 +673,10 @@ void Foam::faMeshReconstructor::writeAddressing() const
|
||||
void Foam::faMeshReconstructor::writeAddressing
|
||||
(
|
||||
const IOobject& io,
|
||||
const labelList& faBoundaryProcAddr,
|
||||
const labelList& faFaceProcAddr,
|
||||
const labelList& faPointProcAddr,
|
||||
const labelList& faEdgeProcAddr
|
||||
const labelUList& faBoundaryProcAddr,
|
||||
const labelUList& faFaceProcAddr,
|
||||
const labelUList& faPointProcAddr,
|
||||
const labelUList& faEdgeProcAddr
|
||||
)
|
||||
{
|
||||
// Write copies
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,7 +34,7 @@ Author
|
||||
Zeljko Tukovic, FSB Zagreb
|
||||
|
||||
SourceFiles
|
||||
processorFaMeshes.C
|
||||
processorFaMeshes.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -59,8 +60,11 @@ class processorFaMeshes
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- List of processor finite volume meshes
|
||||
const UPtrList<fvMesh>& fvMeshes_;
|
||||
//- The area-region name
|
||||
const word areaName_;
|
||||
|
||||
//- List of processor volume meshes (could/should be polyMesh)
|
||||
const UPtrList<fvMesh>& volMeshes_;
|
||||
|
||||
//- List of processor finite area meshes
|
||||
PtrList<faMesh> meshes_;
|
||||
@ -95,16 +99,30 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicit processorFaMeshes(const UPtrList<fvMesh>& procFvMeshes);
|
||||
explicit processorFaMeshes
|
||||
(
|
||||
//! The processor volume meshes (could/should be polyMesh)
|
||||
const UPtrList<fvMesh>& procVolMeshes,
|
||||
//! The area-region name
|
||||
const word& areaName = word()
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The area-region name
|
||||
const word& name() const noexcept { return areaName_; }
|
||||
|
||||
//- The number of processors used
|
||||
label nProcs() const noexcept { return volMeshes_.size(); }
|
||||
|
||||
//- The processor finite-area meshes
|
||||
const PtrList<faMesh>& meshes() const noexcept
|
||||
{
|
||||
return meshes_;
|
||||
}
|
||||
|
||||
//- The processor finite-area meshes
|
||||
PtrList<faMesh>& meshes() noexcept
|
||||
{
|
||||
return meshes_;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,17 +37,23 @@ void Foam::processorFaMeshes::read()
|
||||
// Make sure to clear (and hence unregister) any previously loaded meshes
|
||||
// and fields
|
||||
|
||||
boundaryProcAddressing_.free();
|
||||
faceProcAddressing_.free();
|
||||
edgeProcAddressing_.free();
|
||||
pointProcAddressing_.free();
|
||||
meshes_.free();
|
||||
const label numProc = volMeshes_.size();
|
||||
|
||||
boundaryProcAddressing_.resize_null(numProc);
|
||||
faceProcAddressing_.resize_null(numProc);
|
||||
edgeProcAddressing_.resize_null(numProc);
|
||||
pointProcAddressing_.resize_null(numProc);
|
||||
meshes_.resize_null(numProc);
|
||||
|
||||
forAll(fvMeshes_, proci)
|
||||
for (label proci = 0; proci < numProc; ++proci)
|
||||
{
|
||||
// Construct from polyMesh IO information
|
||||
meshes_.emplace_set(proci, fvMeshes_[proci]);
|
||||
|
||||
meshes_.set
|
||||
(
|
||||
proci,
|
||||
new faMesh(areaName_, volMeshes_[proci])
|
||||
);
|
||||
|
||||
// Read the addressing information
|
||||
|
||||
@ -91,15 +97,12 @@ void Foam::processorFaMeshes::read()
|
||||
|
||||
Foam::processorFaMeshes::processorFaMeshes
|
||||
(
|
||||
const UPtrList<fvMesh>& procFvMeshes
|
||||
const UPtrList<fvMesh>& procVolMeshes,
|
||||
const word& areaName
|
||||
)
|
||||
:
|
||||
fvMeshes_(procFvMeshes),
|
||||
meshes_(procFvMeshes.size()),
|
||||
pointProcAddressing_(meshes_.size()),
|
||||
edgeProcAddressing_(meshes_.size()),
|
||||
faceProcAddressing_(meshes_.size()),
|
||||
boundaryProcAddressing_(meshes_.size())
|
||||
areaName_(areaName.empty() ? polyMesh::defaultRegion : areaName),
|
||||
volMeshes_(procVolMeshes)
|
||||
{
|
||||
read();
|
||||
}
|
||||
Reference in New Issue
Block a user