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 
58 :
59  labelList(std::move(list))
60 {}
61 
62 
63 inline Foam::face::face(std::initializer_list<label> list)
64 :
65  labelList(list)
66 {}
67 
68 
69 template<unsigned N>
71 :
72  labelList(list)
73 {}
74 
75 
76 inline Foam::face::face(const labelUList& list, const labelUList& indices)
77 :
78  labelList(list, indices)
79 {}
80 
81 
82 template<unsigned N>
83 inline Foam::face::face
84 (
85  const labelUList& list,
86  const FixedList<label, N>& indices
87 )
88 :
89  labelList(list, indices)
90 {}
91 
92 
94 :
95  labelList(is)
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 (
103  const UList<point>& meshPoints
104 ) const
105 {
106  // There are as many points as there are labels for them
107  pointField p(size());
108 
109  // For each point in list, set it to the point in 'pnts' addressed
110  // by 'labs'
111  label i = 0;
112  for (const label pointi : *this)
113  {
114  p[i++] = meshPoints[pointi];
115  }
116 
117  // Return list
118  return p;
119 }
120 
121 
123 {
124  const vector n(areaNormal(p));
125  const scalar s(Foam::mag(n));
126  return s < ROOTVSMALL ? Zero : n/s;
127 }
128 
129 
130 inline Foam::scalar Foam::face::mag(const UList<point>& p) const
131 {
132  return ::Foam::mag(areaNormal(p));
133 }
134 
135 
136 inline Foam::label Foam::face::nEdges() const
137 {
138  // for a closed polygon a number of edges is the same as number of points
139  return size();
140 }
141 
142 
143 inline Foam::edge Foam::face::faceEdge(const label n) const
144 {
145  return edge(operator[](n), operator[](fcIndex(n)));
146 }
147 
148 
149 inline bool Foam::face::found(const label pointLabel) const
150 {
151  return labelList::found(pointLabel);
152 }
153 
154 
155 inline Foam::label Foam::face::which(const label pointLabel) const
156 {
157  return labelList::find(pointLabel);
158 }
159 
160 
161 inline Foam::label Foam::face::nextLabel(const label i) const
162 {
163  return labelList::fcValue(i);
164 }
165 
166 
167 inline Foam::label Foam::face::prevLabel(const label i) const
168 {
169  return labelList::rcValue(i);
170 }
171 
172 
173 inline Foam::label Foam::face::nTriangles() const
174 {
175  return size() - 2;
176 }
177 
178 
179 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
180 
181 inline bool Foam::operator==(const face& a, const face& b)
182 {
183  return face::compare(a,b) != 0;
184 }
185 
186 inline bool Foam::operator!=(const face& a, const face& b)
187 {
188  return face::compare(a,b) == 0;
189 }
190 
191 
192 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
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:102
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:130
Foam::face::nEdges
label nEdges() const
Return number of edges.
Definition: faceI.H:136
Foam::face::faceEdge
edge faceEdge(const label n) const
Return n-th face edge.
Definition: faceI.H:143
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:173
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:122
Foam::face::which
label which(const label pointLabel) const
Find local index on face for the point label,.
Definition: faceI.H:155
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:167
Foam::face::nextLabel
label nextLabel(const label i) const
Next vertex on face.
Definition: faceI.H:161
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::face
constexpr face() noexcept=default
Default construct.
Foam::face::found
bool found(const label pointLabel) const
Return true if the point label is found in face.
Definition: faceI.H:149