primitiveMeshTools.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) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2022 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::primitiveMeshTools
29 
30 Description
31  Collection of static functions operating on primitiveMesh (mainly checks).
32 
33 SourceFiles
34  primitiveMeshTools.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_primitiveMeshTools_H
39 #define Foam_primitiveMeshTools_H
40 
41 #include "bitSet.H"
42 #include "primitiveFields.H"
43 #include "pointField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class cell;
52 class face;
53 class primitiveMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class primitiveMeshTools Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61 public:
62 
63  //- Update face centres and areas for the faces in the set faceIDs
64  static void updateFaceCentresAndAreas
65  (
66  const primitiveMesh& mesh,
67  const UList<label>& faceIDs,
68  const pointField& p,
69  vectorField& fCtrs,
70  vectorField& fAreas
71  );
72 
73  //- Update cell centres and volumes for the cells in the set cellIDs
74  static void updateCellCentresAndVols
75  (
76  const primitiveMesh& mesh,
77  const vectorField& fCtrs,
78  const vectorField& fAreas,
79  const List<label>& cellIDs,
80  const List<cell>& cells,
81  vectorField& cellCtrs_s,
82  scalarField& cellVols_s
83  );
84 
85  //- Calculate face centres and areas for specified faces.
86  // Adjusts the lengths of centres and area normals if required.
87  static void makeFaceCentresAndAreas
88  (
89  const UList<face>& faces,
90  const pointField& p,
91  vectorField& fCtrs,
92  vectorField& fAreas
93  );
94 
95  //- Calculate face centres and areas for all mesh faces.
96  // Adjusts the lengths of centres and area normals if required.
97  static void makeFaceCentresAndAreas
98  (
99  const primitiveMesh& mesh,
100  const pointField& p,
101  vectorField& fCtrs,
102  vectorField& fAreas
103  );
104 
105  //- Calculate cell centres and volumes from face properties
106  static void makeCellCentresAndVols
107  (
108  const primitiveMesh& mesh,
109  const vectorField& fCtrs,
110  const vectorField& fAreas,
111  vectorField& cellCtrs,
113  );
114 
115  //- Generate non-orthogonality field (internal faces only)
117  (
118  const primitiveMesh& mesh,
119  const vectorField& fAreas,
120  const vectorField& cellCtrs
121  );
122 
123  //- Generate face pyramid volume fields
124  static void facePyramidVolume
125  (
126  const primitiveMesh& mesh,
127  const pointField& points,
128  const vectorField& cellCtrs,
129  scalarField& ownPyrVol,
130  scalarField& neiPyrVol
131  );
132 
133  //- Generate skewness field
135  (
136  const primitiveMesh& mesh,
137  const pointField& points,
138  const vectorField& fCtrs,
139  const vectorField& fAreas,
140  const vectorField& cellCtrs
141  );
142 
143  //- Generate cell openness and cell aspect ratio field
144  static void cellClosedness
145  (
146  const primitiveMesh& mesh,
147  const Vector<label>& meshD,
148  const vectorField& areas,
149  const scalarField& vols,
150  scalarField& openness,
151  scalarField& aratio
152  );
153 
154  //- Generate face concavity field. Returns per face the (sin of the)
155  //- most concave angle between two consecutive edges
157  (
158  const scalar maxSin,
159  const primitiveMesh& mesh,
160  const pointField& p,
161  const vectorField& faceAreas
162  );
163 
164  //- Generate face flatness field. Compares the individual triangles'
165  //- normals against the face average normal. Between 0 (fully warped)
166  //- and 1 (fully flat)
168  (
169  const primitiveMesh& mesh,
170  const pointField& p,
171  const vectorField& fCtrs,
172  const vectorField& faceAreas
173  );
174 
175  //- Generate edge alignment field. Is per face the minimum aligned edge
176  //- (does not use edge addressing)
178  (
179  const primitiveMesh& mesh,
180  const Vector<label>& directions,
181  const pointField& p
182  );
183 
184  //- Generate cell determinant field. Normalised to 1 for an internal cube.
186  (
187  const primitiveMesh& mesh,
188  const Vector<label>& directions,
189  const vectorField& faceAreas,
190  const bitSet& internalOrCoupledFace
191  );
192 
193 
194  // Helpers: single face check
195 
196  //- Skewness of single face
197  static scalar faceSkewness
198  (
199  const UList<face>& faces,
200  const pointField& p,
201  const vectorField& fCtrs,
202  const vectorField& fAreas,
203 
204  const label facei,
205  const point& ownCc,
206  const point& neiCc
207  );
208 
209  //- Skewness of single boundary face
210  static scalar boundaryFaceSkewness
211  (
212  const UList<face>& faces,
213  const pointField& p,
214  const vectorField& fCtrs,
215  const vectorField& fAreas,
216 
217  const label facei,
218  const point& ownCc
219  );
220 
221  //- Skewness of single face
222  static scalar faceSkewness
223  (
224  const primitiveMesh& mesh,
225  const pointField& p,
226  const vectorField& fCtrs,
227  const vectorField& fAreas,
228 
229  const label facei,
230  const point& ownCc,
231  const point& neiCc
232  );
233 
234  //- Skewness of single boundary face
235  static scalar boundaryFaceSkewness
236  (
237  const primitiveMesh& mesh,
238  const pointField& p,
239  const vectorField& fCtrs,
240  const vectorField& fAreas,
241 
242  const label facei,
243  const point& ownCc
244  );
245 
246  //- Orthogonality of single face
247  static scalar faceOrthogonality
248  (
249  const point& ownCc,
250  const point& neiCc,
251  const vector& s
252  );
253 };
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
static void updateCellCentresAndVols(const primitiveMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, const List< label > &cellIDs, const List< cell > &cells, vectorField &cellCtrs_s, scalarField &cellVols_s)
Update cell centres and volumes for the cells in the set cellIDs.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Definition: directions.H:63
static tmp< scalarField > faceConcavity(const scalar maxSin, const primitiveMesh &mesh, const pointField &p, const vectorField &faceAreas)
Generate face concavity field. Returns per face the (sin of the) most concave angle between two conse...
static tmp< scalarField > faceSkewness(const primitiveMesh &mesh, const pointField &points, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate skewness field.
dynamicFvMesh & mesh
const cellShapeList & cells
const pointField & points
Collection of static functions operating on primitiveMesh (mainly checks).
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static void facePyramidVolume(const primitiveMesh &mesh, const pointField &points, const vectorField &cellCtrs, scalarField &ownPyrVol, scalarField &neiPyrVol)
Generate face pyramid volume fields.
static tmp< scalarField > cellDeterminant(const primitiveMesh &mesh, const Vector< label > &directions, const vectorField &faceAreas, const bitSet &internalOrCoupledFace)
Generate cell determinant field. Normalised to 1 for an internal cube.
const scalarField & cellVols
static tmp< scalarField > edgeAlignment(const primitiveMesh &mesh, const Vector< label > &directions, const pointField &p)
Generate edge alignment field. Is per face the minimum aligned edge (does not use edge addressing) ...
Specialisations of Field<T> for scalar, vector and tensor.
static scalar boundaryFaceSkewness(const UList< face > &faces, const pointField &p, const vectorField &fCtrs, const vectorField &fAreas, const label facei, const point &ownCc)
Skewness of single boundary face.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
static void makeFaceCentresAndAreas(const UList< face > &faces, const pointField &p, vectorField &fCtrs, vectorField &fAreas)
Calculate face centres and areas for specified faces.
static void makeCellCentresAndVols(const primitiveMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, vectorField &cellCtrs, scalarField &cellVols)
Calculate cell centres and volumes from face properties.
static tmp< scalarField > faceOrthogonality(const primitiveMesh &mesh, const vectorField &fAreas, const vectorField &cellCtrs)
Generate non-orthogonality field (internal faces only)
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static void cellClosedness(const primitiveMesh &mesh, const Vector< label > &meshD, const vectorField &areas, const scalarField &vols, scalarField &openness, scalarField &aratio)
Generate cell openness and cell aspect ratio field.
static tmp< scalarField > faceFlatness(const primitiveMesh &mesh, const pointField &p, const vectorField &fCtrs, const vectorField &faceAreas)
Generate face flatness field. Compares the individual triangles&#39; normals against the face average nor...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
labelList cellIDs
static void updateFaceCentresAndAreas(const primitiveMesh &mesh, const UList< label > &faceIDs, const pointField &p, vectorField &fCtrs, vectorField &fAreas)
Update face centres and areas for the faces in the set faceIDs.
Namespace for OpenFOAM.