Loading...
Searching...
No Matches
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 Foam_coupledPolyPatch_H
41#define Foam_coupledPolyPatch_H
42
43#include "polyPatch.H"
44#include "diagTensorField.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
51/*---------------------------------------------------------------------------*\
52 Class coupledPolyPatch Declaration
53\*---------------------------------------------------------------------------*/
54
57 public polyPatch
59public:
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
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>&,
151 );
152
153 //- Write edge in OBJ format
154 static void writeOBJ
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 // Access
246
247 //- Return true because this patch is coupled
248 virtual bool coupled() const
249 {
250 return true;
251 }
252
253 //- Does this side own the patch ?
254 virtual bool owner() const = 0;
255
256 //- Does the coupled side own the patch ?
257 virtual bool neighbour() const
258 {
259 return !owner();
260 }
261
262 //- The referring patchID (eg, for cyclics).
263 virtual label referPatchID() const
264 {
265 return -1;
266 }
267
268 //- Type of transform
269 virtual transformType transform() const
270 {
271 return transform_;
272 }
273
274 //- Type of transform
275 // This is currently only for use when collapsing generated
276 // meshes that can have zero area faces.
277 virtual transformType& transform()
278 {
279 return transform_;
280 }
281
282 //- Transform a patch-based position from other side to this side
283 virtual void transformPosition(pointField&) const = 0;
284
285 //- Transform a patch-based position from other side to this side
286 virtual void transformPosition(point&, const label facei) const = 0;
287
288 //- Are the planes separated.
289 virtual bool separated() const
290 {
291 return separation_.size();
292 }
293
294 //- If the planes are separated the separation vector.
295 virtual const vectorField& separation() const
296 {
297 return separation_;
298 }
299
300 //- Are the cyclic planes parallel.
301 virtual bool parallel() const
302 {
303 return forwardT_.empty();
304 }
305
306 //- Return face transformation tensor.
307 virtual const tensorField& forwardT() const
308 {
309 return forwardT_;
310 }
312 //- Return neighbour-cell transformation tensor.
313 virtual const tensorField& reverseT() const
314 {
315 return reverseT_;
317
318 //- Are faces collocated. Either size 0,1 or length of patch
319 virtual const boolList& collocated() const
320 {
321 return collocated_;
322 }
323
324 scalar matchTolerance() const
325 {
326 return matchTolerance_;
327 }
328
329
330 //- Calculate the patch geometry
331 virtual void calcGeometry
333 const primitivePatch& referPatch,
334 const pointField& thisCtrs,
335 const vectorField& thisAreas,
336 const pointField& thisCc,
337 const pointField& nbrCtrs,
338 const vectorField& nbrAreas,
339 const pointField& nbrCc
340 ) = 0;
341
342 //- Initialize ordering for primitivePatch. Does not
343 // refer to *this (except for name() and type() etc.)
344 virtual void initOrder
345 (
347 const primitivePatch&
348 ) const = 0;
349
350 //- Return new ordering for primitivePatch.
351 // Ordering is -faceMap: for every face
352 // index of the new face -rotation:for every new face the clockwise
353 // shift of the original face. Return false if nothing changes
354 // (faceMap is identity, rotation is 0), true otherwise.
355 virtual bool order
358 const primitivePatch&,
360 labelList& rotation
361 ) const = 0;
362
363 //- Calculate typical tolerance per face. Is currently max distance
364 // from face centre to any of the face vertices.
366 (
367 const UList<face>& faces,
368 const pointField& points,
370 );
371
372 //- Write the polyPatch data as a dictionary
373 virtual void write(Ostream& os) const;
374};
375
376
377// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378
379} // End namespace Foam
380
381// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382
383#endif
384
385// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
const Field< point_type > & points() const noexcept
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:89
void size(const label n)
Definition UList.H:118
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 label referPatchID() const
The referring patchID (eg, for cyclics).
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.
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.
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 transformType & transform()
Type of transform.
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:133
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
A class for handling file names.
Definition fileName.H:75
label index() const noexcept
The index of this patch in the boundaryMesh.
friend class polyBoundaryMesh
Definition polyPatch.H:112
const faceList::subList faces() const
Return mesh faces for the patch.
Definition polyPatch.C:301
const vectorField::subField faceCentres() const
Return face centres.
Definition polyPatch.C:320
polyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Definition polyPatch.C:75
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Definition polyPatch.H:446
const labelUList & faceCells() const
Return face-cell addressing.
Definition polyPatch.C:401
A class for handling words, derived from Foam::string.
Definition word.H:66
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)
List< label > labelList
A List of labels.
Definition List.H:62
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
Definition point.H:37
List< bool > boolList
A List of bools.
Definition List.H:60
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
labelList f(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68