Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::AMIInterpolation
29
30Description
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
44SourceFiles
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"
64#include "AMICache.H"
65
66// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67
68namespace Foam
69{
71/*---------------------------------------------------------------------------*\
72 Class AMIInterpolation Declaration
73\*---------------------------------------------------------------------------*/
74
76{
77public:
78
79 // Public Data Types
80
81 //- Flag to store face-to-face intersection triangles; default = false
82 static bool cacheIntersections_;
83
84 //- Control use of local communicator for AMI communication
85 // localComm : 0 : all processors (backwards compatible)
86 // localComm : 1 : only processors with patch faces
87 // localComm : 2 : like 1 but always include master (for messages)
88 static int useLocalComm_;
89
90 //- Tolerance used when caching the AMI to identify e.g. if the
91 //- current rotation angle has already been captured
92 static scalar cacheThetaTolerance_;
93
95protected:
96
97 //- Local typedef to octree tree-type
99
100 // Protected data
101
102 //- Flag to indicate that the two patches must be matched/an overlap
103 //- exists between them
104 bool requireMatch_;
105
106 //- Flag to indicate that the two patches are co-directional and
107 //- that the orientation of the target patch should be reversed
108 const bool reverseTarget_;
109
110 //- Threshold weight below which interpolation is deactivated
111 const scalar lowWeightCorrection_;
112
113 //- Index of processor that holds all of both sides.
114 //- The value is -1 for distributed cases
115 label singlePatchProc_;
117 //- Communicator to use for parallel operations.
118 label comm_;
119
120 //- Communicator to use for geometry calculations. Not valid (-1) on
121 //- processors that do not have faces
123
124
125 // Source patch
126
127 //- Source face areas
129
130 //- Addresses of target faces per source face
133 //- Weights of target faces per source face
135
136 //- Sum of weights of target faces per source face
139 //- Centroid of target faces per source face
141
142 //- Source patch points if input points are manipulated, e.g.
143 //- projected
145
146 //- Source patch using manipulated input points
148
149 //- Source map pointer - parallel running only
152
153 // Target patch
154
155 //- Target face areas
157
158 //- Addresses of source faces per target face
160
161 //- Weights of source faces per target face
163
164 //- Sum of weights of source faces per target face
167 //- Centroid of source faces per target face
169
170 //- Target patch points if input points are manipulated, e.g.
171 //- projected
173
174 //- Target patch using manipulated input points
176
177 //- Target map pointer - parallel running only
179
180
181 //- Up-to-date flag
183
184 //- Cache
186
187
188 // Protected Member Functions
189
190 //- No copy assignment
191 void operator=(const AMIInterpolation&) = delete;
192
193
194 // Initialisation
196 //- Reset the octree for the patch face search
198 (
199 const primitivePatch& patch
200 ) const;
201
202 //- Calculate if patches are on multiple processors. Allocates
203 //- local communicator and returns -1 or processor containing all
204 //- faces
206 (
207 const primitivePatch& srcPatch,
208 const primitivePatch& tgtPatch,
209 const label comm,
211 ) const;
212
213 //- Project points to surface
215 (
216 const searchableSurface& surf,
218 ) const;
219
220
221 // Access
222
223 //- Return the original src patch with optionally updated points
224 inline const primitivePatch& srcPatch0() const;
225
226 //- Return the original tgt patch with optionally updated points
227 inline const primitivePatch& tgtPatch0() const;
228
229
230 // Evaluation
231
232 //- Normalise the (area) weights - suppresses numerical error in
233 //- weights calculation
234 // NOTE: if area weights are incorrect by 'a significant amount'
235 // normalisation may stabilise the solution, but will introduce
236 // numerical error!
238 (
239 const scalarList& patchAreas,
240 const word& patchName,
241 const labelListList& addr,
242 scalarListList& wght,
243 scalarField& wghtSum,
244 const bool conformal,
245 const bool output,
246 const scalar lowWeightTol,
247 const label comm
248 );
249
250
251public:
252
253 //- Runtime type information
254 TypeName("AMIInterpolation");
255
256 // Selection tables
257
258 //- Selection table for dictionary construction
260 (
261 autoPtr,
263 dict,
264 (
265 const dictionary& dict,
266 const bool reverseTarget
267 ),
268 (
269 dict,
271 )
272 );
273
274 //- Selection table for component-wise construction
276 (
277 autoPtr,
279 component,
280 (
281 const bool requireMatch,
282 const bool reverseTarget,
283 const scalar lowWeightCorrection
284 ),
285 (
289 )
290 );
291
292 //- Selector for dictionary
294 (
295 const word& modelName,
296 const dictionary& dict,
297 const bool reverseTarget = false
298 );
299
300 //- Selector for components
302 (
303 const word& modelName,
304 const bool requireMatch = true,
305 const bool reverseTarget = false,
306 const scalar lowWeightCorrection = -1
307 );
308
309
310 // Constructors
311
312 //- Construct from dictionary
313 explicit AMIInterpolation
314 (
315 const dictionary& dict,
316 const bool reverseTarget = false
317 );
318
319 //- Construct from components
320 explicit AMIInterpolation
321 (
322 const bool requireMatch = true,
323 const bool reverseTarget = false,
324 const scalar lowWeightCorrection = -1
325 );
326
327 //- Construct from agglomeration of AMIInterpolation. Agglomeration
328 //- passed in as new coarse size and addressing from fine from coarse
331 const AMIInterpolation& fineAMI,
332 const labelList& sourceRestrictAddressing,
333 const labelList& neighbourRestrictAddressing
334 );
335
336 //- Construct as copy
338
339 //- Construct and return a clone
340 virtual autoPtr<AMIInterpolation> clone() const
341 {
342 return autoPtr<AMIInterpolation>::New(*this);
343 }
344
345 //- Construct from Istream
346 // Note: does not transfer src(tgt)PatchPts, tsrc(tgt)Patch0_
349
350 //- Destructor
351 virtual ~AMIInterpolation() = default;
352
353
354 // Member Functions
355
356 // Constructor helpers
357
358 static void agglomerate
359 (
360 const autoPtr<mapDistribute>& targetMap,
361 const scalarList& fineSrcMagSf,
362 const labelListList& fineSrcAddress,
363 const scalarListList& fineSrcWeights,
364
365 const labelList& sourceRestrictAddressing,
366 const labelList& targetRestrictAddressing,
367
373 const label comm
374 );
375
376 // Access
377
378 //- Is up-to-date?
379 bool upToDate() const noexcept { return upToDate_; }
380
381 //- Set as up-to-date, return the previous value
382 bool upToDate(bool flag) noexcept
383 {
384 bool old(upToDate_);
385 upToDate_ = flag;
386 return old;
387 }
388
389 //- Return a reference to the AMI cache
390 const AMICache& cache() const noexcept { return cache_; }
391 AMICache& cache() noexcept { return cache_; }
392
393 //- Distributed across processors (singlePatchProc == -1)
394 inline bool distributed() const noexcept;
395
396 //- Return the requireMatch flag
397 inline bool requireMatch() const noexcept;
398
399 //- Set the require match flag, return the \em new value
400 inline bool setRequireMatch(bool flag) noexcept;
401
402 //- Return true if requireMatch and but not lowWeightCorrection
403 inline bool mustMatchFaces() const;
404
405 //- Access to the reverseTarget flag
406 inline bool reverseTarget() const noexcept;
407
408 //- Threshold weight below which interpolation is deactivated
409 inline scalar lowWeightCorrection() const;
410
411 //- Return true if employing a 'lowWeightCorrection'
412 inline bool applyLowWeightCorrection() const;
413
414 //- The processor holding all faces (both sides),
415 //- or -1 if distributed
416 inline label singlePatchProc() const noexcept;
417
418 //- Communicator (local or otherwise) for parallel operations
419 inline label comm() const noexcept;
420
421 //- Set (non-local) communicator for parallel operations.
422 // \returns old value
423 inline label comm(label communicator) noexcept;
424
425 //- Return true if caching is active
426 inline bool cacheActive() const;
428 // Source patch
429
430 //- Return const access to source patch face areas
431 inline const List<scalar>& srcMagSf() const;
432
433 //- Return access to source patch face areas
434 inline List<scalar>& srcMagSf();
435
436 //- Return const access to source patch addressing
437 inline const labelListList& srcAddress() const;
438
439 //- Return access to source patch addressing
440 inline labelListList& srcAddress();
441
442 //- Return const access to source patch weights
443 inline const scalarListList& srcWeights() const;
444
445 //- Return access to source patch weights
446 inline scalarListList& srcWeights();
447
448 //- Return const access to normalisation factor of source
449 //- patch weights (i.e. the sum before normalisation)
450 inline const scalarField& srcWeightsSum() const;
451
452 //- Return access to normalisation factor of source
453 //- patch weights (i.e. the sum before normalisation)
454 inline scalarField& srcWeightsSum();
455
456 //- Return const access to source patch face centroids
457 inline const pointListList& srcCentroids() const;
458
459 //- Return access to source patch face centroids
460 inline pointListList& srcCentroids();
461
462 //- Source map - valid only if singlePatchProc = -1
463 //- This gets source data into a form to be consumed by
464 //- tgtAddress, tgtWeights
465 inline const mapDistribute& srcMap() const;
466
467 //- Pointer to the source map (if distributed).
468 //- Can be checked as a bool.
469 inline const mapDistribute* hasSrcMap() const noexcept;
470
471
472 // Target patch
474 //- Return const access to target patch face areas
475 inline const List<scalar>& tgtMagSf() const;
476
477 //- Return access to target patch face areas
478 inline List<scalar>& tgtMagSf();
479
480 //- Return const access to target patch addressing
481 inline const labelListList& tgtAddress() const;
482
483 //- Return access to target patch addressing
484 inline labelListList& tgtAddress();
485
486 //- Return const access to target patch weights
487 inline const scalarListList& tgtWeights() const;
489 //- Return access to target patch weights
490 inline scalarListList& tgtWeights();
491
492 //- Return const access to normalisation factor of target
493 //- patch weights (i.e. the sum before normalisation)
494 inline const scalarField& tgtWeightsSum() const;
495
496 //- Return access to normalisation factor of target
497 //- patch weights (i.e. the sum before normalisation)
498 inline scalarField& tgtWeightsSum();
499
500 //- Target map - valid only if singlePatchProc=-1.
501 //- This gets target data into a form to be consumed by
502 //- srcAddress, srcWeights
503 inline const mapDistribute& tgtMap() const;
504
505 //- Pointer to the target map (if distributed).
506 //- Can be checked as a bool.
507 inline const mapDistribute* hasTgtMap() const noexcept;
508
509
510 // Manipulation
511
512 //- Update addressing, weights and (optional) centroids
513 virtual bool calculate
514 (
515 const primitivePatch& srcPatch,
516 const primitivePatch& tgtPatch,
517 const autoPtr<searchableSurface>& surfPtr = nullptr
518 );
519
520 //- Set the maps, addresses and weights from an external source
521 void reset
522 (
523 autoPtr<mapDistribute>&& srcToTgtMap,
524 autoPtr<mapDistribute>&& tgtToSrcMap,
529 const label singlePatchProc
530 );
531
532 //- Append additional addressing and weights
533 void append
534 (
535 const primitivePatch& srcPatch,
536 const primitivePatch& tgtPatch
537 );
538
539 //- Normalise the weights
540 void normaliseWeights(const bool conformal, const bool output);
541
542
543 // Evaluation
544
545 // Low-level
546
547 //- Weighted sum of contributions. Note: cop operates on
548 //- single Type only.
549 template<class Type, class CombineOp>
550 static void weightedSum
551 (
552 const scalar lowWeightCorrection,
553 const labelListList& allSlots,
554 const scalarListList& allWeights,
555 const scalarField& weightsSum,
556 const UList<Type>& fld,
557 const CombineOp& cop,
558 List<Type>& result,
559 const UList<Type>& defaultValues
560 );
561
562 //- Weighted sum of contributions (includes caching+interp)
563 //- (for primitive types only)
564 template<class Type>
565 void weightedSum
566 (
567 const bool toSource,
568 const UList<Type>& fld,
569 List<Type>& result,
570 const UList<Type>& defaultValues
571 ) const;
572
573 //- Weighted sum of (potentially distributed) contributions
574 //- and apply caching+interpolation. Note: iop
575 //- operates on single Type only
576 template<class Type, class CombineOp, class InterpolateOp>
577 void interpolate
578 (
579 const bool toSource,
580 const UList<Type>& fld,
581 const CombineOp& cop,
582 const InterpolateOp& iop,
583 List<Type>& result,
584 const UList<Type>& defaultValues
585 ) const;
586
587 //- Interpolate from source to target with supplied op
588 //- to combine existing value with remote value and weight
589 template<class Type, class CombineOp>
591 (
592 const UList<Type>& fld,
593 const CombineOp& cop,
594 List<Type>& result,
595 const UList<Type>& defaultValues = UList<Type>::null()
596 ) const;
597
598 //- Interpolate from target to source with supplied op
599 //- to combine existing value with remote value and weight
600 template<class Type, class CombineOp>
602 (
603 const UList<Type>& fld,
604 const CombineOp& cop,
605 List<Type>& result,
606 const UList<Type>& defaultValues = UList<Type>::null()
607 ) const;
608
609
610 //- Interpolate from target to source with supplied op
611 template<class Type, class CombineOp>
613 (
614 const Field<Type>& fld,
615 const CombineOp& cop,
616 const UList<Type>& defaultValues = UList<Type>::null()
617 ) const;
618
619 //- Interpolate from target tmp field to source with supplied op
620 template<class Type, class CombineOp>
622 (
623 const tmp<Field<Type>>& tFld,
624 const CombineOp& cop,
625 const UList<Type>& defaultValues = UList<Type>::null()
626 ) const;
627
628 //- Interpolate from source to target with supplied op
629 template<class Type, class CombineOp>
631 (
632 const Field<Type>& fld,
633 const CombineOp& cop,
634 const UList<Type>& defaultValues = UList<Type>::null()
635 ) const;
636
637 //- Interpolate from source tmp field to target with supplied op
638 template<class Type, class CombineOp>
640 (
641 const tmp<Field<Type>>& tFld,
642 const CombineOp& cop,
643 const UList<Type>& defaultValues = UList<Type>::null()
644 ) const;
645
646 //- Interpolate from target to source
647 template<class Type>
649 (
650 const Field<Type>& fld,
651 const UList<Type>& defaultValues = UList<Type>::null()
652 ) const;
653
654 //- Interpolate from target tmp field
655 template<class Type>
657 (
658 const tmp<Field<Type>>& tFld,
659 const UList<Type>& defaultValues = UList<Type>::null()
660 ) const;
661
662 //- Interpolate from source to target
663 template<class Type>
665 (
666 const Field<Type>& fld,
667 const UList<Type>& defaultValues = UList<Type>::null()
668 ) const;
669
670 //- Interpolate from source tmp field
671 template<class Type>
673 (
674 const tmp<Field<Type>>& tFld,
675 const UList<Type>& defaultValues = UList<Type>::null()
676 ) const;
677
678
679 // Point intersections
680
681 //- Return source patch face index of point on target patch face
682 label srcPointFace
683 (
684 const primitivePatch& srcPatch,
685 const primitivePatch& tgtPatch,
686 const vector& n,
687 const label tgtFacei,
688 point& tgtPoint
689 )
690 const;
691
692 //- Return target patch face index of point on source patch face
693 label tgtPointFace
694 (
695 const primitivePatch& srcPatch,
696 const primitivePatch& tgtPatch,
697 const vector& n,
698 const label srcFacei,
699 point& srcPoint
700 )
701 const;
702
703 //- Restore AMI weights and addressing from the cache
704 bool restoreCache(const point& refPt);
705
706 //- Add AMI weights and addressing to the cache
707 void addToCache(const point& refPt);
708
709
710 // Checks
711
712 //- Check if src addresses are present in tgt addresses and
713 //- viceversa
714 bool checkSymmetricWeights(const bool log) const;
715
716 //- Write face connectivity as OBJ file
718 (
719 const primitivePatch& srcPatch,
720 const primitivePatch& tgtPatch,
722 ) const;
723
724
725 // I-O
726
727 //- Write AMI as a dictionary
728 virtual void write(Ostream& os) const;
729
730 //- Write AMI raw
731 virtual bool writeData(Ostream& os) const;
732
733
734 // Housekeeping
735
736 //- Non-const access to the up-to-date flag
737 // \deprecated Prefer the upToDate(bool) setter (JAN-2023)
738 bool& upToDate() noexcept { return upToDate_; }
739};
740
741
742// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
743
744} // End namespace Foam
745
746// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
747
748#include "AMIInterpolationI.H"
749
750// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
751
752#ifdef NoRepository
754#endif
755
756// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
757
758#endif
759
760// ************************************************************************* //
label n
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.
Definition AMICache.H:54
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...
Definition Field.H:172
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Class containing processor-to-processor mapping information.
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
A class for managing temporary objects.
Definition tmp.H:75
Encapsulation of data needed to search on PrimitivePatches.
A class for handling words, derived from Foam::string.
Definition word.H:66
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))))
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
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.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
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.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
List< pointList > pointListList
List of pointList.
Definition pointList.H:35
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).
dictionary dict
const pointField & pts
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68