44 const List<nearestAndDist>& localInfo,
45 const primitivePatch& srcPatch,
46 const primitivePatch& tgtPatch
52 boundBox(tgtPatch.points(), tgtPatch.meshPoints(),
false);
57 const pointField& srcCcs = srcPatch.faceCentres();
60 forAll(localInfo, srcFacei)
65 const scalar r2 = localInfo[srcFacei].second();
71 if (procBbs[proci].overlaps(srcCcs[srcFacei], r2))
73 dynSendMap[proci].append(srcFacei);
83 sendMap[proci].transfer(dynSendMap[proci]);
87 Pout<<
"send map - to proc " << proci <<
" sending "
88 << sendMap[proci].size() <<
" elements" <<
endl;
102Foam::autoPtr<Foam::mapDistribute> Foam::nearestFaceAMI::calcDistributed
133 const auto& tgtTree = tgtTreePtr();
137 const point& srcCc = srcCcs[srcCelli];
140 test = tgtTree.findNearest(srcCc, GREAT);
145 localInfo[srcCelli].second() = test.point().distSqr(srcCc);
146 test.setIndex(globalTgtCells.toGlobal(myRank, test.index()));
155 for (
auto& info : localInfo)
157 info.second() = GREAT;
171 map.distribute(remoteInfo);
174 map.distribute(srcCcs);
178 const auto& tgtTree = tgtTreePtr();
185 test = tgtTree.findNearest(srcCcs[i], remoteInfo[i].second());
188 test.setIndex(globalTgtCells.toGlobal(myRank, test.index()));
189 testInfo.second() = test.point().distSqr(srcCcs[i]);
206 map.constructHasFlip(),
223 srcToTgtAddr.setSize(src.size());
224 srcToTgtWght.setSize(src.size());
225 forAll(srcToTgtAddr, srcFacei)
227 nearestEqOp()(localInfo[srcFacei], remoteInfo[srcFacei]);
228 if (localInfo[srcFacei].second() < maxDistance2_)
230 const label tgtFacei = localInfo[srcFacei].first().index();
231 srcToTgtAddr[srcFacei] =
labelList(1, tgtFacei);
253 const bool reverseTarget
257 maxDistance2_(
dict.getOrDefault<scalar>(
"maxDistance2", GREAT))
263 const bool requireMatch,
264 const bool reverseTarget,
265 const scalar lowWeightCorrection
276 maxDistance2_(ami.maxDistance2_)
296 const auto& src = this->srcPatch0();
297 const auto& tgt = this->tgtPatch0();
300 srcMagSf_ =
mag(src.faceAreas());
301 tgtMagSf_ =
mag(tgt.faceAreas());
304 bool symmetric_ =
true;
306 if (this->distributed() && comm() != -1)
331 srcAddress_.setSize(src.size());
332 srcWeights_.setSize(src.size());
336 tgtAddress_.setSize(tgt.size());
337 tgtWeights_.setSize(tgt.size());
343 const auto tgtTreePtr = this->
createTree(tgtPatch);
344 const auto& tgtTree = tgtTreePtr();
348 const point& srcCc = srcCcs[srcFacei];
354 && (
magSqr(srcCc - tgtCcs[hit.index()]) < maxDistance2_)
357 label tgtFacei = hit.index();
358 srcAddress_[srcFacei] =
labelList(1, tgtFacei);
363 tgtAddress_[tgtFacei] =
labelList(1, srcFacei);
372 <<
"Unable to find target face for source face "
380 const auto srcTreePtr = this->
createTree(srcPatch);
381 const auto& srcTree = srcTreePtr();
385 forAll(tgtWeights_, tgtCelli)
387 if (tgtAddress_[tgtCelli].empty())
389 const point& tgtCc = tgtCcs[tgtCelli];
395 && (
magSqr(tgtCc - srcCcs[hit.index()]) < maxDistance2_)
398 tgtAddress_[tgtCelli] =
labelList(1, hit.index());
407 <<
"Unable to find source face for target face "
415 srcWeightsSum_.setSize(srcWeights_.size(), 1);
416 tgtWeightsSum_.setSize(tgtWeights_.size(), 1);
427 os.writeEntryIfDifferent<scalar>(
"maxDistance2", GREAT, maxDistance2_);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
labelListList srcAddress_
Addresses of target faces per source face.
label comm() const noexcept
Communicator (local or otherwise) for parallel operations.
bool distributed() const noexcept
Distributed across processors (singlePatchProc == -1).
scalarList tgtMagSf_
Target face areas.
autoPtr< mapDistribute > srcMapPtr_
Source map pointer - parallel running only.
AMIInterpolation(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
bool requireMatch() const noexcept
Return the requireMatch flag.
const primitivePatch & tgtPatch0() const
Return the original tgt patch with optionally updated points.
bool upToDate_
Up-to-date flag.
autoPtr< mapDistribute > tgtMapPtr_
Target map pointer - parallel running only.
virtual void write(Ostream &os) const
Write AMI as a dictionary.
labelListList tgtAddress_
Addresses of source faces per target face.
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
scalarField srcWeightsSum_
Sum of weights of target faces per source face.
scalarListList tgtWeights_
Weights of source faces per target face.
scalarListList srcWeights_
Weights of target faces per source face.
scalarList srcMagSf_
Source face areas.
const primitivePatch & srcPatch0() const
Return the original src patch with optionally updated points.
scalarField tgtWeightsSum_
Sum of weights of source faces per target face.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
static int & msgType() noexcept
Message tag of standard messages.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
static void distribute(const UPstream::commsTypes commsType, const UList< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const T &nullValue, const CombineOp &cop, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute combine data with specified combine operation and negate operator (for flips).
Class containing processor-to-processor mapping information.
Nearest-face Arbitrary Mesh Interface (AMI) method.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing and weights.
nearestFaceAMI(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
virtual void write(Ostream &os) const
Write.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for handling debugging switches.
List< scalarList > scalarListList
List of scalarList.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
static autoPtr< indexedOctree< treeDataPoint > > createTree(const pointField &points)
Construct search tree for points.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Tuple2< pointIndexHit, scalar > nearestAndDist
Combine operator for nearest.
const nearestAndDist nearestZero(nearestAndDist(pointIndexHit(), -GREAT))
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
List< scalar > scalarList
List of scalar.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized.