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 
61 private:
62 
63  // Private Member Functions
64 
65  //- No copy assignment
66  void operator=(const advancingFrontAMI&) = delete;
67 
68 
69  // Parallel operations
70 
71  label calcOverlappingProcs
72  (
73  const List<treeBoundBoxList>& procBb,
74  const treeBoundBox& bb,
75  boolList& overlaps
76  ) const;
77 
78  void distributePatches
79  (
80  const mapDistribute& map,
81  const primitivePatch& pp,
82  const globalIndex& gi,
83  List<faceList>& faces,
85  List<labelList>& tgtFaceIDs
86  ) const;
87 
88  void distributeAndMergePatches
89  (
90  const mapDistribute& map,
91  const primitivePatch& tgtPatch,
92  const globalIndex& gi,
93  faceList& tgtFaces,
94  pointField& tgtPoints,
95  labelList& tgtFaceIDs
96  ) const;
97 
98  autoPtr<mapDistribute> calcProcMap
99  (
100  const primitivePatch& srcPatch,
101  const primitivePatch& tgtPatch
102  ) const;
103 
104 
105 protected:
106 
107  // Protected data
108 
109  //- Storage for src-side triangle decomposition
111 
112  //- Storage for tgt-side triangle decomposition
114 
115  //- Demand-driven extended target mesh (distributed parallel usage)
117 
118  //- Extended patch faces
120 
121  //- Extended patch points
123 
124  //- Extended patch face IDs
126 
127  //- Extended patch map
129 
130  //- Labels of faces that are not overlapped by any target faces
131  //- (should be empty for correct functioning for fully covered AMIs)
133 
134  //- Octree used to find face seeds
136 
137  //- Face triangulation mode
139 
140 
141  // Protected Member Functions
142 
143  // Helper functions
144 
145  //- Create a map that extends tgtPatch so that it covers srcPatch
146  void createExtendedTgtPatch();
147 
148  //- Check AMI patch coupling
149  void checkPatches() const;
150 
151  virtual bool calculate
152  (
153  const primitivePatch& srcPatch,
154  const primitivePatch& tgtPatch,
155  const autoPtr<searchableSurface>& surfPtr = nullptr
156  );
157 
158  //- Initialise walk and return true if all ok
159  bool initialiseWalk
160  (
161  label& srcFacei,
162  label& tgtFacei
163  );
164 
165  //- Write triangle intersection to OBJ file
167  (
168  const scalar area,
169  const face& f1,
170  const face& f2,
171  const pointField& f1Points,
172  const pointField& f2Points
173  ) const;
174 
175 
176  // Common AMI method functions
177 
178  label findTargetFace
179  (
180  const label srcFacei,
181  const UList<label>& excludeFaces = UList<label>::null(),
182  const label srcFacePti = -1
183  ) const;
184 
185  //- Add faces neighbouring facei to the ID list
186  void appendNbrFaces
187  (
188  const label facei,
189  const primitivePatch& patch,
190  const DynamicList<label>& visitedFaces,
191  DynamicList<label>& faceIDs
192  ) const;
193 
194  //- Helper function to decompose a patch
195  void triangulatePatch
196  (
197  const primitivePatch& patch,
198  List<DynamicList<face>>& tris,
199  List<scalar>& magSf
200  ) const;
201 
202  //- Correction for non-conformal interpolations, e.g. for ACMI
203  virtual void nonConformalCorrection();
204 
205 
206 public:
207 
208  //- Runtime type information
209  TypeName("advancingFrontAMI");
210 
211  // Constructors
212 
213  //- Construct from components
215  (
216  const dictionary& dict,
217  const bool reverseTarget
218  );
219 
220  //- Construct from components
222  (
223  const bool requireMatch = true,
224  const bool reverseTarget = false,
225  const scalar lowWeightCorrection = -1,
228  );
229 
230  //- Construct as copy
232 
233  //- Construct and return a clone
234  virtual autoPtr<AMIInterpolation> clone() const
235  {
236  return autoPtr<AMIInterpolation>(new advancingFrontAMI(*this));
237  }
238 
239 
240  //- Destructor
241  virtual ~advancingFrontAMI() = default;
242 
243 
244  // Member Functions
245 
246  //- Return const access to the source patch
247  inline const primitivePatch& srcPatch() const;
248 
249  //- Return const access to the target patch
250  inline const primitivePatch& tgtPatch() const;
251 
252  //- Labels of faces that are not overlapped by any target faces
253  // Note: this should be empty for correct functioning
254  inline const labelList& srcNonOverlap() const;
255 };
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End namespace Foam
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #include "advancingFrontAMII.H"
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
Foam::advancingFrontAMI::triangulatePatch
void triangulatePatch(const primitivePatch &patch, List< DynamicList< face >> &tris, List< scalar > &magSf) const
Helper function to decompose a patch.
Definition: advancingFrontAMI.C:303
Foam::advancingFrontAMI::initialiseWalk
bool initialiseWalk(label &srcFacei, label &tgtFacei)
Initialise walk and return true if all ok.
Definition: advancingFrontAMI.C:118
Foam::advancingFrontAMI::clone
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
Definition: advancingFrontAMI.H:233
Foam::faceAreaIntersect::triangulationMode
triangulationMode
Definition: faceAreaIntersect.H:63
Foam::DynamicList< label >
Foam::advancingFrontAMI::nonConformalCorrection
virtual void nonConformalCorrection()
Correction for non-conformal interpolations, e.g. for ACMI.
Definition: advancingFrontAMI.C:348
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::advancingFrontAMI::srcNonOverlap_
labelList srcNonOverlap_
Definition: advancingFrontAMI.H:131
Foam::advancingFrontAMI::calculate
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
Definition: advancingFrontAMI.C:437
AMIInterpolation.H
advancingFrontAMII.H
Foam::advancingFrontAMI::extendedTgtPoints_
pointField extendedTgtPoints_
Extended patch points.
Definition: advancingFrontAMI.H:121
faceAreaIntersect.H
Foam::advancingFrontAMI::appendNbrFaces
void appendNbrFaces(const label facei, const primitivePatch &patch, const DynamicList< label > &visitedFaces, DynamicList< label > &faceIDs) const
Add faces neighbouring facei to the ID list.
Definition: advancingFrontAMI.C:271
Foam::advancingFrontAMI::extendedTgtFaces_
faceList extendedTgtFaces_
Extended patch faces.
Definition: advancingFrontAMI.H:118
Foam::advancingFrontAMI::checkPatches
void checkPatches() const
Check AMI patch coupling.
Definition: advancingFrontAMI.C:45
Foam::Field< vector >
Foam::advancingFrontAMI::createExtendedTgtPatch
void createExtendedTgtPatch()
Create a map that extends tgtPatch so that it covers srcPatch.
Definition: advancingFrontAMI.C:84
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
className.H
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Foam::advancingFrontAMI::srcNonOverlap
const labelList & srcNonOverlap() const
Labels of faces that are not overlapped by any target faces.
Definition: advancingFrontAMII.H:59
pointList.H
Foam::AMIInterpolation::requireMatch
bool requireMatch() const
Access to the requireMatch flag.
Definition: AMIInterpolationI.H:74
Foam::advancingFrontAMI::treePtr_
autoPtr< indexedOctree< treeType > > treePtr_
Octree used to find face seeds.
Definition: advancingFrontAMI.H:134
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::advancingFrontAMI::findTargetFace
label findTargetFace(const label srcFacei, const UList< label > &excludeFaces=UList< label >::null(), const label srcFacePti=-1) const
Definition: advancingFrontAMI.C:231
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::advancingFrontAMI::tgtTris_
List< DynamicList< face > > tgtTris_
Storage for tgt-side triangle decomposition.
Definition: advancingFrontAMI.H:112
Foam::advancingFrontAMI::extendedTgtMapPtr_
autoPtr< mapDistribute > extendedTgtMapPtr_
Extended patch map.
Definition: advancingFrontAMI.H:127
Foam::advancingFrontAMI::extendedTgtFaceIDs_
labelList extendedTgtFaceIDs_
Extended patch face IDs.
Definition: advancingFrontAMI.H:124
Foam::advancingFrontAMI::triMode_
const faceAreaIntersect::triangulationMode triMode_
Face triangulation mode.
Definition: advancingFrontAMI.H:137
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::AMIInterpolation::lowWeightCorrection
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
Definition: AMIInterpolationI.H:99
Foam::advancingFrontAMI::writeIntersectionOBJ
void writeIntersectionOBJ(const scalar area, const face &f1, const face &f2, const pointField &f1Points, const pointField &f2Points) const
Write triangle intersection to OBJ file.
Definition: advancingFrontAMI.C:180
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::advancingFrontAMI::extendedTgtPatchPtr_
autoPtr< primitivePatch > extendedTgtPatchPtr_
Demand-driven extended target mesh (distributed parallel usage)
Definition: advancingFrontAMI.H:115
Foam::advancingFrontAMI::~advancingFrontAMI
virtual ~advancingFrontAMI()=default
Destructor.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::AMIInterpolation
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Definition: AMIInterpolation.H:79
Foam::UList< label >
Foam::advancingFrontAMI::TypeName
TypeName("advancingFrontAMI")
Runtime type information.
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::advancingFrontAMI
Base class for Arbitrary Mesh Interface (AMI) methods.
Definition: advancingFrontAMI.H:55
Foam::AMIInterpolation::reverseTarget
bool reverseTarget() const
Access to the reverseTarget flag.
Definition: AMIInterpolationI.H:93
Foam::fieldTypes::area
const wordList area
Standard area field types (scalar, vector, tensor, etc)
Foam::advancingFrontAMI::srcPatch
const primitivePatch & srcPatch() const
Return const access to the source patch.
Definition: advancingFrontAMII.H:28
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
DynamicList.H
Foam::advancingFrontAMI::tgtPatch
const primitivePatch & tgtPatch() const
Return const access to the target patch.
Definition: advancingFrontAMII.H:41
Foam::advancingFrontAMI::srcTris_
List< DynamicList< face > > srcTris_
Storage for src-side triangle decomposition.
Definition: advancingFrontAMI.H:109
Foam::advancingFrontAMI::advancingFrontAMI
advancingFrontAMI(const dictionary &dict, const bool reverseTarget)
Construct from components.
Definition: advancingFrontAMI.C:372
Foam::faceAreaIntersect::tmMesh
Definition: faceAreaIntersect.H:66
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79