mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use multi-world connection object for managing mappedPatches
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -30,6 +30,7 @@ License
|
|||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "ListListOps.H"
|
#include "ListListOps.H"
|
||||||
#include "meshSearchMeshObject.H"
|
#include "meshSearchMeshObject.H"
|
||||||
|
#include "multiWorldConnectionsObject.H"
|
||||||
#include "meshTools.H"
|
#include "meshTools.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "Random.H"
|
#include "Random.H"
|
||||||
@ -48,7 +49,7 @@ License
|
|||||||
#include "faceAreaWeightAMI.H"
|
#include "faceAreaWeightAMI.H"
|
||||||
#include "OTstream.H"
|
#include "OTstream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
@ -119,53 +120,31 @@ Foam::autoPtr<Foam::fileName> Foam::mappedPatchBase::readDatabase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::mappedPatchBase::communicator
|
bool Foam::mappedPatchBase::addWorldConnection()
|
||||||
|
{
|
||||||
|
if (sameWorld())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Time& runTime = patch_.boundaryMesh().mesh().time();
|
||||||
|
return const_cast<multiWorldConnections&>
|
||||||
(
|
(
|
||||||
const word& sampleWorld
|
multiWorldConnections::New(runTime)
|
||||||
)
|
).addConnectionByName(sampleWorld_);
|
||||||
{
|
|
||||||
// Start off with local world
|
|
||||||
label comm = UPstream::worldComm;
|
|
||||||
|
|
||||||
if (!sampleWorld.empty() && Pstream::parRun())
|
|
||||||
{
|
|
||||||
if (!UPstream::allWorlds().found(sampleWorld))
|
|
||||||
{
|
|
||||||
FatalErrorInFunction << "Cannot find sampleWorld " << sampleWorld
|
|
||||||
<< " in set of worlds " << UPstream::allWorlds()
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelList& worldIDs = UPstream::worldIDs();
|
|
||||||
|
|
||||||
DynamicList<label> subRanks(worldIDs.size());
|
Foam::label Foam::mappedPatchBase::getWorldCommunicator() const
|
||||||
forAll(worldIDs, proci)
|
|
||||||
{
|
{
|
||||||
const label worldi = worldIDs[proci];
|
if (sameWorld())
|
||||||
if
|
|
||||||
(
|
|
||||||
worldi == UPstream::myWorldID()
|
|
||||||
|| UPstream::allWorlds()[worldi] == sampleWorld
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
subRanks.append(proci);
|
return UPstream::worldComm;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate new communicator with parent 0 (= world)
|
const Time& runTime = patch_.boundaryMesh().mesh().time();
|
||||||
comm = UPstream::allocateCommunicator(0, subRanks, true);
|
return
|
||||||
|
multiWorldConnections::New(runTime).getCommByName(sampleWorld_);
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Pout<< "mappedPatchBase::communicator :"
|
|
||||||
<< " myWorld:" << UPstream::myWorld()
|
|
||||||
<< " sampleWorld:" << sampleWorld
|
|
||||||
<< " using subRanks:" << subRanks
|
|
||||||
<< " new comm:" << comm << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return comm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -180,8 +159,8 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::facePoints
|
|||||||
(void)mesh.tetBasePtIs();
|
(void)mesh.tetBasePtIs();
|
||||||
|
|
||||||
// Initialise to face-centre
|
// Initialise to face-centre
|
||||||
tmp<pointField> tfacePoints(new pointField(patch_.size()));
|
auto tfacePoints = tmp<pointField>::New(patch_.size());
|
||||||
pointField& facePoints = tfacePoints.ref();
|
auto& facePoints = tfacePoints.ref();
|
||||||
|
|
||||||
forAll(pp, facei)
|
forAll(pp, facei)
|
||||||
{
|
{
|
||||||
@ -208,18 +187,30 @@ void Foam::mappedPatchBase::collectSamples
|
|||||||
pointField& patchFc // Per sample: originating centre
|
pointField& patchFc // Per sample: originating centre
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
DebugInFunction << nl;
|
||||||
Pstream::warnComm = comm_;
|
|
||||||
|
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myComm = getCommunicator(); // Get or create
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label myRank = Pstream::myProcNo(myComm);
|
||||||
|
const label nProcs = Pstream::nProcs(myComm);
|
||||||
|
|
||||||
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
|
Pstream::warnComm = myComm;
|
||||||
|
|
||||||
|
if (debug & 2)
|
||||||
|
{
|
||||||
|
Perr<< "patch: " << patch_.name()
|
||||||
|
<< "[rank=" << myRank << " procs=" << nProcs
|
||||||
|
<< " comm=" << myComm << "] collect samples" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Collect all sample points and the faces they come from.
|
// Collect all sample points and the faces they come from.
|
||||||
{
|
{
|
||||||
List<pointField> globalFc(nProcs);
|
List<pointField> globalFc(nProcs);
|
||||||
globalFc[myRank] = facePoints;
|
globalFc[myRank] = facePoints;
|
||||||
Pstream::gatherList(globalFc, Pstream::msgType(), comm_);
|
|
||||||
Pstream::scatterList(globalFc, Pstream::msgType(), comm_);
|
Pstream::gatherList(globalFc, Pstream::msgType(), myComm);
|
||||||
|
Pstream::scatterList(globalFc, Pstream::msgType(), myComm);
|
||||||
|
|
||||||
// Rework into straight list
|
// Rework into straight list
|
||||||
patchFc = ListListOps::combine<pointField>
|
patchFc = ListListOps::combine<pointField>
|
||||||
(
|
(
|
||||||
@ -231,8 +222,8 @@ void Foam::mappedPatchBase::collectSamples
|
|||||||
{
|
{
|
||||||
List<pointField> globalSamples(nProcs);
|
List<pointField> globalSamples(nProcs);
|
||||||
globalSamples[myRank] = samplePoints(facePoints);
|
globalSamples[myRank] = samplePoints(facePoints);
|
||||||
Pstream::gatherList(globalSamples, Pstream::msgType(), comm_);
|
Pstream::gatherList(globalSamples, Pstream::msgType(), myComm);
|
||||||
Pstream::scatterList(globalSamples, Pstream::msgType(), comm_);
|
Pstream::scatterList(globalSamples, Pstream::msgType(), myComm);
|
||||||
// Rework into straight list
|
// Rework into straight list
|
||||||
samples = ListListOps::combine<pointField>
|
samples = ListListOps::combine<pointField>
|
||||||
(
|
(
|
||||||
@ -245,8 +236,8 @@ void Foam::mappedPatchBase::collectSamples
|
|||||||
labelListList globalFaces(nProcs);
|
labelListList globalFaces(nProcs);
|
||||||
globalFaces[myRank] = identity(patch_.size());
|
globalFaces[myRank] = identity(patch_.size());
|
||||||
// Distribute to all processors
|
// Distribute to all processors
|
||||||
Pstream::gatherList(globalFaces, Pstream::msgType(), comm_);
|
Pstream::gatherList(globalFaces, Pstream::msgType(), myComm);
|
||||||
Pstream::scatterList(globalFaces, Pstream::msgType(), comm_);
|
Pstream::scatterList(globalFaces, Pstream::msgType(), myComm);
|
||||||
|
|
||||||
patchFaces = ListListOps::combine<labelList>
|
patchFaces = ListListOps::combine<labelList>
|
||||||
(
|
(
|
||||||
@ -258,13 +249,13 @@ void Foam::mappedPatchBase::collectSamples
|
|||||||
{
|
{
|
||||||
labelList procToWorldIndex(nProcs);
|
labelList procToWorldIndex(nProcs);
|
||||||
procToWorldIndex[myRank] = mySampleWorld;
|
procToWorldIndex[myRank] = mySampleWorld;
|
||||||
Pstream::gatherList(procToWorldIndex, Pstream::msgType(), comm_);
|
Pstream::gatherList(procToWorldIndex, Pstream::msgType(), myComm);
|
||||||
Pstream::scatterList(procToWorldIndex, Pstream::msgType(), comm_);
|
Pstream::scatterList(procToWorldIndex, Pstream::msgType(), myComm);
|
||||||
|
|
||||||
labelList nPerProc(nProcs);
|
labelList nPerProc(nProcs);
|
||||||
nPerProc[myRank] = patch_.size();
|
nPerProc[myRank] = patch_.size();
|
||||||
Pstream::gatherList(nPerProc, Pstream::msgType(), comm_);
|
Pstream::gatherList(nPerProc, Pstream::msgType(), myComm);
|
||||||
Pstream::scatterList(nPerProc, Pstream::msgType(), comm_);
|
Pstream::scatterList(nPerProc, Pstream::msgType(), myComm);
|
||||||
|
|
||||||
patchFaceWorlds.setSize(patchFaces.size());
|
patchFaceWorlds.setSize(patchFaces.size());
|
||||||
patchFaceProcs.setSize(patchFaces.size());
|
patchFaceProcs.setSize(patchFaces.size());
|
||||||
@ -280,7 +271,8 @@ void Foam::mappedPatchBase::collectSamples
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
|
Pstream::warnComm = oldWarnComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -296,9 +288,12 @@ void Foam::mappedPatchBase::findLocalSamples
|
|||||||
List<nearInfoWorld>& nearest
|
List<nearInfoWorld>& nearest
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Find the local cell containing the samples
|
DebugInFunction << nl;
|
||||||
|
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myComm = getCommunicator(); // Get or create
|
||||||
|
|
||||||
|
// Find the local cell containing the samples
|
||||||
|
const label myRank = Pstream::myProcNo(myComm);
|
||||||
|
|
||||||
// Lookup the correct region
|
// Lookup the correct region
|
||||||
const polyMesh& mesh = lookupMesh(sampleRegion);
|
const polyMesh& mesh = lookupMesh(sampleRegion);
|
||||||
@ -601,32 +596,32 @@ void Foam::mappedPatchBase::findSamples
|
|||||||
pointField& sampleLocations
|
pointField& sampleLocations
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
DebugInFunction << nl;
|
||||||
|
|
||||||
// Find the processor/cell containing the samples. Does not account
|
// Find the processor/cell containing the samples. Does not account
|
||||||
// for samples being found in two processors.
|
// for samples being found in two processors.
|
||||||
|
|
||||||
|
const label myComm = getCommunicator(); // Get or create
|
||||||
|
const label myRank = Pstream::myProcNo(myComm);
|
||||||
|
const label nProcs = Pstream::nProcs(myComm);
|
||||||
|
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
Pstream::warnComm = myComm;
|
||||||
|
|
||||||
wordList samplePatches(nProcs);
|
wordList samplePatches(nProcs);
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
|
||||||
Pstream::warnComm = comm_;
|
|
||||||
samplePatches[myRank] = samplePatch_;
|
samplePatches[myRank] = samplePatch_;
|
||||||
Pstream::gatherList(samplePatches, Pstream::msgType(), comm_);
|
Pstream::gatherList(samplePatches, Pstream::msgType(), myComm);
|
||||||
Pstream::scatterList(samplePatches, Pstream::msgType(), comm_);
|
Pstream::scatterList(samplePatches, Pstream::msgType(), myComm);
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
}
|
}
|
||||||
wordList sampleRegions(nProcs);
|
wordList sampleRegions(nProcs);
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
|
||||||
Pstream::warnComm = comm_;
|
|
||||||
sampleRegions[myRank] = sampleRegion_;
|
sampleRegions[myRank] = sampleRegion_;
|
||||||
Pstream::gatherList(sampleRegions, Pstream::msgType(), comm_);
|
Pstream::gatherList(sampleRegions, Pstream::msgType(), myComm);
|
||||||
Pstream::scatterList(sampleRegions, Pstream::msgType(), comm_);
|
Pstream::scatterList(sampleRegions, Pstream::msgType(), myComm);
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find all the info for nearest
|
// Find all the info for nearest
|
||||||
List<nearInfoWorld> nearest(samples.size());
|
List<nearInfoWorld> nearest(samples.size());
|
||||||
forAll(nearest, samplei)
|
forAll(nearest, samplei)
|
||||||
@ -680,8 +675,6 @@ void Foam::mappedPatchBase::findSamples
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const label oldComm(Pstream::warnComm);
|
|
||||||
Pstream::warnComm = comm_;
|
|
||||||
|
|
||||||
// Find nearest. Combine on master.
|
// Find nearest. Combine on master.
|
||||||
Pstream::listCombineGather
|
Pstream::listCombineGather
|
||||||
@ -689,13 +682,13 @@ void Foam::mappedPatchBase::findSamples
|
|||||||
nearest,
|
nearest,
|
||||||
nearestWorldEqOp(),
|
nearestWorldEqOp(),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
myComm
|
||||||
);
|
);
|
||||||
Pstream::listCombineScatter(nearest, Pstream::msgType(), comm_);
|
Pstream::listCombineScatter(nearest, Pstream::msgType(), myComm);
|
||||||
|
|
||||||
//if (debug)
|
//if (debug)
|
||||||
//{
|
//{
|
||||||
// Pout<< "** AFter combining:" << endl;
|
// Pout<< "** After combining:" << endl;
|
||||||
// forAll(nearest, samplei)
|
// forAll(nearest, samplei)
|
||||||
// {
|
// {
|
||||||
// Pout<< " sample:" << samples[samplei]
|
// Pout<< " sample:" << samples[samplei]
|
||||||
@ -735,7 +728,7 @@ void Foam::mappedPatchBase::findSamples
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pstream::warnComm = oldComm;
|
Pstream::warnComm = oldWarnComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -748,6 +741,10 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
<< "Mapping already calculated" << exit(FatalError);
|
<< "Mapping already calculated" << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugInFunction << nl;
|
||||||
|
|
||||||
|
const label myComm = getCommunicator(); // Get or create
|
||||||
|
|
||||||
//// Make sure if running in database that there is a syncObjects FO
|
//// Make sure if running in database that there is a syncObjects FO
|
||||||
//if (sampleDatabase() && !sameWorld())
|
//if (sampleDatabase() && !sameWorld())
|
||||||
//{
|
//{
|
||||||
@ -806,11 +803,11 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
<< " on the same patch, on the same region"
|
<< " on the same patch, on the same region"
|
||||||
<< " will find the faces themselves which does not make sense"
|
<< " will find the faces themselves which does not make sense"
|
||||||
<< " for anything but testing." << endl
|
<< " for anything but testing." << endl
|
||||||
<< "patch_:" << patch_.name() << endl
|
<< "patch:" << patch_.name() << endl
|
||||||
<< "sampleRegion_:" << sampleRegion() << endl
|
<< "sampleRegion:" << sampleRegion() << endl
|
||||||
<< "mode_:" << sampleModeNames_[mode_] << endl
|
<< "mode:" << sampleModeNames_[mode_] << endl
|
||||||
<< "samplePatch_:" << samplePatch() << endl
|
<< "samplePatch:" << samplePatch() << endl
|
||||||
<< "offsetMode_:" << offsetModeNames_[offsetMode_] << endl;
|
<< "offsetMode:" << offsetModeNames_[offsetMode_] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,7 +874,7 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
nNotFound++;
|
nNotFound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reduce(nNotFound, sumOp<label>(), Pstream::msgType(), comm_);
|
reduce(nNotFound, sumOp<label>(), Pstream::msgType(), myComm);
|
||||||
|
|
||||||
if (nNotFound > 0)
|
if (nNotFound > 0)
|
||||||
{
|
{
|
||||||
@ -937,7 +934,7 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
// - cell/face sample is in (so source when mapping)
|
// - cell/face sample is in (so source when mapping)
|
||||||
// sampleIndices, sampleProcs.
|
// sampleIndices, sampleProcs.
|
||||||
|
|
||||||
if (Pstream::master(comm_))
|
if (Pstream::master(myComm))
|
||||||
{
|
{
|
||||||
forAll(samples, i)
|
forAll(samples, i)
|
||||||
{
|
{
|
||||||
@ -954,7 +951,7 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (debug && Pstream::master(comm_))
|
if (debug && Pstream::master(myComm))
|
||||||
{
|
{
|
||||||
//forAll(samples, i)
|
//forAll(samples, i)
|
||||||
//{
|
//{
|
||||||
@ -993,7 +990,7 @@ void Foam::mappedPatchBase::calcMapping() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine schedule.
|
// Determine schedule.
|
||||||
mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs, comm_));
|
mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs, myComm));
|
||||||
|
|
||||||
// Rework the schedule from indices into samples to cell data to send,
|
// Rework the schedule from indices into samples to cell data to send,
|
||||||
// face data to receive.
|
// face data to receive.
|
||||||
@ -1104,6 +1101,13 @@ void Foam::mappedPatchBase::calcAMI() const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugInFunction << nl;
|
||||||
|
|
||||||
|
const label myComm = getCommunicator(); // Get or create
|
||||||
|
|
||||||
|
const label oldWorldComm(Pstream::worldComm);
|
||||||
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
|
|
||||||
// Check if running locally
|
// Check if running locally
|
||||||
if (sampleWorld_.empty() || sameWorld())
|
if (sampleWorld_.empty() || sameWorld())
|
||||||
{
|
{
|
||||||
@ -1136,17 +1140,15 @@ void Foam::mappedPatchBase::calcAMI() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct/apply AMI interpolation to determine addressing and
|
// Construct/apply AMI interpolation to determine addressing and
|
||||||
// weights. Make sure to use optional inter-world communicator.
|
// weights.
|
||||||
|
|
||||||
const label oldWorldComm = Pstream::worldComm;
|
// Change to use inter-world communicator
|
||||||
Pstream::worldComm = comm_;
|
Pstream::worldComm = myComm;
|
||||||
|
Pstream::warnComm = Pstream::worldComm;
|
||||||
const label oldComm(Pstream::warnComm);
|
|
||||||
Pstream::warnComm = UPstream::worldComm;
|
|
||||||
|
|
||||||
AMIPtr_->calculate(patch_, nbrPatch0, surfPtr());
|
AMIPtr_->calculate(patch_, nbrPatch0, surfPtr());
|
||||||
|
|
||||||
Pstream::warnComm = oldComm;
|
Pstream::warnComm = oldWarnComm;
|
||||||
Pstream::worldComm = oldWorldComm;
|
Pstream::worldComm = oldWorldComm;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1163,11 +1165,8 @@ void Foam::mappedPatchBase::calcAMI() const
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Change to use inter-world communicator
|
// Change to use inter-world communicator
|
||||||
const label oldWorldComm = Pstream::worldComm;
|
Pstream::worldComm = myComm;
|
||||||
Pstream::worldComm = comm_;
|
Pstream::warnComm = Pstream::worldComm;
|
||||||
|
|
||||||
const label oldComm(Pstream::warnComm);
|
|
||||||
Pstream::warnComm = UPstream::worldComm;
|
|
||||||
|
|
||||||
if (masterWorld())
|
if (masterWorld())
|
||||||
{
|
{
|
||||||
@ -1186,7 +1185,7 @@ void Foam::mappedPatchBase::calcAMI() const
|
|||||||
// Now the AMI addressing/weights will be from src side (on masterWorld
|
// Now the AMI addressing/weights will be from src side (on masterWorld
|
||||||
// processors) to tgt side (on other processors)
|
// processors) to tgt side (on other processors)
|
||||||
|
|
||||||
Pstream::warnComm = oldComm;
|
Pstream::warnComm = oldWarnComm;
|
||||||
Pstream::worldComm = oldWorldComm;
|
Pstream::worldComm = oldWorldComm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1216,28 +1215,26 @@ const Foam::objectRegistry& Foam::mappedPatchBase::subRegistry
|
|||||||
Foam::mappedPatchBase::mappedPatchBase(const polyPatch& pp)
|
Foam::mappedPatchBase::mappedPatchBase(const polyPatch& pp)
|
||||||
:
|
:
|
||||||
patch_(pp),
|
patch_(pp),
|
||||||
sampleWorld_(word::null),
|
sampleWorld_(),
|
||||||
sampleRegion_(patch_.boundaryMesh().mesh().name()),
|
sampleRegion_(patch_.boundaryMesh().mesh().name()),
|
||||||
mode_(NEARESTPATCHFACE),
|
mode_(NEARESTPATCHFACE),
|
||||||
samplePatch_(word::null),
|
samplePatch_(),
|
||||||
coupleGroup_(),
|
coupleGroup_(),
|
||||||
sampleDatabasePtr_(),
|
sampleDatabasePtr_(),
|
||||||
offsetMode_(UNIFORM),
|
offsetMode_(UNIFORM),
|
||||||
offset_(Zero),
|
offset_(Zero),
|
||||||
offsets_(pp.size(), offset_),
|
offsets_(pp.size(), offset_),
|
||||||
distance_(0),
|
distance_(0),
|
||||||
comm_(communicator(sampleWorld_)),
|
communicator_(-1), // Demand-driven (cached value)
|
||||||
sameRegion_
|
sameRegion_(true),
|
||||||
(
|
|
||||||
sampleWorld_.empty()
|
|
||||||
&& sampleRegion_ == patch_.boundaryMesh().mesh().name()
|
|
||||||
),
|
|
||||||
mapPtr_(nullptr),
|
mapPtr_(nullptr),
|
||||||
AMIReverse_(false),
|
AMIReverse_(false),
|
||||||
AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
|
AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
|
||||||
surfPtr_(nullptr),
|
surfPtr_(nullptr),
|
||||||
surfDict_(fileName("surface"))
|
surfDict_(fileName("surface"))
|
||||||
{}
|
{
|
||||||
|
// NOTE: same region, no sample-world. Thus no world-world communication
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::mappedPatchBase::mappedPatchBase
|
Foam::mappedPatchBase::mappedPatchBase
|
||||||
@ -1249,29 +1246,17 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
const vectorField& offsets
|
const vectorField& offsets
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
patch_(pp),
|
mappedPatchBase
|
||||||
sampleWorld_(word::null),
|
|
||||||
sampleRegion_(sampleRegion),
|
|
||||||
mode_(mode),
|
|
||||||
samplePatch_(samplePatch),
|
|
||||||
coupleGroup_(),
|
|
||||||
sampleDatabasePtr_(),
|
|
||||||
offsetMode_(NONUNIFORM),
|
|
||||||
offset_(Zero),
|
|
||||||
offsets_(offsets),
|
|
||||||
distance_(0),
|
|
||||||
comm_(communicator(sampleWorld_)),
|
|
||||||
sameRegion_
|
|
||||||
(
|
(
|
||||||
sampleWorld_.empty()
|
pp,
|
||||||
&& sampleRegion_ == patch_.boundaryMesh().mesh().name()
|
sampleRegion,
|
||||||
),
|
mode,
|
||||||
mapPtr_(nullptr),
|
samplePatch,
|
||||||
AMIReverse_(false),
|
scalar(0)
|
||||||
AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
|
)
|
||||||
surfPtr_(nullptr),
|
{
|
||||||
surfDict_(fileName("surface"))
|
mappedPatchBase::setOffset(offsets);
|
||||||
{}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::mappedPatchBase::mappedPatchBase
|
Foam::mappedPatchBase::mappedPatchBase
|
||||||
@ -1280,32 +1265,20 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
const word& sampleRegion,
|
const word& sampleRegion,
|
||||||
const sampleMode mode,
|
const sampleMode mode,
|
||||||
const word& samplePatch,
|
const word& samplePatch,
|
||||||
const vector& offset
|
const vector& uniformOffset
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
patch_(pp),
|
mappedPatchBase
|
||||||
sampleWorld_(word::null),
|
|
||||||
sampleRegion_(sampleRegion),
|
|
||||||
mode_(mode),
|
|
||||||
samplePatch_(samplePatch),
|
|
||||||
coupleGroup_(),
|
|
||||||
sampleDatabasePtr_(),
|
|
||||||
offsetMode_(UNIFORM),
|
|
||||||
offset_(offset),
|
|
||||||
offsets_(0),
|
|
||||||
distance_(0),
|
|
||||||
comm_(communicator(sampleWorld_)),
|
|
||||||
sameRegion_
|
|
||||||
(
|
(
|
||||||
sampleWorld_.empty()
|
pp,
|
||||||
&& sampleRegion_ == patch_.boundaryMesh().mesh().name()
|
sampleRegion,
|
||||||
),
|
mode,
|
||||||
mapPtr_(nullptr),
|
samplePatch,
|
||||||
AMIReverse_(false),
|
scalar(0)
|
||||||
AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
|
)
|
||||||
surfPtr_(nullptr),
|
{
|
||||||
surfDict_(fileName("surface"))
|
mappedPatchBase::setOffset(uniformOffset);
|
||||||
{}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::mappedPatchBase::mappedPatchBase
|
Foam::mappedPatchBase::mappedPatchBase
|
||||||
@ -1314,11 +1287,11 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
const word& sampleRegion,
|
const word& sampleRegion,
|
||||||
const sampleMode mode,
|
const sampleMode mode,
|
||||||
const word& samplePatch,
|
const word& samplePatch,
|
||||||
const scalar distance
|
const scalar normalDistance
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
patch_(pp),
|
patch_(pp),
|
||||||
sampleWorld_(word::null),
|
sampleWorld_(),
|
||||||
sampleRegion_(sampleRegion),
|
sampleRegion_(sampleRegion),
|
||||||
mode_(mode),
|
mode_(mode),
|
||||||
samplePatch_(samplePatch),
|
samplePatch_(samplePatch),
|
||||||
@ -1327,8 +1300,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
offsetMode_(NORMAL),
|
offsetMode_(NORMAL),
|
||||||
offset_(Zero),
|
offset_(Zero),
|
||||||
offsets_(0),
|
offsets_(0),
|
||||||
distance_(distance),
|
distance_(normalDistance),
|
||||||
comm_(communicator(sampleWorld_)),
|
communicator_(-1), // Demand-driven (cached value)
|
||||||
sameRegion_
|
sameRegion_
|
||||||
(
|
(
|
||||||
sampleWorld_.empty()
|
sampleWorld_.empty()
|
||||||
@ -1339,7 +1312,9 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
|
AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
|
||||||
surfPtr_(nullptr),
|
surfPtr_(nullptr),
|
||||||
surfDict_(fileName("surface"))
|
surfDict_(fileName("surface"))
|
||||||
{}
|
{
|
||||||
|
addWorldConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::mappedPatchBase::mappedPatchBase
|
Foam::mappedPatchBase::mappedPatchBase
|
||||||
@ -1358,8 +1333,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
offsetMode_(UNIFORM),
|
offsetMode_(UNIFORM),
|
||||||
offset_(Zero),
|
offset_(Zero),
|
||||||
offsets_(0),
|
offsets_(0),
|
||||||
distance_(0.0),
|
distance_(0),
|
||||||
comm_(communicator(sampleWorld_)),
|
communicator_(-1), // Demand-driven (cached value)
|
||||||
sameRegion_
|
sameRegion_
|
||||||
(
|
(
|
||||||
sampleWorld_.empty()
|
sampleWorld_.empty()
|
||||||
@ -1379,6 +1354,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
surfPtr_(nullptr),
|
surfPtr_(nullptr),
|
||||||
surfDict_(dict.subOrEmptyDict("surface"))
|
surfDict_(dict.subOrEmptyDict("surface"))
|
||||||
{
|
{
|
||||||
|
addWorldConnection();
|
||||||
|
|
||||||
if (!coupleGroup_.valid())
|
if (!coupleGroup_.valid())
|
||||||
{
|
{
|
||||||
if (sampleWorld_.empty() && sampleRegion_.empty())
|
if (sampleWorld_.empty() && sampleRegion_.empty())
|
||||||
@ -1448,8 +1425,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
offsetMode_(UNIFORM),
|
offsetMode_(UNIFORM),
|
||||||
offset_(Zero),
|
offset_(Zero),
|
||||||
offsets_(0),
|
offsets_(0),
|
||||||
distance_(0.0),
|
distance_(0),
|
||||||
comm_(communicator(sampleWorld_)),
|
communicator_(-1), // Demand-driven (cached value)
|
||||||
sameRegion_
|
sameRegion_
|
||||||
(
|
(
|
||||||
sampleWorld_.empty()
|
sampleWorld_.empty()
|
||||||
@ -1469,6 +1446,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
surfPtr_(nullptr),
|
surfPtr_(nullptr),
|
||||||
surfDict_(dict.subOrEmptyDict("surface"))
|
surfDict_(dict.subOrEmptyDict("surface"))
|
||||||
{
|
{
|
||||||
|
addWorldConnection();
|
||||||
|
|
||||||
if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
|
if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
@ -1479,7 +1458,6 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!coupleGroup_.valid())
|
if (!coupleGroup_.valid())
|
||||||
{
|
{
|
||||||
if (sampleWorld_.empty() && sampleRegion_.empty())
|
if (sampleWorld_.empty() && sampleRegion_.empty())
|
||||||
@ -1514,7 +1492,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
offset_(mpb.offset_),
|
offset_(mpb.offset_),
|
||||||
offsets_(mpb.offsets_),
|
offsets_(mpb.offsets_),
|
||||||
distance_(mpb.distance_),
|
distance_(mpb.distance_),
|
||||||
comm_(mpb.comm_),
|
communicator_(mpb.communicator_),
|
||||||
sameRegion_(mpb.sameRegion_),
|
sameRegion_(mpb.sameRegion_),
|
||||||
mapPtr_(nullptr),
|
mapPtr_(nullptr),
|
||||||
AMIReverse_(mpb.AMIReverse_),
|
AMIReverse_(mpb.AMIReverse_),
|
||||||
@ -1552,7 +1530,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
|||||||
: vectorField()
|
: vectorField()
|
||||||
),
|
),
|
||||||
distance_(mpb.distance_),
|
distance_(mpb.distance_),
|
||||||
comm_(mpb.comm_),
|
communicator_(mpb.communicator_),
|
||||||
sameRegion_(mpb.sameRegion_),
|
sameRegion_(mpb.sameRegion_),
|
||||||
mapPtr_(nullptr),
|
mapPtr_(nullptr),
|
||||||
AMIReverse_(mpb.AMIReverse_),
|
AMIReverse_(mpb.AMIReverse_),
|
||||||
@ -1572,14 +1550,44 @@ Foam::mappedPatchBase::~mappedPatchBase()
|
|||||||
|
|
||||||
void Foam::mappedPatchBase::clearOut()
|
void Foam::mappedPatchBase::clearOut()
|
||||||
{
|
{
|
||||||
mapPtr_.clear();
|
mapPtr_.reset(nullptr);
|
||||||
surfPtr_.clear();
|
surfPtr_.reset(nullptr);
|
||||||
AMIPtr_->upToDate() = false;
|
AMIPtr_->upToDate() = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::mappedPatchBase::setOffset(const scalar normalDist)
|
||||||
|
{
|
||||||
|
clearOut();
|
||||||
|
offsetMode_ = offsetMode::NORMAL;
|
||||||
|
offset_ = Zero;
|
||||||
|
offsets_.clear();
|
||||||
|
distance_ = normalDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::mappedPatchBase::setOffset(const vector& uniformOffset)
|
||||||
|
{
|
||||||
|
clearOut();
|
||||||
|
offsetMode_ = offsetMode::UNIFORM;
|
||||||
|
offset_ = uniformOffset;
|
||||||
|
offsets_.clear();
|
||||||
|
distance_ = Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::mappedPatchBase::setOffset(const vectorField& offsets)
|
||||||
|
{
|
||||||
|
clearOut();
|
||||||
|
offsetMode_ = offsetMode::NONUNIFORM;
|
||||||
|
offset_ = Zero;
|
||||||
|
offsets_ = offsets;
|
||||||
|
distance_ = Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::polyMesh& Foam::mappedPatchBase::lookupMesh
|
const Foam::polyMesh& Foam::mappedPatchBase::lookupMesh
|
||||||
(
|
(
|
||||||
const word& sampleRegion
|
const word& sampleRegion
|
||||||
@ -1653,8 +1661,8 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints
|
|||||||
const pointField& fc
|
const pointField& fc
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
tmp<pointField> tfld(new pointField(fc));
|
auto tfld = tmp<pointField>::New(fc);
|
||||||
pointField& fld = tfld.ref();
|
auto& fld = tfld.ref();
|
||||||
|
|
||||||
switch (offsetMode_)
|
switch (offsetMode_)
|
||||||
{
|
{
|
||||||
@ -1725,7 +1733,7 @@ Foam::pointIndexHit Foam::mappedPatchBase::facePoint
|
|||||||
return pointIndexHit(true, fc, 0);
|
return pointIndexHit(true, fc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
label celli = mesh.faceOwner()[facei];
|
const label celli = mesh.faceOwner()[facei];
|
||||||
const point& cc = mesh.cellCentres()[celli];
|
const point& cc = mesh.cellCentres()[celli];
|
||||||
vector d = fc-cc;
|
vector d = fc-cc;
|
||||||
|
|
||||||
@ -1918,7 +1926,7 @@ void Foam::mappedPatchBase::write(Ostream& os) const
|
|||||||
|
|
||||||
if (sampleDatabasePtr_)
|
if (sampleDatabasePtr_)
|
||||||
{
|
{
|
||||||
os.writeEntry("sampleDatabase", sampleDatabasePtr_.valid());
|
os.writeEntry("sampleDatabase", Switch::name(true));
|
||||||
// Write database path if differing
|
// Write database path if differing
|
||||||
os.writeEntryIfDifferent<fileName>
|
os.writeEntryIfDifferent<fileName>
|
||||||
(
|
(
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -112,7 +112,6 @@ class mapDistribute;
|
|||||||
|
|
||||||
class mappedPatchBase
|
class mappedPatchBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Type enumerations
|
// Type enumerations
|
||||||
@ -150,7 +149,6 @@ public:
|
|||||||
|
|
||||||
class nearestEqOp
|
class nearestEqOp
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void operator()(nearInfo& x, const nearInfo& y) const
|
void operator()(nearInfo& x, const nearInfo& y) const
|
||||||
@ -171,7 +169,6 @@ public:
|
|||||||
|
|
||||||
class maxProcEqOp
|
class maxProcEqOp
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void operator()(nearInfo& x, const nearInfo& y) const
|
void operator()(nearInfo& x, const nearInfo& y) const
|
||||||
@ -197,7 +194,6 @@ public:
|
|||||||
|
|
||||||
class nearestWorldEqOp
|
class nearestWorldEqOp
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void operator()(nearInfoWorld& x, const nearInfoWorld& y) const
|
void operator()(nearInfoWorld& x, const nearInfoWorld& y) const
|
||||||
@ -225,7 +221,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected data
|
// Protected Data
|
||||||
|
|
||||||
//- Patch to sample
|
//- Patch to sample
|
||||||
const polyPatch& patch_;
|
const polyPatch& patch_;
|
||||||
@ -261,7 +257,7 @@ protected:
|
|||||||
scalar distance_;
|
scalar distance_;
|
||||||
|
|
||||||
//- Communicator
|
//- Communicator
|
||||||
label comm_;
|
label communicator_;
|
||||||
|
|
||||||
//- Same region
|
//- Same region
|
||||||
mutable bool sameRegion_;
|
mutable bool sameRegion_;
|
||||||
@ -294,8 +290,11 @@ protected:
|
|||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Optionally allocate a world-local communicator
|
//- Add a world-world connection
|
||||||
static label communicator(const word& sampleWorld);
|
bool addWorldConnection();
|
||||||
|
|
||||||
|
//- Get the communicator for the world-world connection
|
||||||
|
label getWorldCommunicator() const;
|
||||||
|
|
||||||
//- Lookup mesh
|
//- Lookup mesh
|
||||||
const polyMesh& lookupMesh(const word& region) const;
|
const polyMesh& lookupMesh(const word& region) const;
|
||||||
@ -309,11 +308,11 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
//- Get the points from face-centre-decomposition face centres
|
//- Get the points from face-centre-decomposition face centres
|
||||||
// and project them onto the face-diagonal-decomposition triangles.
|
//- and project them onto the face-diagonal-decomposition triangles.
|
||||||
tmp<pointField> facePoints(const polyPatch&) const;
|
tmp<pointField> facePoints(const polyPatch&) const;
|
||||||
|
|
||||||
//- Collect single list of samples and originating processor+face +
|
//- Collect single list of samples and originating processor+face +
|
||||||
// wanted world
|
//- wanted world
|
||||||
void collectSamples
|
void collectSamples
|
||||||
(
|
(
|
||||||
const label mySampleWorld, // My wanted sampling world
|
const label mySampleWorld, // My wanted sampling world
|
||||||
@ -362,7 +361,7 @@ protected:
|
|||||||
void calcAMI() const;
|
void calcAMI() const;
|
||||||
|
|
||||||
|
|
||||||
// Database handling
|
// Database Handling
|
||||||
|
|
||||||
//- Read optional database name from dictionary
|
//- Read optional database name from dictionary
|
||||||
static autoPtr<fileName> readDatabase(const dictionary& dict);
|
static autoPtr<fileName> readDatabase(const dictionary& dict);
|
||||||
@ -422,7 +421,7 @@ public:
|
|||||||
const word& sampleRegion,
|
const word& sampleRegion,
|
||||||
const sampleMode sampleMode,
|
const sampleMode sampleMode,
|
||||||
const word& samplePatch,
|
const word& samplePatch,
|
||||||
const vector& offset
|
const vector& uniformOffset
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from offsetMode=normal and distance
|
//- Construct from offsetMode=normal and distance
|
||||||
@ -432,7 +431,7 @@ public:
|
|||||||
const word& sampleRegion,
|
const word& sampleRegion,
|
||||||
const sampleMode sampleMode,
|
const sampleMode sampleMode,
|
||||||
const word& samplePatch,
|
const word& samplePatch,
|
||||||
const scalar distance
|
const scalar normalDistance
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from dictionary
|
//- Construct from dictionary
|
||||||
@ -459,17 +458,29 @@ public:
|
|||||||
virtual ~mappedPatchBase();
|
virtual ~mappedPatchBase();
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
void clearOut();
|
void clearOut();
|
||||||
|
|
||||||
|
//- Change to normal offset with given distance
|
||||||
|
void setOffset(const scalar normalDist);
|
||||||
|
|
||||||
|
//- Change to uniform offset with value
|
||||||
|
void setOffset(const vector& uniformOffset);
|
||||||
|
|
||||||
|
//- Change to non-uniform offsets
|
||||||
|
void setOffset(const vectorField& offsets);
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- What to sample
|
//- What to sample
|
||||||
inline const sampleMode& mode() const;
|
inline sampleMode mode() const noexcept;
|
||||||
|
|
||||||
//- World to sample
|
//- World to sample
|
||||||
inline const word& sampleWorld() const;
|
inline const word& sampleWorld() const noexcept;
|
||||||
|
|
||||||
//- Region to sample
|
//- Region to sample
|
||||||
inline const word& sampleRegion() const;
|
inline const word& sampleRegion() const;
|
||||||
@ -484,12 +495,15 @@ public:
|
|||||||
inline label sampleSize() const;
|
inline label sampleSize() const;
|
||||||
|
|
||||||
//- Offset vector (from patch faces to destination mesh objects)
|
//- Offset vector (from patch faces to destination mesh objects)
|
||||||
inline const vector& offset() const;
|
inline const vector& offset() const noexcept;
|
||||||
|
|
||||||
//- Offset vector (from patch faces to destination mesh objects)
|
//- Offset vectors (from patch faces to destination mesh objects)
|
||||||
inline const vectorField& offsets() const;
|
inline const vectorField& offsets() const noexcept;
|
||||||
|
|
||||||
//- Communicator
|
//- Get the communicator (worldComm or world-to-world)
|
||||||
|
inline label getCommunicator() const;
|
||||||
|
|
||||||
|
//- Identical to getCommunicator()
|
||||||
inline label comm() const;
|
inline label comm() const;
|
||||||
|
|
||||||
//- Is sample world the local world?
|
//- Is sample world the local world?
|
||||||
@ -499,7 +513,7 @@ public:
|
|||||||
inline bool masterWorld() const;
|
inline bool masterWorld() const;
|
||||||
|
|
||||||
//- Cached sampleRegion != mesh.name()
|
//- Cached sampleRegion != mesh.name()
|
||||||
inline bool sameRegion() const;
|
inline bool sameRegion() const noexcept;
|
||||||
|
|
||||||
//- Return reference to the parallel distribution map
|
//- Return reference to the parallel distribution map
|
||||||
inline const mapDistribute& map() const;
|
inline const mapDistribute& map() const;
|
||||||
@ -547,7 +561,7 @@ public:
|
|||||||
|
|
||||||
inline bool sampleDatabase() const
|
inline bool sampleDatabase() const
|
||||||
{
|
{
|
||||||
return sampleDatabasePtr_.valid();
|
return bool(sampleDatabasePtr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Helper: return path to store data to be sent to processor i
|
//- Helper: return path to store data to be sent to processor i
|
||||||
@ -615,7 +629,7 @@ public:
|
|||||||
// I/O
|
// I/O
|
||||||
|
|
||||||
//- Write as a dictionary
|
//- Write as a dictionary
|
||||||
virtual void write(Ostream&) const;
|
virtual void write(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -26,14 +26,14 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
inline const Foam::mappedPatchBase::sampleMode&
|
inline Foam::mappedPatchBase::sampleMode
|
||||||
Foam::mappedPatchBase::mode() const
|
Foam::mappedPatchBase::mode() const noexcept
|
||||||
{
|
{
|
||||||
return mode_;
|
return mode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::word& Foam::mappedPatchBase::sampleWorld() const
|
inline const Foam::word& Foam::mappedPatchBase::sampleWorld() const noexcept
|
||||||
{
|
{
|
||||||
return sampleWorld_;
|
return sampleWorld_;
|
||||||
}
|
}
|
||||||
@ -132,29 +132,48 @@ inline Foam::label Foam::mappedPatchBase::sampleSize() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::vector& Foam::mappedPatchBase::offset() const
|
inline const Foam::vector& Foam::mappedPatchBase::offset() const noexcept
|
||||||
{
|
{
|
||||||
return offset_;
|
return offset_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::vectorField& Foam::mappedPatchBase::offsets() const
|
inline const Foam::vectorField& Foam::mappedPatchBase::offsets() const noexcept
|
||||||
{
|
{
|
||||||
return offsets_;
|
return offsets_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::mappedPatchBase::getCommunicator() const
|
||||||
|
{
|
||||||
|
// Cached communicator, or a get a new one
|
||||||
|
if (communicator_ == -1)
|
||||||
|
{
|
||||||
|
const_cast<label&>(communicator_) = getWorldCommunicator();
|
||||||
|
}
|
||||||
|
return communicator_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::mappedPatchBase::comm() const
|
inline Foam::label Foam::mappedPatchBase::comm() const
|
||||||
{
|
{
|
||||||
return comm_;
|
// Cached communicator, or a get a new one
|
||||||
|
if (communicator_ == -1)
|
||||||
|
{
|
||||||
|
const_cast<label&>(communicator_) = getWorldCommunicator();
|
||||||
|
}
|
||||||
|
return communicator_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::mappedPatchBase::sameWorld() const
|
inline bool Foam::mappedPatchBase::sameWorld() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
(
|
||||||
UPstream::allWorlds().size() == 1
|
UPstream::allWorlds().size() == 1
|
||||||
|| UPstream::myWorld() == sampleWorld_;
|
|| sampleWorld_.empty()
|
||||||
|
|| UPstream::myWorld() == sampleWorld_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -164,18 +183,14 @@ inline bool Foam::mappedPatchBase::masterWorld() const
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use ordering in allWorlds
|
// Use ordering in allWorlds
|
||||||
const label myWorld = UPstream::myWorldID();
|
const label otherWorldId = UPstream::allWorlds().find(sampleWorld_);
|
||||||
const label mySampleWorld =
|
return (otherWorldId < 0 || (UPstream::myWorldID() < otherWorldId));
|
||||||
UPstream::allWorlds().find(sampleWorld_);
|
|
||||||
return myWorld < mySampleWorld;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::mappedPatchBase::sameRegion() const
|
inline bool Foam::mappedPatchBase::sameRegion() const noexcept
|
||||||
{
|
{
|
||||||
return sameRegion_;
|
return sameRegion_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,14 +29,16 @@ License
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::mappedPatchBase::distribute(List<Type>& lst) const
|
void Foam::mappedPatchBase::distribute(List<Type>& lst) const
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
const label myComm = getCommunicator(); // Get or create
|
||||||
Pstream::warnComm = comm_;
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
|
Pstream::warnComm = myComm;
|
||||||
|
|
||||||
switch (mode_)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case NEARESTPATCHFACEAMI:
|
case NEARESTPATCHFACEAMI:
|
||||||
{
|
{
|
||||||
const label oldWorldComm = Pstream::worldComm;
|
const label oldWorldComm(Pstream::worldComm);
|
||||||
Pstream::worldComm = comm_;
|
Pstream::worldComm = myComm;
|
||||||
|
|
||||||
if (sameWorld())
|
if (sameWorld())
|
||||||
{
|
{
|
||||||
@ -90,7 +93,8 @@ void Foam::mappedPatchBase::distribute(List<Type>& lst) const
|
|||||||
map().distribute(lst);
|
map().distribute(lst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
|
Pstream::warnComm = oldWarnComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,14 +105,16 @@ void Foam::mappedPatchBase::distribute
|
|||||||
const CombineOp& cop
|
const CombineOp& cop
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
const label myComm = getCommunicator(); // Get or create
|
||||||
Pstream::warnComm = comm_;
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
|
Pstream::warnComm = myComm;
|
||||||
|
|
||||||
switch (mode_)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case NEARESTPATCHFACEAMI:
|
case NEARESTPATCHFACEAMI:
|
||||||
{
|
{
|
||||||
const label oldWorldComm = Pstream::worldComm;
|
const label oldWorldComm(Pstream::worldComm);
|
||||||
Pstream::worldComm = comm_;
|
Pstream::worldComm = myComm;
|
||||||
lst = AMI().interpolateToSource(Field<Type>(std::move(lst)), cop);
|
lst = AMI().interpolateToSource(Field<Type>(std::move(lst)), cop);
|
||||||
Pstream::worldComm = oldWorldComm;
|
Pstream::worldComm = oldWorldComm;
|
||||||
break;
|
break;
|
||||||
@ -129,25 +135,28 @@ void Foam::mappedPatchBase::distribute
|
|||||||
cop,
|
cop,
|
||||||
flipOp(),
|
flipOp(),
|
||||||
UPstream::msgType(),
|
UPstream::msgType(),
|
||||||
comm_
|
myComm
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
|
Pstream::warnComm = oldWarnComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::mappedPatchBase::reverseDistribute(List<Type>& lst) const
|
void Foam::mappedPatchBase::reverseDistribute(List<Type>& lst) const
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
const label myComm = getCommunicator(); // Get or create
|
||||||
Pstream::warnComm = comm_;
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
|
Pstream::warnComm = myComm;
|
||||||
|
|
||||||
switch (mode_)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case NEARESTPATCHFACEAMI:
|
case NEARESTPATCHFACEAMI:
|
||||||
{
|
{
|
||||||
const label oldWorldComm = Pstream::worldComm;
|
const label oldWorldComm(Pstream::worldComm);
|
||||||
Pstream::worldComm = comm_;
|
Pstream::worldComm = myComm;
|
||||||
lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)));
|
lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)));
|
||||||
Pstream::worldComm = oldWorldComm;
|
Pstream::worldComm = oldWorldComm;
|
||||||
break;
|
break;
|
||||||
@ -158,7 +167,8 @@ void Foam::mappedPatchBase::reverseDistribute(List<Type>& lst) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
|
Pstream::warnComm = oldWarnComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,14 +179,16 @@ void Foam::mappedPatchBase::reverseDistribute
|
|||||||
const CombineOp& cop
|
const CombineOp& cop
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label oldComm(Pstream::warnComm);
|
const label myComm = getCommunicator(); // Get or create
|
||||||
Pstream::warnComm = comm_;
|
const label oldWarnComm(Pstream::warnComm);
|
||||||
|
Pstream::warnComm = myComm;
|
||||||
|
|
||||||
switch (mode_)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case NEARESTPATCHFACEAMI:
|
case NEARESTPATCHFACEAMI:
|
||||||
{
|
{
|
||||||
const label oldWorldComm = Pstream::worldComm;
|
const label oldWorldComm(Pstream::worldComm);
|
||||||
Pstream::worldComm = comm_;
|
Pstream::worldComm = myComm;
|
||||||
lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)), cop);
|
lst = AMI().interpolateToTarget(Field<Type>(std::move(lst)), cop);
|
||||||
Pstream::worldComm = oldWorldComm;
|
Pstream::worldComm = oldWorldComm;
|
||||||
break;
|
break;
|
||||||
@ -198,12 +210,13 @@ void Foam::mappedPatchBase::reverseDistribute
|
|||||||
cop,
|
cop,
|
||||||
flipOp(),
|
flipOp(),
|
||||||
UPstream::msgType(),
|
UPstream::msgType(),
|
||||||
comm_
|
myComm
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pstream::warnComm = oldComm;
|
|
||||||
|
Pstream::warnComm = oldWarnComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user