33 template<
class SourcePatch,
class TargetPatch>
36 if (debug && (!srcPatch_.size() || !tgtPatch_.size()))
38 Pout<<
"AMI: Patches not on processor: Source faces = " 39 << srcPatch_.size() <<
", target faces = " << tgtPatch_.size()
46 const scalar maxBoundsError = 0.05;
49 boundBox bbSrc(srcPatch_.points(), srcPatch_.meshPoints(),
true);
50 boundBox bbTgt(tgtPatch_.points(), tgtPatch_.meshPoints(),
true);
53 bbTgtInf.inflate(maxBoundsError);
55 if (!bbTgtInf.contains(bbSrc))
58 <<
"Source and target patch bounding boxes are not similar" 60 <<
" source box span : " << bbSrc.span() <<
nl 61 <<
" target box span : " << bbTgt.span() <<
nl 62 <<
" source box : " << bbSrc <<
nl 63 <<
" target box : " << bbTgt <<
nl 64 <<
" inflated target box : " << bbTgtInf <<
endl;
70 template<
class SourcePatch,
class TargetPatch>
85 srcAddress.
setSize(srcPatch_.size());
86 srcWeights.
setSize(srcPatch_.size());
87 tgtAddress.
setSize(tgtPatch_.size());
88 tgtWeights.
setSize(tgtPatch_.size());
91 if (!srcPatch_.size())
95 else if (!tgtPatch_.size())
98 << srcPatch_.size() <<
" source faces but no target faces" <<
endl;
107 if ((srcFacei == -1) || (tgtFacei == -1))
111 bool foundFace =
false;
114 tgtFacei = findTargetFace(facei);
128 <<
"Unable to find initial target face" 138 Pout<<
"AMI: initial target face = " << tgtFacei <<
endl;
145 template<
class SourcePatch,
class TargetPatch>
155 static label count = 1;
160 Pout<<
"Face intersection area (" << count <<
"):" <<
nl 161 <<
" f1 face = " << f1 <<
nl 162 <<
" f1 pts = " << f1pts <<
nl 163 <<
" f2 face = " << f2 <<
nl 164 <<
" f2 pts = " << f2pts <<
nl 165 <<
" area = " << area
189 os<<
" " << f1pts.
size() + i + 1;
191 os<<
" " << f1pts.
size() + 1 <<
endl;
197 template<
class SourcePatch,
class TargetPatch>
203 treeBoundBox bb(tgtPatch_.points(), tgtPatch_.meshPoints());
206 if (!treePtr_.valid())
228 template<
class SourcePatch,
class TargetPatch>
234 label targetFacei = -1;
236 const pointField& srcPts = srcPatch_.points();
237 const face& srcFace = srcPatch_[srcFacei];
239 const scalar srcFaceArea = srcMagSf_[srcFacei];
241 pointIndexHit sample = treePtr_->findNearest(srcPt, 10.0*srcFaceArea);
245 targetFacei = sample.
index();
249 Pout<<
"Source point = " << srcPt <<
", Sample point = " 250 << sample.
hitPoint() <<
", Sample index = " << sample.
index()
259 template<
class SourcePatch,
class TargetPatch>
263 const TargetPatch& patch,
268 const labelList& nbrFaces = patch.faceFaces()[facei];
273 label nbrFacei = nbrFaces[i];
277 if (nbrFacei == visitedFaces[j])
288 if (nbrFacei == faceIDs[j])
299 const vector& n1 = patch.faceNormals()[facei];
300 const vector& n2 = patch.faceNormals()[nbrFacei];
302 scalar cosI = n1 & n2;
315 template<
class SourcePatch,
class TargetPatch>
318 const SourcePatch& srcPatch,
319 const TargetPatch& tgtPatch,
323 const bool reverseTarget,
324 const bool requireMatch
329 reverseTarget_(reverseTarget),
330 requireMatch_(requireMatch),
340 template<
class SourcePatch,
class TargetPatch>
347 template<
class SourcePatch,
class TargetPatch>
point centre(const pointField &) const
Centre point of face.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void appendNbrFaces(const label facei, const TargetPatch &patch, const DynamicList< label > &visitedFaces, DynamicList< label > &faceIDs) const
Add faces neighbouring facei to the ID list.
A face is a list of labels corresponding to mesh vertices.
virtual ~AMIMethod()
Destructor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool hit() const
Is there a hit.
Unit conversion functions.
void writeIntersectionOBJ(const scalar area, const face &f1, const face &f2, const pointField &f1Points, const pointField &f2Points) const
Write triangle intersection to OBJ file.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A bounding box defined in terms of the points at its extremities.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
dimensionedScalar cos(const dimensionedScalar &ds)
label findTargetFace(const label srcFacei) const
Find face on target patch that overlaps source face.
Encapsulation of data needed to search on PrimitivePatches.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void resetTree()
Reset the octree for the target patch face search.
void checkPatches() const
Check AMI patch coupling.
errorManip< error > abort(error &err)
Base class for Arbitrary Mesh Interface (AMI) methods.
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
prefixOSstream Pout(cout,"Pout")
word name(const complex &)
Return a string representation of a complex.
void setSize(const label)
Reset size of List.
Non-pointer based hierarchical recursive searching.
#define WarningInFunction
Report a warning using Foam::Warning.
bool initialise(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label &srcFacei, label &tgtFacei)
Initialise and return true if all ok.
label index() const
Return index.
const Point & hitPoint() const
Return hit point.
Standard boundBox + extra functionality for use in octree.
virtual bool conformal() const
Flag to indicate that interpolation patches are conformal.
pointField points(const pointField &) const
Return the points corresponding to this face.