polyPatch.C
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-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2021 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
27\*---------------------------------------------------------------------------*/
28
29#include "polyPatch.H"
31#include "polyBoundaryMesh.H"
32#include "polyMesh.H"
33#include "primitiveMesh.H"
34#include "SubField.H"
35#include "entry.H"
36#include "dictionary.H"
37#include "pointPatchField.H"
38#include "demandDrivenData.H"
39
40// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41
42namespace Foam
43{
45
47 (
48 debug::debugSwitch("disallowGenericPolyPatch", 0)
49 );
50
53
56}
57
58
59// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
60
62{
64}
65
66
68{
70 clearAddressing();
71}
72
73
75{
77}
78
79
80// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81
83(
84 const word& name,
85 const label size,
86 const label start,
87 const label index,
88 const polyBoundaryMesh& bm,
89 const word& patchType
90)
91:
92 patchIdentifier(name, index),
94 (
95 faceSubList(bm.mesh().faces(), size, start),
96 bm.mesh().points()
97 ),
98 start_(start),
99 boundaryMesh_(bm),
100 faceCellsPtr_(nullptr),
101 mePtr_(nullptr)
102{
103 if (!patchType.empty() && constraintType(patchType))
104 {
105 inGroups().appendUniq(patchType);
106 }
107}
108
109
111(
112 const word& name,
113 const label size,
114 const label start,
115 const label index,
116 const polyBoundaryMesh& bm,
117 const word& physicalType,
118 const wordList& inGroups
119)
120:
121 patchIdentifier(name, index, physicalType, inGroups),
123 (
124 faceSubList(bm.mesh().faces(), size, start),
125 bm.mesh().points()
126 ),
127 start_(start),
128 boundaryMesh_(bm),
129 faceCellsPtr_(nullptr),
130 mePtr_(nullptr)
131{}
132
133
135(
136 const word& name,
137 const dictionary& dict,
138 const label index,
139 const polyBoundaryMesh& bm,
140 const word& patchType
141)
142:
143 patchIdentifier(name, dict, index),
145 (
147 (
148 bm.mesh().faces(),
149 dict.get<label>("nFaces"),
150 dict.get<label>("startFace")
151 ),
152 bm.mesh().points()
153 ),
154 start_(dict.get<label>("startFace")),
155 boundaryMesh_(bm),
156 faceCellsPtr_(nullptr),
157 mePtr_(nullptr)
158{
159 if (!patchType.empty() && constraintType(patchType))
160 {
161 inGroups().appendUniq(patchType);
162 }
163}
164
165
167(
168 const polyPatch& pp,
169 const polyBoundaryMesh& bm
170)
171:
172 patchIdentifier(pp),
174 (
176 (
177 bm.mesh().faces(),
178 pp.size(),
179 pp.start()
180 ),
181 bm.mesh().points()
182 ),
183 start_(pp.start()),
184 boundaryMesh_(bm),
185 faceCellsPtr_(nullptr),
186 mePtr_(nullptr)
187{}
188
189
191(
192 const polyPatch& pp,
193 const polyBoundaryMesh& bm,
194 const label index,
195 const label newSize,
196 const label newStart
197)
198:
199 patchIdentifier(pp, index),
201 (
203 (
204 bm.mesh().faces(),
205 newSize,
206 newStart
207 ),
208 bm.mesh().points()
209 ),
210 start_(newStart),
211 boundaryMesh_(bm),
212 faceCellsPtr_(nullptr),
213 mePtr_(nullptr)
214{}
215
216
218(
219 const polyPatch& pp,
220 const polyBoundaryMesh& bm,
221 const label index,
222 const labelUList& mapAddressing,
223 const label newStart
224)
225:
226 patchIdentifier(pp, index),
228 (
230 (
231 bm.mesh().faces(),
232 mapAddressing.size(),
233 newStart
234 ),
235 bm.mesh().points()
236 ),
237 start_(newStart),
238 boundaryMesh_(bm),
239 faceCellsPtr_(nullptr),
240 mePtr_(nullptr)
241{}
242
243
245:
248 start_(p.start_),
249 boundaryMesh_(p.boundaryMesh_),
250 faceCellsPtr_(nullptr),
251 mePtr_(nullptr)
252{}
253
254
256(
257 const polyPatch& p,
258 const labelList& faceCells
259)
260:
261 polyPatch(p)
262{
263 faceCellsPtr_ = new labelList::subList(faceCells, faceCells.size());
264}
265
266
267// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
268
270{
271 clearAddressing();
272}
273
274
275// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
276
278{
279 return
280 (
283 );
284}
285
286
288{
289 const auto& cnstrTable = *dictionaryConstructorTablePtr_;
290
291 wordList cTypes(cnstrTable.size());
292
293 label i = 0;
294
295 forAllConstIters(cnstrTable, iter)
296 {
297 if (constraintType(iter.key()))
298 {
299 cTypes[i++] = iter.key();
300 }
301 }
302
303 cTypes.setSize(i);
304
305 return cTypes;
306}
307
308
309Foam::label Foam::polyPatch::offset() const
310{
311 return start_ - boundaryMesh().start();
312}
313
314
316{
317 return boundaryMesh_;
318}
319
320
322{
323 return patchSlice(boundaryMesh().mesh().faceCentres());
324}
325
326
328{
329 return patchSlice(boundaryMesh().mesh().faceAreas());
330}
331
332
334{
335 tmp<vectorField> tcc(new vectorField(size()));
336 vectorField& cc = tcc.ref();
337
338 // get reference to global cell centres
339 const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
340
341 const labelUList& faceCells = this->faceCells();
342
343 forAll(faceCells, facei)
344 {
345 cc[facei] = gcc[faceCells[facei]];
346 }
347
348 return tcc;
349}
350
351
353{
354 tmp<scalarField> tfraction(new scalarField(size()));
355 scalarField& fraction = tfraction.ref();
356
357 const vectorField::subField faceAreas = this->faceAreas();
358 const pointField& points = this->points();
359
360 forAll(*this, facei)
361 {
362 const face& curFace = this->operator[](facei);
363 fraction[facei] =
364 mag(faceAreas[facei])/(curFace.mag(points) + ROOTVSMALL);
365 }
366
367 return tfraction;
368}
369
370
372{
373 if (!faceCellsPtr_)
374 {
375 faceCellsPtr_ = new labelList::subList
376 (
377 patchSlice(boundaryMesh().mesh().faceOwner())
378 );
379 }
380
381 return *faceCellsPtr_;
382}
383
384
386{
387 if (!mePtr_)
388 {
389 mePtr_ =
390 new labelList
391 (
393 (
394 boundaryMesh().mesh().edges(),
395 boundaryMesh().mesh().pointEdges()
396 )
397 );
398 }
399
400 return *mePtr_;
401}
402
403
405{
408 deleteDemandDrivenData(faceCellsPtr_);
410}
411
412
414{
415 os.writeEntry("type", type());
417 os.writeEntry("nFaces", size());
418 os.writeEntry("startFace", start());
419}
420
421
423{}
424
425
427(
429 const primitivePatch&,
431 labelList& rotation
432) const
433{
434 // Nothing changed.
435 return false;
436}
437
438
439// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
440
442{
443 clearAddressing();
444
447 start_ = p.start_;
448}
449
450
451// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
452
454{
455 p.write(os);
457 return os;
458}
459
460
461// ************************************************************************* //
bool found
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
SubList< label > subList
Declare type of subList.
Definition: List.H:111
void setSize(const label n)
Alias for resize()
Definition: List.H:218
label appendUniq(const T &val)
Append an element if not already in the list.
Definition: ListI.H:232
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
A list of faces which address into the list of points.
void operator=(const PrimitivePatch< FaceList, PointField > &rhs)
Copy assign faces. Leave points alone (could be a reference).
Buffers for inter-processor communications streams (UOPstream, UIPstream).
SubField is a Field obtained as a section of another Field, without its own allocation....
Definition: SubField.H:62
A List obtained as a section of another List.
Definition: SubList.H:70
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:63
virtual const word & constraintType() const
Return the constraint type this pointPatch implements.
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
scalar mag(const UList< point > &p) const
Magnitude of face area.
Definition: faceI.H:112
virtual bool write()
Write the output fields.
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:148
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
Identifies a patch by name and index, with optional physical type and group information.
patchIdentifier & operator=(const patchIdentifier &)=default
Copy assignment.
const wordList & inGroups() const noexcept
The (optional) groups that the patch belongs to.
Abstract base class for point-mesh patch fields.
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
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:287
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:327
label offset() const
The offset where this patch starts in the boundary face list.
Definition: polyPatch.C:309
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:74
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:422
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:315
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:321
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:269
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:277
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:441
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:404
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:133
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:333
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:371
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:385
tmp< scalarField > areaFraction() const
Definition: polyPatch.C:352
virtual bool write(const bool valid=true) const
Write using setting from DB.
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
dynamicFvMesh & mesh
Template functions to aid in the implementation of demand driven data.
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
#define FUNCTION_NAME
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
Definition: debug.C:225
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:66
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
void deleteDemandDrivenData(DataPtr &dataPtr)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition: stdFoam.H:278