Go to the documentation of this file.
50 if (
debug && (!src.size() || !tgt.size()))
52 Pout<<
"AMI: Patches not on processor: Source faces = "
53 << src.size() <<
", target faces = " << tgt.size()
60 const scalar maxBoundsError = 0.05;
63 boundBox bbSrc(src.points(), src.meshPoints(),
true);
64 boundBox bbTgt(tgt.points(), tgt.meshPoints(),
true);
67 bbTgtInf.inflate(maxBoundsError);
69 if (!bbTgtInf.contains(bbSrc))
72 <<
"Source and target patch bounding boxes are not similar"
74 <<
" source box span : " << bbSrc.span() <<
nl
75 <<
" target box span : " << bbTgt.span() <<
nl
76 <<
" source box : " << bbSrc <<
nl
77 <<
" target box : " << bbTgt <<
nl
78 <<
" inflated target box : " << bbTgtInf <<
endl;
89 extendedTgtMapPtr_.reset(calcProcMap(srcPatch0(), tgtPatch0()));
95 distributeAndMergePatches
107 extendedTgtPatchPtr_.reset
120 const auto& src = this->srcPatch();
121 const auto& tgt = this->tgtPatch();
123 bool foundFace =
false;
130 else if (!tgt.size())
133 << src.size() <<
" source faces but no target faces" <<
endl;
139 treePtr_.reset(createTree(tgt));
142 if ((srcFacei == -1) || (tgtFacei == -1))
148 tgtFacei = findTargetFace(facei);
162 <<
"Unable to find initial target face"
172 Pout<<
"AMI: initial target face = " << tgtFacei <<
endl;
188 static label
count = 1;
193 Pout<<
"Face intersection area (" <<
count <<
"):" <<
nl
194 <<
" f1 face = " << f1 <<
nl
195 <<
" f1 pts = " << f1pts <<
nl
196 <<
" f2 face = " << f2 <<
nl
197 <<
" f2 pts = " << f2pts <<
nl
198 <<
" area = " <<
area
203 for (
const point& pt : f1pts)
214 for (
const point& pt : f2pts)
219 const label
n = f1pts.size();
222 os<<
" " <<
n + i + 1;
232 const label srcFacei,
234 const label srcFacePti
237 const auto& src = srcPatch();
239 label targetFacei = -1;
242 const face& srcFace = src[srcFacei];
246 const boundBox bb(srcPts, srcFace,
false);
249 srcFacePti == -1 ? bb.
centre() : srcPts[srcFace[srcFacePti]];
256 targetFacei =
sample.index();
260 Pout<<
"Source point = " << srcPt <<
", Sample point = "
261 <<
sample.hitPoint() <<
", Sample index = " <<
sample.index()
283 for (
const label nbrFacei : nbrFaces)
286 if (!visitedFaces.found(nbrFacei) && !faceIDs.found(nbrFacei))
291 const scalar cosI = n1 & n2;
310 tris.setSize(
patch.size());
334 for (
const face&
f : triFaces)
350 if (!requireMatch_ && distributed())
358 tgtMagSf_ = tgtPatch0().magFaceAreas();
360 for (
const labelList& smap : this->extendedTgtMapPtr_->subMap())
374 const bool reverseTarget
380 extendedTgtPatchPtr_(
nullptr),
382 extendedTgtPoints_(),
383 extendedTgtFaceIDs_(),
384 extendedTgtMapPtr_(
nullptr),
400 const bool requireMatch,
401 const bool reverseTarget,
402 const scalar lowWeightCorrection,
409 extendedTgtPatchPtr_(
nullptr),
411 extendedTgtPoints_(),
412 extendedTgtFaceIDs_(),
413 extendedTgtMapPtr_(
nullptr),
424 extendedTgtPatchPtr_(nullptr),
426 extendedTgtPoints_(),
427 extendedTgtFaceIDs_(),
428 extendedTgtMapPtr_(nullptr),
430 triMode_(ami.triMode_)
449 createExtendedTgtPatch();
452 const auto& src = this->srcPatch();
453 const auto& tgt = this->tgtPatch();
456 srcMagSf_.setSize(src.size(), 1.0);
457 tgtMagSf_.setSize(tgt.size(), 1.0);
460 triangulatePatch(src, srcTris_, srcMagSf_);
461 triangulatePatch(tgt, tgtTris_, tgtMagSf_);
467 srcAddress_.setSize(src.size());
468 srcWeights_.setSize(src.size());
469 tgtAddress_.setSize(tgt.size());
470 tgtWeights_.setSize(tgt.size());
int debug
Static debugging option.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
void triangulatePatch(const primitivePatch &patch, List< DynamicList< face >> &tris, List< scalar > &magSf) const
Helper function to decompose a patch.
bool initialiseWalk(label &srcFacei, label &tgtFacei)
Initialise walk and return true if all ok.
A List obtained as a section of another List.
virtual void nonConformalCorrection()
Correction for non-conformal interpolations, e.g. for ACMI.
Unit conversion functions.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & max() const
Maximum describing the bounding box.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void appendNbrFaces(const label facei, const primitivePatch &patch, const DynamicList< label > &visitedFaces, DynamicList< label > &faceIDs) const
Add faces neighbouring facei to the ID list.
static const Enum< triangulationMode > triangulationModeNames_
void checkPatches() const
Check AMI patch coupling.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
point centre() const
The centre (midpoint) of the bounding box.
void createExtendedTgtPatch()
Create a map that extends tgtPatch so that it covers srcPatch.
void setSize(const label n)
Alias for resize()
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Class containing processor-to-processor mapping information.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
label findTargetFace(const label srcFacei, const UList< label > &excludeFaces=UList< label >::null(), const label srcFacePti=-1) const
errorManip< error > abort(error &err)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Output to file stream, using an OSstream.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
const std::string patch
OpenFOAM patch number as a std::string.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
pointField points(const UList< point > &pts) const
Return the points corresponding to this face.
Base class for Arbitrary Mesh Interface (AMI) methods.
const wordList area
Standard area field types (scalar, vector, tensor, etc)
A bounding box defined in terms of min/max extrema points.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A List with indirect addressing.
const primitivePatch & srcPatch() const
Return const access to the source patch.
A face is a list of labels corresponding to mesh vertices.
const primitivePatch & tgtPatch() const
Return const access to the target patch.
defineTypeNameAndDebug(combustionModel, 0)
advancingFrontAMI(const dictionary &dict, const bool reverseTarget)
Construct from components.
#define WarningInFunction
Report a warning using Foam::Warning.
static void triangleFan(const face &f, DynamicList< face > &faces)
Decompose face into triangle fan.
triangle< point, const point & > triPointRef
A triangle using referred points.
A list of faces which address into the list of points.
Minimal example by using system/controlDict.functions:
dimensionedScalar cos(const dimensionedScalar &ds)