advancingFrontAMI.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2020 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::advancingFrontAMI
29 
30 Description
31  Base class for Arbitrary Mesh Interface (AMI) methods
32 
33 SourceFiles
34  advancingFrontAMI.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef advancingFrontAMI_H
39 #define advancingFrontAMI_H
40 
41 #include "className.H"
42 #include "DynamicList.H"
43 #include "faceAreaIntersect.H"
44 #include "pointList.H"
45 #include "AMIInterpolation.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class advancingFrontAMI Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public AMIInterpolation
59 {
60 public:
61 
62  //- Area normalisation mode
63  enum class areaNormalisationMode
64  {
65  project,
67  };
68 
70 
71 
72 private:
73 
74  // Private Member Functions
75 
76  //- No copy assignment
77  void operator=(const advancingFrontAMI&) = delete;
78 
79 
80  // Parallel operations
81 
82  label calcOverlappingProcs
83  (
84  const List<treeBoundBoxList>& procBb,
85  const treeBoundBox& bb,
86  boolList& overlaps
87  ) const;
88 
89  void distributePatches
90  (
91  const mapDistribute& map,
92  const primitivePatch& pp,
93  const globalIndex& gi,
94  List<faceList>& faces,
96  List<labelList>& tgtFaceIDs
97  ) const;
98 
99  void distributeAndMergePatches
100  (
101  const mapDistribute& map,
102  const primitivePatch& tgtPatch,
103  const globalIndex& gi,
104  faceList& tgtFaces,
105  pointField& tgtPoints,
106  labelList& tgtFaceIDs
107  ) const;
108 
109  autoPtr<mapDistribute> calcProcMap
110  (
111  const primitivePatch& srcPatch,
112  const primitivePatch& tgtPatch
113  ) const;
114 
115 
116 protected:
117 
118  // Protected data
119 
120  //- Maximum squared distance
121  const scalar maxDistance2_;
123  //- Minimum (cos of) angle. 1 for perfectly matching.
124  const scalar minCosAngle_;
125 
126  //- Storage for src-side triangle decomposition
128 
129  //- Storage for tgt-side triangle decomposition
131 
132  //- Demand-driven extended target mesh (distributed parallel usage)
134 
135  //- Extended patch faces
138  //- Extended patch points
140 
141  //- Extended patch face IDs
143 
144  //- Extended patch map
146 
147  //- Labels of faces that are not overlapped by any target faces
148  //- (should be empty for correct functioning for fully covered AMIs)
150 
151  //- Octree used to find face seeds
153 
154  //- Face triangulation mode
156 
157  //- Area normalisation mode; default = project
159 
160 
161  // Protected Member Functions
163  // Helper functions
164 
165  //- Create a map that extends tgtPatch so that it covers srcPatch
166  void createExtendedTgtPatch();
167 
168  //- Check AMI patch coupling
169  void checkPatches() const;
170 
171  //- Is source/target a valid pair (i.e. not too far/different
172  // orientation). Used for prefiltering before e.g. area overlap
173  bool isCandidate(const label srcFacei, const label tgtFacei) const;
174 
175  virtual bool calculate
176  (
177  const primitivePatch& srcPatch,
179  const autoPtr<searchableSurface>& surfPtr = nullptr
180  );
181 
182  //- Initialise walk and return true if all ok
184  (
185  label& srcFacei,
186  label& tgtFacei
187  );
188 
189  //- Write triangle intersection to OBJ file
191  (
192  const scalar area,
193  const face& f1,
194  const face& f2,
195  const pointField& f1Points,
196  const pointField& f2Points
197  ) const;
198 
199 
200  // Common AMI method functions
201 
202  label findTargetFace
203  (
204  const label srcFacei,
205  const UList<label>& excludeFaces = UList<label>::null(),
206  const label srcFacePti = -1
207  ) const;
208 
209  //- Add faces neighbouring facei to the ID list
210  void appendNbrFaces
211  (
212  const label facei,
213  const primitivePatch& patch,
214  const DynamicList<label>& visitedFaces,
215  DynamicList<label>& faceIDs
216  ) const;
217 
218  //- Helper function to decompose a patch
219  void triangulatePatch
220  (
221  const primitivePatch& patch,
222  List<DynamicList<face>>& tris,
223  List<scalar>& magSf
224  ) const;
225 
226  //- Correction for non-conformal interpolations, e.g. for ACMI
227  virtual void nonConformalCorrection();
228 
229 
230 public:
231 
232  //- Runtime type information
233  TypeName("advancingFrontAMI");
234 
235  // Constructors
236 
237  //- Construct from components
239  (
240  const dictionary& dict,
241  const bool reverseTarget
242  );
243 
244  //- Construct from components
246  (
247  const bool requireMatch = true,
248  const bool reverseTarget = false,
249  const scalar lowWeightCorrection = -1,
252  );
253 
254  //- Construct as copy
256 
257  //- Construct and return a clone
258  virtual autoPtr<AMIInterpolation> clone() const
259  {
260  return autoPtr<AMIInterpolation>(new advancingFrontAMI(*this));
261  }
262 
263 
264  //- Destructor
265  virtual ~advancingFrontAMI() = default;
266 
267 
268  // Member Functions
269 
270  //- Return const access to the source patch
271  inline const primitivePatch& srcPatch() const;
272 
273  //- Return const access to the target patch
274  inline const primitivePatch& tgtPatch() const;
275 
276  //- Labels of faces that are not overlapped by any target faces
277  // Note: this should be empty for correct functioning
278  inline const labelList& srcNonOverlap() const;
279 
280 
281  // I-O
282 
283  //- Write
284  virtual void write(Ostream& os) const;
285 };
286 
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 } // End namespace Foam
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 #include "advancingFrontAMII.H"
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #endif
299 
300 // ************************************************************************* //
areaNormalisationMode
Area normalisation mode.
label findTargetFace(const label srcFacei, const UList< label > &excludeFaces=UList< label >::null(), const label srcFacePti=-1) const
pointField extendedTgtPoints_
Extended patch points.
dictionary dict
const faceAreaIntersect::triangulationMode triMode_
Face triangulation mode.
void writeIntersectionOBJ(const scalar area, const face &f1, const face &f2, const pointField &f1Points, const pointField &f2Points) const
Write triangle intersection to OBJ file.
autoPtr< mapDistribute > extendedTgtMapPtr_
Extended patch map.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:68
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const scalar maxDistance2_
Maximum squared distance.
virtual ~advancingFrontAMI()=default
Destructor.
static const Enum< areaNormalisationMode > areaNormalisationModeNames_
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
areaNormalisationMode areaNormalisationMode_
Area normalisation mode; default = project.
bool requireMatch() const noexcept
Return the requireMatch flag.
bool initialiseWalk(label &srcFacei, label &tgtFacei)
Initialise walk and return true if all ok.
TypeName("advancingFrontAMI")
Runtime type information.
void createExtendedTgtPatch()
Create a map that extends tgtPatch so that it covers srcPatch.
const scalar minCosAngle_
Minimum (cos of) angle. 1 for perfectly matching.
virtual void write(Ostream &os) const
Write.
const primitivePatch & tgtPatch() const
Return const access to the target patch.
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:61
const pointField & points
const wordList area
Standard area field types (scalar, vector, tensor, etc)
const labelList & srcNonOverlap() const
Labels of faces that are not overlapped by any target faces.
List< DynamicList< face > > tgtTris_
Storage for tgt-side triangle decomposition.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
labelList extendedTgtFaceIDs_
Extended patch face IDs.
bool isCandidate(const label srcFacei, const label tgtFacei) const
Is source/target a valid pair (i.e. not too far/different.
OBJstream os(runTime.globalPath()/outputName)
faceList extendedTgtFaces_
Extended patch faces.
List< DynamicList< face > > srcTris_
Storage for src-side triangle decomposition.
autoPtr< indexedOctree< treeType > > treePtr_
Octree used to find face seeds.
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
void checkPatches() const
Check AMI patch coupling.
void appendNbrFaces(const label facei, const primitivePatch &patch, const DynamicList< label > &visitedFaces, DynamicList< label > &faceIDs) const
Add faces neighbouring facei to the ID list.
virtual void nonConformalCorrection()
Correction for non-conformal interpolations, e.g. for ACMI.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
Class containing processor-to-processor mapping information.
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
void triangulatePatch(const primitivePatch &patch, List< DynamicList< face >> &tris, List< scalar > &magSf) const
Helper function to decompose a patch.
Base class for Arbitrary Mesh Interface (AMI) methods.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
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.
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:90
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
labelList srcNonOverlap_
Labels of faces that are not overlapped by any target faces (should be empty for correct functioning ...
autoPtr< primitivePatch > extendedTgtPatchPtr_
Demand-driven extended target mesh (distributed parallel usage)
const primitivePatch & srcPatch() const
Return const access to the source patch.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
advancingFrontAMI(const dictionary &dict, const bool reverseTarget)
Construct from components.