openfoam/applications/utilities/parallelProcessing/redistributePar/parFvFieldDistributor.C
Mark Olesen 6644cf8ddb ENH: cleanup/reorganize parts of redistributePar
- separate out lagrangian routines etc

- align names with regular decompose/reconstruct methods
2022-05-25 13:12:38 +00:00

116 lines
3.4 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
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 "parFvFieldDistributor.H"
#include "bitSet.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::parFvFieldDistributor::verbose_ = 1;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::parFvFieldDistributor::createPatchFaceMaps()
{
const fvBoundaryMesh& fvb = srcMesh_.boundary();
patchFaceMaps_.resize(fvb.size());
forAll(fvb, patchi)
{
if (!isA<processorFvPatch>(fvb[patchi]))
{
// Create compact map for patch faces only
// - compact for used faces only (destination patch faces)
labelList oldToNewSub;
labelList oldToNewConstruct;
// Copy face map
patchFaceMaps_.set
(
patchi,
new mapDistributeBase(distMap_.faceMap())
);
patchFaceMaps_[patchi].compactRemoteData
(
bitSet(tgtMesh_.boundaryMesh()[patchi].range()),
oldToNewSub,
oldToNewConstruct,
srcMesh_.nFaces(), // max index of subMap
UPstream::msgType()
);
//Pout<< "patchMap:" << patchFaceMaps_[patchi] << endl;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parFvFieldDistributor::parFvFieldDistributor
(
const fvMesh& srcMesh,
fvMesh& tgtMesh,
const mapDistributePolyMesh& distMap,
const bool isWriteProc
)
:
srcMesh_(srcMesh),
tgtMesh_(tgtMesh),
distMap_(distMap),
isWriteProc_(isWriteProc)
{
createPatchFaceMaps();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::parFvFieldDistributor::reconstructPoints()
{
// Reconstruct the points for moving mesh cases and write them out
distributedFieldMapper mapper
(
labelUList::null(),
distMap_.pointMap()
);
pointField newPoints(srcMesh_.points(), mapper);
tgtMesh_.movePoints(newPoints);
if (Pstream::master())
{
tgtMesh_.write();
}
}
// ************************************************************************* //