coupledPolyPatch.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-2015 OpenFOAM Foundation
9  Copyright (C) 2019 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::coupledPolyPatch
29 
30 Description
31  The coupledPolyPatch is an abstract base class for patches that couple
32  regions of the computational domain e.g. cyclic and processor-processor
33  links.
34 
35 SourceFiles
36  coupledPolyPatch.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef coupledPolyPatch_H
41 #define coupledPolyPatch_H
42 
43 #include "polyPatch.H"
44 #include "diagTensorField.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class coupledPolyPatch Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class coupledPolyPatch
56 :
57  public polyPatch
58 {
59 public:
60 
61  enum transformType
62  {
63  UNKNOWN, // unspecified; automatic ordering
64  ROTATIONAL, // rotation along coordinate axis
65  TRANSLATIONAL, // translation
66  COINCIDENTFULLMATCH,// assume no transforms
67  // and check the points in faces match
68  NOORDERING // unspecified, no automatic ordering
69  };
70 
72 
73 
74 private:
75 
76  // Private data
77 
78  //- Default matching tolerance
79  static const scalar defaultMatchTol_;
80 
81  //- Local matching tolerance
82  const scalar matchTolerance_;
83 
84  //- Type of transformation
85  transformType transform_;
86 
87  //- Offset (distance) vector from one side of the couple to the other
88  mutable vectorField separation_;
89 
90  //- Face transformation tensor
91  mutable tensorField forwardT_;
92 
93  //- Neighbour-cell transformation tensor
94  mutable tensorField reverseT_;
95 
96  //- Are faces collocated. Either size 0,1 or length of patch.
97  mutable boolList collocated_;
98 
99 
100 protected:
101 
102  // Protected Member Functions
103 
104  //- Calculate the transformation tensors
105  // smallDist : matching distance per face
106  // absTol : absolute error in normal
107  // if transformType = unknown it first tries rotational, then
108  // translational transform
110  (
111  const vectorField& Cf,
112  const vectorField& Cr,
113  const vectorField& nf,
114  const vectorField& nr,
115  const scalarField& smallDist,
116  const scalar absTol,
117  const transformType = UNKNOWN
118  ) const;
119 
120  //- Initialise the calculation of the patch geometry
121  virtual void initGeometry(PstreamBuffers&) = 0;
122 
123  //- Calculate the patch geometry
124  virtual void calcGeometry(PstreamBuffers&) = 0;
125 
126  //- Initialise the patches for moving points
127  virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
128 
129  //- Correct patches after moving points
130  virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
131 
132  //- Initialise the update of the patch topology
133  virtual void initUpdateMesh(PstreamBuffers&) = 0;
134 
135  //- Update of the patch topology
136  virtual void updateMesh(PstreamBuffers&) = 0;
137 
138 
139  //- Write point in OBJ format
140  static void writeOBJ(Ostream& os, const point& pt);
141 
142  //- Write selected points in OBJ format
143  static void writeOBJ(Ostream&, const pointField&, const labelList&);
144 
145  //- Write patch
146  static void writeOBJ
147  (
148  const fileName&,
149  const UList<face>&,
150  const pointField&
151  );
152 
153  //- Write edge in OBJ format
154  static void writeOBJ
155  (
156  Ostream& os,
157  const point& p0,
158  const point& p1,
159  label& vertI
160  );
161 
162  //- Get a unique anchor point for all faces
164  (
165  const UList<face>&,
166  const pointField&,
167  const transformType
168  );
169 
170  //- Get the number of vertices face f needs to be rotated such that
171  // its f[0] point aligns with given anchor (within tol).
172  static label getRotation
173  (
174  const pointField& points,
175  const face& f,
176  const point& anchor,
177  const scalar tol
178  );
179 
180 
181 public:
182 
183  //- Runtime type information
184  TypeName("coupled");
185 
186 
187  // Constructors
188 
189  //- Construct from components
191  (
192  const word& name,
193  const label size,
194  const label start,
195  const label index,
196  const polyBoundaryMesh& bm,
197  const word& patchType,
199  );
200 
201  //- Construct from dictionary
203  (
204  const word& name,
205  const dictionary& dict,
206  const label index,
207  const polyBoundaryMesh& bm,
208  const word& patchType
209  );
210 
211  //- Copy construct, resetting the boundary mesh
213 
214  //- Copy construct, resetting the faceCells
216 
217  //- Construct given the original patch and resetting the
218  //- face list and boundary mesh information
220  (
221  const coupledPolyPatch& pp,
222  const polyBoundaryMesh& bm,
223  const label index,
224  const label newSize,
225  const label newStart
226  );
227 
228  //- Construct given the original patch and a map
230  (
231  const coupledPolyPatch& pp,
232  const polyBoundaryMesh& bm,
233  const label index,
234  const labelUList& mapAddressing,
235  const label newStart
236  );
237 
238 
239  //- Destructor
240  virtual ~coupledPolyPatch();
241 
242 
243  // Member Functions
244 
245 
246  // Access
247 
248  //- Return true because this patch is coupled
249  virtual bool coupled() const
250  {
251  return true;
252  }
253 
254  //- Does this side own the patch ?
255  virtual bool owner() const = 0;
256 
257  //- Does the coupled side own the patch ?
258  virtual bool neighbour() const
259  {
260  return !owner();
261  }
262 
263  //- Type of transform
264  virtual transformType transform() const
265  {
266  return transform_;
267  }
268 
269  //- Type of transform
270  // This is currently only for use when collapsing generated
271  // meshes that can have zero area faces.
272  virtual transformType& transform()
273  {
274  return transform_;
275  }
276 
277  //- Transform a patch-based position from other side to this side
278  virtual void transformPosition(pointField&) const = 0;
279 
280  //- Transform a patch-based position from other side to this side
281  virtual void transformPosition(point&, const label facei) const = 0;
282 
283  //- Are the planes separated.
284  virtual bool separated() const
285  {
286  return separation_.size();
287  }
288 
289  //- If the planes are separated the separation vector.
290  virtual const vectorField& separation() const
291  {
292  return separation_;
293  }
294 
295  //- Are the cyclic planes parallel.
296  virtual bool parallel() const
297  {
298  return forwardT_.empty();
299  }
300 
301  //- Return face transformation tensor.
302  virtual const tensorField& forwardT() const
303  {
304  return forwardT_;
305  }
306 
307  //- Return neighbour-cell transformation tensor.
308  virtual const tensorField& reverseT() const
309  {
310  return reverseT_;
311  }
312 
313  //- Are faces collocated. Either size 0,1 or length of patch
314  virtual const boolList& collocated() const
315  {
316  return collocated_;
317  }
318 
319  scalar matchTolerance() const
320  {
321  return matchTolerance_;
322  }
323 
324 
325  //- Calculate the patch geometry
326  virtual void calcGeometry
327  (
328  const primitivePatch& referPatch,
329  const pointField& thisCtrs,
330  const vectorField& thisAreas,
331  const pointField& thisCc,
332  const pointField& nbrCtrs,
333  const vectorField& nbrAreas,
334  const pointField& nbrCc
335  ) = 0;
336 
337  //- Initialize ordering for primitivePatch. Does not
338  // refer to *this (except for name() and type() etc.)
339  virtual void initOrder
340  (
342  const primitivePatch&
343  ) const = 0;
344 
345  //- Return new ordering for primitivePatch.
346  // Ordering is -faceMap: for every face
347  // index of the new face -rotation:for every new face the clockwise
348  // shift of the original face. Return false if nothing changes
349  // (faceMap is identity, rotation is 0), true otherwise.
350  virtual bool order
351  (
353  const primitivePatch&,
355  labelList& rotation
356  ) const = 0;
357 
358  //- Calculate typical tolerance per face. Is currently max distance
359  // from face centre to any of the face vertices.
360  static scalarField calcFaceTol
361  (
362  const UList<face>& faces,
363  const pointField& points,
364  const pointField& faceCentres
365  );
366 
367  //- Write the polyPatch data as a dictionary
368  virtual void write(Ostream& os) const;
369 };
370 
371 
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 
374 } // End namespace Foam
375 
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 
378 #endif
379 
380 // ************************************************************************* //
Foam::coupledPolyPatch::getAnchorPoints
static pointField getAnchorPoints(const UList< face > &, const pointField &, const transformType)
Get a unique anchor point for all faces.
Definition: coupledPolyPatch.C:133
Foam::PrimitivePatch::points
const Field< point_type > & points() const noexcept
Return reference to global points.
Definition: PrimitivePatch.H:299
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::coupledPolyPatch::separation
virtual const vectorField & separation() const
If the planes are separated the separation vector.
Definition: coupledPolyPatch.H:289
Foam::Enum< transformType >
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
polyPatch.H
Foam::coupledPolyPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: coupledPolyPatch.H:301
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:88
Foam::coupledPolyPatch::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: coupledPolyPatch.H:307
Foam::coupledPolyPatch::transformTypeNames
static const Enum< transformType > transformTypeNames
Definition: coupledPolyPatch.H:70
Foam::coupledPolyPatch::neighbour
virtual bool neighbour() const
Does the coupled side own the patch ?
Definition: coupledPolyPatch.H:257
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:54
Foam::coupledPolyPatch::owner
virtual bool owner() const =0
Does this side own the patch ?
Foam::coupledPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)=0
Update of the patch topology.
diagTensorField.H
Foam::coupledPolyPatch::write
virtual void write(Ostream &os) const
Write the polyPatch data as a dictionary.
Definition: coupledPolyPatch.C:577
Foam::coupledPolyPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: coupledPolyPatch.H:295
Foam::coupledPolyPatch::separated
virtual bool separated() const
Are the planes separated.
Definition: coupledPolyPatch.H:283
Foam::Field< vector >
Foam::coupledPolyPatch::NOORDERING
Definition: coupledPolyPatch.H:67
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::coupledPolyPatch::getRotation
static label getRotation(const pointField &points, const face &f, const point &anchor, const scalar tol)
Get the number of vertices face f needs to be rotated such that.
Definition: coupledPolyPatch.C:241
Foam::coupledPolyPatch::initGeometry
virtual void initGeometry(PstreamBuffers &)=0
Initialise the calculation of the patch geometry.
Foam::coupledPolyPatch::UNKNOWN
Definition: coupledPolyPatch.H:62
Foam::coupledPolyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &)=0
Correct patches after moving points.
Foam::coupledPolyPatch::COINCIDENTFULLMATCH
Definition: coupledPolyPatch.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::coupledPolyPatch::TypeName
TypeName("coupled")
Runtime type information.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::coupledPolyPatch::matchTolerance
scalar matchTolerance() const
Definition: coupledPolyPatch.H:318
Foam::coupledPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)=0
Initialise the update of the patch topology.
Foam::coupledPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const =0
Initialize ordering for primitivePatch. Does not.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::coupledPolyPatch::calcFaceTol
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
Definition: coupledPolyPatch.C:201
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:361
Foam::coupledPolyPatch::transform
virtual transformType transform() const
Type of transform.
Definition: coupledPolyPatch.H:263
Foam::coupledPolyPatch::ROTATIONAL
Definition: coupledPolyPatch.H:63
Foam::coupledPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const =0
Return new ordering for primitivePatch.
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:321
f
labelList f(nPoints)
Foam::coupledPolyPatch::transformPosition
virtual void transformPosition(pointField &) const =0
Transform a patch-based position from other side to this side.
Foam::Vector< scalar >
Foam::coupledPolyPatch::~coupledPolyPatch
virtual ~coupledPolyPatch()
Destructor.
Definition: coupledPolyPatch.C:571
Foam::List< bool >
Foam::UList< face >
Foam::coupledPolyPatch::calcTransformTensors
void calcTransformTensors(const vectorField &Cf, const vectorField &Cr, const vectorField &nf, const vectorField &nr, const scalarField &smallDist, const scalar absTol, const transformType=UNKNOWN) const
Calculate the transformation tensors.
Definition: coupledPolyPatch.C:295
Foam::coupledPolyPatch::initMovePoints
virtual void initMovePoints(PstreamBuffers &, const pointField &)=0
Initialise the patches for moving points.
Foam::coupledPolyPatch::coupled
virtual bool coupled() const
Return true because this patch is coupled.
Definition: coupledPolyPatch.H:248
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::coupledPolyPatch::collocated
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
Definition: coupledPolyPatch.H:313
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
p0
const volScalarField & p0
Definition: EEqn.H:36
Foam::coupledPolyPatch::writeOBJ
static void writeOBJ(Ostream &os, const point &pt)
Write point in OBJ format.
Definition: coupledPolyPatch.C:60
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::coupledPolyPatch::transformType
transformType
Definition: coupledPolyPatch.H:60
Foam::coupledPolyPatch::calcGeometry
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
Foam::coupledPolyPatch::TRANSLATIONAL
Definition: coupledPolyPatch.H:64
Foam::coupledPolyPatch::coupledPolyPatch
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType, const transformType transform)
Construct from components.
Definition: coupledPolyPatch.C:476
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79