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 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 Namespace
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 primitiveMeshTools_H
39 #define 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 primitiveMesh;
52 
53 /*---------------------------------------------------------------------------*\
54  Namespace primitiveMeshTools Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 {
59 public:
60 
61  //- Calculate face centres and areas
62  static void makeFaceCentresAndAreas
63  (
64  const primitiveMesh& mesh,
65  const pointField& p,
66  vectorField& fCtrs,
67  vectorField& fAreas
68  );
69 
70  //- Calculate cell centres and volumes from face properties
71  static void makeCellCentresAndVols
72  (
73  const primitiveMesh& mesh,
74  const vectorField& fCtrs,
75  const vectorField& fAreas,
76  vectorField& cellCtrs,
78  );
79 
80  //- Generate non-orthogonality field (internal faces only)
82  (
83  const primitiveMesh& mesh,
84  const vectorField& fAreas,
85  const vectorField& cellCtrs
86  );
87 
88  //- Generate face pyramid volume fields
89  static void facePyramidVolume
90  (
91  const primitiveMesh& mesh,
92  const pointField& points,
93  const vectorField& cellCtrs,
94  scalarField& ownPyrVol,
95  scalarField& neiPyrVol
96  );
97 
98  //- Generate skewness field
100  (
101  const primitiveMesh& mesh,
102  const pointField& points,
103  const vectorField& fCtrs,
104  const vectorField& fAreas,
105  const vectorField& cellCtrs
106  );
107 
108  //- Generate cell openness and cell ascpect ratio field
109  static void cellClosedness
110  (
111  const primitiveMesh& mesh,
112  const Vector<label>& meshD,
113  const vectorField& areas,
114  const scalarField& vols,
115  scalarField& openness,
116  scalarField& aratio
117  );
118 
119  //- Generate face concavity field. Returns per face the (sin of the)
120  // most concave angle between two consecutive edges
122  (
123  const scalar maxSin,
124  const primitiveMesh& mesh,
125  const pointField& p,
126  const vectorField& faceAreas
127  );
128 
129  //- Generate face flatness field. Compares the individual triangles'
130  // normals against the face average normal. Between 0 (fully warped)
131  // and 1 (fully flat)
133  (
134  const primitiveMesh& mesh,
135  const pointField& p,
136  const vectorField& fCtrs,
137  const vectorField& faceAreas
138  );
139 
140  //- Generate edge alignment field. Is per face the minimum aligned edge
141  // (does not use edge addressing)
143  (
144  const primitiveMesh& mesh,
145  const Vector<label>& directions,
146  const pointField& p
147  );
148 
149  //- Generate cell determinant field. Normalised to 1 for an internal cube.
151  (
152  const primitiveMesh& mesh,
153  const Vector<label>& directions,
154  const vectorField& faceAreas,
155  const bitSet& internalOrCoupledFace
156  );
157 
158 
159  // Helpers: single face check
160 
161  //- Skewness of single face
162  static scalar faceSkewness
163  (
164  const primitiveMesh& mesh,
165  const pointField& p,
166  const vectorField& fCtrs,
167  const vectorField& fAreas,
168 
169  const label facei,
170  const point& ownCc,
171  const point& neiCc
172  );
173 
174  //- Skewness of single boundary face
175  static scalar boundaryFaceSkewness
176  (
177  const primitiveMesh& mesh,
178  const pointField& p,
179  const vectorField& fCtrs,
180  const vectorField& fAreas,
181 
182  const label facei,
183  const point& ownCc
184  );
185 
186  //- Orthogonality of single face
187  static scalar faceOrthogonality
188  (
189  const point& ownCc,
190  const point& neiCc,
191  const vector& s
192  );
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Foam::primitiveMeshTools::cellDeterminant
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.
Definition: primitiveMeshTools.C:628
p
volScalarField & p
Definition: createFieldRefs.H:8
s
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))
Definition: gmvOutputSpray.H:25
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::primitiveMeshTools::faceConcavity
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)
Definition: primitiveMeshTools.C:508
Foam::primitiveMeshTools::faceOrthogonality
static tmp< scalarField > faceOrthogonality(const primitiveMesh &mesh, const vectorField &fAreas, const vectorField &cellCtrs)
Generate non-orthogonality field (internal faces only)
Definition: primitiveMeshTools.C:296
Foam::directions
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Definition: directions.H:67
bitSet.H
primitiveFields.H
Specialisations of Field<T> for scalar, vector and tensor.
Foam::primitiveMeshTools::makeCellCentresAndVols
static void makeCellCentresAndVols(const primitiveMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, vectorField &cellCtrs, scalarField &cellVols)
Calculate cell centres and volumes from face properties.
Definition: primitiveMeshTools.C:107
Foam::Field< vector >
cellVols
const scalarField & cellVols
Definition: temperatureAndPressureVariables.H:51
Foam::primitiveMeshTools::faceFlatness
static tmp< scalarField > faceFlatness(const primitiveMesh &mesh, const pointField &p, const vectorField &fCtrs, const vectorField &faceAreas)
Generate face flatness field. Compares the individual triangles'.
Definition: primitiveMeshTools.C:578
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
pointField.H
Foam::primitiveMeshTools::faceSkewness
static tmp< scalarField > faceSkewness(const primitiveMesh &mesh, const pointField &points, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate skewness field.
Definition: primitiveMeshTools.C:324
Foam::primitiveMeshTools::makeFaceCentresAndAreas
static void makeFaceCentresAndAreas(const primitiveMesh &mesh, const pointField &p, vectorField &fCtrs, vectorField &fAreas)
Calculate face centres and areas.
Definition: primitiveMeshTools.C:38
Foam::Vector< label >
Foam::primitiveMeshTools::cellClosedness
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 ascpect ratio field.
Definition: primitiveMeshTools.C:414
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::primitiveMeshTools::boundaryFaceSkewness
static scalar boundaryFaceSkewness(const primitiveMesh &mesh, const pointField &p, const vectorField &fCtrs, const vectorField &fAreas, const label facei, const point &ownCc)
Skewness of single boundary face.
Definition: primitiveMeshTools.C:243
Foam::primitiveMeshTools
Definition: primitiveMeshTools.H:57
Foam::primitiveMeshTools::facePyramidVolume
static void facePyramidVolume(const primitiveMesh &mesh, const pointField &points, const vectorField &cellCtrs, scalarField &ownPyrVol, scalarField &neiPyrVol)
Generate face pyramid volume fields.
Definition: primitiveMeshTools.C:375
Foam::primitiveMeshTools::edgeAlignment
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.
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78