primitiveMeshFaceCentresAndAreas.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) 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
27Description
28 Calculate the face centres and areas.
29
30 Calculate the centre by breaking the face into triangles using the face
31 centre and area-weighted averaging their centres. This method copes with
32 small face-concavity.
33
34\*---------------------------------------------------------------------------*/
35
36#include "primitiveMesh.H"
37#include "primitiveMeshTools.H"
38
39// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40
42{
43 if (debug)
44 {
45 Pout<< "primitiveMesh::calcFaceCentresAndAreas() : "
46 << "Calculating face centres and areas"
47 << endl;
48 }
49
50 // These are always calculated in tandem, but only once.
51 if (faceCentresPtr_ || faceAreasPtr_)
52 {
54 << "Face centres and areas already calculated"
55 << abort(FatalError);
56 }
57
58 faceCentresPtr_ = new vectorField(nFaces());
59 vectorField& fCtrs = *faceCentresPtr_;
60
61 faceAreasPtr_ = new vectorField(nFaces());
62 vectorField& fAreas = *faceAreasPtr_;
63
65
66 if (debug)
67 {
68 Pout<< "primitiveMesh::calcFaceCentresAndAreas() : "
69 << "Finished calculating face centres and areas"
70 << endl;
71 }
72}
73
74
75// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76
78{
79 if (!faceCentresPtr_)
80 {
81 //calcFaceCentresAndAreas();
82 const_cast<primitiveMesh&>(*this).updateGeom();
83 }
84
85 return *faceCentresPtr_;
86}
87
88
90{
91 if (!faceAreasPtr_)
92 {
93 //calcFaceCentresAndAreas();
94 const_cast<primitiveMesh&>(*this).updateGeom();
95 }
96
97 return *faceAreasPtr_;
98}
99
100
101// ************************************************************************* //
static void makeFaceCentresAndAreas(const UList< face > &faces, const pointField &p, vectorField &fCtrs, vectorField &fAreas)
Calculate face centres and areas for specified faces.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79
const vectorField & faceCentres() const
label nFaces() const noexcept
Number of mesh faces.
const vectorField & faceAreas() const
void calcFaceCentresAndAreas() const
Calculate face centres and areas.
virtual const pointField & points() const =0
Return mesh points.
virtual void updateGeom()
Update all geometric data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Field< vector > vectorField
Specialisation of Field<T> for vector.
error FatalError
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.