cyclicAMIPolyPatch.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) 2011-2021 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::cyclicAMIPolyPatch
26 
27 Description
28  Cyclic patch for Arbitrary Mesh Interface (AMI)
29 
30 SourceFiles
31  cyclicAMIPolyPatch.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef cyclicAMIPolyPatch_H
36 #define cyclicAMIPolyPatch_H
37 
38 #include "coupledPolyPatch.H"
39 #include "cyclicTransform.H"
40 #include "AMIInterpolation.H"
41 #include "polyBoundaryMesh.H"
42 #include "coupleGroupIdentifier.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class cyclicAMIPolyPatch Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public coupledPolyPatch,
56  public cyclicTransform
57 {
58 protected:
59 
60  // Protected data
61 
62  //- Name of cyclic neighbour patch
63  mutable word nbrPatchName_;
64 
65  //- Optional patchGroup to find nbrPatch
67 
68  //- Index of cyclic neighbour patch
69  mutable label nbrPatchID_;
70 
71  //- AMI interpolation classes
73 
74  //- AMI transforms (from source to target)
76 
77  //- Flag to indicate that slave patch should be reversed for AMI
78  const bool AMIReverse_;
79 
80  //- Flag to indicate that patches should match/overlap
81  const bool AMIRequireMatch_;
82 
83  //- Low weight correction threshold for AMI
84  const scalar AMILowWeightCorrection_;
85 
86  //- AMI Method
88 
89  //- Projection surface
91 
92  //- Dictionary used during projection surface construction
93  const dictionary surfDict_;
94 
95 
96  // Protected Member Functions
97 
98  //- Reset the AMI interpolator
99  virtual void resetAMI() const;
100 
101  //- Initialise the calculation of the patch geometry
102  virtual void initCalcGeometry(PstreamBuffers&);
103 
104  //- Calculate the patch geometry
105  virtual void calcGeometry(PstreamBuffers&);
106 
107  //- Initialise the patches for moving points
108  virtual void initMovePoints(PstreamBuffers& pBufs, const pointField&);
109 
110  //- Correct patches after moving points
111  virtual void movePoints(PstreamBuffers& pBufs, const pointField&);
112 
113  //- Initialise the update of the patch topology
114  virtual void initUpdateMesh(PstreamBuffers&);
115 
116  //- Update of the patch topology
117  virtual void updateMesh(PstreamBuffers&);
118 
119  //- Clear geometry
120  virtual void clearGeom();
121 
122  //- Reset the patch name
123  virtual void rename(const wordList& newNames);
124 
125  //- Reset the patch index
126  virtual void reorder(const labelUList& newToOldIndex);
127 
128 
129 public:
130 
131  //- Runtime type information
132  TypeName("cyclicAMI");
133 
134 
135  // Constructors
136 
137  //- Construct from (base couped patch) components
139  (
140  const word& name,
141  const label size,
142  const label start,
143  const label index,
144  const polyBoundaryMesh& bm,
145  const word& patchType,
146  const bool AMIRequireMatch = true,
149  );
150 
151  //- Construct from dictionary
153  (
154  const word& name,
155  const dictionary& dict,
156  const label index,
157  const polyBoundaryMesh& bm,
158  const word& patchType,
159  const bool AMIRequireMatch = true,
162  );
163 
164  //- Construct as copy, resetting the boundary mesh
166 
167  //- Construct given the original patch and resetting the
168  // face list and boundary mesh information
170  (
171  const cyclicAMIPolyPatch& pp,
172  const polyBoundaryMesh& bm,
173  const label index,
174  const label newSize,
175  const label newStart,
176  const word& nbrPatchName
177  );
178 
179  //- Construct given the original patch and a map
181  (
182  const cyclicAMIPolyPatch& pp,
183  const polyBoundaryMesh& bm,
184  const label index,
185  const labelUList& mapAddressing,
186  const label newStart
187  );
188 
189 
190  //- Construct and return a clone, resetting the boundary mesh
191  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
192  {
193  return autoPtr<polyPatch>(new cyclicAMIPolyPatch(*this, bm));
194  }
195 
196  //- Construct and return a clone, resetting the face list
197  // and boundary mesh
199  (
200  const polyBoundaryMesh& bm,
201  const label index,
202  const label newSize,
203  const label newStart
204  ) const
205  {
206  return autoPtr<polyPatch>
207  (
209  (
210  *this,
211  bm,
212  index,
213  newSize,
214  newStart,
215  nbrPatchName_
216  )
217  );
218  }
219 
220  //- Construct and return a clone, resetting the face list
221  // and boundary mesh
223  (
224  const polyBoundaryMesh& bm,
225  const label index,
226  const labelUList& mapAddressing,
227  const label newStart
228  ) const
229  {
230  return autoPtr<polyPatch>
231  (
233  (
234  *this,
235  bm,
236  index,
237  mapAddressing,
238  newStart
239  )
240  );
241  }
242 
243 
244  //- Destructor
245  virtual ~cyclicAMIPolyPatch();
246 
247 
248  // Member Functions
249 
250  // Access
251 
252  //- Is patch 'coupled'. Note that on AMI the geometry is not
253  // coupled but the fields are!
254  virtual bool coupled() const
255  {
256  return false;
257  }
258 
259  //- Neighbour patch name
260  inline const word& nbrPatchName() const;
261 
262  //- Neighbour patch ID
263  virtual label nbrPatchID() const;
264 
265  //- Does this side own the patch?
266  virtual bool owner() const;
267 
268  //- Return a reference to the neighbour patch
269  virtual const cyclicAMIPolyPatch& nbrPatch() const;
270 
271  //- Return a reference to the projection surface
272  const autoPtr<searchableSurface>& surfPtr() const;
273 
274  //- Return a reference to the AMI interpolators
275  const PtrList<AMIInterpolation>& AMIs() const;
276 
277  //- Return a reference to the AMI transforms
278  const List<transformer>& AMITransforms() const;
279 
280  //- Return true if applying the low weight correction
281  bool applyLowWeightCorrection() const;
282 
283  //- Return the weights sum for this patch
284  virtual const scalarField& weightsSum() const;
285 
286  //- Return the weights sum for the neighbour patch
287  virtual const scalarField& nbrWeightsSum() const;
288 
289 
290  // Transformations
291 
292  //- Return transformation between the coupled patches
293  virtual const transformer& transform() const
294  {
296  }
297 
298 
299  // Interpolations
300 
301  //- Interpolate field
302  template<class Type>
304  (
305  const Field<Type>& fld,
306  const UList<Type>& defaultValues = UList<Type>()
307  ) const;
308 
309  //- Interpolate tmp field
310  template<class Type>
312  (
313  const tmp<Field<Type>>& tFld,
314  const UList<Type>& defaultValues = UList<Type>()
315  ) const;
316 
317  //- Interpolate field component
319  (
320  const scalarField& field,
321  const direction cmpt,
322  const direction rank,
323  const scalarUList& defaultValues = scalarUList()
324  ) const;
325 
326 
327  //- Initialise ordering for primitivePatch. Does not
328  // refer to *this (except for name() and type() etc.)
329  virtual void initOrder
330  (
332  const primitivePatch&
333  ) const;
334 
335  //- Return new ordering for primitivePatch.
336  // Ordering is -faceMap: for every face
337  // index of the new face -rotation:for every new face the clockwise
338  // shift of the original face. Return false if nothing changes
339  // (faceMap is identity, rotation is 0), true otherwise.
340  virtual bool order
341  (
343  const primitivePatch&,
345  labelList& rotation
346  ) const;
347 
348  //- Return the transform and face indices on neighbour patch which
349  // shares point p following trajectory vector n
351  (
352  const label facei,
353  const vector& n,
354  point& p
355  ) const;
356 
357  //- Index of processor that holds all of both sides, or -1 if
358  // distributed
359  label singlePatchProc() const;
360 
361  //- Write the polyPatch data as a dictionary
362  virtual void write(Ostream&) const;
363 };
364 
365 
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 
368 } // End namespace Foam
369 
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 
372 #include "cyclicAMIPolyPatchI.H"
373 
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 
376 #ifdef NoRepository
378 #endif
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 #endif
383 
384 // ************************************************************************* //
virtual void clearGeom()
Clear geometry.
virtual void resetAMI() const
Reset the AMI interpolator.
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
dictionary dict
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
const word & name() const
Return name.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool coupled() const
Is patch &#39;coupled&#39;. Note that on AMI the geometry is not.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
uint8_t direction
Definition: direction.H:45
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
labelPair pointAMIAndFace(const label facei, const vector &n, point &p) const
Return the transform and face indices on neighbour patch which.
bool applyLowWeightCorrection() const
Return true if applying the low weight correction.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
tmp< Field< Type > > interpolate(const Field< Type > &fld, const UList< Type > &defaultValues=UList< Type >()) const
Interpolate field.
virtual autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
interpolationMethod
Enumeration specifying interpolation method.
const bool AMIRequireMatch_
Flag to indicate that patches should match/overlap.
const dictionary surfDict_
Dictionary used during projection surface construction.
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
label nbrPatchID_
Index of cyclic neighbour patch.
virtual const scalarField & nbrWeightsSum() const
Return the weights sum for the neighbour patch.
const List< transformer > & AMITransforms() const
Return a reference to the AMI transforms.
virtual label nbrPatchID() const
Neighbour patch ID.
virtual const cyclicAMIPolyPatch & nbrPatch() const
Return a reference to the neighbour patch.
const coupleGroupIdentifier coupleGroup_
Optional patchGroup to find nbrPatch.
cyclicAMIPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType, const bool AMIRequireMatch=true, const AMIInterpolation::interpolationMethod AMIMethod=AMIInterpolation::imFaceAreaWeight)
Construct from (base couped patch) components.
A list of faces which address into the list of points.
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const AMIInterpolation::interpolationMethod AMIMethod_
AMI Method.
const PtrList< AMIInterpolation > & AMIs() const
Return a reference to the AMI interpolators.
A class for handling words, derived from string.
Definition: word.H:59
const autoPtr< searchableSurface > & surfPtr() const
Return a reference to the projection surface.
const scalar AMILowWeightCorrection_
Low weight correction threshold for AMI.
label singlePatchProc() const
Index of processor that holds all of both sides, or -1 if.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
virtual const transformer & transform() const
Return transformation between the coupled patches.
PtrList< AMIInterpolation > AMIs_
AMI interpolation classes.
Cyclic patch for Arbitrary Mesh Interface (AMI)
const transformer & transform() const
Return transformation between the coupled patches.
virtual const scalarField & weightsSum() const
Return the weights sum for this patch.
Encapsulates using patchGroups to specify coupled patch.
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:60
Base class for Arbitrary Mesh Interface (AMI) methods.
Definition: AMIMethod.H:55
virtual ~cyclicAMIPolyPatch()
Destructor.
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Buffers for inter-processor communications streams (UOPstream, UIPstream).
TypeName("cyclicAMI")
Runtime type information.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const word & nbrPatchName() const
Neighbour patch name.
virtual bool owner() const
Does this side own the patch?
label index() const
Return the index of this patch in the boundaryMesh.
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:309
UList< scalar > scalarUList
A UList of scalars.
Definition: scalarList.H:48
label n
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Cyclic plane tranformation.
rDeltaTY field()
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
word nbrPatchName_
Name of cyclic neighbour patch.
virtual void rename(const wordList &newNames)
Reset the patch name.
Namespace for OpenFOAM.
virtual void movePoints(PstreamBuffers &pBufs, const pointField &)
Correct patches after moving points.
virtual void initMovePoints(PstreamBuffers &pBufs, const pointField &)
Initialise the patches for moving points.
autoPtr< searchableSurface > surfPtr_
Projection surface.
List< transformer > AMITransforms_
AMI transforms (from source to target)