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:
@ -32,7 +32,6 @@ License
|
||||
#include "edgeFields.H"
|
||||
#include "fileOperation.H"
|
||||
#include "BitOps.H"
|
||||
#include "ListOps.H"
|
||||
#include "polyMesh.H"
|
||||
#include "processorFaPatch.H"
|
||||
|
||||
@ -432,12 +431,12 @@ Foam::faMeshTools::loadOrCreateMesh_impl
|
||||
}
|
||||
else if (readHandlerPtr && haveLocalMesh)
|
||||
{
|
||||
const label numProcs = UPstream::nProcs(UPstream::worldComm);
|
||||
const label numWorldProcs = UPstream::nProcs(UPstream::worldComm);
|
||||
const label realWorldComm = UPstream::worldComm;
|
||||
|
||||
const labelList meshProcIds(BitOps::sortedToc(haveMesh));
|
||||
|
||||
UPstream::communicator newCommunicator;
|
||||
const label oldWorldComm = UPstream::commWorld();
|
||||
|
||||
auto& readHandler = *readHandlerPtr;
|
||||
auto oldHandler = fileOperation::fileHandler(readHandler);
|
||||
@ -447,13 +446,13 @@ Foam::faMeshTools::loadOrCreateMesh_impl
|
||||
// Instead allocate a new communicator for everyone with a mesh
|
||||
|
||||
// Comparing global ranks in the communicator.
|
||||
|
||||
if (ListOps::equal(meshProcIds, UPstream::procID(fileHandler().comm())))
|
||||
if (UPstream::sameProcs(fileHandler().comm(), meshProcIds))
|
||||
{
|
||||
const_cast<fileOperation&>(fileHandler()).nProcs(numWorldProcs);
|
||||
// Can use the handler communicator as is.
|
||||
UPstream::commWorld(fileHandler().comm());
|
||||
}
|
||||
else if (UPstream::nProcs(fileHandler().comm()) != numProcs)
|
||||
else if (UPstream::nProcs(fileHandler().comm()) != numWorldProcs)
|
||||
{
|
||||
// Need a new communicator for the fileHandler.
|
||||
|
||||
@ -468,10 +467,10 @@ Foam::faMeshTools::loadOrCreateMesh_impl
|
||||
meshPtr = autoPtr<faMesh>::New(areaName, pMesh, false);
|
||||
|
||||
readHandler = fileOperation::fileHandler(oldHandler);
|
||||
UPstream::commWorld(oldWorldComm);
|
||||
UPstream::commWorld(realWorldComm);
|
||||
|
||||
// Reset mesh communicator to the real world comm
|
||||
meshPtr().comm() = UPstream::commWorld();
|
||||
meshPtr().comm() = realWorldComm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,100 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki 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::faPatchFieldMapperPatchRef
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faPatchFieldMapperPatchRef_H
|
||||
#define faPatchFieldMapperPatchRef_H
|
||||
|
||||
#include "faPatchFieldMapper.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faPatchFieldMapperPatchRef Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faPatchFieldMapperPatchRef
|
||||
:
|
||||
public faPatchFieldMapper
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const faPatch& sourcePatch_;
|
||||
const faPatch& targetPatch_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
faPatchFieldMapperPatchRef(const faPatchFieldMapperPatchRef&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const faPatchFieldMapperPatchRef&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
faPatchFieldMapperPatchRef(const faPatch& source, const faPatch& target)
|
||||
:
|
||||
sourcePatch_(source),
|
||||
targetPatch_(target)
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
const faPatch& sourcePatch() const
|
||||
{
|
||||
return sourcePatch_;
|
||||
}
|
||||
|
||||
const faPatch& targetPatch() const
|
||||
{
|
||||
return targetPatch_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -390,7 +390,7 @@ Foam::labelList Foam::fvMeshTools::removeEmptyPatches
|
||||
if (keepPatches.found(pp.name()))
|
||||
{
|
||||
newToOld[newI] = patchI;
|
||||
oldToNew[patchI] = newI++;
|
||||
oldToNew[patchI] = newI++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -777,7 +777,7 @@ Foam::fvMeshTools::loadOrCreateMeshImpl
|
||||
|
||||
// Patch types
|
||||
// ~~~~~~~~~~~
|
||||
// Read and scatter master patches (without reading master mesh!)
|
||||
// Read and broadcast master patches (without reading master mesh!)
|
||||
|
||||
PtrList<entry> patchEntries;
|
||||
if (UPstream::master())
|
||||
@ -951,10 +951,12 @@ Foam::fvMeshTools::loadOrCreateMeshImpl
|
||||
}
|
||||
else if (readHandlerPtr && haveLocalMesh)
|
||||
{
|
||||
const label numWorldProcs = UPstream::nProcs(UPstream::worldComm);
|
||||
const label realWorldComm = UPstream::worldComm;
|
||||
|
||||
const labelList meshProcIds(BitOps::sortedToc(haveMesh));
|
||||
|
||||
UPstream::communicator newCommunicator;
|
||||
const label oldWorldComm = UPstream::commWorld();
|
||||
|
||||
auto& readHandler = *readHandlerPtr;
|
||||
auto oldHandler = fileOperation::fileHandler(readHandler);
|
||||
@ -963,31 +965,14 @@ Foam::fvMeshTools::loadOrCreateMeshImpl
|
||||
// only include the ranks for the current IO rank.
|
||||
// Instead allocate a new communicator for everyone with a mesh
|
||||
|
||||
const auto& handlerProcIds = UPstream::procID(fileHandler().comm());
|
||||
|
||||
// Comparing global ranks in the communicator.
|
||||
// Use std::equal for the List<label> vs List<int> comparison
|
||||
|
||||
if
|
||||
(
|
||||
meshProcIds.size() == handlerProcIds.size()
|
||||
&& std::equal
|
||||
(
|
||||
meshProcIds.cbegin(),
|
||||
meshProcIds.cend(),
|
||||
handlerProcIds.cbegin()
|
||||
)
|
||||
)
|
||||
if (UPstream::sameProcs(fileHandler().comm(), meshProcIds))
|
||||
{
|
||||
const_cast<fileOperation&>(fileHandler()).nProcs(UPstream::nProcs(oldWorldComm));
|
||||
const_cast<fileOperation&>(fileHandler()).nProcs(numWorldProcs);
|
||||
// Can use the handler communicator as is.
|
||||
UPstream::commWorld(fileHandler().comm());
|
||||
}
|
||||
else if
|
||||
(
|
||||
UPstream::nProcs(fileHandler().comm())
|
||||
!= UPstream::nProcs(UPstream::worldComm)
|
||||
)
|
||||
else if (UPstream::nProcs(fileHandler().comm()) != numWorldProcs)
|
||||
{
|
||||
// Need a new communicator for the fileHandler.
|
||||
|
||||
@ -1002,10 +987,10 @@ Foam::fvMeshTools::loadOrCreateMeshImpl
|
||||
meshPtr = autoPtr<fvMesh>::New(io, false);
|
||||
|
||||
readHandler = fileOperation::fileHandler(oldHandler);
|
||||
UPstream::commWorld(oldWorldComm);
|
||||
UPstream::commWorld(realWorldComm);
|
||||
|
||||
// Reset mesh communicator to the real world comm
|
||||
meshPtr().polyMesh::comm() = UPstream::commWorld();
|
||||
meshPtr().polyMesh::comm() = realWorldComm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -218,7 +218,7 @@ public:
|
||||
static autoPtr<mapDistributePolyMesh> readProcAddressing
|
||||
(
|
||||
const fvMesh& procMesh,
|
||||
const autoPtr<fvMesh>& baseMeshPtr
|
||||
const fvMesh* baseMeshPtr
|
||||
);
|
||||
|
||||
//- Write addressing if decomposing (1 to many) or reconstructing
|
||||
@ -227,10 +227,23 @@ public:
|
||||
(
|
||||
const fvMesh& procMesh,
|
||||
const mapDistributePolyMesh& map,
|
||||
//! running in decompose vs reconstruct mode
|
||||
const bool decompose,
|
||||
const fileName& writeHandlerInstance,
|
||||
//! the instance for maps
|
||||
const fileName& writeInstance,
|
||||
//! The output file handler
|
||||
refPtr<fileOperation>& writeHandler
|
||||
);
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Read procAddressing components (reconstructing)
|
||||
static autoPtr<mapDistributePolyMesh> readProcAddressing
|
||||
(
|
||||
const fvMesh& procMesh,
|
||||
const autoPtr<fvMesh>& baseMeshPtr
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,7 +45,7 @@ namespace Foam
|
||||
static autoPtr<mapDistributePolyMesh> createReconstructMap
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const autoPtr<fvMesh>& baseMeshPtr,
|
||||
const fvMesh* baseMeshPtr,
|
||||
const labelList& cellProcAddressing,
|
||||
const labelList& faceProcAddressing,
|
||||
const labelList& pointProcAddressing,
|
||||
@ -109,7 +109,7 @@ static autoPtr<mapDistributePolyMesh> createReconstructMap
|
||||
|
||||
|
||||
// NB: can only have a reconstruct on master!
|
||||
if (Pstream::master() && baseMeshPtr && baseMeshPtr->nCells())
|
||||
if (UPstream::master() && baseMeshPtr && baseMeshPtr->nCells())
|
||||
{
|
||||
const fvMesh& baseMesh = *baseMeshPtr;
|
||||
|
||||
@ -219,7 +219,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh>
|
||||
Foam::fvMeshTools::readProcAddressing
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const autoPtr<fvMesh>& baseMeshPtr
|
||||
const fvMesh* baseMeshPtr
|
||||
)
|
||||
{
|
||||
// Processor-local reading
|
||||
@ -303,7 +303,7 @@ void Foam::fvMeshTools::writeProcAddressing
|
||||
const fvMesh& mesh,
|
||||
const mapDistributePolyMesh& map,
|
||||
const bool decompose,
|
||||
const fileName& writeHandlerInstance,
|
||||
const fileName& writeInstance,
|
||||
refPtr<fileOperation>& writeHandler
|
||||
)
|
||||
{
|
||||
@ -431,21 +431,22 @@ void Foam::fvMeshTools::writeProcAddressing
|
||||
// as instance so instead of e.g. 'celllMap.write()' directly call
|
||||
// the chosen file-handler.
|
||||
|
||||
if (!writeInstance.empty())
|
||||
{
|
||||
cellMap.instance() = writeInstance;
|
||||
faceMap.instance() = writeInstance;
|
||||
pointMap.instance() = writeInstance;
|
||||
patchMap.instance() = writeInstance;
|
||||
}
|
||||
|
||||
const auto& tm = cellMap.time();
|
||||
const IOstreamOption opt(tm.writeFormat(), tm.writeCompression());
|
||||
const IOstreamOption opt(tm.writeStreamOption());
|
||||
{
|
||||
auto oldHandler = fileOperation::fileHandler(writeHandler);
|
||||
|
||||
cellMap.instance() = writeHandlerInstance;
|
||||
const bool cellOk = fileHandler().writeObject(cellMap, opt, true);
|
||||
|
||||
faceMap.instance() = writeHandlerInstance;
|
||||
const bool faceOk = fileHandler().writeObject(faceMap, opt, true);
|
||||
|
||||
pointMap.instance() = writeHandlerInstance;
|
||||
const bool pointOk = fileHandler().writeObject(pointMap, opt, true);
|
||||
|
||||
patchMap.instance() = writeHandlerInstance;
|
||||
const bool patchOk = fileHandler().writeObject(patchMap, opt, true);
|
||||
|
||||
writeHandler = fileOperation::fileHandler(oldHandler);
|
||||
@ -463,4 +464,17 @@ void Foam::fvMeshTools::writeProcAddressing
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Housekeeping * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::mapDistributePolyMesh>
|
||||
Foam::fvMeshTools::readProcAddressing
|
||||
(
|
||||
const fvMesh& procMesh,
|
||||
const autoPtr<fvMesh>& baseMeshPtr
|
||||
)
|
||||
{
|
||||
return readProcAddressing(procMesh, baseMeshPtr.get());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
faFieldDecomposer.C
|
||||
faFieldDecomposerCache.C
|
||||
faFieldDecomposer.cxx
|
||||
faFieldDecomposerCache.cxx
|
||||
|
||||
faMeshDecomposition.C
|
||||
faMeshDecomposition.cxx
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfaDecompose
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,9 +35,9 @@ Author
|
||||
Hrvoje Jasak, Wikki Ltd.
|
||||
|
||||
SourceFiles
|
||||
faFieldDecomposer.C
|
||||
fvFieldDecomposerCache.C
|
||||
faFieldDecomposerTemplates.C
|
||||
faFieldDecomposer.cxx
|
||||
faFieldDecomposer.txx
|
||||
fvFieldDecomposerCache.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -90,9 +90,9 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
label size() const
|
||||
label size() const noexcept
|
||||
{
|
||||
return directAddressing_.size();
|
||||
}
|
||||
@ -102,7 +102,7 @@ public:
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
bool direct() const noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -112,7 +112,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelUList& directAddressing() const
|
||||
const labelUList& directAddressing() const noexcept
|
||||
{
|
||||
return directAddressing_;
|
||||
}
|
||||
@ -144,7 +144,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
label size() const
|
||||
label size() const noexcept
|
||||
{
|
||||
return directAddressing_.size();
|
||||
}
|
||||
@ -154,7 +154,7 @@ public:
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
bool direct() const noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -164,7 +164,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelUList& directAddressing() const
|
||||
const labelUList& directAddressing() const noexcept
|
||||
{
|
||||
return directAddressing_;
|
||||
}
|
||||
@ -192,7 +192,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
label size() const
|
||||
label size() const noexcept
|
||||
{
|
||||
return addressing_.size();
|
||||
}
|
||||
@ -202,7 +202,7 @@ public:
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
bool direct() const noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -212,12 +212,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelListList& addressing() const
|
||||
const labelListList& addressing() const noexcept
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
const scalarListList& weights() const
|
||||
const scalarListList& weights() const noexcept
|
||||
{
|
||||
return weights_;
|
||||
}
|
||||
@ -232,13 +232,13 @@ private:
|
||||
const faMesh& procMesh_;
|
||||
|
||||
//- Reference to edge addressing
|
||||
const labelList& edgeAddressing_;
|
||||
const labelUList& edgeAddressing_;
|
||||
|
||||
//- Reference to face addressing
|
||||
const labelList& faceAddressing_;
|
||||
const labelUList& faceAddressing_;
|
||||
|
||||
//- Reference to boundary addressing
|
||||
const labelList& boundaryAddressing_;
|
||||
const labelUList& boundaryAddressing_;
|
||||
|
||||
//- List of patch field decomposers
|
||||
PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
|
||||
@ -270,11 +270,11 @@ public:
|
||||
//- Construct without mappers, added later with reset()
|
||||
faFieldDecomposer
|
||||
(
|
||||
const Foam::zero,
|
||||
Foam::zero,
|
||||
const faMesh& procMesh, // Target mesh
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
const labelUList& edgeAddressing,
|
||||
const labelUList& faceAddressing,
|
||||
const labelUList& boundaryAddressing
|
||||
);
|
||||
|
||||
//- Construct from components using information from the complete mesh
|
||||
@ -282,9 +282,9 @@ public:
|
||||
(
|
||||
const faMesh& completeMesh, // Source mesh
|
||||
const faMesh& procMesh, // Target mesh
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
const labelUList& edgeAddressing,
|
||||
const labelUList& faceAddressing,
|
||||
const labelUList& boundaryAddressing
|
||||
);
|
||||
|
||||
//- Construct from components without the complete mesh
|
||||
@ -292,15 +292,15 @@ public:
|
||||
(
|
||||
// Information about the complete mesh
|
||||
const label nTotalFaces,
|
||||
const List<labelRange>& boundaryRanges,
|
||||
const UList<labelRange>& boundaryRanges,
|
||||
const labelUList& edgeOwner,
|
||||
const labelUList& edgeNeigbour,
|
||||
|
||||
// Addressing for processor mesh
|
||||
const faMesh& procMesh, // Target mesh
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
const labelUList& edgeAddressing,
|
||||
const labelUList& faceAddressing,
|
||||
const labelUList& boundaryAddressing
|
||||
);
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- True if no mappers have been allocated
|
||||
bool empty() const;
|
||||
bool empty() const noexcept;
|
||||
|
||||
//- Remove all mappers
|
||||
void clear();
|
||||
@ -323,7 +323,7 @@ public:
|
||||
void reset
|
||||
(
|
||||
const label nTotalFaces,
|
||||
const List<labelRange>& boundaryRanges,
|
||||
const UList<labelRange>& boundaryRanges,
|
||||
const labelUList& edgeOwner,
|
||||
const labelUList& edgeNeigbour
|
||||
);
|
||||
@ -448,7 +448,7 @@ public:
|
||||
//- Supports reading/sending fields
|
||||
void readAllFields
|
||||
(
|
||||
const boolList& haveMeshOnProc,
|
||||
const boolUList& haveMeshOnProc,
|
||||
const faMeshSubset* subsetter,
|
||||
const faMesh& mesh,
|
||||
IOobjectList& objects
|
||||
@ -470,7 +470,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "faFieldDecomposerTemplates.C"
|
||||
#include "faFieldDecomposer.txx"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -126,21 +126,17 @@ processorEdgePatchFieldDecomposer
|
||||
|
||||
Foam::faFieldDecomposer::faFieldDecomposer
|
||||
(
|
||||
const Foam::zero,
|
||||
Foam::zero,
|
||||
const faMesh& procMesh,
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
const labelUList& edgeAddressing,
|
||||
const labelUList& faceAddressing,
|
||||
const labelUList& boundaryAddressing
|
||||
)
|
||||
:
|
||||
procMesh_(procMesh),
|
||||
edgeAddressing_(edgeAddressing),
|
||||
faceAddressing_(faceAddressing),
|
||||
boundaryAddressing_(boundaryAddressing),
|
||||
// Mappers
|
||||
patchFieldDecomposerPtrs_(),
|
||||
processorAreaPatchFieldDecomposerPtrs_(),
|
||||
processorEdgePatchFieldDecomposerPtrs_()
|
||||
boundaryAddressing_(boundaryAddressing)
|
||||
{}
|
||||
|
||||
|
||||
@ -148,14 +144,14 @@ Foam::faFieldDecomposer::faFieldDecomposer
|
||||
(
|
||||
const faMesh& completeMesh,
|
||||
const faMesh& procMesh,
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
const labelUList& edgeAddressing,
|
||||
const labelUList& faceAddressing,
|
||||
const labelUList& boundaryAddressing
|
||||
)
|
||||
:
|
||||
faFieldDecomposer
|
||||
(
|
||||
zero{},
|
||||
Foam::zero{},
|
||||
procMesh,
|
||||
edgeAddressing,
|
||||
faceAddressing,
|
||||
@ -169,19 +165,19 @@ Foam::faFieldDecomposer::faFieldDecomposer
|
||||
Foam::faFieldDecomposer::faFieldDecomposer
|
||||
(
|
||||
const label nTotalFaces,
|
||||
const List<labelRange>& boundaryRanges,
|
||||
const UList<labelRange>& boundaryRanges,
|
||||
const labelUList& edgeOwner,
|
||||
const labelUList& edgeNeigbour,
|
||||
|
||||
const faMesh& procMesh,
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
const labelUList& edgeAddressing,
|
||||
const labelUList& faceAddressing,
|
||||
const labelUList& boundaryAddressing
|
||||
)
|
||||
:
|
||||
faFieldDecomposer
|
||||
(
|
||||
zero{},
|
||||
Foam::zero{},
|
||||
procMesh,
|
||||
edgeAddressing,
|
||||
faceAddressing,
|
||||
@ -194,7 +190,7 @@ Foam::faFieldDecomposer::faFieldDecomposer
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::faFieldDecomposer::empty() const
|
||||
bool Foam::faFieldDecomposer::empty() const noexcept
|
||||
{
|
||||
return patchFieldDecomposerPtrs_.empty();
|
||||
}
|
||||
@ -211,16 +207,16 @@ void Foam::faFieldDecomposer::clear()
|
||||
void Foam::faFieldDecomposer::reset
|
||||
(
|
||||
const label nTotalFaces,
|
||||
const List<labelRange>& boundaryRanges,
|
||||
const UList<labelRange>& boundaryRanges,
|
||||
const labelUList& edgeOwner,
|
||||
const labelUList& edgeNeigbour
|
||||
)
|
||||
{
|
||||
clear();
|
||||
const label nMappers = procMesh_.boundary().size();
|
||||
patchFieldDecomposerPtrs_.resize(nMappers);
|
||||
processorAreaPatchFieldDecomposerPtrs_.resize(nMappers);
|
||||
processorEdgePatchFieldDecomposerPtrs_.resize(nMappers);
|
||||
|
||||
patchFieldDecomposerPtrs_.resize_null(nMappers);
|
||||
processorAreaPatchFieldDecomposerPtrs_.resize_null(nMappers);
|
||||
processorEdgePatchFieldDecomposerPtrs_.resize_null(nMappers);
|
||||
|
||||
forAll(boundaryAddressing_, patchi)
|
||||
{
|
||||
@ -282,11 +278,11 @@ void Foam::faFieldDecomposer::reset
|
||||
|
||||
void Foam::faFieldDecomposer::reset(const faMesh& completeMesh)
|
||||
{
|
||||
clear();
|
||||
const label nMappers = procMesh_.boundary().size();
|
||||
patchFieldDecomposerPtrs_.resize(nMappers);
|
||||
processorAreaPatchFieldDecomposerPtrs_.resize(nMappers);
|
||||
processorEdgePatchFieldDecomposerPtrs_.resize(nMappers);
|
||||
|
||||
patchFieldDecomposerPtrs_.resize_null(nMappers);
|
||||
processorAreaPatchFieldDecomposerPtrs_.resize_null(nMappers);
|
||||
processorEdgePatchFieldDecomposerPtrs_.resize_null(nMappers);
|
||||
|
||||
// Create weightings now - needed for proper parallel synchronization
|
||||
//// (void)completeMesh.weights();
|
||||
@ -265,7 +265,7 @@ void Foam::faFieldDecomposer::fieldsCache::readAllFields
|
||||
|
||||
void Foam::faFieldDecomposer::fieldsCache::readAllFields
|
||||
(
|
||||
const boolList& haveMeshOnProc,
|
||||
const boolUList& haveMeshOnProc,
|
||||
const faMeshSubset* subsetter,
|
||||
const faMesh& mesh,
|
||||
IOobjectList& objects
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021,2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,24 +35,20 @@ Author
|
||||
Hrvoje Jasak, Wikki Ltd.
|
||||
|
||||
SourceFiles
|
||||
faMeshDecomposition.C
|
||||
faMeshDecomposition.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_faMeshDecomposition_H
|
||||
#define Foam_faMeshDecomposition_H
|
||||
|
||||
#include "polyMesh.H"
|
||||
#include "faMesh.H"
|
||||
#include "labelList.H"
|
||||
#include "PtrList.H"
|
||||
#include "point.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faMeshDecomposition Declaration
|
||||
Class faMeshDecomposition Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faMeshDecomposition
|
||||
@ -61,8 +57,11 @@ class faMeshDecomposition
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- The area-region name
|
||||
const word areaName_;
|
||||
|
||||
//- Number of processors in decomposition
|
||||
label nProcs_;
|
||||
const label nProcs_;
|
||||
|
||||
//- Is the decomposition data to be distributed for each processor
|
||||
bool distributed_;
|
||||
@ -128,6 +127,11 @@ class faMeshDecomposition
|
||||
|
||||
void distributeFaces();
|
||||
|
||||
//- No copy construct
|
||||
faMeshDecomposition(const faMeshDecomposition&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const faMeshDecomposition&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
@ -135,13 +139,27 @@ public:
|
||||
|
||||
//- Construct from components.
|
||||
//- Values will come from the volume decomposition
|
||||
// \param mesh the fvMesh
|
||||
// \param nProcessors the number of processors
|
||||
// \param params additional parameters, sent to updateParameters
|
||||
faMeshDecomposition
|
||||
(
|
||||
//! The area-region name
|
||||
const word& areaName,
|
||||
//! The underlying polyMesh
|
||||
const polyMesh& mesh,
|
||||
//! The number of processors
|
||||
const label nProcessors,
|
||||
//! Additional parameters, sent to updateParameters
|
||||
const dictionary& params = dictionary::null
|
||||
);
|
||||
|
||||
//- Construct from components (default area region).
|
||||
//- Values will come from the volume decomposition
|
||||
faMeshDecomposition
|
||||
(
|
||||
//! The underlying polyMesh
|
||||
const polyMesh& mesh,
|
||||
//! The number of processors
|
||||
const label nProcessors,
|
||||
//! Additional parameters, sent to updateParameters
|
||||
const dictionary& params = dictionary::null
|
||||
);
|
||||
|
||||
@ -154,20 +172,17 @@ public:
|
||||
|
||||
// Settings
|
||||
|
||||
//- The area-region name
|
||||
const word& name() const noexcept { return areaName_; }
|
||||
|
||||
//- Number of processor in decomposition
|
||||
label nProcs() const noexcept
|
||||
{
|
||||
return nProcs_;
|
||||
}
|
||||
label nProcs() const noexcept { return nProcs_; }
|
||||
|
||||
//- Is decomposition data to be distributed for each processor
|
||||
bool distributed() const noexcept
|
||||
{
|
||||
return distributed_;
|
||||
}
|
||||
bool distributed() const noexcept { return distributed_; }
|
||||
|
||||
//- Change distributed flag
|
||||
bool distributed(const bool on) noexcept
|
||||
bool distributed(bool on) noexcept
|
||||
{
|
||||
bool old(distributed_);
|
||||
distributed_ = on;
|
||||
@ -177,11 +192,11 @@ public:
|
||||
//- Are global face zones used
|
||||
bool useGlobalFaceZones() const noexcept
|
||||
{
|
||||
return distributed_;
|
||||
return hasGlobalFaceZones_;
|
||||
}
|
||||
|
||||
//- Change global face zones flag
|
||||
bool useGlobalFaceZones(const bool on) noexcept
|
||||
bool useGlobalFaceZones(bool on) noexcept
|
||||
{
|
||||
bool old(hasGlobalFaceZones_);
|
||||
hasGlobalFaceZones_ = on;
|
||||
@ -208,7 +223,7 @@ public:
|
||||
void decomposeMesh();
|
||||
|
||||
//- Write decomposition
|
||||
bool writeDecomposition();
|
||||
bool writeDecomposition() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,6 @@ License
|
||||
#include "dictionary.H"
|
||||
#include "labelIOList.H"
|
||||
#include "processorFaPatch.H"
|
||||
#include "faMesh.H"
|
||||
#include "OSspecific.H"
|
||||
#include "Map.H"
|
||||
#include "SLList.H"
|
||||
@ -42,9 +41,10 @@ License
|
||||
|
||||
void Foam::faMeshDecomposition::distributeFaces()
|
||||
{
|
||||
const word& polyMeshRegionName = mesh().name();
|
||||
const word& polyMeshRegionName = faMesh::mesh().name();
|
||||
|
||||
Info<< "\nCalculating distribution of finiteArea faces" << endl;
|
||||
Info<< "\nCalculating distribution of finite-area faces ["
|
||||
<< polyMesh::regionName(areaName_) << "]" << endl;
|
||||
|
||||
cpuTime decompositionTime;
|
||||
|
||||
@ -69,7 +69,7 @@ void Foam::faMeshDecomposition::distributeFaces()
|
||||
)
|
||||
);
|
||||
|
||||
IOobject ioAddr
|
||||
IOobject ioFvAddr
|
||||
(
|
||||
"procAddressing",
|
||||
"constant",
|
||||
@ -82,8 +82,11 @@ void Foam::faMeshDecomposition::distributeFaces()
|
||||
|
||||
|
||||
// faceProcAddressing (polyMesh)
|
||||
ioAddr.rename("faceProcAddressing");
|
||||
labelIOList fvFaceProcAddressing(ioAddr);
|
||||
ioFvAddr.resetHeader("faceProcAddressing");
|
||||
const labelList fvFaceProcAddressing
|
||||
(
|
||||
labelIOList::readContents(ioFvAddr)
|
||||
);
|
||||
|
||||
labelHashSet faceProcAddressingHash;
|
||||
faceProcAddressingHash.reserve(fvFaceProcAddressing.size());
|
||||
@ -99,20 +102,17 @@ void Foam::faMeshDecomposition::distributeFaces()
|
||||
if (hasGlobalFaceZones_)
|
||||
{
|
||||
// owner (polyMesh)
|
||||
ioAddr.rename("owner");
|
||||
const label ownerSize = labelIOList(ioAddr).size();
|
||||
ioFvAddr.resetHeader("owner");
|
||||
const label ownerSize = labelIOList::readContentsSize(ioFvAddr);
|
||||
|
||||
for (int i = 0; i < ownerSize; ++i)
|
||||
for (label i = 0; i < ownerSize; ++i)
|
||||
{
|
||||
faceProcAddressingHash.insert(fvFaceProcAddressing[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faceProcAddressingHash.insert
|
||||
(
|
||||
static_cast<labelList&>(fvFaceProcAddressing)
|
||||
);
|
||||
faceProcAddressingHash.insert(fvFaceProcAddressing);
|
||||
}
|
||||
|
||||
forAll(faceLabels(), facei)
|
||||
@ -137,16 +137,18 @@ void Foam::faMeshDecomposition::distributeFaces()
|
||||
|
||||
Foam::faMeshDecomposition::faMeshDecomposition
|
||||
(
|
||||
const word& areaName,
|
||||
const polyMesh& mesh,
|
||||
const label nProcessors,
|
||||
const dictionary& params
|
||||
)
|
||||
:
|
||||
faMesh(mesh),
|
||||
faMesh(areaName, mesh),
|
||||
areaName_(areaName.empty() ? polyMesh::defaultRegion : areaName),
|
||||
nProcs_(nProcessors),
|
||||
distributed_(false),
|
||||
hasGlobalFaceZones_(false),
|
||||
faceToProc_(nFaces()),
|
||||
faceToProc_(faMesh::nFaces()),
|
||||
procFaceLabels_(nProcs_),
|
||||
procMeshEdgesMap_(nProcs_),
|
||||
procNInternalEdges_(nProcs_, Zero),
|
||||
@ -168,6 +170,23 @@ Foam::faMeshDecomposition::faMeshDecomposition
|
||||
}
|
||||
|
||||
|
||||
Foam::faMeshDecomposition::faMeshDecomposition
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label nProcessors,
|
||||
const dictionary& params
|
||||
)
|
||||
:
|
||||
faMeshDecomposition
|
||||
(
|
||||
polyMesh::defaultRegion,
|
||||
mesh,
|
||||
nProcessors,
|
||||
params
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::faMeshDecomposition::updateParameters
|
||||
@ -188,9 +207,10 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
// Decide which cell goes to which processor
|
||||
distributeFaces();
|
||||
|
||||
const word& polyMeshRegionName = mesh().name();
|
||||
const word& polyMeshRegionName = faMesh::mesh().name();
|
||||
|
||||
Info<< "\nDistributing faces to processors" << endl;
|
||||
Info<< "\nDistributing faces to processors ["
|
||||
<< polyMesh::regionName(areaName_) << "]" << endl;
|
||||
|
||||
labelList nLocalFaces(nProcs_, Zero);
|
||||
|
||||
@ -267,16 +287,21 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
|
||||
|
||||
// pointProcAddressing (polyMesh)
|
||||
ioAddr.rename("pointProcAddressing");
|
||||
labelIOList fvPointProcAddressing(ioAddr);
|
||||
ioAddr.resetHeader("pointProcAddressing");
|
||||
const labelList fvPointProcAddressing
|
||||
(
|
||||
labelIOList::readContents(ioAddr)
|
||||
);
|
||||
|
||||
Map<label> fvFaceProcAddressingHash;
|
||||
|
||||
{
|
||||
// faceProcAddressing (polyMesh)
|
||||
ioAddr.rename("faceProcAddressing");
|
||||
labelIOList fvFaceProcAddressing(ioAddr);
|
||||
|
||||
ioAddr.resetHeader("faceProcAddressing");
|
||||
const labelList fvFaceProcAddressing
|
||||
(
|
||||
labelIOList::readContents(ioAddr)
|
||||
);
|
||||
fvFaceProcAddressingHash = invertToMap(fvFaceProcAddressing);
|
||||
}
|
||||
|
||||
@ -296,9 +321,10 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
).val();
|
||||
}
|
||||
|
||||
// Create processor finite area mesh
|
||||
// Create processor finite-area mesh
|
||||
faMesh procMesh
|
||||
(
|
||||
areaName_,
|
||||
procFvMesh,
|
||||
labelList(procFaceLabels_[procI])
|
||||
);
|
||||
@ -315,18 +341,12 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
edgesHash.insert(patch.edges()[edgei], edgesHash.size());
|
||||
}
|
||||
|
||||
forAll(boundary(), patchi)
|
||||
for (const auto& fap : faMesh::boundary())
|
||||
{
|
||||
// Include emptyFaPatch
|
||||
const label size = boundary()[patchi].labelList::size();
|
||||
|
||||
for (label edgei=0; edgei < size; ++edgei)
|
||||
// Also include emptyFaPatch etc
|
||||
for (const label edgei : fap.edgeLabels())
|
||||
{
|
||||
edgesHash.insert
|
||||
(
|
||||
patch.edges()[boundary()[patchi][edgei]],
|
||||
edgesHash.size()
|
||||
);
|
||||
edgesHash.insert(patch.edges()[edgei], edgesHash.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,6 +538,8 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const faPatch& fap = patches[patchI];
|
||||
|
||||
// Reset size and start index for all processors
|
||||
forAll(procPatchSize_, procI)
|
||||
{
|
||||
@ -526,7 +548,7 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
procEdgeList[procI].size();
|
||||
}
|
||||
|
||||
const label patchStart = patches[patchI].start();
|
||||
const label patchStart = fap.start();
|
||||
|
||||
// if (!isA<cyclicFaPatch>(patches[patchI]))
|
||||
if (true)
|
||||
@ -1030,9 +1052,10 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
)
|
||||
);
|
||||
|
||||
// create finite area mesh
|
||||
// Create processor finite-area mesh
|
||||
faMesh procMesh
|
||||
(
|
||||
areaName_,
|
||||
procFvMesh,
|
||||
labelList(procFaceLabels_[procI])
|
||||
);
|
||||
@ -1101,9 +1124,9 @@ void Foam::faMeshDecomposition::decomposeMesh()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::faMeshDecomposition::writeDecomposition()
|
||||
bool Foam::faMeshDecomposition::writeDecomposition() const
|
||||
{
|
||||
const word& polyMeshRegionName = mesh().name();
|
||||
const word& polyMeshRegionName = faMesh::mesh().name();
|
||||
|
||||
Info<< "\nConstructing processor FA meshes" << endl;
|
||||
|
||||
@ -1144,23 +1167,29 @@ bool Foam::faMeshDecomposition::writeDecomposition()
|
||||
)
|
||||
);
|
||||
|
||||
labelIOList fvBoundaryProcAddressing
|
||||
IOobject ioFvAddr
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"boundaryProcAddressing",
|
||||
"constant",
|
||||
polyMesh::meshSubDir,
|
||||
procFvMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
"procAddressing",
|
||||
"constant",
|
||||
polyMesh::meshSubDir,
|
||||
procFvMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
);
|
||||
|
||||
// boundaryProcAddressing (polyMesh)
|
||||
ioFvAddr.resetHeader("boundaryProcAddressing");
|
||||
const labelList fvBoundaryProcAddressing
|
||||
(
|
||||
labelIOList::readContents(ioFvAddr)
|
||||
);
|
||||
|
||||
|
||||
// Create finite area mesh
|
||||
// Create processor finite-area mesh
|
||||
faMesh procMesh
|
||||
(
|
||||
areaName_,
|
||||
procFvMesh,
|
||||
labelList(procFaceLabels_[procI])
|
||||
);
|
||||
@ -1303,7 +1332,6 @@ bool Foam::faMeshDecomposition::writeDecomposition()
|
||||
maxProcPatches = max(maxProcPatches, nProcPatches);
|
||||
|
||||
// Write the addressing information
|
||||
|
||||
IOobject ioAddr
|
||||
(
|
||||
"procAddressing",
|
||||
@ -1317,19 +1345,19 @@ bool Foam::faMeshDecomposition::writeDecomposition()
|
||||
|
||||
// pointProcAddressing
|
||||
ioAddr.rename("pointProcAddressing");
|
||||
IOList<label>::writeContents(ioAddr, procPatchPointAddressing_[procI]);
|
||||
labelIOList::writeContents(ioAddr, procPatchPointAddressing_[procI]);
|
||||
|
||||
// edgeProcAddressing
|
||||
ioAddr.rename("edgeProcAddressing");
|
||||
IOList<label>::writeContents(ioAddr, procEdgeAddressing_[procI]);
|
||||
labelIOList::writeContents(ioAddr, procEdgeAddressing_[procI]);
|
||||
|
||||
// faceProcAddressing
|
||||
ioAddr.rename("faceProcAddressing");
|
||||
IOList<label>::writeContents(ioAddr, procFaceAddressing_[procI]);
|
||||
labelIOList::writeContents(ioAddr, procFaceAddressing_[procI]);
|
||||
|
||||
// boundaryProcAddressing
|
||||
ioAddr.rename("boundaryProcAddressing");
|
||||
IOList<label>::writeContents(ioAddr, procBoundaryAddressing_[procI]);
|
||||
labelIOList::writeContents(ioAddr, procBoundaryAddressing_[procI]);
|
||||
}
|
||||
|
||||
|
||||
@ -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