Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Euclidian3Geometry.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Euclidian3Geometry.h (C) 2000-2020 */
9/* */
10/* Calculs géométriques en 3D Euclidienne. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_GEOMETRY_EUCLIDIAN_EUCLIDIAN3GEOMETRY_H
14#define ARCANE_GEOMETRY_EUCLIDIAN_EUCLIDIAN3GEOMETRY_H
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/geometry/IGeometry.h"
18#include "arcane/ArcaneTypes.h"
19#include "arcane/MeshVariable.h"
20#include "arcane/VariableTypedef.h"
21#include "arcane/MathUtils.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::Numerics
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
33: public IGeometry
34{
35public:
37 : m_coords(coords) { }
38
39 virtual ~Euclidian3Geometry() { }
40
42
44 Real3 computeCenter(const ItemWithNodes & item);
45
47
53
55 Real computeMeasure(const ItemWithNodes & item);
56
58
59 Real computeLength(const ItemWithNodes & item);
60
62
63 Real computeArea(const ItemWithNodes & item);
64
66
67 Real computeVolume(const ItemWithNodes & item);
68
70 Real3 computeSurfaceCenter(Integer n, const Real3 * coords);
71
73 Real3 computeOrientedArea(Integer n, const Real3 * coords);
74
76 Real computeLength(const Real3& m, const Real3& n);
77
79
80public:
82 struct IComputeLine {
83 IComputeLine(Euclidian3Geometry * geom) : m_geom(geom), m_coords(geom->m_coords) { }
84 virtual ~IComputeLine() { }
85 virtual void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center) = 0;
86 Euclidian3Geometry * m_geom;
87 const VariableNodeReal3 & m_coords;
88 };
89
90 struct ComputeLine2 : public IComputeLine {
92 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center);
93 };
94
96 IComputeSurface(Euclidian3Geometry * geom) : m_geom(geom), m_coords(geom->m_coords) { }
97 virtual ~IComputeSurface() { }
98 virtual void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center) = 0;
99 Euclidian3Geometry * m_geom;
100 const VariableNodeReal3 & m_coords;
101 };
102
104 : public IComputeSurface {
106 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center);
107 };
108
109 struct ComputeQuad4 : public IComputeSurface {
111 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center);
112 };
113
116 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center);
117 };
118
121 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real3 & orientation, Real3 & center);
122 };
123
125 IComputeVolume(Euclidian3Geometry * geom) : m_geom(geom), m_coords(geom->m_coords) { }
126 virtual ~IComputeVolume() { }
127 virtual void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real & measure, Real3 & center) = 0;
128 virtual void computeVolumeArea(const ItemWithNodes & item, Real & area) = 0;
129 Euclidian3Geometry * m_geom;
130 const VariableNodeReal3 & m_coords;
131 };
132
135 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real & measure, Real3 & center);
136 void computeVolumeArea(const ItemWithNodes & item, Real & area);
137 };
138
141 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real & measure, Real3 & center)
142 {
143 ARCANE_UNUSED(item);
144 ARCANE_UNUSED(measure);
145 ARCANE_UNUSED(center);
147 }
148 void computeVolumeArea(const ItemWithNodes & item, Real & area)
149 {
150 ARCANE_UNUSED(item);
151 ARCANE_UNUSED(area);
153 }
154 };
155
157 : public IComputeVolume
158 {
160 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real & measure, Real3 & center)
161 {
162 ARCANE_UNUSED(item);
163 ARCANE_UNUSED(measure);
164 ARCANE_UNUSED(center);
166 }
167 void computeVolumeArea(const ItemWithNodes & item, Real & area)
168 {
169 ARCANE_UNUSED(item);
170 ARCANE_UNUSED(area);
172 }
173 };
174
177 void computeOrientedMeasureAndCenter(const ItemWithNodes & item, Real & measure, Real3 & center);
178 void computeVolumeArea(const ItemWithNodes & item, Real & area);
179 };
180
191
193 static inline Real3 computeTriangleNormal(const Real3 & n0, const Real3 & n1, const Real3 & n2)
194 {
195 return math::vecMul(n1-n0,n2-n0) / 2.0;
196 }
197
198 static inline Real computeTriangleSurface(const Real3 & n0, const Real3 & n1, const Real3 & n2)
199 {
200 return math::normeR3(computeTriangleNormal(n0,n1,n2));
201 }
202
203 static inline Real3 computeTriangleCenter(const Real3 & n0, const Real3 & n1, const Real3 & n2)
204 {
205 return (n0+n1+n2) / 3.0;
206 }
207
208 static inline Real computeTetraedronVolume(const Real3 & n0, const Real3 & n1, const Real3 & n2, const Real3 & n3)
209 {
210 return math::mixteMul(n1-n0,n2-n0,n3-n0) / 6.0;
211 }
212
213 static inline Real3 computeTetraedronCenter(const Real3 & n0, const Real3 & n1, const Real3 & n2, const Real3 & n3)
214 {
215 return 0.25 * (n0+n1+n2+n3);
216 }
217
218 static inline Real3 computeQuadrilateralCenter(const Real3 & n0, const Real3 & n1, const Real3 & n2, const Real3 & n3)
219 {
220 const Real s0 = computeTriangleSurface(n0,n1,n2);
221 const Real s1 = computeTriangleSurface(n0,n2,n3);
222 const Real s2 = computeTriangleSurface(n1,n2,n3);
223 const Real s3 = computeTriangleSurface(n0,n1,n3);
224 return (s0 * computeTriangleCenter(n0,n1,n2) +
225 s1 * computeTriangleCenter(n0,n2,n3) +
226 s2 * computeTriangleCenter(n1,n2,n3) +
227 s3 * computeTriangleCenter(n0,n1,n3)) / (s0+s1+s2+s3);
228 }
229
230 static inline Real3 computePentagonalCenter(const Real3 & n0, const Real3 & n1, const Real3 & n2, const Real3 & n3, const Real3 & n4)
231 {
232 const Real s0 = computeTriangleSurface(n4,n0,n1);
233 const Real s1 = computeTriangleSurface(n0,n1,n2);
234 const Real s2 = computeTriangleSurface(n1,n2,n3);
235 const Real s3 = computeTriangleSurface(n2,n3,n4);
236 const Real s4 = computeTriangleSurface(n3,n4,n0);
237 const Real s5 = computeTriangleSurface(n0,n2,n3);
238 const Real s6 = computeTriangleSurface(n1,n3,n4);
239 const Real s7 = computeTriangleSurface(n2,n4,n0);
240 const Real s8 = computeTriangleSurface(n3,n0,n1);
241 const Real s9 = computeTriangleSurface(n4,n1,n2);
242
243 return (2*(s0 * computeTriangleCenter(n4,n0,n1) +
244 s1 * computeTriangleCenter(n0,n1,n2) +
245 s2 * computeTriangleCenter(n1,n2,n3) +
246 s3 * computeTriangleCenter(n2,n3,n4) +
247 s4 * computeTriangleCenter(n3,n4,n0)) +
248 s5 * computeTriangleCenter(n0,n2,n3) +
249 s6 * computeTriangleCenter(n1,n3,n4) +
250 s7 * computeTriangleCenter(n2,n4,n0) +
251 s8 * computeTriangleCenter(n3,n0,n1) +
252 s9 * computeTriangleCenter(n4,n1,n2)) / (2*(s0+s1+s2+s3+s4) + s5 + s6 + s7 + s8 + s9);
253 }
254
255 static inline Real3 computeHexagonalCenter(const Real3 & n0, const Real3 & n1, const Real3 & n2, const Real3 & n3, const Real3 & n4, const Real3 & n5)
256 {
257 const Real s0 = computeTriangleSurface(n0,n1,n5);
258 const Real s1 = computeTriangleSurface(n1,n2,n3);
259 const Real s2 = computeTriangleSurface(n3,n4,n5);
260 const Real s3 = computeTriangleSurface(n1,n3,n5);
261 const Real s4 = computeTriangleSurface(n0,n1,n2);
262 const Real s5 = computeTriangleSurface(n2,n3,n4);
263 const Real s6 = computeTriangleSurface(n4,n5,n0);
264 const Real s7 = computeTriangleSurface(n0,n2,n4);
265
266 return (s0 * computeTriangleCenter(n0,n1,n5) +
267 s1 * computeTriangleCenter(n1,n2,n3) +
268 s2 * computeTriangleCenter(n3,n4,n5) +
269 s3 * computeTriangleCenter(n1,n3,n5) +
270 s4 * computeTriangleCenter(n0,n1,n2) +
271 s5 * computeTriangleCenter(n2,n3,n4) +
272 s6 * computeTriangleCenter(n4,n5,n0) +
273 s7 * computeTriangleCenter(n0,n2,n4)) / (s0 + s1 + s2 + s3 + s4 + s5 + s6 + s7);
274 }
276
277protected:
278 const VariableNodeReal3 & m_coords;
279};
280
281/*---------------------------------------------------------------------------*/
282/*---------------------------------------------------------------------------*/
283
284} // End namespace Arcane::Numerics
285
286/*---------------------------------------------------------------------------*/
287/*---------------------------------------------------------------------------*/
288
289#endif
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
Elément de maillage s'appuyant sur des noeuds (Edge,Face,Cell).
Definition Item.h:714
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Real computeMeasure(const ItemWithNodes &item)
Calcul de la mesure (sans orientation)
Real computeVolume(const ItemWithNodes &item)
Calcul du volume.
Real3 computeOrientedArea(Integer n, const Real3 *coords)
Calcul de l'aire orientée (ie normale)
Real computeArea(const ItemWithNodes &item)
Calcul de l'aire.
Real computeLength(const ItemWithNodes &item)
Calcul de la longueyr.
Real3 computeSurfaceCenter(Integer n, const Real3 *coords)
Calcul du centre.
Real3 computeCenter(const ItemWithNodes &item)
Calcul du centre de masse.
Real3 computeOrientedMeasure(const ItemWithNodes &item)
Calcul de la mesure orientée.
Interface de calculs géométriques.
Definition IGeometry.h:25
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Exception lorsqu'une fonction n'est pas implémentée.
ARCCORE_HOST_DEVICE Real3 vecMul(Real3 u, Real3 v)
Produit vectoriel de u par v. dans .
Definition MathUtils.h:52
ARCCORE_HOST_DEVICE Real mixteMul(Real3 u, Real3 v, Real3 w)
Produit mixte de u, v et w.
Definition MathUtils.h:159
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
Real normeR3(Real3 v1)
Norme d'un vecteur.
Definition MathUtils.h:653