44 const List<nearestAndDist>& localInfo,
52 boundBox(tgtPatch.points(), tgtPatch.meshPoints(),
true);
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;
104 autoPtr<indexedOctree<treeType>> tgtTreePtr;
111 globalIndex globalTgtCells(tgt.size());
121 List<nearestAndDist> localInfo(src.size());
124 const auto& tgtTree = tgtTreePtr();
128 const point& srcCc = srcCcs[srcCelli];
131 test = tgtTree.findNearest(srcCc, GREAT);
136 localInfo[srcCelli].second() = test.point().distSqr(srcCc);
137 test.setIndex(globalTgtCells.toGlobal(test.index()));
146 for (
auto& info : localInfo)
148 info.second() = GREAT;
158 autoPtr<mapDistribute> mapPtr = calcFaceMap(localInfo, src, tgt);
159 mapDistribute& map = mapPtr();
161 List<nearestAndDist> remoteInfo(localInfo);
162 map.distribute(remoteInfo);
165 map.distribute(srcCcs);
169 const auto& tgtTree = tgtTreePtr();
176 test = tgtTree.findNearest(srcCcs[i], remoteInfo[i].second());
179 test.setIndex(globalTgtCells.toGlobal(test.index()));
180 testInfo.second() = test.point().distSqr(srcCcs[i]);
181 nearestEqOp()(remoteInfo[i], testInfo);
197 map.constructHasFlip(),
212 srcToTgtAddr.setSize(src.size());
213 srcToTgtWght.setSize(src.size());
214 forAll(srcToTgtAddr, srcFacei)
216 nearestEqOp()(localInfo[srcFacei], remoteInfo[srcFacei]);
217 if (localInfo[srcFacei].second() < maxDistance2_)
219 const label tgtFacei = localInfo[srcFacei].first().index();
220 srcToTgtAddr[srcFacei] =
labelList(1, tgtFacei);
225 List<Map<label>> cMap;
235 const bool reverseTarget
239 maxDistance2_(
dict.getOrDefault<scalar>(
"maxDistance2", GREAT))
245 const bool requireMatch,
246 const bool reverseTarget,
247 const scalar lowWeightCorrection
258 maxDistance2_(ami.maxDistance2_)
278 const auto& src = this->srcPatch0();
279 const auto& tgt = this->tgtPatch0();
282 srcMagSf_ =
mag(src.faceAreas());
283 tgtMagSf_ =
mag(tgt.faceAreas());
286 bool symmetric_ =
true;
288 if (this->distributed())
313 srcAddress_.setSize(src.size());
314 srcWeights_.setSize(src.size());
318 tgtAddress_.setSize(tgt.size());
319 tgtWeights_.setSize(tgt.size());
325 const auto tgtTreePtr = this->
createTree(tgtPatch);
326 const auto& tgtTree = tgtTreePtr();
330 const point& srcCc = srcCcs[srcFacei];
336 && (
magSqr(srcCc - tgtCcs[hit.index()]) < maxDistance2_)
339 label tgtFacei = hit.index();
340 srcAddress_[srcFacei] =
labelList(1, tgtFacei);
345 tgtAddress_[tgtFacei] =
labelList(1, srcFacei);
354 <<
"Unable to find target face for source face " 362 const auto srcTreePtr = this->
createTree(srcPatch);
363 const auto& srcTree = srcTreePtr();
367 forAll(tgtWeights_, tgtCelli)
369 if (tgtAddress_[tgtCelli].empty())
371 const point& tgtCc = tgtCcs[tgtCelli];
377 && (
magSqr(tgtCc - srcCcs[hit.index()]) < maxDistance2_)
380 tgtAddress_[tgtCelli] =
labelList(1, hit.index());
389 <<
"Unable to find source face for target face " 397 srcWeightsSum_.setSize(srcWeights_.size(), 1);
398 tgtWeightsSum_.setSize(tgtWeights_.size(), 1);
List< scalar > scalarList
List of scalar.
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 myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static const List< T > & null()
Return a null List.
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.
static void allGatherList(List< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses linear/tree communication. ...
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...
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute data with specified negate operator (for flips).
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
"nonBlocking" : (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)
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.