AMIMethod.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::AMIMethod
26 
27 Description
28  Base class for Arbitrary Mesh Interface (AMI) methods
29 
30 SourceFiles
31  AMIMethod.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef AMIMethod_H
36 #define AMIMethod_H
37 
38 #include "className.H"
39 #include "DynamicList.H"
40 #include "faceAreaIntersect.H"
41 #include "indexedOctree.H"
42 #include "treeDataPrimitivePatch.H"
43 #include "treeBoundBoxList.H"
44 #include "primitivePatch.H"
45 #include "runTimeSelectionTables.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class AMIMethod Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class AMIMethod
57 {
58 protected:
59 
60  //- Local typedef to octree tree-type
62 
63 
64  // Protected data
65 
66  //- Reference to source patch
68 
69  //- Reference to target patch
71 
72  //- Flag to indicate that the two patches are co-directional and
73  // that the orientation of the target patch should be reversed
74  const bool reverseTarget_;
75 
76  //- Flag to indicate that the two patches must be matched/an overlap
77  // exists between them
78  const bool requireMatch_;
79 
80  //- Source face areas
81  const scalarField& srcMagSf_;
82 
83  //- Target face areas
84  const scalarField& tgtMagSf_;
85 
86  //- Labels of faces that are not overlapped by any target faces
87  // (should be empty for correct functioning)
89 
90  //- Octree used to find face seeds
92 
93  //- Face triangulation mode
95 
96 
97  // Protected Member Functions
98 
99  // Helper functions
100 
101  //- Check AMI patch coupling
102  void checkPatches() const;
103 
104  //- Initialise and return true if all ok
105  bool initialise
106  (
107  labelListList& srcAddress,
108  scalarListList& srcWeights,
109  labelListList& tgtAddress,
110  scalarListList& tgtWeights,
111  label& srcFacei,
112  label& tgtFacei
113  );
114 
115  //- Write triangle intersection to OBJ file
117  (
118  const scalar area,
119  const face& f1,
120  const face& f2,
121  const pointField& f1Points,
122  const pointField& f2Points
123  ) const;
124 
125 
126  // Common AMI method functions
127 
128  //- Reset the octree for the target patch face search
129  void resetTree();
130 
131  //- Find face on target patch that overlaps source face
132  label findTargetFace(const label srcFacei) const;
133 
134  //- Add faces neighbouring facei to the ID list
135  void appendNbrFaces
136  (
137  const label facei,
138  const primitivePatch& patch,
139  const DynamicList<label>& visitedFaces,
140  DynamicList<label>& faceIDs
141  ) const;
142 
143  //- The maximum edge angle that the walk will cross
144  virtual scalar maxWalkAngle() const;
145 
146 
147 public:
148 
149  //- Runtime type information
150  TypeName("AMIMethod");
151 
152 
153  //- Declare runtime constructor selection table
155  (
156  autoPtr,
157  AMIMethod,
158  components,
159  (
160  const primitivePatch& srcPatch,
161  const primitivePatch& tgtPatch,
162  const scalarField& srcMagSf,
163  const scalarField& tgtMagSf,
165  const bool reverseTarget,
166  const bool requireMatch
167  ),
168  (
169  srcPatch,
170  tgtPatch,
171  srcMagSf,
172  tgtMagSf,
173  triMode,
174  reverseTarget,
175  requireMatch
176  )
177  );
178 
179 
180  // Constructors
181 
182  //- Construct from components
183  AMIMethod
184  (
185  const primitivePatch& srcPatch,
186  const primitivePatch& tgtPatch,
187  const scalarField& srcMagSf,
188  const scalarField& tgtMagSf,
190  const bool reverseTarget,
191  const bool requireMatch
192  );
193 
194  //- Disallow default bitwise copy construction
195  AMIMethod(const AMIMethod&) = delete;
196 
197 
198  //- Selector
199  static autoPtr<AMIMethod> New
200  (
201  const word& methodName,
202  const primitivePatch& srcPatch,
203  const primitivePatch& tgtPatch,
204  const scalarField& srcMagSf,
205  const scalarField& tgtMagSf,
207  const bool reverseTarget,
208  const bool requireMatch
209  );
210 
211 
212  //- Destructor
213  virtual ~AMIMethod();
214 
215 
216  // Member Functions
217 
218  // Access
219 
220  //- Labels of faces that are not overlapped by any target faces
221  // Note: this should be empty for correct functioning
222  inline const labelList& srcNonOverlap() const;
223 
224  //- Flag to indicate that interpolation patches are conformal
225  virtual bool conformal() const;
226 
227 
228  // Manipulation
229 
230  //- Update addressing and weights
231  virtual void calculate
232  (
233  labelListList& srcAddress,
234  scalarListList& srcWeights,
235  labelListList& tgtAddress,
236  scalarListList& tgtWeights,
237  label srcFacei = -1,
238  label tgtFacei = -1
239  ) = 0;
240 
241 
242  // Member Operators
243 
244  //- Disallow default bitwise assignment
245  void operator=(const AMIMethod&) = delete;
246 };
247 
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 } // End namespace Foam
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #include "AMIMethodI.H"
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #endif
260 
261 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
virtual ~AMIMethod()
Destructor.
Definition: AMIMethod.C:348
const bool requireMatch_
Flag to indicate that the two patches must be matched/an overlap.
Definition: AMIMethod.H:77
AMIMethod(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const scalarField &srcMagSf, const scalarField &tgtMagSf, const faceAreaIntersect::triangulationMode &triMode, const bool reverseTarget, const bool requireMatch)
Construct from components.
Definition: AMIMethod.C:325
void operator=(const AMIMethod &)=delete
Disallow default bitwise assignment.
const primitivePatch & tgtPatch_
Reference to target patch.
Definition: AMIMethod.H:69
const labelList & srcNonOverlap() const
Labels of faces that are not overlapped by any target faces.
Definition: AMIMethodI.H:26
virtual void calculate(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label srcFacei=-1, label tgtFacei=-1)=0
Update addressing and weights.
label findTargetFace(const label srcFacei) const
Find face on target patch that overlaps source face.
Definition: AMIMethod.C:234
scalar f1
Definition: createFields.H:28
const scalarField & tgtMagSf_
Target face areas.
Definition: AMIMethod.H:83
static autoPtr< AMIMethod > New(const word &methodName, const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const scalarField &srcMagSf, const scalarField &tgtMagSf, const faceAreaIntersect::triangulationMode &triMode, const bool reverseTarget, const bool requireMatch)
Selector.
Definition: AMIMethodNew.C:31
labelList srcNonOverlap_
Labels of faces that are not overlapped by any target faces.
Definition: AMIMethod.H:87
const primitivePatch & srcPatch_
Reference to source patch.
Definition: AMIMethod.H:66
A list of faces which address into the list of points.
A class for handling words, derived from string.
Definition: word.H:59
Encapsulation of data needed to search on PrimitivePatches.
virtual bool conformal() const
Flag to indicate that interpolation patches are conformal.
Definition: AMIMethod.C:354
void resetTree()
Reset the octree for the target patch face search.
Definition: AMIMethod.C:203
Base class for Arbitrary Mesh Interface (AMI) methods.
Definition: AMIMethod.H:55
void checkPatches() const
Check AMI patch coupling.
Definition: AMIMethod.C:42
autoPtr< indexedOctree< treeType > > treePtr_
Octree used to find face seeds.
Definition: AMIMethod.H:90
treeDataPrimitivePatch< primitivePatch > treeType
Local typedef to octree tree-type.
Definition: AMIMethod.H:60
const faceAreaIntersect::triangulationMode triMode_
Face triangulation mode.
Definition: AMIMethod.H:93
const scalarField & srcMagSf_
Source face areas.
Definition: AMIMethod.H:80
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: AMIMethod.C:264
TypeName("AMIMethod")
Runtime type information.
bool initialise(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label &srcFacei, label &tgtFacei)
Initialise and return true if all ok.
Definition: AMIMethod.C:79
Macro definitions for declaring ClassName(), NamespaceName(), etc.
virtual scalar maxWalkAngle() const
The maximum edge angle that the walk will cross.
Definition: AMIMethod.C:316
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
declareRunTimeSelectionTable(autoPtr, AMIMethod, components,(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const scalarField &srcMagSf, const scalarField &tgtMagSf, const faceAreaIntersect::triangulationMode &triMode, const bool reverseTarget, const bool requireMatch),(srcPatch, tgtPatch, srcMagSf, tgtMagSf, triMode, reverseTarget, requireMatch))
Declare runtime constructor selection table.
const bool reverseTarget_
Flag to indicate that the two patches are co-directional and.
Definition: AMIMethod.H:73
Namespace for OpenFOAM.
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: AMIMethod.C:153