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 -------------------------------------------------------------------------------
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 Description
27  Calculate the face centres and areas.
28 
29  Calculate the centre by breaking the face into triangles using the face
30  centre and area-weighted averaging their centres. This method copes with
31  small face-concavity.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #include "primitiveMesh.H"
36 #include "primitiveMeshTools.H"
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
41 {
42  if (debug)
43  {
44  Pout<< "primitiveMesh::calcFaceCentresAndAreas() : "
45  << "Calculating face centres and face areas"
46  << endl;
47  }
48 
49  // It is an error to attempt to recalculate faceCentres
50  // if the pointer is already set
51  if (faceCentresPtr_ || faceAreasPtr_)
52  {
54  << "Face centres or face 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 
64  primitiveMeshTools::makeFaceCentresAndAreas(*this, points(), fCtrs, fAreas);
65 
66  if (debug)
67  {
68  Pout<< "primitiveMesh::calcFaceCentresAndAreas() : "
69  << "Finished calculating face centres and face 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 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::primitiveMesh::points
virtual const pointField & points() const =0
Return mesh points.
primitiveMeshTools.H
primitiveMesh.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::Field< vector >
Foam::primitiveMesh::calcFaceCentresAndAreas
void calcFaceCentresAndAreas() const
Calculate face centres and areas.
Definition: primitiveMeshFaceCentresAndAreas.C:40
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
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
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:77
Foam::primitiveMesh::nFaces
label nFaces() const noexcept
Number of mesh faces.
Definition: primitiveMeshI.H:90
Foam::primitiveMesh::updateGeom
virtual void updateGeom()
Update all geometric data.
Definition: primitiveMesh.C:365
Foam::primitiveMesh::faceAreas
const vectorField & faceAreas() const
Definition: primitiveMeshFaceCentresAndAreas.C:89
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78