56Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
63 const label fineLevelIndex,
64 const label coarseComm
90 const auto& fineCyclicACMIInterface =
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
183Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
190 GAMGInterface(index, coarseInterfaces, is),
206 const label comm =
AMI().
comm();
216Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
226 const label coarseComm,
227 const label myProcNo,
236 faceRestrictAddresssing
245 >(fineInterface).neighbPatchID()
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))
332 firstValidAMI = inti;
335 const auto&
AMI = intf.AMI();
343 if (!
AMI.distributed())
345 singlePatchProc =
AMI.singlePatchProc();
347 else if (
AMI.comm() != -1)
349 singlePatchProc = -1;
351 srcHasFlip ||
AMI.srcMap().constructHasFlip();
353 tgtHasFlip ||
AMI.tgtMap().constructHasFlip();
355 requireMatch =
AMI.requireMatch();
356 reverseTarget =
AMI.reverseTarget();
357 lowWeightCorrection =
AMI.lowWeightCorrection();
359 nSrc +=
AMI.srcAddress().size();
360 nTgt +=
AMI.tgtAddress().size();
362 if (
AMI.srcMagSf().size())
365 if (
AMI.srcMagSf().size() !=
AMI.srcAddress().size())
368 <<
"srcMagSf size:" <<
AMI.srcMagSf().size()
369 <<
"srcAddress size:" <<
AMI.srcAddress().size()
373 if (
AMI.srcCentroids().size())
375 hasSrcCentroids =
true;
376 if (
AMI.srcCentroids().size() !=
AMI.srcAddress().size())
379 <<
"srcCentroids size:" <<
AMI.srcCentroids().size()
380 <<
"srcAddress size:" <<
AMI.srcAddress().size()
384 if (
AMI.tgtMagSf().size())
387 if (
AMI.tgtMagSf().size() !=
AMI.tgtAddress().size())
390 <<
"tgtMagSf size:" <<
AMI.tgtMagSf().size()
391 <<
"tgtAddress size:" <<
AMI.tgtAddress().size()
405 [](AMIType&
x,
const AMIType&
y)
407 if (
y.first() <
x.first())
418 <<
" singlePatchProc:" << singlePatchProc
419 <<
" srcHasFlip:" << srcHasFlip
420 <<
" tgtHasFlip:" << tgtHasFlip
421 <<
" requireMatch:" << requireMatch
422 <<
" reverseTarget:" << reverseTarget
423 <<
" lowWeightCorrection:" << lowWeightCorrection
424 <<
" hasSrcMagSf:" << hasSrcMagSf
425 <<
" hasSrcCentroids:" << hasSrcCentroids
426 <<
" hasTgtMagSf:" << hasTgtMagSf
444 autoPtr<mapDistribute> srcToTgtMap;
447 autoPtr<mapDistribute> tgtToSrcMap;
449 if (singlePatchProc == -1)
456 labelList localRanks(allInterfaces.size(), -1);
463 forAll(allInterfaces, inti)
465 if (allInterfaces.set(inti))
472 if (!intf.amiPtr_ || intf.AMI().comm() == -1)
481 DynamicList<label> oldRanks(nOldRanks);
482 forAll(allInterfaces, inti)
484 if (allInterfaces.set(inti))
491 if (!intf.amiPtr_ || intf.AMI().comm() == -1)
497 if (intf.myProcNo() == -1)
505 fineRank = intf.myProcNo();
508 oldRanks.append(fineRank);
509 localRanks[inti] = fineRank;
525 UPtrList<const mapDistribute> srcMaps(allInterfaces.size());
526 UPtrList<const mapDistribute> tgtMaps(allInterfaces.size());
527 forAll(allInterfaces, inti)
529 if (allInterfaces.set(inti))
542 const auto&
AMI = intf.AMI();
544 if (
AMI.comm() != -1)
546 srcMaps.set(inti, &
AMI.srcMap());
547 tgtMaps.set(inti, &
AMI.tgtMap());
555 List<Map<label>> srcCompactMaps;
573 if (tgtAddress.size())
576 forAll(allInterfaces, inti)
578 if (allInterfaces.set(inti))
590 const auto&
AMI = intf.AMI();
591 const auto& tgtSlots =
AMI.tgtAddress();
592 const label localSize =
593 srcStartOfLocal[inti+1]
594 - srcStartOfLocal[inti];
599 auto& newSlots = tgtAddress[alli++];
600 newSlots = tgtSlots[tgti];
607 srcStartOfLocal[inti],
608 srcCompactMaps[inti],
612 for (
const label slot : newSlots)
617 || slot >= srcToTgtMap().constructSize()
637 List<Map<label>> tgtCompactMaps;
655 if (srcAddress.size())
658 forAll(allInterfaces, inti)
660 if (allInterfaces.set(inti))
672 const auto&
AMI = intf.AMI();
673 const auto& srcSlots =
AMI.srcAddress();
674 const label localSize =
675 tgtStartOfLocal[inti+1]
676 - tgtStartOfLocal[inti];
681 auto& newSlots = srcAddress[alli++];
682 newSlots = srcSlots[srci];
688 tgtStartOfLocal[inti],
689 tgtCompactMaps[inti],
693 for (
const label slot : newSlots)
698 || slot >= tgtToSrcMap().constructSize()
722 const auto& map = srcToTgtMap().subMap();
724 bool usesRemote =
false;
727 if (proci != myAgglom)
729 const auto& ss = srcToTgtMap().subMap()[proci];
730 const auto& sc = srcToTgtMap().constructMap()[proci];
731 const auto& ts = tgtToSrcMap().subMap()[proci];
732 const auto& tc = tgtToSrcMap().constructMap()[proci];
734 if (ss.size() || sc.size() || ts.size() || tc.size())
748 DebugPout<<
"** making fully local on new rank "
749 << myAgglom <<
" in comm:" << coarseComm <<
endl;
750 singlePatchProc = myAgglom;
760 srcAddress.setSize(nSrc);
761 tgtAddress.setSize(nTgt);
765 forAll(allInterfaces, inti)
767 if (allInterfaces.set(inti))
779 const auto&
AMI = intf.AMI();
781 const auto& srcA =
AMI.srcAddress();
782 if (srcAddress.size())
787 srcAddress[srci++] = srcA[i]+nTgt;
791 const auto& tgtA =
AMI.tgtAddress();
792 if (tgtAddress.size())
797 tgtAddress[tgti++] = tgtA[i]+nSrc;
807 srcWeights.setSize(nSrc);
810 srcMagSf.setSize(nSrc);
814 srcCentroids.setSize(nSrc);
816 tgtWeights.setSize(nTgt);
819 tgtMagSf.setSize(nTgt);
826 forAll(allInterfaces, inti)
828 if (allInterfaces.set(inti))
840 const auto&
AMI = intf.AMI();
842 const auto& srcA =
AMI.srcAddress();
845 SubList<scalarList>(srcWeights, srcA.size(), nSrc) =
851 SubList<scalar>(srcMagSf, srcA.size(), nSrc) =
858 SubList<pointList>(srcCentroids, srcA.size(), nSrc) =
863 const auto& tgtA =
AMI.tgtAddress();
866 SubList<scalarList>(tgtWeights, tgtA.size(), nTgt) =
871 SubList<scalar>(tgtMagSf, tgtA.size(), nTgt) =
892 amiPtr_().comm(coarseComm),
895 std::move(srcToTgtMap),
896 std::move(tgtToSrcMap),
897 std::move(srcAddress),
898 std::move(srcWeights),
899 std::move(tgtAddress),
900 std::move(tgtWeights),
903 amiPtr_().srcMagSf() = std::move(srcMagSf);
904 amiPtr_().srcCentroids() = std::move(srcCentroids);
905 amiPtr_().tgtMagSf() = std::move(tgtMagSf);
932 pnf[facei] = iF[nbrFaceCells[facei]];
943 const bool hasAMI = bool(amiPtr_);
957 const label comm = AMI().comm();
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label comm() const noexcept
Communicator (local or otherwise) for parallel operations.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A 1D vector of objects of type <T> with a fixed length <N>.
Abstract base class for GAMG agglomerated interfaces.
labelList faceRestrictAddressing_
Face restrict addressing.
virtual label index() const
virtual const lduInterfacePtrsList & coarseInterfaces() const
virtual const labelUList & faceCells() const
Return faceCell addressing.
labelList faceCells_
Face-cell addressing.
GAMGInterface(const GAMGInterface &)=delete
No copy construct.
virtual void write(Ostream &) const =0
Write to stream.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
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.
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm, const int tag=UPstream::msgType())
Gather individual values into list locations.
A non-owning sub-view of a List (allocated or unallocated storage).
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
T & first()
Access first element of the list, position [0].
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
commsTypes
Communications types.
static int & msgType() noexcept
Message tag of standard messages.
@ broadcast
broadcast [MPI]
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
label size() const noexcept
The number of entries in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void clear() noexcept
Same as reset(nullptr).
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
GAMG agglomerated cyclic ACMI interface.
virtual const cyclicACMIGAMGInterface & neighbPatch() const
Return processor number.
virtual void write(Ostream &) const
Write to stream.
virtual bool owner() const
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual label neighbPatchID() const
Cyclic interface functions.
virtual const AMIPatchToPatchInterpolation & AMI() const
virtual label myProcNo() const
-1 or old local rank
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Transfer and return internal field adjacent to the interface.
virtual const tensorField & forwardT() const
Return face transformation tensor.
An abstract base class for cyclic ACMI coupled interfaces.
cyclicACMILduInterface() noexcept=default
Default construct.
Smooth ATC in cells next to a set of patches supplied by type.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
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.
Class containing processor-to-processor mapping information.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugPout
Report an information message using Foam::Pout.
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
List< scalarList > scalarListList
List of scalarList.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
Ostream & endl(Ostream &os)
Add newline and flush stream.
AMIInterpolation AMIPatchToPatchInterpolation
Patch-to-patch interpolation == Foam::AMIInterpolation.
Field< label > labelField
Specialisation of Field<T> for label.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
List< scalar > scalarList
List of scalar.
List< pointList > pointListList
List of pointList.
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&).
#define forAll(list, i)
Loop across all elements in list.