partTetI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "triangle.H"
29 #include "tetrahedron.H"
30 #include "IOstreams.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 {
41 }
42 
43 inline partTet::partTet
44 (
45  const label a,
46  const label b,
47  const label c,
48  const label d
49 )
50 {
51  data_[0] = a;
52  data_[1] = b;
53  data_[2] = c;
54  data_[3] = d;
55 }
56 
58 {
59 }
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
63 inline label partTet::a() const
64 {
65  return data_[0];
66 }
67 
68 inline label partTet::b() const
69 {
70  return data_[1];
71 }
72 
73 inline label partTet::c() const
74 {
75  return data_[2];
76 }
77 
78 inline label partTet::d() const
79 {
80  return data_[3];
81 }
82 
83 inline label partTet::size() const
84 {
85  return 4;
86 }
87 
88 inline label partTet::whichPosition(const label pointI) const
89 {
90  for(label i=0;i<4;++i)
91  if( data_[i] == pointI )
92  return i;
93 
94  return -1;
95 }
96 
97 template<class PointField>
98 inline vector partTet::Sa(const PointField& points) const
99 {
101  (
102  points[data_[1]],
103  points[data_[2]],
104  points[data_[3]]
105  );
106 
107  return tria.normal();
108  //return triangle<point, point>(b_, c_, d_).normal();
109 }
110 
111 template<class PointField>
112 inline vector partTet::Sb(const PointField& points) const
113 {
115  (
116  points[data_[0]],
117  points[data_[3]],
118  points[data_[2]]
119  );
120 
121  return tria.normal();
122  //return triangle<point, point>(a_, d_, c_).normal();
123 }
124 
125 template<class PointField>
126 inline vector partTet::Sc(const PointField& points) const
127 {
129  (
130  points[data_[0]],
131  points[data_[1]],
132  points[data_[3]]
133  );
134 
135  return tria.normal();
136  //return triangle<point, point>(a_, b_, d_).normal();
137 }
138 
139 template<class PointField>
140 inline vector partTet::Sd(const PointField& points) const
141 {
143  (
144  points[data_[0]],
145  points[data_[2]],
146  points[data_[1]]
147  );
148 
149  return tria.normal();
150  //return triangle<point, point>(a_, c_, b_).normal();
151 }
152 
153 template<class PointField>
154 inline scalar partTet::mag(const PointField& points) const
155 {
157  (
158  points[data_[0]],
159  points[data_[1]],
160  points[data_[2]],
161  points[data_[3]]
162  );
163 
164  return tet.mag();
165  //return (1.0/6.0)*(((b_ - a_) ^ (c_ - a_)) & (d_ - a_));
166 }
167 
168 template<class PointField>
169 inline point partTet::crcmCentre(const PointField& points) const
170 {
172  (
173  points[data_[0]],
174  points[data_[1]],
175  points[data_[2]],
176  points[data_[3]]
177  );
178 
179  return tet.circumCentre();
180 }
181 
182 template<class PointField>
183 inline scalar partTet::crcmRadius(const PointField& points) const
184 {
186  (
187  points[data_[0]],
188  points[data_[1]],
189  points[data_[2]],
190  points[data_[3]]
191  );
192 
193  return tet.circumRadius();
194 }
195 
196 template<class PointField>
197 inline point partTet::centroid(const PointField& points) const
198 {
199  point p = points[data_[0]];
200  for(label i=1;i<4;++i)
201  p += points[data_[i]];
202 
203  p /= 4;
204  return p;
205 }
206 
208 {
210  edges[0] = edge(data_[0], data_[1]);
211  edges[1] = edge(data_[0], data_[2]);
212  edges[2] = edge(data_[0], data_[3]);
213  edges[3] = edge(data_[3], data_[1]);
214  edges[4] = edge(data_[1], data_[2]);
215  edges[5] = edge(data_[3], data_[2]);
216 
217  return edges;
218 }
219 
220 inline edge partTet::getEdge(const label eI) const
221 {
222  switch( eI )
223  {
224  case 0:
225  {
226  return edge(data_[0], data_[1]);
227  } break;
228  case 1:
229  {
230  return edge(data_[0], data_[2]);
231  } break;
232  case 2:
233  {
234  return edge(data_[0], data_[3]);
235  } break;
236  case 3:
237  {
238  return edge(data_[3], data_[1]);
239  } break;
240  case 4:
241  {
242  return edge(data_[1], data_[2]);
243  } break;
244  case 5:
245  {
246  return edge(data_[3], data_[2]);
247  } break;
248  }
249 
250  FatalErrorIn("inline edge partTet::getEdge(const label) const")
251  << "Invalid edge index given " << eI << abort(FatalError);
252 
253  return edge();
254 }
255 
256 inline label partTet::operator[](const label i) const
257 {
258  return data_[i];
259 }
260 
261 inline void partTet::operator=(const partTet& tet)
262 {
263  for(label i=0;i<4;++i)
264  data_[i] = tet.data_[i];
265 }
266 
267 inline bool partTet::operator==(const partTet& tet) const
268 {
269  if( this->a() != tet.a() )
270  return false;
271  if( this->b() != tet.b() )
272  return false;
273  if( this->c() != tet.c() )
274  return false;
275  if( this->d() != tet.d() )
276  return false;
277 
278  return true;
279 }
280 
281 inline bool partTet::operator!=(const partTet& tet) const
282 {
283  return !this->operator==(tet);
284 }
285 
286 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
287 
288 inline Ostream& operator<<(Ostream& os, const partTet& t)
289 {
290  os << nl
292  << t.a() << token::SPACE << t.b()
293  << token::SPACE << t.c() << token::SPACE << t.d()
294  << token::END_LIST;
295 
296  return os;
297 }
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace Foam
302 
303 // ************************************************************************* //
Foam::partTet::Sc
vector Sc(const PointField &) const
Definition: partTetI.H:126
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::partTet::crcmRadius
scalar crcmRadius(const PointField &) const
Definition: partTetI.H:183
p
p
Definition: pEqn.H:62
Foam::partTet::Sb
vector Sb(const PointField &) const
Definition: partTetI.H:112
Foam::partTet::data_
label data_[4]
Definition: partTet.H:58
Foam::partTet::d
label d() const
Definition: partTetI.H:78
triangle.H
Foam::partTet::b
label b() const
Definition: partTetI.H:68
Foam::partTet::operator!=
bool operator!=(const partTet &) const
Definition: partTetI.H:281
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::tetrahedron::circumCentre
Point circumCentre() const
Return circum-centre.
Definition: tetrahedronI.H:178
Foam::partTet
Definition: partTet.H:53
Foam::partTet::crcmCentre
point crcmCentre(const PointField &) const
Return circum-centre.
Definition: partTetI.H:169
Foam::partTet::operator[]
label operator[](const label) const
Definition: partTetI.H:256
Foam::partTet::Sd
vector Sd(const PointField &) const
Definition: partTetI.H:140
Foam::partTet::centroid
point centroid(const PointField &) const
Return centroid of the tetrahedron.
Definition: partTetI.H:197
Foam::triangle
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:59
Foam::partTet::operator=
void operator=(const partTet &)
Definition: partTetI.H:261
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
Foam::triangle::normal
vector normal() const
Return vector normal.
Definition: triangleI.H:116
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::tetrahedron::circumRadius
scalar circumRadius() const
Return circum-radius.
Definition: tetrahedronI.H:205
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::partTet::size
label size() const
Definition: partTetI.H:83
Foam::partTet::c
label c() const
Definition: partTetI.H:73
Foam::FatalError
error FatalError
Foam::partTet::getEdge
edge getEdge(const label) const
Return edge.
Definition: partTetI.H:220
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::partTet::edges
FixedList< edge, 6 > edges() const
Return edges.
Definition: partTetI.H:207
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::partTet::Sa
vector Sa(const PointField &) const
Return face normal.
Definition: partTetI.H:98
Foam::partTet::mag
scalar mag(const PointField &) const
Return volume.
Definition: partTetI.H:154
Foam::partTet::~partTet
~partTet()
Definition: partTetI.H:57
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::partTet::partTet
partTet()
Null construct.
Definition: partTetI.H:39
Foam::Vector< scalar >
Foam::partTet::whichPosition
label whichPosition(const label) const
find position of the node in the partTet
Definition: partTetI.H:88
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::partTet::a
label a() const
Return vertices.
Definition: partTetI.H:63
Foam::tetrahedron::mag
scalar mag() const
Return volume.
Definition: tetrahedronI.H:171
Foam::partTet::operator==
bool operator==(const partTet &) const
Definition: partTetI.H:267
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
tetrahedron.H
Foam::tetrahedron
A tetrahedron primitive.
Definition: tetrahedron.H:62
Foam::token::SPACE
@ SPACE
Definition: token.H:95