Arcane  v3.16.6.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Real3x3.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* Real3x3.h (C) 2000-2025 */
9/* */
10/* Matrice 3x3 de 'Real'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_REAL3X3_H
13#define ARCANE_UTILS_REAL3X3_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Real3.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
31{
32 public:
33
34 Real3POD x;
35 Real3POD y;
36 Real3POD z;
37};
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
65class ARCANE_UTILS_EXPORT Real3x3
66{
67 public:
68
70 constexpr ARCCORE_HOST_DEVICE Real3x3()
71 : x(Real3::zero())
72 , y(Real3::zero())
73 , z(Real3::zero())
74 {}
75
77 constexpr ARCCORE_HOST_DEVICE Real3x3(Real3 ax, Real3 ay, Real3 az)
78 : x(ax)
79 , y(ay)
80 , z(az)
81 {}
82
87 ARCANE_DEPRECATED_116 Real3x3(Real ax, Real ay, Real az, Real bx, Real by, Real bz, Real cx, Real cy, Real cz)
88 : x(ax, bx, cx)
89 , y(ay, by, cy)
90 , z(az, bz, cz)
91 {}
92
94 Real3x3(const Real3x3& f) = default;
96 constexpr ARCCORE_HOST_DEVICE explicit Real3x3(const Real3x3POD& f)
97 : x(f.x)
98 , y(f.y)
99 , z(f.z)
100 {}
101
103 constexpr ARCCORE_HOST_DEVICE explicit Real3x3(Real v)
104 {
105 x = y = z = v;
106 }
107
109 constexpr ARCCORE_HOST_DEVICE explicit Real3x3(ConstArrayView<Real> av)
110 : x(av[0], av[1], av[2])
111 , y(av[3], av[4], av[5])
112 , z(av[6], av[7], av[8])
113 {}
114
116 Real3x3& operator=(const Real3x3& f) = default;
117
119 constexpr ARCCORE_HOST_DEVICE Real3x3& operator=(Real v)
120 {
121 x = y = z = v;
122 return (*this);
123 }
124
125 public:
126
130
131 public:
132
134 constexpr ARCCORE_HOST_DEVICE static Real3x3 null() { return Real3x3(); }
135
137 constexpr ARCCORE_HOST_DEVICE static Real3x3 zero() { return Real3x3(); }
138
140 constexpr ARCCORE_HOST_DEVICE static Real3x3 identity() { return Real3x3(Real3(1.0, 0.0, 0.0), Real3(0.0, 1.0, 0.0), Real3(0.0, 0.0, 1.0)); }
141
143 constexpr ARCCORE_HOST_DEVICE static Real3x3 fromColumns(Real ax, Real ay, Real az, Real bx, Real by, Real bz, Real cx, Real cy, Real cz)
144 {
145 return Real3x3(Real3(ax, bx, cx), Real3(ay, by, cy), Real3(az, bz, cz));
146 }
147
149 constexpr ARCCORE_HOST_DEVICE static Real3x3 fromLines(Real ax, Real bx, Real cx, Real ay, Real by, Real cy, Real az, Real bz, Real cz)
150 {
151 return Real3x3(Real3(ax, bx, cx), Real3(ay, by, cy), Real3(az, bz, cz));
152 }
153
154 public:
155
157 constexpr ARCCORE_HOST_DEVICE Real3x3 copy() const { return (*this); }
158
160 constexpr ARCCORE_HOST_DEVICE Real3x3& reset()
161 {
162 *this = zero();
163 return (*this);
164 }
165
167 constexpr ARCCORE_HOST_DEVICE Real3x3& assign(Real3 ax, Real3 ay, Real3 az)
168 {
169 x = ax;
170 y = ay;
171 z = az;
172 return (*this);
173 }
174
176 constexpr ARCCORE_HOST_DEVICE Real3x3& assign(Real3x3 f)
177 {
178 x = f.x;
179 y = f.y;
180 z = f.z;
181 return (*this);
182 }
183
186 constexpr ARCCORE_HOST_DEVICE ArrayView<Real> view()
187 {
188 return { 9, &x.x };
189 }
190
193 constexpr ARCCORE_HOST_DEVICE ConstArrayView<Real> constView() const
194 {
195 return { 9, &x.x };
196 }
197
202 std::istream& assign(std::istream& i);
204 std::ostream& print(std::ostream& o) const;
206 std::ostream& printXyz(std::ostream& o) const;
207
209 constexpr ARCCORE_HOST_DEVICE Real3x3& add(Real3x3 b)
210 {
211 x += b.x;
212 y += b.y;
213 z += b.z;
214 return (*this);
215 }
216
217 constexpr ARCCORE_HOST_DEVICE Real3x3& sub(Real3x3 b)
218 {
219 x -= b.x;
220 y -= b.y;
221 z -= b.z;
222 return (*this);
223 }
224
225 constexpr ARCCORE_HOST_DEVICE Real3x3& addSame(Real3 b)
226 {
227 x += b;
228 y += b;
229 z += b;
230 return (*this);
231 }
232
233 constexpr ARCCORE_HOST_DEVICE Real3x3& subSame(Real3 b)
234 {
235 x -= b;
236 y -= b;
237 z -= b;
238 return (*this);
239 }
240
241 constexpr ARCCORE_HOST_DEVICE Real3x3& operator+=(Real3x3 b) { return add(b); }
243 constexpr ARCCORE_HOST_DEVICE Real3x3& operator-=(Real3x3 b) { return sub(b); }
245 constexpr ARCCORE_HOST_DEVICE void operator*=(Real b)
246 {
247 x *= b;
248 y *= b;
249 z *= b;
250 }
251
252 constexpr ARCCORE_HOST_DEVICE void operator/=(Real b)
253 {
254 x /= b;
255 y /= b;
256 z /= b;
257 }
258
259 constexpr ARCCORE_HOST_DEVICE Real3x3 operator+(Real3x3 b) const { return Real3x3(x + b.x, y + b.y, z + b.z); }
261 constexpr ARCCORE_HOST_DEVICE Real3x3 operator-(Real3x3 b) const { return Real3x3(x - b.x, y - b.y, z - b.z); }
263 constexpr ARCCORE_HOST_DEVICE Real3x3 operator-() const { return Real3x3(-x, -y, -z); }
264
271 constexpr ARCCORE_HOST_DEVICE bool operator==(Real3x3 b) const
272 {
273 return x == b.x && y == b.y && z == b.z;
274 }
275
282 constexpr ARCCORE_HOST_DEVICE bool operator!=(Real3x3 b) const
283 {
284 return !operator==(b);
285 }
286
291 ARCCORE_HOST_DEVICE Real3 operator[](Integer i) const
292 {
293 ARCCORE_CHECK_AT(i, 3);
294 return (&x)[i];
295 }
296
301 ARCCORE_HOST_DEVICE Real3 operator()(Integer i) const
302 {
303 ARCCORE_CHECK_AT(i, 3);
304 return (&x)[i];
305 }
306
312 ARCCORE_HOST_DEVICE Real operator()(Integer i, Integer j) const
313 {
314 ARCCORE_CHECK_AT(i, 3);
315 ARCCORE_CHECK_AT(j, 3);
316 return (&x)[i][j];
317 }
318
323 ARCCORE_HOST_DEVICE Real3& operator[](Integer i)
324 {
325 ARCCORE_CHECK_AT(i, 3);
326 return (&x)[i];
327 }
328
333 ARCCORE_HOST_DEVICE Real3& operator()(Integer i)
334 {
335 ARCCORE_CHECK_AT(i, 3);
336 return (&x)[i];
337 }
338
344 ARCCORE_HOST_DEVICE Real& operator()(Integer i, Integer j)
345 {
346 ARCCORE_CHECK_AT(i, 3);
347 ARCCORE_CHECK_AT(j, 3);
348 return (&x)[i][j];
349 }
350
352 constexpr ARCCORE_HOST_DEVICE Real determinant() const
353 {
354 return (x.x * (y.y * z.z - y.z * z.y) + x.y * (y.z * z.x - y.x * z.z) + x.z * (y.x * z.y - y.y * z.x));
355 }
356
358 friend std::ostream& operator<<(std::ostream& o, Real3x3 t)
359 {
360 return t.printXyz(o);
361 }
362
364 friend std::istream& operator>>(std::istream& i, Real3x3& t)
365 {
366 return t.assign(i);
367 }
368
370 friend constexpr ARCCORE_HOST_DEVICE Real3x3 operator*(Real sca, Real3x3 vec)
371 {
372 return Real3x3(vec.x * sca, vec.y * sca, vec.z * sca);
373 }
374
376 friend constexpr ARCCORE_HOST_DEVICE Real3x3 operator*(Real3x3 vec, Real sca)
377 {
378 return Real3x3(vec.x * sca, vec.y * sca, vec.z * sca);
379 }
380
382 friend constexpr ARCCORE_HOST_DEVICE Real3x3 operator/(Real3x3 vec, Real sca)
383 {
384 return Real3x3(vec.x / sca, vec.y / sca, vec.z / sca);
385 }
386
393 friend constexpr ARCCORE_HOST_DEVICE bool operator<(Real3x3 v1, Real3x3 v2)
394 {
395 if (v1.x == v2.x) {
396 if (v1.y == v2.y)
397 return v1.z < v2.z;
398 else
399 return v1.y < v2.y;
400 }
401 return (v1.x < v2.x);
402 }
403
404 public:
405
406 // TODO: rendre obsolète mi-2025: ARCANE_DEPRECATED_REASON("Y2024: Use math::isNearlyZero(const Real3x3&) instead")
407 inline constexpr ARCCORE_HOST_DEVICE bool isNearlyZero() const;
408
409 private:
410
416 constexpr ARCCORE_HOST_DEVICE static bool _eq(Real a, Real b)
417 {
418 return TypeEqualT<Real>::isEqual(a, b);
419 }
420};
421
422/*---------------------------------------------------------------------------*/
423/*---------------------------------------------------------------------------*/
424
425namespace math
426{
438 inline constexpr ARCCORE_HOST_DEVICE bool isNearlyZero(const Real3x3& v)
439 {
440 return isNearlyZero(v.x) && isNearlyZero(v.y) && isNearlyZero(v.z);
441 }
442} // namespace math
443
444/*---------------------------------------------------------------------------*/
445/*---------------------------------------------------------------------------*/
446
447inline constexpr ARCCORE_HOST_DEVICE bool Real3x3::
448isNearlyZero() const
449{
450 return math::isNearlyZero(*this);
451}
452
453/*---------------------------------------------------------------------------*/
454/*---------------------------------------------------------------------------*/
455
456} // End namespace Arcane
457
458/*---------------------------------------------------------------------------*/
459/*---------------------------------------------------------------------------*/
460
461#endif
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Classe gérant une matrice de réel de dimension 3x3.
Definition Real3x3.h:66
constexpr __host__ __device__ Real3x3 operator-(Real3x3 b) const
Créé un triplet qui vaut b soustrait de ce triplet.
Definition Real3x3.h:261
constexpr __host__ static __device__ Real3x3 null()
Construit le tenseur nul.
Definition Real3x3.h:134
Real3x3(const Real3x3 &f)=default
Construit un triplet identique à f.
friend constexpr __host__ __device__ Real3x3 operator*(Real sca, Real3x3 vec)
Multiplication par un scalaire.
Definition Real3x3.h:370
constexpr __host__ __device__ Real3x3 & add(Real3x3 b)
Ajoute b au triplet.
Definition Real3x3.h:209
constexpr __host__ static __device__ Real3x3 identity()
Construit la matrice identité
Definition Real3x3.h:140
constexpr __host__ __device__ Real3x3 & subSame(Real3 b)
Soustrait b à chaque composante du triplet.
Definition Real3x3.h:233
std::ostream & printXyz(std::ostream &o) const
Ecrit le triplet sur le flot o sous la forme (x,y,z)
Definition Real3x3.cc:49
constexpr __host__ __device__ Real3x3 & assign(Real3 ax, Real3 ay, Real3 az)
Affecte à l'instance les lignes (ax,ay,az)
Definition Real3x3.h:167
Real3 z
premier élément du triplet
Definition Real3x3.h:129
constexpr __host__ __device__ bool operator==(Real3x3 b) const
Compare composant pas composante l'instance courante à b.
Definition Real3x3.h:271
friend constexpr __host__ __device__ bool operator<(Real3x3 v1, Real3x3 v2)
Opérateur de comparaison.
Definition Real3x3.h:393
constexpr __host__ __device__ Real3x3 & sub(Real3x3 b)
Soustrait b au triplet.
Definition Real3x3.h:217
constexpr __host__ static __device__ Real3x3 fromLines(Real ax, Real bx, Real cx, Real ay, Real by, Real cy, Real az, Real bz, Real cz)
Construit la matrice ((ax,bx,cx),(ay,by,cy),(az,bz,cz)).
Definition Real3x3.h:149
constexpr __host__ __device__ Real3x3 & operator=(Real v)
Affecte à l'instance le triplet (v,v,v).
Definition Real3x3.h:119
constexpr __host__ __device__ Real3x3 & reset()
Remet à zéro les coefficients de la matrice.
Definition Real3x3.h:160
Real3 y
premier élément du triplet
Definition Real3x3.h:128
constexpr __host__ __device__ Real3x3 & assign(Real3x3 f)
Copie la matrice f.
Definition Real3x3.h:176
constexpr __host__ __device__ Real determinant() const
Déterminant de la matrice.
Definition Real3x3.h:352
__host__ __device__ Real3 operator()(Integer i) const
Accès en lecture seule à la i-ème (entre 0 et 2 inclus) ligne de l'instance.
Definition Real3x3.h:301
constexpr __host__ static __device__ Real3x3 fromColumns(Real ax, Real ay, Real az, Real bx, Real by, Real bz, Real cx, Real cy, Real cz)
Construit la matrice ((ax,bx,cx),(ay,by,cy),(az,bz,cz)).
Definition Real3x3.h:143
constexpr __host__ __device__ Real3x3()
Construit la matrice avec tous les coefficiants nuls.
Definition Real3x3.h:70
constexpr __host__ __device__ Real3x3(ConstArrayView< Real > av)
Construit le triplet ((av[0], av[1], av[2]), (av[3], av[4], av[5]), (av[6], av[7],...
Definition Real3x3.h:109
__host__ __device__ Real3 operator[](Integer i) const
Accès en lecture seule à la i-ème (entre 0 et 2 inclus) ligne de l'instance.
Definition Real3x3.h:291
constexpr __host__ __device__ Real3x3 & addSame(Real3 b)
Ajoute b à chaque composante du triplet.
Definition Real3x3.h:225
Real3x3 & operator=(const Real3x3 &f)=default
Opérateur de recopie.
constexpr __host__ __device__ ArrayView< Real > view()
Definition Real3x3.h:186
constexpr __host__ __device__ ConstArrayView< Real > constView() const
Definition Real3x3.h:193
constexpr __host__ __device__ Real3x3(const Real3x3POD &f)
Construit un triplet identique à f.
Definition Real3x3.h:96
constexpr __host__ __device__ bool operator!=(Real3x3 b) const
Compare deux triplets. Pour la notion d'égalité, voir operator==()
Definition Real3x3.h:282
Real3 x
premier élément du triplet
Definition Real3x3.h:127
constexpr __host__ __device__ Real3x3(Real v)
Construit l'instance avec le triplet (v,v,v).
Definition Real3x3.h:103
friend std::ostream & operator<<(std::ostream &o, Real3x3 t)
Ecrit le triplet t sur le flot o.
Definition Real3x3.h:358
__host__ __device__ Real3 & operator[](Integer i)
Accès à la i-ème ligne (entre 0 et 2 inclus) de l'instance.
Definition Real3x3.h:323
constexpr __host__ static __device__ bool _eq(Real a, Real b)
Compare les valeurs de a et b avec le comparateur TypeEqualT.
Definition Real3x3.h:416
constexpr __host__ static __device__ Real3x3 zero()
Construit la matrice nulle.
Definition Real3x3.h:137
__host__ __device__ Real operator()(Integer i, Integer j) const
Accès en lecture seule à la i-ème ligne et j-ème colonne.
Definition Real3x3.h:312
friend std::istream & operator>>(std::istream &i, Real3x3 &t)
Lit le triplet t à partir du flot o.
Definition Real3x3.h:364
constexpr __host__ __device__ Real3x3(Real3 ax, Real3 ay, Real3 az)
Construit la matrice avec les lignes (ax,ay,az)
Definition Real3x3.h:77
constexpr __host__ __device__ Real3x3 & operator+=(Real3x3 b)
Ajoute b au triplet.
Definition Real3x3.h:241
constexpr __host__ __device__ void operator/=(Real b)
Divise chaque composante de la matrice par le réel b.
Definition Real3x3.h:252
constexpr __host__ __device__ Real3x3 copy() const
Retourne une copie de la matrice.
Definition Real3x3.h:157
constexpr __host__ __device__ Real3x3 operator-() const
Créé un tenseur opposé au tenseur actuel.
Definition Real3x3.h:263
constexpr __host__ __device__ Real3x3 operator+(Real3x3 b) const
Créé un triplet qui vaut ce triplet ajouté à b.
Definition Real3x3.h:259
ARCANE_DEPRECATED_116 Real3x3(Real ax, Real ay, Real az, Real bx, Real by, Real bz, Real cx, Real cy, Real cz)
Construit le tenseur ((ax,bx,cx),(ay,by,cy),(az,bz,cz)).
Definition Real3x3.h:87
constexpr __host__ __device__ void operator*=(Real b)
Multiple chaque composante de la matrice par le réel b.
Definition Real3x3.h:245
__host__ __device__ Real & operator()(Integer i, Integer j)
Accès à la i-ème ligne et j-ème colonne.
Definition Real3x3.h:344
constexpr __host__ __device__ Real3x3 & operator-=(Real3x3 b)
Soustrait b au triplet.
Definition Real3x3.h:243
friend constexpr __host__ __device__ Real3x3 operator/(Real3x3 vec, Real sca)
Division par un scalaire.
Definition Real3x3.h:382
friend constexpr __host__ __device__ Real3x3 operator*(Real3x3 vec, Real sca)
Multiplication par un scalaire.
Definition Real3x3.h:376
__host__ __device__ Real3 & operator()(Integer i)
Accès à la i-ème ligne (entre 0 et 2 inclus) de l'instance.
Definition Real3x3.h:333
constexpr __host__ static __device__ bool isEqual(const T &a, const T &b)
Compare a à b.
Definition Numeric.h:92
Espace de nom pour l'utilisation des accélérateurs.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
double Real
Type représentant un réel.
Structure POD pour un Real3x3.
Definition Real3x3.h:31