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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::coupledPolyPatch
29
30Description
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
35SourceFiles
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
48namespace Foam
49{
50
51/*---------------------------------------------------------------------------*\
52 Class coupledPolyPatch Declaration
53\*---------------------------------------------------------------------------*/
56:
57 public polyPatch
58{
59public:
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 };
72
73
74private:
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
100protected:
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
181public:
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 }
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.
361 (
362 const UList<face>& faces,
363 const pointField& points,
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// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of faces which address into the list of points.
const Field< point_type > & points() const noexcept
Return reference to global points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual transformType transform() const
Type of transform.
scalar matchTolerance() const
virtual void initMovePoints(PstreamBuffers &, const pointField &)=0
Initialise the patches for moving points.
virtual bool coupled() const
Return true because this patch is coupled.
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
virtual void updateMesh(PstreamBuffers &)=0
Update of the patch topology.
virtual void initUpdateMesh(PstreamBuffers &)=0
Initialise the update of the patch topology.
virtual void transformPosition(point &, const label facei) const =0
Transform a patch-based position from other side to this side.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const =0
Return new ordering for primitivePatch.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual bool separated() const
Are the planes separated.
virtual bool parallel() const
Are the cyclic planes parallel.
virtual void movePoints(PstreamBuffers &, const pointField &)=0
Correct patches after moving points.
virtual bool owner() const =0
Does this side own the patch ?
TypeName("coupled")
Runtime type information.
static const Enum< transformType > transformTypeNames
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.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
virtual const vectorField & separation() const
If the planes are separated the separation vector.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const =0
Initialize ordering for primitivePatch. Does not.
virtual void calcGeometry(const primitivePatch &referPatch, const pointField &thisCtrs, const vectorField &thisAreas, const pointField &thisCc, const pointField &nbrCtrs, const vectorField &nbrAreas, const pointField &nbrCc)=0
Calculate the patch geometry.
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
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.
virtual void transformPosition(pointField &) const =0
Transform a patch-based position from other side to this side.
static pointField getAnchorPoints(const UList< face > &, const pointField &, const transformType)
Get a unique anchor point for all faces.
virtual bool neighbour() const
Does the coupled side own the patch ?
virtual ~coupledPolyPatch()
Destructor.
virtual void initGeometry(PstreamBuffers &)=0
Initialise the calculation of the patch geometry.
virtual const tensorField & forwardT() const
Return face transformation tensor.
static void writeOBJ(Ostream &os, const point &pt)
Write point in OBJ format.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
A class for handling file names.
Definition: fileName.H:76
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:364
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:321
A class for handling words, derived from Foam::string.
Definition: word.H:68
const volScalarField & p0
Definition: EEqn.H:36
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
runTime write()
labelList f(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73