42 cyclicACMIGAMGInterface,
48 cyclicACMIGAMGInterface,
56 Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
63 const label fineLevelIndex,
64 const label coarseComm
90 const auto& fineCyclicACMIInterface =
91 refCast<const cyclicACMILduInterface>(fineInterface);
101 localRestrictAddressing.
size()
106 for (
const label curMaster : localRestrictAddressing)
108 const auto iter = masterToCoarseFace.
cfind(curMaster);
113 dynFaceRestrictAddressing.append(iter.val());
118 const label coarseI = dynFaceCells.size();
119 dynFaceRestrictAddressing.append(coarseI);
120 dynFaceCells.append(curMaster);
121 masterToCoarseFace.insert(curMaster, coarseI);
132 if (fineCyclicACMIInterface.owner())
141 DynamicList<label> dynNbrFaceRestrictAddressing
143 neighbourRestrictAddressing.
size()
146 Map<label> masterToCoarseFace(neighbourRestrictAddressing.
size());
148 for (
const label curMaster : neighbourRestrictAddressing)
150 const auto iter = masterToCoarseFace.cfind(curMaster);
155 dynNbrFaceRestrictAddressing.
append(iter.val());
160 const label coarseI = masterToCoarseFace.size();
161 dynNbrFaceRestrictAddressing.append(coarseI);
162 masterToCoarseFace.insert(curMaster, coarseI);
166 nbrFaceRestrictAddressing.transfer(dynNbrFaceRestrictAddressing);
174 fineCyclicACMIInterface.AMI(),
176 nbrFaceRestrictAddressing
183 Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
190 GAMGInterface(index, coarseInterfaces, is),
206 const label comm =
AMI().
comm();
216 Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
220 const lduInterface& fineInterface,
226 const label coarseComm,
227 const label myProcNo,
236 faceRestrictAddresssing
244 const cyclicACMILduInterface
245 >(fineInterface).neighbPatchID()
250 refCast<const cyclicACMILduInterface>(fineInterface).owner()
254 refCast<const cyclicACMILduInterface>(fineInterface).forwardT()
258 refCast<const cyclicACMILduInterface>(fineInterface).reverseT()
291 FixedList<bool, 4>&
bools = globalInfo.second().
first().first();
294 label& firstValidAMI = globalInfo.first();
295 bool& requireMatch =
bools[0];
296 bool& reverseTarget =
bools[1];
297 bool& srcHasFlip =
bools[2];
298 bool& tgtHasFlip =
bools[3];
299 scalar& lowWeightCorrection = globalInfo.second().
first().second();
300 label& singlePatchProc = globalInfo.second().second();
304 requireMatch =
false;
305 reverseTarget =
false;
308 lowWeightCorrection = -1;
309 singlePatchProc = -1;
312 bool hasSrcMagSf =
false;
313 bool hasSrcCentroids =
false;
314 bool hasTgtMagSf =
false;
318 forAll(allInterfaces, inti)
320 if (allInterfaces.set(inti))
323 refCast<const cyclicACMIGAMGInterface>(allInterfaces[inti]);
332 firstValidAMI = inti;
335 const auto&
AMI = intf.AMI();
339 singlePatchProc = -1;
365 hasSrcCentroids =
true;
395 [](AMIType&
x,
const AMIType&
y)
397 if (
y.first() <
x.first())
408 <<
" singlePatchProc:" << singlePatchProc
409 <<
" srcHasFlip:" << srcHasFlip
410 <<
" tgtHasFlip:" << tgtHasFlip
411 <<
" requireMatch:" << requireMatch
412 <<
" reverseTarget:" << reverseTarget
413 <<
" lowWeightCorrection:" << lowWeightCorrection
414 <<
" hasSrcMagSf:" << hasSrcMagSf
415 <<
" hasSrcCentroids:" << hasSrcCentroids
416 <<
" hasTgtMagSf:" << hasTgtMagSf
434 autoPtr<mapDistribute> srcToTgtMap;
437 autoPtr<mapDistribute> tgtToSrcMap;
439 if (singlePatchProc == -1)
446 labelList localRanks(allInterfaces.size(), -1);
453 forAll(allInterfaces, inti)
455 if (allInterfaces.set(inti))
457 const auto& intf = refCast<const cyclicACMIGAMGInterface>
462 if (!intf.amiPtr_ || intf.AMI().comm() == -1)
471 DynamicList<label> oldRanks(nOldRanks);
472 forAll(allInterfaces, inti)
474 if (allInterfaces.set(inti))
476 const auto& intf = refCast<const cyclicACMIGAMGInterface>
481 if (!intf.amiPtr_ || intf.AMI().comm() == -1)
487 if (intf.myProcNo() == -1)
495 fineRank = intf.myProcNo();
498 oldRanks.append(fineRank);
499 localRanks[inti] = fineRank;
515 UPtrList<const mapDistribute> srcMaps(allInterfaces.size());
516 UPtrList<const mapDistribute> tgtMaps(allInterfaces.size());
517 forAll(allInterfaces, inti)
519 if (allInterfaces.set(inti))
521 const auto& intf = refCast<const cyclicACMIGAMGInterface>
532 const auto&
AMI = intf.AMI();
545 List<Map<label>> srcCompactMaps;
563 if (tgtAddress.size())
566 forAll(allInterfaces, inti)
568 if (allInterfaces.set(inti))
570 const auto& intf = refCast<const cyclicACMIGAMGInterface>
580 const auto&
AMI = intf.AMI();
582 const label localSize =
583 srcStartOfLocal[inti+1]
584 - srcStartOfLocal[inti];
589 auto& newSlots = tgtAddress[alli++];
590 newSlots = tgtSlots[tgti];
597 srcStartOfLocal[inti],
598 srcCompactMaps[inti],
602 for (
const label slot : newSlots)
607 || slot >= srcToTgtMap().constructSize()
627 List<Map<label>> tgtCompactMaps;
645 if (srcAddress.size())
648 forAll(allInterfaces, inti)
650 if (allInterfaces.set(inti))
652 const auto& intf = refCast<const cyclicACMIGAMGInterface>
662 const auto&
AMI = intf.AMI();
664 const label localSize =
665 tgtStartOfLocal[inti+1]
666 - tgtStartOfLocal[inti];
671 auto& newSlots = srcAddress[alli++];
672 newSlots = srcSlots[srci];
678 tgtStartOfLocal[inti],
679 tgtCompactMaps[inti],
683 for (
const label slot : newSlots)
688 || slot >= tgtToSrcMap().constructSize()
712 const auto& map = srcToTgtMap().subMap();
714 bool usesRemote =
false;
717 if (proci != myAgglom)
719 const auto& ss = srcToTgtMap().subMap()[proci];
720 const auto& sc = srcToTgtMap().constructMap()[proci];
721 const auto& ts = tgtToSrcMap().subMap()[proci];
722 const auto& tc = tgtToSrcMap().constructMap()[proci];
724 if (ss.size() || sc.size() || ts.size() || tc.size())
738 DebugPout<<
"** making fully local on new rank " 739 << myAgglom <<
" in comm:" << coarseComm <<
endl;
740 singlePatchProc = myAgglom;
750 srcAddress.setSize(nSrc);
751 tgtAddress.setSize(nTgt);
755 forAll(allInterfaces, inti)
757 if (allInterfaces.set(inti))
759 const auto& intf = refCast<const cyclicACMIGAMGInterface>
769 const auto&
AMI = intf.AMI();
772 if (srcAddress.size())
777 srcAddress[srci++] = srcA[i]+nTgt;
782 if (tgtAddress.size())
787 tgtAddress[tgti++] = tgtA[i]+nSrc;
797 srcWeights.setSize(nSrc);
800 srcMagSf.setSize(nSrc);
804 srcCentroids.setSize(nSrc);
806 tgtWeights.setSize(nTgt);
809 tgtMagSf.setSize(nTgt);
816 forAll(allInterfaces, inti)
818 if (allInterfaces.set(inti))
820 const auto& intf = refCast<const cyclicACMIGAMGInterface>
830 const auto&
AMI = intf.AMI();
835 SubList<scalarList>(srcWeights, srcA.size(), nSrc) =
841 SubList<scalar>(srcMagSf, srcA.size(), nSrc) =
848 SubList<pointList>(srcCentroids, srcA.size(), nSrc) =
856 SubList<scalarList>(tgtWeights, tgtA.size(), nTgt) =
861 SubList<scalar>(tgtMagSf, tgtA.size(), nTgt) =
882 amiPtr_().comm(coarseComm),
885 std::move(srcToTgtMap),
886 std::move(tgtToSrcMap),
887 std::move(srcAddress),
888 std::move(srcWeights),
889 std::move(tgtAddress),
890 std::move(tgtWeights),
893 amiPtr_().srcMagSf() = std::move(srcMagSf);
894 amiPtr_().srcCentroids() = std::move(srcCentroids);
895 amiPtr_().tgtMagSf() = std::move(tgtMagSf);
922 pnf[facei] = iF[nbrFaceCells[facei]];
933 const bool hasAMI = bool(amiPtr_);
947 const label comm = AMI().comm();
List< scalar > scalarList
List of scalar.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
GAMG agglomerated cyclic ACMI interface.
void size(const label n)
Older name for setAddressableSize.
const pointListList & srcCentroids() const
Return const access to source patch face centroids.
label comm() const noexcept
Communicator (local or otherwise) for parallel operations.
errorManipArg< error, int > exit(error &err, const int errNo=1)
commsTypes
Communications types.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
const scalarListList & tgtWeights() const
Return const access to target patch weights.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
AMIInterpolation AMIPatchToPatchInterpolation
Patch-to-patch interpolation == Foam::AMIInterpolation.
virtual const labelUList & faceCells() const
Return faceCell addressing.
const mapDistribute & srcMap() const
Source map - valid only if singlePatchProc = -1 This gets source data into a form to be consumed by t...
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
virtual void write(Ostream &) const
Write to stream.
const labelListList & tgtAddress() const
Return const access to target patch addressing.
T & first()
Access first element of the list, position [0].
bool requireMatch() const noexcept
Return the requireMatch flag.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
static int & msgType() noexcept
Message tag of standard messages.
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
labelList faceRestrictAddressing_
Face restrict addressing.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
bool distributed() const noexcept
Distributed across processors (singlePatchProc == -1)
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
void setSize(const label n)
Alias for resize()
const List< scalar > & tgtMagSf() const
Return const access to target patch face areas.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
List< scalarList > scalarListList
List of scalarList.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
An abstract base class for cyclic ACMI coupled interfaces.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
const scalarListList & srcWeights() const
Return const access to source patch weights.
bool constructHasFlip() const noexcept
Does constructMap include a sign.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
const List< scalar > & srcMagSf() const
Return const access to source patch face areas.
Abstract base class for GAMG agglomerated interfaces.
static void combineReduce(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors...
virtual void write(Ostream &) const =0
Write to stream.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
virtual const AMIPatchToPatchInterpolation & AMI() const
#define DebugPout
Report an information message using Foam::Pout.
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm, const int tag=UPstream::msgType())
Gather individual values into list locations.
labelList faceCells_
Face-cell addressing.
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Transfer and return internal field adjacent to the interface.
List< label > labelList
A List of labels.
const mapDistribute & tgtMap() const
Target map - valid only if singlePatchProc=-1. This gets target data into a form to be consumed by sr...
List< pointList > pointListList
List of pointList.
A class for managing temporary objects.
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
const labelListList & srcAddress() const
Return const access to source patch addressing.
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
static label renumberMap(labelListList &mapElements, const labelUList &oldToNew, const bool hasFlip)
Helper for renumbering the (compacted) map elements using the supplied old-to-new mapping...
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)