44 const List<nearestAndDist>& localInfo,
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;
110 autoPtr<indexedOctree<treeType>> tgtTreePtr;
117 globalIndex globalTgtCells(tgt.size(), comm());
130 List<nearestAndDist> localInfo(src.size());
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;
167 autoPtr<mapDistribute> mapPtr = calcFaceMap(localInfo, src, tgt);
168 mapDistribute& map = mapPtr();
170 List<nearestAndDist> remoteInfo(localInfo);
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]);
190 nearestEqOp()(remoteInfo[i], testInfo);
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);
236 List<Map<label>> cMap;
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);
List< scalar > scalarList
List of scalar.
label comm() const noexcept
Communicator (local or otherwise) for parallel operations.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
static int & msgType() noexcept
Message tag of standard messages.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
A list of faces which address into the list of points.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
static autoPtr< indexedOctree< treeDataPoint > > createTree(const pointField &points)
Construct search tree for points.
List< scalarList > scalarListList
List of scalarList.
Tuple2< pointIndexHit, scalar > nearestAndDist
Combine operator for nearest.
Nearest-face Arbitrary Mesh Interface (AMI) method.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
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.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing and weights.
virtual void write(Ostream &os) const
Write.
nearestFaceAMI(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
List< label > labelList
A List of labels.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
const nearestAndDist nearestZero(nearestAndDist(pointIndexHit(), -GREAT))
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
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)...
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
virtual void write(Ostream &os) const
Write AMI as a dictionary.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)