44 const List<nearestAndDist>& localInfo,
45 const primitivePatch& srcPatch,
46 const primitivePatch& tgtPatch
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 dynSendMap[proci].shrink();
84 sendMap[proci].transfer(dynSendMap[proci]);
88 Pout<<
"send map - to proc " << proci <<
" sending "
89 << sendMap[proci].size() <<
" elements" <<
endl;
105 autoPtr<indexedOctree<treeType>> tgtTreePtr;
108 tgtTreePtr = this->createTree(tgt);
112 globalIndex globalTgtCells(tgt.size());
122 List<nearestAndDist> localInfo(src.size());
125 const auto& tgtTree = tgtTreePtr();
129 const point& srcCc = srcCcs[srcCelli];
132 test = tgtTree.findNearest(srcCc, GREAT);
137 localInfo[srcCelli].second() =
magSqr(srcCc - test.hitPoint());
138 test.setIndex(globalTgtCells.toGlobal(test.index()));
147 for (
auto& info : localInfo)
149 info.second() = GREAT;
159 autoPtr<mapDistribute> mapPtr = calcFaceMap(localInfo, src, tgt);
160 mapDistribute& map = mapPtr();
162 List<nearestAndDist> remoteInfo(localInfo);
163 map.distribute(remoteInfo);
166 map.distribute(srcCcs);
170 const auto& tgtTree = tgtTreePtr();
177 test = tgtTree.findNearest(srcCcs[i], remoteInfo[i].second());
180 test.setIndex(globalTgtCells.toGlobal(test.index()));
181 testInfo.second() =
magSqr(test.hitPoint() - srcCcs[i]);
182 nearestEqOp()(remoteInfo[i], testInfo);
192 mapDistributeBase::distribute
198 map.constructHasFlip(),
213 srcToTgtAddr.setSize(src.size());
214 srcToTgtWght.setSize(src.size());
215 forAll(srcToTgtAddr, srcFacei)
217 nearestEqOp()(localInfo[srcFacei], remoteInfo[srcFacei]);
218 if (localInfo[srcFacei].second() < maxDistance2_)
220 const label tgtFacei = localInfo[srcFacei].first().index();
221 srcToTgtAddr[srcFacei] =
labelList(1, tgtFacei);
226 List<Map<label>> cMap;
236 const bool reverseTarget
240 maxDistance2_(
dict.getOrDefault<scalar>(
"maxDistance2", GREAT))
246 const bool requireMatch,
247 const bool reverseTarget,
248 const scalar lowWeightCorrection
259 maxDistance2_(ami.maxDistance2_)
277 AMIInterpolation::calculate(srcPatch, tgtPatch, surfPtr);
279 const auto& src = this->srcPatch0();
280 const auto& tgt = this->tgtPatch0();
283 srcMagSf_ =
mag(src.faceAreas());
284 tgtMagSf_ =
mag(tgt.faceAreas());
287 bool symmetric_ =
true;
289 if (this->distributed())
314 srcAddress_.setSize(src.size());
315 srcWeights_.setSize(src.size());
319 tgtAddress_.setSize(tgt.size());
320 tgtWeights_.setSize(tgt.size());
326 const auto tgtTreePtr = this->createTree(tgtPatch);
327 const auto& tgtTree = tgtTreePtr();
331 const point& srcCc = srcCcs[srcFacei];
337 && (
magSqr(srcCc - tgtCcs[hit.
index()]) < maxDistance2_)
340 label tgtFacei = hit.
index();
341 srcAddress_[srcFacei] =
labelList(1, tgtFacei);
346 tgtAddress_[tgtFacei] =
labelList(1, srcFacei);
355 <<
"Unable to find target face for source face "
363 const auto srcTreePtr = this->createTree(srcPatch);
364 const auto& srcTree = srcTreePtr();
368 forAll(tgtWeights_, tgtCelli)
370 if (tgtAddress_[tgtCelli].empty())
372 const point& tgtCc = tgtCcs[tgtCelli];
378 && (
magSqr(tgtCc - srcCcs[hit.
index()]) < maxDistance2_)
390 <<
"Unable to find source face for target face "
398 srcWeightsSum_.setSize(srcWeights_.size(), 1);
399 tgtWeightsSum_.setSize(tgtWeights_.size(), 1);
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...
static const List< T > & null()
Return a null List.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
A list of faces which address into the list of points.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
static void allGatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
@ nonBlocking
"nonBlocking"
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool write()
Write the output fields.
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.
int myProcNo() const noexcept
Return processor number.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
List< label > labelList
A List of labels.
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
vectorField pointField
pointField is a vectorField.
Tuple2< pointIndexHit, scalar > nearestAndDist
Combine operator for nearest.
List< scalar > scalarList
A List of scalars.
vector point
Point is a vector.
const nearestAndDist nearestZero(nearestAndDist(pointIndexHit(), -GREAT))
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< scalarList > scalarListList
A List of scalarList.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.