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