faPatch.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2020 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::faPatch
29 
30 Description
31  Finite area patch class. Used for 2-D non-Euclidian finite area method.
32 
33 Author
34  Zeljko Tukovic, FMENA
35  Hrvoje Jasak, Wikki Ltd.
36 
37 SourceFiles
38  faPatch.C
39  faPatchNew.C
40  faPatchTemplates.C
41  faPatchFaMeshTemplates.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef faPatch_H
46 #define faPatch_H
47 
48 #include "patchIdentifier.H"
49 #include "labelList.H"
50 #include "pointField.H"
51 #include "typeInfo.H"
52 #include "faPatchFieldsFwd.H"
53 #include "autoPtr.H"
54 #include "runTimeSelectionTables.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 class faBoundaryMesh;
62 class faPatch;
63 Ostream& operator<<(Ostream&, const faPatch&);
64 
65 /*---------------------------------------------------------------------------*\
66  Class faPatch Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class faPatch
70 :
71  public labelList,
72  public patchIdentifier
73 {
74  // Private Data
75 
76  //- Neighbour polyPatch index
77  const label ngbPolyPatchIndex_;
78 
79  //- Reference to boundary mesh
80  const faBoundaryMesh& boundaryMesh_;
81 
82 
83  // Demand-driven private data
84 
85  //- Edge-face addressing
86  mutable labelList::subList* edgeFacesPtr_;
87 
88  //- Local points labels
89  mutable labelList* pointLabelsPtr_;
90 
91  //- Point-edge addressing
92  mutable labelListList* pointEdgesPtr_;
93 
94 
95  // Private Member Functions
96 
97  //- No copy construct
98  faPatch(const faPatch&) = delete;
99 
100  //- No copy assignment
101  void operator=(const faPatch&) = delete;
102 
103 
104  //- Clear out topological patch data
105  void clearOut();
106 
107 
108 protected:
109 
110  // Protected Member Functions
111 
112  //- The faPatch geometry initialisation is called by faBoundaryMesh
113  friend class faBoundaryMesh;
114 
115  //- Calculate patch point labels
116  void calcPointLabels() const;
117 
118  //- Calculate patch point-edge addressing
119  void calcPointEdges() const;
120 
121  //- Initialise the calculation of the patch geometry
122  virtual void initGeometry()
123  {}
124 
125  //- Calculate the patch geometry
126  virtual void calcGeometry()
127  {}
128 
129  //- Initialise the patches for moving points
130  virtual void initMovePoints(const pointField&)
131  {}
132 
133  //- Correct patch after moving points
134  virtual void movePoints(const pointField&);
135 
136  //- Initialise the update of the patch topology
137  virtual void initUpdateMesh()
138  {}
139 
140  //- Update of the patch topology
141  virtual void updateMesh()
142  {}
143 
144 
145 public:
146 
148 
149  //- Runtime type information
150  TypeName("patch");
151 
152  // Declare run-time constructor selection tables
153 
155  (
156  autoPtr,
157  faPatch,
158  dictionary,
159  (
160  const word& name,
161  const dictionary& dict,
162  const label index,
163  const faBoundaryMesh& bm
164  ),
165  (name, dict, index, bm)
166  );
167 
168 
169  // Constructors
170 
171  //- Construct from components
172  faPatch
173  (
174  const word& name,
175  const labelList& edgeLabels,
176  const label index,
177  const faBoundaryMesh& bm,
178  const label ngbPolyPatchIndex
179  );
180 
181  //- Construct from dictionary
182  faPatch
183  (
184  const word& name,
185  const dictionary& dict,
186  const label index,
187  const faBoundaryMesh& bm
188  );
189 
190  //- Construct as copy, resetting the boundary mesh
191  faPatch(const faPatch&, const faBoundaryMesh&);
192 
193  //- Construct and return a clone, resetting the edge list
194  //- and boundary mesh
196  (
197  const faBoundaryMesh& bm,
198  const labelList& edgeLabels,
199  const label index,
200  const label ngbPolyPatchIndex
201  ) const
202  {
203  return
205  (name(), edgeLabels, index, bm, ngbPolyPatchIndex);
206  }
207 
208 
209  // Selectors
210 
211  //- Return a pointer to a new patch created
212  //- on freestore from dictionary
213  static autoPtr<faPatch> New
214  (
215  const word& name,
216  const dictionary& dict,
217  const label index,
218  const faBoundaryMesh& bm
219  );
220 
221 
222  //- Destructor
223  virtual ~faPatch();
224 
225 
226  // Member Functions
227 
228  //- Return number of patch points
229  label nPoints() const
230  {
231  return pointLabels().size();
232  }
233 
234  //- Return neighbour polyPatch index
235  label ngbPolyPatchIndex() const;
236 
237  //- Return boundaryMesh reference
238  const faBoundaryMesh& boundaryMesh() const;
239 
240  //- Return true if this patch is coupled
241  virtual bool coupled() const
242  {
243  return false;
244  }
245 
246  //- Patch start in edge list
247  label start() const;
248 
249  //- Patch size
250  virtual label size() const
251  {
252  return labelList::size();
253  }
254 
255  //- Return label of edge in patch from global edge label
256  inline label whichEdge(const label l) const
257  {
258  return l - start();
259  }
260 
261  //- Slice list to patch
262  template<class T>
263  typename List<T>::subList patchSlice(const List<T>& l) const
264  {
265  return typename List<T>::subList(l, size(), start());
266  }
267 
268 
269  //- Write
270  virtual void write(Ostream&) const;
271 
272 
273  // Access functions for geometrical data
274 
275  //- Return patch point labels
276  const labelList& pointLabels() const;
277 
278  //- Return patch point-edge addressing
279  const labelListList& pointEdges() const;
280 
281  //- Return edge neighbour polyPatch faces
283 
284  //- Return normals of neighbour polyPatch faces
286 
287  //- Return normals of neighbour polyPatch joined points
289 
290  //- Return edge-face addressing
291  const labelUList& edgeFaces() const;
292 
293  //- Return edge centres
294  const vectorField& edgeCentres() const;
295 
296  //- Return edge length vectors
297  const vectorField& edgeLengths() const;
298 
299  //- Return edge length magnitudes
300  const scalarField& magEdgeLengths() const;
301 
302  //- Return edge normals
304 
305  //- Return neighbour face centres
307 
308  //- Return cell-centre to face-centre vector
309  // except for coupled patches for which the cell-centre
310  // to coupled-cell-centre vector is returned
311  virtual tmp<vectorField> delta() const;
312 
313 
314  // Access functions for demand driven data
315 
316  //- Make patch weighting factors
317  virtual void makeWeights(scalarField&) const;
318 
319  //- Return patch weighting factors
320  const scalarField& weights() const;
321 
322  //- Make patch edge - neighbour face distances
323  virtual void makeDeltaCoeffs(scalarField&) const;
324 
325  void makeCorrectionVectors(vectorField&) const;
326 
327  //- Return patch edge - neighbour face distances
328  const scalarField& deltaCoeffs() const;
329 
330 
331  // Topological changes
332 
333  //- Reset edge list
334  void resetEdges(const labelList&);
335 
336 
337  // Evaluation
338 
339  //- Return given internal field next to patch as patch field
340  template<class Type>
342 
343  //- Return the corresponding patchField of the named field
344  template<class GeometricField, class Type>
345  const typename GeometricField::Patch& patchField
346  (
347  const GeometricField&
348  ) const;
349 
350  //- Lookup and return the patchField of the named field from the
351  //- local objectRegistry.
352  // N.B. The dummy pointer arguments are used if this function is
353  // instantiated within a templated function to avoid a bug in gcc.
354  // See inletOutletFvPatchField.C and outletInletFvPatchField.C
355  template<class GeometricField, class Type>
357  (
358  const word& name,
359  const GeometricField* = nullptr,
360  const Type* = nullptr
361  ) const;
362 
363 
364  // Ostream Operator
365 
366  friend Ostream& operator<<(Ostream&, const faPatch&);
367 };
368 
369 
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 
372 } // End namespace Foam
373 
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 
376 #ifdef NoRepository
377  #include "faPatchTemplates.C"
378 #endif
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 #endif
383 
384 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::faPatch::ngbPolyPatchIndex
label ngbPolyPatchIndex() const
Return neighbour polyPatch index.
Definition: faPatch.C:120
Foam::faPatch::edgeFaceCentres
tmp< vectorField > edgeFaceCentres() const
Return neighbour face centres.
Definition: faPatch.C:408
Foam::faPatch::pointEdges
const labelListList & pointEdges() const
Return patch point-edge addressing.
Definition: faPatch.C:231
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
typeInfo.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faPatch::movePoints
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: faPatch.C:468
Foam::faPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Return patch edge - neighbour face distances.
Definition: faPatch.C:450
Foam::faPatch::makeWeights
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: faPatch.C:456
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::faPatch::calcGeometry
virtual void calcGeometry()
Calculate the patch geometry.
Definition: faPatch.H:125
Foam::faPatch::calcPointLabels
void calcPointLabels() const
Calculate patch point labels.
Definition: faPatch.C:149
Foam::faPatch::New
static autoPtr< faPatch > New(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm)
Definition: faPatchNew.C:35
Foam::faPatch::nPoints
label nPoints() const
Return number of patch points.
Definition: faPatch.H:228
Foam::faPatch::patchInternalField
tmp< Field< Type > > patchInternalField(const UList< Type > &) const
Return given internal field next to patch as patch field.
Foam::faPatch::delta
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: faPatch.C:428
faPatchFieldsFwd.H
Foam::faPatch::weights
const scalarField & weights() const
Return patch weighting factors.
Definition: faPatch.C:462
Foam::faPatch::initUpdateMesh
virtual void initUpdateMesh()
Initialise the update of the patch topology.
Definition: faPatch.H:136
Foam::faPatch::ngbPolyPatchFaceNormals
tmp< vectorField > ngbPolyPatchFaceNormals() const
Return normals of neighbour polyPatch faces.
Definition: faPatch.C:310
Foam::faPatch::edgeFaces
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:366
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::faBoundaryMesh
Finite area boundary mesh.
Definition: faBoundaryMesh.H:66
Foam::faPatch::initMovePoints
virtual void initMovePoints(const pointField &)
Initialise the patches for moving points.
Definition: faPatch.H:129
Foam::faPatch::boundaryMesh
const faBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: faPatch.C:126
Foam::patchIdentifier
Identifies a patch by name, patch index and physical type.
Definition: patchIdentifier.H:54
labelList.H
Foam::Field< vector >
Foam::faPatch::makeDeltaCoeffs
virtual void makeDeltaCoeffs(scalarField &) const
Make patch edge - neighbour face distances.
Definition: faPatch.C:434
Foam::faPatch::TypeName
TypeName("patch")
Runtime type information.
Foam::faPatch::edgeCentres
const vectorField & edgeCentres() const
Return edge centres.
Definition: faPatch.C:380
Foam::faPatch::ngbPolyPatchFaces
labelList ngbPolyPatchFaces() const
Return edge neighbour polyPatch faces.
Definition: faPatch.C:242
Foam::faPatch::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, faPatch, dictionary,(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm),(name, dict, index, bm))
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:114
Foam::faPatch::patchField
const GeometricField::Patch & patchField(const GeometricField &) const
Return the corresponding patchField of the named field.
Definition: faPatchTemplates.C:54
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::faPatch::patchSlice
List< T >::subList patchSlice(const List< T > &l) const
Slice list to patch.
Definition: faPatch.H:262
Foam::faPatch::makeCorrectionVectors
void makeCorrectionVectors(vectorField &) const
Definition: faPatch.C:440
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faPatch::start
label start() const
Patch start in edge list.
Definition: faPatch.C:132
Foam::faPatch::coupled
virtual bool coupled() const
Return true if this patch is coupled.
Definition: faPatch.H:240
Foam::faPatch::updateMesh
virtual void updateMesh()
Update of the patch topology.
Definition: faPatch.H:140
Foam::faPatch::~faPatch
virtual ~faPatch()
Destructor.
Definition: faPatch.C:112
pointField.H
Foam::faPatch::pointLabels
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:138
patchIdentifier.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::faPatch::magEdgeLengths
const scalarField & magEdgeLengths() const
Return edge length magnitudes.
Definition: faPatch.C:392
Foam::faPatch::operator<<
friend Ostream & operator<<(Ostream &, const faPatch &)
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::faPatch::write
virtual void write(Ostream &) const
Write.
Definition: faPatch.C:481
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList< label >
Foam::faPatch::edgeNormals
tmp< vectorField > edgeNormals() const
Return edge normals.
Definition: faPatch.C:398
Foam::faPatch::initGeometry
virtual void initGeometry()
Initialise the calculation of the patch geometry.
Definition: faPatch.H:121
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::List< label >::clone
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:99
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::GeometricField::Patch
PatchField< Type > Patch
Definition: GeometricField.H:111
Foam::faPatch::ngbPolyPatchPointNormals
tmp< vectorField > ngbPolyPatchPointNormals() const
Return normals of neighbour polyPatch joined points.
Definition: faPatch.C:338
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:68
Foam::faPatch::resetEdges
void resetEdges(const labelList &)
Reset edge list.
Definition: faPatch.C:472
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
faPatchTemplates.C
Foam::faPatch::edgeLengths
const vectorField & edgeLengths() const
Return edge length vectors.
Definition: faPatch.C:386
Foam::faPatch::BoundaryMesh
faBoundaryMesh BoundaryMesh
Definition: faPatch.H:146
Foam::faPatch::calcPointEdges
void calcPointEdges() const
Calculate patch point-edge addressing.
Definition: faPatch.C:188
Foam::faPatch::lookupPatchField
const GeometricField::Patch & lookupPatchField(const word &name, const GeometricField *=nullptr, const Type *=nullptr) const
Definition: faPatchFaMeshTemplates.C:34
Foam::faPatch::whichEdge
label whichEdge(const label l) const
Return label of edge in patch from global edge label.
Definition: faPatch.H:255
autoPtr.H
Foam::faPatch::size
virtual label size() const
Patch size.
Definition: faPatch.H:249