faceI.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2017-2020 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 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 inline Foam::label Foam::face::right(const label i) const
32 {
33  return i;
34 }
35 
36 
37 inline Foam::label Foam::face::left(const label i) const
38 {
39  return rcIndex(i);
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
45 inline Foam::face::face(const label sz)
46 :
47  labelList(sz, -1)
48 {}
49 
50 
51 inline Foam::face::face(const labelUList& list)
52 :
53  labelList(list)
54 {}
55 
56 
57 template<unsigned N>
59 :
60  labelList(list)
61 {}
62 
63 
64 inline Foam::face::face(std::initializer_list<label> list)
65 :
66  labelList(list)
67 {}
68 
69 
71 :
72  labelList(std::move(list))
73 {}
74 
75 
77 :
78  labelList(is)
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 (
86  const UList<point>& meshPoints
87 ) const
88 {
89  // There are as many points as there are labels for them
90  pointField p(size());
91 
92  // For each point in list, set it to the point in 'pnts' addressed
93  // by 'labs'
94  label i = 0;
95  for (const label pointi : *this)
96  {
97  p[i++] = meshPoints[pointi];
98  }
99 
100  // Return list
101  return p;
102 }
103 
104 
106 {
107  const vector n(areaNormal(p));
108  const scalar s(Foam::mag(n));
109  return s < ROOTVSMALL ? Zero : n/s;
110 }
111 
112 
113 inline Foam::scalar Foam::face::mag(const UList<point>& p) const
114 {
115  return ::Foam::mag(areaNormal(p));
116 }
117 
118 
119 inline Foam::label Foam::face::nEdges() const
120 {
121  // for a closed polygon a number of edges is the same as number of points
122  return size();
123 }
124 
125 
126 inline Foam::edge Foam::face::faceEdge(const label n) const
127 {
128  return edge(operator[](n), operator[](fcIndex(n)));
129 }
130 
131 
132 inline bool Foam::face::found(const label pointLabel) const
133 {
134  return labelList::found(pointLabel);
135 }
136 
137 
138 inline Foam::label Foam::face::which(const label pointLabel) const
139 {
140  return labelList::find(pointLabel);
141 }
142 
143 
144 inline Foam::label Foam::face::nextLabel(const label i) const
145 {
146  return labelList::fcValue(i);
147 }
148 
149 
150 inline Foam::label Foam::face::prevLabel(const label i) const
151 {
152  return labelList::rcValue(i);
153 }
154 
155 
156 inline Foam::label Foam::face::nTriangles() const
157 {
158  return size() - 2;
159 }
160 
161 
162 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
163 
164 inline bool Foam::operator==(const face& a, const face& b)
165 {
166  return face::compare(a,b) != 0;
167 }
168 
169 inline bool Foam::operator!=(const face& a, const face& b)
170 {
171  return face::compare(a,b) == 0;
172 }
173 
174 
175 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::face::points
pointField points(const UList< point > &points) const
Return the points corresponding to this face.
Definition: faceI.H:85
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::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::face::mag
scalar mag(const UList< point > &p) const
Magnitude of face area.
Definition: faceI.H:113
Foam::face::nEdges
label nEdges() const
Return number of edges.
Definition: faceI.H:119
Foam::face::faceEdge
edge faceEdge(const label n) const
Return n-th face edge.
Definition: faceI.H:126
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::face::nTriangles
label nTriangles() const
Number of triangles after splitting.
Definition: faceI.H:156
Foam::face::compare
static int compare(const face &a, const face &b)
Compare faces.
Definition: face.C:300
Foam::operator!=
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:235
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::face::unitNormal
vector unitNormal(const UList< point > &p) const
The unit normal.
Definition: faceI.H:105
Foam::face::face
face()=default
Default construct.
Foam::face::which
label which(const label pointLabel) const
Find local index on face for the point label,.
Definition: faceI.H:138
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Field< vector >
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::ListOps::find
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Find index of the first occurrence that satisfies the predicate.
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::face::prevLabel
label prevLabel(const label i) const
Previous vertex on face.
Definition: faceI.H:150
Foam::face::nextLabel
label nextLabel(const label i) const
Next vertex on face.
Definition: faceI.H:144
Foam::Vector< scalar >
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::UList< label >
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::face::found
bool found(const label pointLabel) const
Return true if the point label is found in face.
Definition: faceI.H:132