52#ifndef Foam_AMIInterpolation_H
53#define Foam_AMIInterpolation_H
240 const word& patchName,
244 const bool conformal,
246 const scalar lowWeightTol,
295 const word& modelName,
303 const word& modelName,
332 const labelList& sourceRestrictAddressing,
333 const labelList& neighbourRestrictAddressing
365 const labelList& sourceRestrictAddressing,
366 const labelList& targetRestrictAddressing,
549 template<class Type, class CombineOp>
557 const CombineOp& cop,
559 const
UList<Type>& defaultValues
570 const
UList<Type>& defaultValues
576 template<class Type, class CombineOp, class InterpolateOp>
581 const CombineOp& cop,
582 const InterpolateOp& iop,
584 const
UList<Type>& defaultValues
589 template<class Type, class CombineOp>
593 const CombineOp& cop,
595 const
UList<Type>& defaultValues =
UList<Type>::null()
600 template<class Type, class CombineOp>
604 const CombineOp& cop,
606 const
UList<Type>& defaultValues =
UList<Type>::null()
611 template<class Type, class CombineOp>
615 const CombineOp& cop,
616 const
UList<Type>& defaultValues =
UList<Type>::null()
620 template<class Type, class CombineOp>
624 const CombineOp& cop,
625 const
UList<Type>& defaultValues =
UList<Type>::null()
629 template<class Type, class CombineOp>
633 const CombineOp& cop,
634 const
UList<Type>& defaultValues =
UList<Type>::null()
638 template<class Type, class CombineOp>
642 const CombineOp& cop,
643 const
UList<Type>& defaultValues =
UList<Type>::null()
651 const
UList<Type>& defaultValues =
UList<Type>::null()
659 const
UList<Type>& defaultValues =
UList<Type>::null()
667 const
UList<Type>& defaultValues =
UList<Type>::null()
675 const
UList<Type>& defaultValues =
UList<Type>::null()
687 const label tgtFacei,
698 const label srcFacei,
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Provides caching of weights and addressing to AMIInterpolation.
bool requireMatch_
Flag to indicate that the two patches must be matched/an overlap exists between them.
const mapDistribute & srcMap() const
Source map - valid only if singlePatchProc = -1 This gets source data into a form to be consumed by t...
const AMICache & cache() const noexcept
Return a reference to the AMI cache.
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
refPtr< primitivePatch > tsrcPatch0_
Source patch using manipulated input points.
label singlePatchProc_
Index of processor that holds all of both sides. The value is -1 for distributed cases.
bool mustMatchFaces() const
Return true if requireMatch and but not lowWeightCorrection.
const scalarField & srcWeightsSum() const
Return const access to normalisation factor of source patch weights (i.e. the sum before normalisatio...
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
bool cacheActive() const
Return true if caching is active.
labelListList srcAddress_
Addresses of target faces per source face.
label comm() const noexcept
Communicator (local or otherwise) for parallel operations.
bool distributed() const noexcept
Distributed across processors (singlePatchProc == -1).
label calcDistribution(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const label comm, autoPtr< UPstream::communicator > &geomComm) const
Calculate if patches are on multiple processors. Allocates local communicator and returns -1 or proce...
const mapDistribute * hasTgtMap() const noexcept
Pointer to the target map (if distributed). Can be checked as a bool.
scalarList tgtMagSf_
Target face areas.
const mapDistribute & tgtMap() const
Target map - valid only if singlePatchProc=-1. This gets target data into a form to be consumed by sr...
bool upToDate() const noexcept
Is up-to-date?
const scalarListList & tgtWeights() const
Return const access to target patch weights.
void projectPointsToSurface(const searchableSurface &surf, pointField &pts) const
Project points to surface.
const labelListList & srcAddress() const
Return const access to source patch addressing.
const bool reverseTarget_
Flag to indicate that the two patches are co-directional and that the orientation of the target patch...
virtual ~AMIInterpolation()=default
Destructor.
autoPtr< mapDistribute > srcMapPtr_
Source map pointer - parallel running only.
autoPtr< UPstream::communicator > geomComm_
Communicator to use for geometry calculations. Not valid (-1) on processors that do not have faces.
const scalarField & tgtWeightsSum() const
Return const access to normalisation factor of target patch weights (i.e. the sum before normalisatio...
AMIInterpolation(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
treeDataPrimitivePatch< primitivePatch > treeType
Local typedef to octree tree-type.
pointField srcPatchPts_
Source patch points if input points are manipulated, e.g. projected.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
void interpolateToSource(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Interpolate from target to source with supplied op to combine existing value with remote value and we...
bool checkSymmetricWeights(const bool log) const
Check if src addresses are present in tgt addresses and viceversa.
pointField tgtPatchPts_
Target patch points if input points are manipulated, e.g. projected.
virtual bool writeData(Ostream &os) const
Write AMI raw.
bool requireMatch() const noexcept
Return the requireMatch flag.
static scalar cacheThetaTolerance_
Tolerance used when caching the AMI to identify e.g. if the current rotation angle has already been c...
const primitivePatch & tgtPatch0() const
Return the original tgt patch with optionally updated points.
void operator=(const AMIInterpolation &)=delete
No copy assignment.
bool upToDate_
Up-to-date flag.
declareRunTimeSelectionTable(autoPtr, AMIInterpolation, dict,(const dictionary &dict, const bool reverseTarget),(dict, reverseTarget))
Selection table for dictionary construction.
autoPtr< mapDistribute > tgtMapPtr_
Target map pointer - parallel running only.
declareRunTimeSelectionTable(autoPtr, AMIInterpolation, component,(const bool requireMatch, const bool reverseTarget, const scalar lowWeightCorrection),(requireMatch, reverseTarget, lowWeightCorrection))
Selection table for component-wise construction.
const scalarListList & srcWeights() const
Return const access to source patch weights.
virtual void write(Ostream &os) const
Write AMI as a dictionary.
void reset(autoPtr< mapDistribute > &&srcToTgtMap, autoPtr< mapDistribute > &&tgtToSrcMap, labelListList &&srcAddress, scalarListList &&srcWeights, labelListList &&tgtAddress, scalarListList &&tgtWeights, const label singlePatchProc)
Set the maps, addresses and weights from an external source.
labelListList tgtAddress_
Addresses of source faces per target face.
label srcPointFace(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const vector &n, const label tgtFacei, point &tgtPoint) const
Return source patch face index of point on target patch face.
const scalar lowWeightCorrection_
Threshold weight below which interpolation is deactivated.
pointListList srcCentroids_
Centroid of target faces per source face.
label singlePatchProc() const noexcept
The processor holding all faces (both sides), or -1 if distributed.
const mapDistribute * hasSrcMap() const noexcept
Pointer to the source map (if distributed). Can be checked as a bool.
const pointListList & srcCentroids() const
Return const access to source patch face centroids.
static bool cacheIntersections_
Flag to store face-to-face intersection triangles; default = false.
void writeFaceConnectivity(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const labelListList &srcAddress) const
Write face connectivity as OBJ file.
AMICache & cache() noexcept
bool setRequireMatch(bool flag) noexcept
Set the require match flag, return the new value.
label comm_
Communicator to use for parallel operations.
static void normaliseWeights(const scalarList &patchAreas, const word &patchName, const labelListList &addr, scalarListList &wght, scalarField &wghtSum, const bool conformal, const bool output, const scalar lowWeightTol, const label comm)
Normalise the (area) weights - suppresses numerical error in weights calculation.
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
scalarField srcWeightsSum_
Sum of weights of target faces per source face.
refPtr< primitivePatch > ttgtPatch0_
Target patch using manipulated input points.
void append(const primitivePatch &srcPatch, const primitivePatch &tgtPatch)
Append additional addressing and weights.
autoPtr< indexedOctree< treeType > > createTree(const primitivePatch &patch) const
Reset the octree for the patch face search.
bool applyLowWeightCorrection() const
Return true if employing a 'lowWeightCorrection'.
scalarListList tgtWeights_
Weights of source faces per target face.
static void weightedSum(const scalar lowWeightCorrection, const labelListList &allSlots, const scalarListList &allWeights, const scalarField &weightsSum, const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues)
Weighted sum of contributions. Note: cop operates on single Type only.
bool upToDate(bool flag) noexcept
Set as up-to-date, return the previous value.
void interpolate(const bool toSource, const UList< Type > &fld, const CombineOp &cop, const InterpolateOp &iop, List< Type > &result, const UList< Type > &defaultValues) const
Weighted sum of (potentially distributed) contributions and apply caching+interpolation....
pointListList tgtCentroids_
Centroid of source faces per target face.
scalarListList srcWeights_
Weights of target faces per source face.
const List< scalar > & srcMagSf() const
Return const access to source patch face areas.
label tgtPointFace(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const vector &n, const label srcFacei, point &srcPoint) const
Return target patch face index of point on source patch face.
static void agglomerate(const autoPtr< mapDistribute > &targetMap, const scalarList &fineSrcMagSf, const labelListList &fineSrcAddress, const scalarListList &fineSrcWeights, const labelList &sourceRestrictAddressing, const labelList &targetRestrictAddressing, scalarList &srcMagSf, labelListList &srcAddress, scalarListList &srcWeights, scalarField &srcWeightsSum, autoPtr< mapDistribute > &tgtMap, const label comm)
scalarList srcMagSf_
Source face areas.
const primitivePatch & srcPatch0() const
Return the original src patch with optionally updated points.
void addToCache(const point &refPt)
Add AMI weights and addressing to the cache.
bool restoreCache(const point &refPt)
Restore AMI weights and addressing from the cache.
scalarField tgtWeightsSum_
Sum of weights of source faces per target face.
static int useLocalComm_
Control use of local communicator for AMI communication.
const List< scalar > & tgtMagSf() const
Return const access to target patch face areas.
const labelListList & tgtAddress() const
Return const access to target patch addressing.
void interpolateToTarget(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Interpolate from source to target with supplied op to combine existing value with remote value and we...
static autoPtr< AMIInterpolation > New(const word &modelName, const dictionary &dict, const bool reverseTarget=false)
Selector for dictionary.
TypeName("AMIInterpolation")
Runtime type information.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Class containing processor-to-processor mapping information.
A class for managing references or pointers (no reference counting).
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
A class for managing temporary objects.
Encapsulation of data needed to search on PrimitivePatches.
A class for handling words, derived from Foam::string.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
List< scalarList > scalarListList
List of scalarList.
Type weightedSum(const UList< scalar > &weights, const UList< Type > &fld)
The local weighted sum (integral) of a field, using the mag() of the weights.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar log(const dimensionedScalar &ds)
vector point
Point is a vector.
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
List of scalar.
List< pointList > pointListList
List of pointList.
Various functors for unary and binary operations. Can be used for parallel combine-reduce operations ...
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.