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))
57 WarningIn(
"AMIMethod<SourcePatch, TargetPatch>::checkPatches()")
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())
99 "void Foam::AMIMethod<SourcePatch, TargetPatch>::initialise" 109 << srcPatch_.size() <<
" source faces but no target faces" <<
endl;
118 if ((srcFaceI == -1) || (tgtFaceI == -1))
122 bool foundFace =
false;
125 tgtFaceI = findTargetFace(faceI);
140 "void Foam::AMIMethod<SourcePatch, TargetPatch>::initialise" 149 ) <<
"Unable to find initial target face" 159 Pout<<
"AMI: initial target face = " << tgtFaceI <<
endl;
166 template<
class SourcePatch,
class TargetPatch>
176 static label count = 1;
181 Pout<<
"Face intersection area (" << count <<
"):" <<
nl 182 <<
" f1 face = " << f1 <<
nl 183 <<
" f1 pts = " << f1pts <<
nl 184 <<
" f2 face = " << f2 <<
nl 185 <<
" f2 pts = " << f2pts <<
nl 186 <<
" area = " << area
210 os<<
" " << f1pts.
size() + i + 1;
212 os<<
" " << f1pts.
size() + 1 <<
endl;
218 template<
class SourcePatch,
class TargetPatch>
227 if (!treePtr_.valid())
249 template<
class SourcePatch,
class TargetPatch>
255 label targetFaceI = -1;
257 const pointField& srcPts = srcPatch_.points();
258 const face& srcFace = srcPatch_[srcFaceI];
260 const scalar srcFaceArea = srcMagSf_[srcFaceI];
262 pointIndexHit sample = treePtr_->findNearest(srcPt, 10.0*srcFaceArea);
266 targetFaceI = sample.
index();
270 Pout<<
"Source point = " << srcPt <<
", Sample point = " 271 << sample.
hitPoint() <<
", Sample index = " << sample.
index()
280 template<
class SourcePatch,
class TargetPatch>
284 const TargetPatch& patch,
289 const labelList& nbrFaces = patch.faceFaces()[faceI];
294 label nbrFaceI = nbrFaces[i];
298 if (nbrFaceI == visitedFaces[j])
309 if (nbrFaceI == faceIDs[j])
320 const vector& n1 = patch.faceNormals()[faceI];
321 const vector& n2 = patch.faceNormals()[nbrFaceI];
323 scalar cosI = n1 & n2;
336 template<
class SourcePatch,
class TargetPatch>
339 const SourcePatch& srcPatch,
340 const TargetPatch& tgtPatch,
344 const bool reverseTarget,
345 const bool requireMatch
350 reverseTarget_(reverseTarget),
351 requireMatch_(requireMatch),
361 template<
class SourcePatch,
class TargetPatch>
368 template<
class SourcePatch,
class TargetPatch>
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
void appendNbrFaces(const label faceI, const TargetPatch &patch, const DynamicList< label > &visitedFaces, DynamicList< label > &faceIDs) const
Add faces neighbouring faceI to the ID list.
word name(const complex &)
Return a string representation of a complex.
Base class for Arbitrary Mesh Interface (AMI) methods.
label findTargetFace(const label srcFaceI) const
Find face on target patch that overlaps source face.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Standard boundBox + extra functionality for use in octree.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool hit() const
Is there a hit.
label index() const
Return index.
point centre(const pointField &) const
Centre point of face.
const Point & hitPoint() const
Return hit point.
A face is a list of labels corresponding to mesh vertices.
bool initialise(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label &srcFaceI, label &tgtFaceI)
Initialise and return true if all ok.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
dimensionedScalar cos(const dimensionedScalar &ds)
void checkPatches() const
Check AMI patch coupling.
Unit conversion functions.
Encapsulation of data needed to search on PrimitivePatches.
errorManip< error > abort(error &err)
virtual ~AMIMethod()
Destructor.
void writeIntersectionOBJ(const scalar area, const face &f1, const face &f2, const pointField &f1Points, const pointField &f2Points) const
Write triangle intersection to OBJ file.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A bounding box defined in terms of the points at its extremities.
Non-pointer based hierarchical recursive searching.
virtual bool conformal() const
Flag to indicate that interpolation patches are conformal.
void resetTree()
Reset the octree for the target patch face search.
pointField points(const pointField &) const
Return the points corresponding to this face.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of point.
prefixOSstream Pout(cout,"Pout")