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