AMIInterpolation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::AMIInterpolation
29 
30 Description
31  Interpolation class dealing with transfer of data between two
32  primitive patches with an arbitrary mesh interface (AMI).
33 
34  Based on the algorithm given in:
35 
36  Conservative interpolation between volume meshes by local Galerkin
37  projection, Farrell PE and Maddison JR, 2011, Comput. Methods Appl.
38  Mech Engrg, Volume 200, Issues 1-4, pp 89-100
39 
40  Interpolation requires that the two patches should have opposite
41  orientations (opposite normals). The 'reverseTarget' flag can be used to
42  reverse the orientation of the target patch.
43 
44 SourceFiles
45  AMIInterpolationI.H
46  AMIInterpolation.C
47  AMIInterpolationNew.C
48  AMIInterpolationTemplates.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef Foam_AMIInterpolation_H
53 #define Foam_AMIInterpolation_H
54 
55 #include "searchableSurface.H"
56 #include "boolList.H"
57 #include "primitivePatch.H"
58 #include "ops.H"
59 #include "refPtr.H"
60 #include "pointList.H"
61 #include "indexedOctree.H"
62 #include "treeDataPrimitivePatch.H"
63 #include "runTimeSelectionTables.H"
64 
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class AMIInterpolation Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class AMIInterpolation
76 {
77 public:
78 
79  // Public Data Types
80 
81  static bool cacheIntersections_;
82 
83 
84 protected:
85 
86  //- Local typedef to octree tree-type
88 
89  // Protected data
90 
91  //- Flag to indicate that the two patches must be matched/an overlap
92  //- exists between them
93  bool requireMatch_;
94 
95  //- Flag to indicate that the two patches are co-directional and
96  //- that the orientation of the target patch should be reversed
97  const bool reverseTarget_;
98 
99  //- Threshold weight below which interpolation is deactivated
100  const scalar lowWeightCorrection_;
101 
102  //- Index of processor that holds all of both sides.
103  //- The value is -1 for distributed cases
104  label singlePatchProc_;
105 
106  //- Communicator to use for parallel operations.
107  label comm_;
108 
110  // Source patch
111 
112  //- Source face areas
115  //- Addresses of target faces per source face
117 
118  //- Weights of target faces per source face
120 
121  //- Sum of weights of target faces per source face
123 
124  //- Centroid of target faces per source face
126 
127  //- Source patch points if input points are manipulated, e.g.
128  //- projected
130 
131  //- Source patch using manipulated input points
133 
134  //- Source map pointer - parallel running only
136 
138 
139  // Target patch
140 
141  //- Target face areas
143 
144  //- Addresses of source faces per target face
146 
147  //- Weights of source faces per target face
149 
150  //- Sum of weights of source faces per target face
152 
153  //- Centroid of source faces per target face
155 
156  //- Target patch points if input points are manipulated, e.g.
157  //- projected
159 
160  //- Target patch using manipulated input points
162 
163  //- Target map pointer - parallel running only
165 
166  //- Up-to-date flag
167  bool upToDate_;
168 
169 
170  // Protected Member Functions
171 
172  //- No copy assignment
173  void operator=(const AMIInterpolation&) = delete;
174 
175 
176  // Initialisation
178  //- Reset the octree for the patch face search
180  (
181  const primitivePatch& patch
182  ) const;
183 
184  //- Calculate if patches are on multiple processors
185  label calcDistribution
186  (
187  const primitivePatch& srcPatch,
188  const primitivePatch& tgtPatch
189  ) const;
190 
191  //- Project points to surface
193  (
194  const searchableSurface& surf,
195  pointField& pts
196  ) const;
197 
199  // Access
200 
201  //- Return the orginal src patch with optionally updated points
202  inline const primitivePatch& srcPatch0() const;
204  //- Return the orginal tgt patch with optionally updated points
205  inline const primitivePatch& tgtPatch0() const;
206 
207 
208  // Evaluation
209 
210  //- Normalise the (area) weights - suppresses numerical error in
211  //- weights calculation
212  // NOTE: if area weights are incorrect by 'a significant amount'
213  // normalisation may stabilise the solution, but will introduce
214  // numerical error!
215  static void normaliseWeights
216  (
217  const scalarList& patchAreas,
218  const word& patchName,
219  const labelListList& addr,
220  scalarListList& wght,
221  scalarField& wghtSum,
222  const bool conformal,
223  const bool output,
224  const scalar lowWeightTol,
225  const label comm
226  );
227 
228 
229  // Constructor helpers
230 
231  static void agglomerate
232  (
233  const autoPtr<mapDistribute>& targetMap,
234  const scalarList& fineSrcMagSf,
235  const labelListList& fineSrcAddress,
236  const scalarListList& fineSrcWeights,
237 
238  const labelList& sourceRestrictAddressing,
239  const labelList& targetRestrictAddressing,
240 
246  const label comm
247  );
248 
249 
250 public:
251 
252  //- Runtime type information
253  TypeName("AMIInterpolation");
254 
255  // Selection tables
256 
257  //- Selection table for dictionary construction
259  (
260  autoPtr,
262  dict,
263  (
264  const dictionary& dict,
265  const bool reverseTarget
266  ),
267  (
268  dict,
270  )
271  );
272 
273  //- Selection table for component-wise construction
275  (
276  autoPtr,
278  component,
279  (
280  const bool requireMatch,
281  const bool reverseTarget,
282  const scalar lowWeightCorrection
283  ),
284  (
285  requireMatch,
288  )
289  );
290 
291  //- Selector for dictionary
293  (
294  const word& modelName,
295  const dictionary& dict,
296  const bool reverseTarget = false
297  );
298 
299  //- Selector for components
301  (
302  const word& modelName,
303  const bool requireMatch = true,
304  const bool reverseTarget = false,
305  const scalar lowWeightCorrection = -1
306  );
307 
308 
309  // Constructors
310 
311  //- Construct from dictionary
312  explicit AMIInterpolation
313  (
314  const dictionary& dict,
315  const bool reverseTarget = false
316  );
317 
318  //- Construct from components
319  explicit AMIInterpolation
320  (
321  const bool requireMatch = true,
322  const bool reverseTarget = false,
323  const scalar lowWeightCorrection = -1
324  );
325 
326  //- Construct from agglomeration of AMIInterpolation. Agglomeration
327  //- passed in as new coarse size and addressing from fine from coarse
329  (
330  const AMIInterpolation& fineAMI,
331  const labelList& sourceRestrictAddressing,
332  const labelList& neighbourRestrictAddressing
333  );
334 
335  //- Construct as copy
337 
338  //- Construct and return a clone
339  virtual autoPtr<AMIInterpolation> clone() const
340  {
341  return autoPtr<AMIInterpolation>::New(*this);
342  }
343 
344  //- Construct from Istream
345  // Note: does not transfer src(tgt)PatchPts, tsrc(tgt)Patch0_
347 
348 
349  //- Destructor
350  virtual ~AMIInterpolation() = default;
351 
352 
353  // Member Functions
354 
355  // Access
356 
357  //- Is up-to-date?
358  bool upToDate() const noexcept { return upToDate_; }
359 
360  //- Set as up-to-date, return the previous value
361  bool upToDate(bool flag) noexcept
362  {
363  bool old(upToDate_);
364  upToDate_ = flag;
365  return old;
366  }
367 
368  //- Distributed across processors (singlePatchProc == -1)
369  inline bool distributed() const noexcept;
370 
371  //- Return the requireMatch flag
372  inline bool requireMatch() const noexcept;
373 
374  //- Set the require match flag, return the \em new value
375  inline bool setRequireMatch(bool flag) noexcept;
376 
377  //- Return true if requireMatch and but not lowWeightCorrection
378  inline bool mustMatchFaces() const;
379 
380  //- Access to the reverseTarget flag
381  inline bool reverseTarget() const noexcept;
382 
383  //- Threshold weight below which interpolation is deactivated
384  inline scalar lowWeightCorrection() const;
385 
386  //- Return true if employing a 'lowWeightCorrection'
387  inline bool applyLowWeightCorrection() const;
388 
389  //- The processor holding all faces (both sides),
390  //- or -1 if distributed
391  inline label singlePatchProc() const noexcept;
392 
393  //- Communicator to use for parallel operations
394  inline label comm() const;
395 
396  //- Set communicator to use for parallel operations. Return
397  // old value
398  inline label comm(const label newComm);
399 
400 
401  // Source patch
402 
403  //- Return const access to source patch face areas
404  inline const List<scalar>& srcMagSf() const;
405 
406  //- Return access to source patch face areas
407  inline List<scalar>& srcMagSf();
408 
409  //- Return const access to source patch addressing
410  inline const labelListList& srcAddress() const;
411 
412  //- Return access to source patch addressing
413  inline labelListList& srcAddress();
414 
415  //- Return const access to source patch weights
416  inline const scalarListList& srcWeights() const;
417 
418  //- Return access to source patch weights
419  inline scalarListList& srcWeights();
420 
421  //- Return const access to normalisation factor of source
422  //- patch weights (i.e. the sum before normalisation)
423  inline const scalarField& srcWeightsSum() const;
424 
425  //- Return access to normalisation factor of source
426  //- patch weights (i.e. the sum before normalisation)
427  inline scalarField& srcWeightsSum();
428 
429  //- Return const access to source patch face centroids
430  inline const pointListList& srcCentroids() const;
431 
432  //- Return access to source patch face centroids
433  inline pointListList& srcCentroids();
434 
435  //- Source map - valid only if singlePatchProc = -1
436  //- This gets source data into a form to be consumed by
437  //- tgtAddress, tgtWeights
438  inline const mapDistribute& srcMap() const;
439 
440  //- Pointer to the source map (if distributed).
441  //- Can be checked as a bool.
442  inline const mapDistribute* hasSrcMap() const noexcept;
443 
444 
445  // Target patch
447  //- Return const access to target patch face areas
448  inline const List<scalar>& tgtMagSf() const;
449 
450  //- Return access to target patch face areas
451  inline List<scalar>& tgtMagSf();
452 
453  //- Return const access to target patch addressing
454  inline const labelListList& tgtAddress() const;
455 
456  //- Return access to target patch addressing
457  inline labelListList& tgtAddress();
458 
459  //- Return const access to target patch weights
460  inline const scalarListList& tgtWeights() const;
461 
462  //- Return access to target patch weights
463  inline scalarListList& tgtWeights();
464 
465  //- Return const access to normalisation factor of target
466  //- patch weights (i.e. the sum before normalisation)
467  inline const scalarField& tgtWeightsSum() const;
468 
469  //- Return access to normalisation factor of target
470  //- patch weights (i.e. the sum before normalisation)
471  inline scalarField& tgtWeightsSum();
472 
473  //- Target map - valid only if singlePatchProc=-1.
474  //- This gets target data into a form to be consumed by
475  //- srcAddress, srcWeights
476  inline const mapDistribute& tgtMap() const;
477 
478  //- Pointer to the target map (if distributed).
479  //- Can be checked as a bool.
480  inline const mapDistribute* hasTgtMap() const noexcept;
481 
482 
483  // Manipulation
484 
485  //- Update addressing, weights and (optional) centroids
486  virtual bool calculate
487  (
488  const primitivePatch& srcPatch,
489  const primitivePatch& tgtPatch,
490  const autoPtr<searchableSurface>& surfPtr = nullptr
491  );
492 
493  //- Set the maps, addresses and weights from an external source
494  void reset
495  (
496  autoPtr<mapDistribute>&& srcToTgtMap,
497  autoPtr<mapDistribute>&& tgtToSrcMap,
502  const label singlePatchProc
503  );
504 
505  //- Append additional addressing and weights
506  void append
507  (
508  const primitivePatch& srcPatch,
509  const primitivePatch& tgtPatch
510  );
511 
512  //- Normalise the weights
513  void normaliseWeights(const bool conformal, const bool output);
514 
515 
516  // Evaluation
517 
518  // Low-level
519 
520  //- Weighted sum of contributions
521  template<class Type, class CombineOp>
522  static void weightedSum
523  (
524  const scalar lowWeightCorrection,
525  const labelListList& allSlots,
526  const scalarListList& allWeights,
527  const scalarField& weightsSum,
528  const UList<Type>& fld,
529  const CombineOp& cop,
530  List<Type>& result,
531  const UList<Type>& defaultValues
532  );
533 
534  //- Weighted sum of contributions
535  template<class Type>
536  void weightedSum
537  (
538  const bool interpolateToSource,
539  const UList<Type>& fld,
540  List<Type>& result,
541  const UList<Type>& defaultValues
542  ) const;
543 
544  //- Interpolate from target to source with supplied op
545  //- to combine existing value with remote value and weight
546  template<class Type, class CombineOp>
548  (
549  const UList<Type>& fld,
550  const CombineOp& cop,
551  List<Type>& result,
552  const UList<Type>& defaultValues = UList<Type>::null()
553  ) const;
554 
555  //- Interpolate from source to target with supplied op
556  //- to combine existing value with remote value and weight
557  template<class Type, class CombineOp>
559  (
560  const UList<Type>& fld,
561  const CombineOp& cop,
562  List<Type>& result,
563  const UList<Type>& defaultValues = UList<Type>::null()
564  ) const;
565 
566 
567  //- Interpolate from target to source with supplied op
568  template<class Type, class CombineOp>
570  (
571  const Field<Type>& fld,
572  const CombineOp& cop,
573  const UList<Type>& defaultValues = UList<Type>::null()
574  ) const;
575 
576  //- Interpolate from target tmp field to source with supplied op
577  template<class Type, class CombineOp>
579  (
580  const tmp<Field<Type>>& tFld,
581  const CombineOp& cop,
582  const UList<Type>& defaultValues = UList<Type>::null()
583  ) const;
584 
585  //- Interpolate from source to target with supplied op
586  template<class Type, class CombineOp>
588  (
589  const Field<Type>& fld,
590  const CombineOp& cop,
591  const UList<Type>& defaultValues = UList<Type>::null()
592  ) const;
593 
594  //- Interpolate from source tmp field to target with supplied op
595  template<class Type, class CombineOp>
597  (
598  const tmp<Field<Type>>& tFld,
599  const CombineOp& cop,
600  const UList<Type>& defaultValues = UList<Type>::null()
601  ) const;
602 
603  //- Interpolate from target to source
604  template<class Type>
606  (
607  const Field<Type>& fld,
608  const UList<Type>& defaultValues = UList<Type>::null()
609  ) const;
610 
611  //- Interpolate from target tmp field
612  template<class Type>
614  (
615  const tmp<Field<Type>>& tFld,
616  const UList<Type>& defaultValues = UList<Type>::null()
617  ) const;
618 
619  //- Interpolate from source to target
620  template<class Type>
622  (
623  const Field<Type>& fld,
624  const UList<Type>& defaultValues = UList<Type>::null()
625  ) const;
626 
627  //- Interpolate from source tmp field
628  template<class Type>
630  (
631  const tmp<Field<Type>>& tFld,
632  const UList<Type>& defaultValues = UList<Type>::null()
633  ) const;
634 
635 
636  // Point intersections
637 
638  //- Return source patch face index of point on target patch face
639  label srcPointFace
640  (
641  const primitivePatch& srcPatch,
642  const primitivePatch& tgtPatch,
643  const vector& n,
644  const label tgtFacei,
645  point& tgtPoint
646  )
647  const;
648 
649  //- Return target patch face index of point on source patch face
650  label tgtPointFace
651  (
652  const primitivePatch& srcPatch,
653  const primitivePatch& tgtPatch,
654  const vector& n,
655  const label srcFacei,
656  point& srcPoint
657  )
658  const;
659 
660 
661  // Checks
662 
663  //- Check if src addresses are present in tgt addresses and
664  //- viceversa
665  bool checkSymmetricWeights(const bool log) const;
666 
667  //- Write face connectivity as OBJ file
669  (
670  const primitivePatch& srcPatch,
671  const primitivePatch& tgtPatch,
673  ) const;
674 
675 
676  // I-O
677 
678  //- Write AMI as a dictionary
679  virtual void write(Ostream& os) const;
680 
681  //- Write AMI raw
682  virtual bool writeData(Ostream& os) const;
683 
684 
685  // Housekeeping
686 
687  //- Non-const access to the up-to-date flag
688  // \deprecated Prefer the upToDate(bool) setter (JAN-2023)
689  bool& upToDate() noexcept { return upToDate_; }
690 };
691 
692 
693 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
694 
695 } // End namespace Foam
696 
697 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
698 
699 #include "AMIInterpolationI.H"
700 
701 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
702 
703 #ifdef NoRepository
704  #include "AMIInterpolationTemplates.C"
705 #endif
706 
707 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
708 
709 #endif
710 
711 // ************************************************************************* //
TypeName("AMIInterpolation")
Runtime type information.
label singlePatchProc_
Index of processor that holds all of both sides. The value is -1 for distributed cases.
dictionary dict
void append(const primitivePatch &srcPatch, const primitivePatch &tgtPatch)
Append additional addressing and weights.
const pointListList & srcCentroids() const
Return const access to source patch face centroids.
refPtr< primitivePatch > tsrcPatch0_
Source patch using manipulated input points.
virtual ~AMIInterpolation()=default
Destructor.
pointListList tgtCentroids_
Centroid of source faces per target face.
labelListList tgtAddress_
Addresses of source faces per target face.
pointListList srcCentroids_
Centroid of target faces per source face.
dimensionedScalar log(const dimensionedScalar &ds)
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const scalarListList & tgtWeights() const
Return const access to target patch weights.
pointField tgtPatchPts_
Target patch points if input points are manipulated, e.g. projected.
bool mustMatchFaces() const
Return true if requireMatch and but not lowWeightCorrection.
autoPtr< mapDistribute > tgtMapPtr_
Target map pointer - parallel running only.
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
treeDataPrimitivePatch< primitivePatch > treeType
Local typedef to octree tree-type.
void writeFaceConnectivity(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const labelListList &srcAddress) const
Write face connectivity as OBJ file.
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.
void projectPointsToSurface(const searchableSurface &surf, pointField &pts) const
Project points to surface.
autoPtr< indexedOctree< treeType > > createTree(const primitivePatch &patch) const
Reset the octree for the patch face search.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const mapDistribute & srcMap() const
Source map - valid only if singlePatchProc = -1 This gets source data into a form to be consumed by t...
virtual bool writeData(Ostream &os) const
Write AMI raw.
const labelListList & tgtAddress() const
Return const access to target patch addressing.
bool requireMatch() const noexcept
Return the requireMatch flag.
label singlePatchProc() const noexcept
The processor holding all faces (both sides), or -1 if distributed.
Various functors for unary and binary operations. Can be used for parallel combine-reduce operations ...
refPtr< primitivePatch > ttgtPatch0_
Target patch using manipulated input points.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
bool distributed() const noexcept
Distributed across processors (singlePatchProc == -1)
static bool cacheIntersections_
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
declareRunTimeSelectionTable(autoPtr, AMIInterpolation, dict,(const dictionary &dict, const bool reverseTarget),(dict, reverseTarget))
Selection table for dictionary construction.
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
autoPtr< mapDistribute > srcMapPtr_
Source map pointer - parallel running only.
label comm_
Communicator to use for parallel operations.
AMIInterpolation(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
A list of faces which address into the list of points.
const primitivePatch & tgtPatch0() const
Return the orginal tgt patch with optionally updated points.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
const List< scalar > & tgtMagSf() const
Return const access to target patch face areas.
bool upToDate() const noexcept
Is up-to-date?
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)
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool upToDate_
Up-to-date flag.
const mapDistribute * hasTgtMap() const noexcept
Pointer to the target map (if distributed). Can be checked as a bool.
Encapsulation of data needed to search on PrimitivePatches.
const primitivePatch & srcPatch0() const
Return the orginal src patch with optionally updated points.
const scalarField & tgtWeightsSum() const
Return const access to normalisation factor of target patch weights (i.e. the sum before normalisatio...
bool checkSymmetricWeights(const bool log) const
Check if src addresses are present in tgt addresses and viceversa.
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...
scalarListList srcWeights_
Weights of target faces per source face.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
scalarField srcWeightsSum_
Sum of weights of target faces per source face.
const mapDistribute * hasSrcMap() const noexcept
Pointer to the source map (if distributed). Can be checked as a bool.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const scalarListList & srcWeights() const
Return const access to source patch weights.
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.
OBJstream os(runTime.globalPath()/outputName)
bool setRequireMatch(bool flag) noexcept
Set the require match flag, return the new value.
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
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...
const List< scalar > & srcMagSf() const
Return const access to source patch face areas.
const scalarField & srcWeightsSum() const
Return const access to normalisation factor of source patch weights (i.e. the sum before normalisatio...
scalarList tgtMagSf_
Target face areas.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
scalarField tgtWeightsSum_
Sum of weights of source faces per target face.
labelListList srcAddress_
Addresses of target faces per source face.
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. ...
Class containing processor-to-processor mapping information.
bool requireMatch_
Flag to indicate that the two patches must be matched/an overlap exists between them.
scalarListList tgtWeights_
Weights of source faces per target face.
pointField srcPatchPts_
Source patch points if input points are manipulated, e.g. projected.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const std::string patch
OpenFOAM patch number as a std::string.
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:44
label n
label calcDistribution(const primitivePatch &srcPatch, const primitivePatch &tgtPatch) const
Calculate if patches are on multiple processors.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
static autoPtr< AMIInterpolation > New(const word &modelName, const dictionary &dict, const bool reverseTarget=false)
Selector for dictionary.
Macros to ease declaration of run-time selection tables.
const mapDistribute & tgtMap() const
Target map - valid only if singlePatchProc=-1. This gets target data into a form to be consumed by sr...
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
const labelListList & srcAddress() const
Return const access to source patch addressing.
scalarList srcMagSf_
Source face areas.
void operator=(const AMIInterpolation &)=delete
No copy assignment.
const scalar lowWeightCorrection_
Threshold weight below which interpolation is deactivated.
const bool reverseTarget_
Flag to indicate that the two patches are co-directional and that the orientation of the target patch...
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.
bool applyLowWeightCorrection() const
Return true if employing a &#39;lowWeightCorrection&#39;.
label comm() const
Communicator to use for parallel operations.
Namespace for OpenFOAM.
virtual void write(Ostream &os) const
Write AMI as a dictionary.
const pointField & pts