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;
224 os<<
" " <<
n + 1 <<
endl;
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)
353 const bool reverseTarget
359 extendedTgtPatchPtr_(
nullptr),
361 extendedTgtPoints_(),
362 extendedTgtFaceIDs_(),
363 extendedTgtMapPtr_(
nullptr),
379 const bool requireMatch,
380 const bool reverseTarget,
381 const scalar lowWeightCorrection,
388 extendedTgtPatchPtr_(
nullptr),
390 extendedTgtPoints_(),
391 extendedTgtFaceIDs_(),
392 extendedTgtMapPtr_(
nullptr),
403 extendedTgtPatchPtr_(nullptr),
405 extendedTgtPoints_(),
406 extendedTgtFaceIDs_(),
407 extendedTgtMapPtr_(nullptr),
409 triMode_(ami.triMode_)
427 createExtendedTgtPatch();
430 const auto& src = this->srcPatch();
431 const auto& tgt = this->tgtPatch();
434 srcMagSf_.setSize(src.size(), 1.0);
435 tgtMagSf_.setSize(tgt.size(), 1.0);
438 triangulatePatch(src, srcTris_, srcMagSf_);
439 triangulatePatch(tgt, tgtTris_, tgtMagSf_);
445 srcAddress_.setSize(src.size());
446 srcWeights_.setSize(src.size());
447 tgtAddress_.setSize(tgt.size());
448 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.
label index() const
Return index.
pointField points(const UList< point > &points) const
Return the points corresponding to this face.
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.
bool hit() const
Is there a hit.
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
An Ostream wrapper for parallel output to std::cout.
#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...
const Point & hitPoint() const
Return hit point.
point centre() const
The centre (midpoint) of the bounding box.
word name(const complex &c)
Return string representation of complex.
void createExtendedTgtPatch()
Create a map that extends tgtPatch so that it covers srcPatch.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Class containing processor-to-processor mapping information.
virtual bool conformal() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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...
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.
const primitivePatch & srcPatch() const
Return const access to the source patch.
A face is a list of labels corresponding to mesh vertices.
void setSize(const label newSize)
Alias for resize(const label)
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 list of faces which address into the list of points.
dimensionedScalar cos(const dimensionedScalar &ds)