Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Real3Proxy.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/* Real3Proxy.h (C) 2000-2018 */
9/* */
10/* Proxy d'un 'Real3'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_REAL3PROXY_H
13#define ARCANE_UTILS_REAL3PROXY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Real3.h"
18#include "arcane/utils/BuiltInProxy.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23ARCANE_BEGIN_NAMESPACE
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28typedef BuiltInProxy<Real> RealProxy;
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
35class ARCANE_UTILS_EXPORT Real3Proxy
36: public Real3POD
37{
38 public:
39
41 Real3Proxy(Real3& value,const MemoryAccessInfo& info)
42 : x(value.x,info), y(value.y,info), z(value.z,info), m_value(value), m_info(info) {}
45 : x(f.x), y(f.y), z(f.z), m_value(f.m_value), m_info(f.m_info) {}
46 Real3 operator=(const Real3Proxy f)
47 { x = f.x; y = f.y; z = f.z; return m_value; }
48 Real3 operator=(Real3 f)
49 { x = f.x; y = f.y; z = f.z; return m_value; }
52 { x = v; y = v; z = v; return m_value; }
53 operator Real3() const
54 {
55 return getValue();
56 }
57 //operator Real3&()
58 //{
59 // return getValueMutable();
60 //}
61 public:
62
66
67 private:
68
69 Real3& m_value;
70 MemoryAccessInfo m_info;
71
72 public:
73
75 Real3 copy() const { return Real3(x,y,z); }
77 Real3Proxy& reset() { x = y = z = 0.; return (*this); }
79 Real3Proxy& assign(Real ax,Real ay,Real az)
80 { x = ax; y = ay; z = az; return (*this); }
83 { x = f.x; y = f.y; z = f.z; return (*this); }
99 bool isNearlyZero() const
100 {
101 return math::isNearlyZero(x.getValue()) && math::isNearlyZero(y.getValue()) && math::isNearlyZero(z.getValue());
102 }
104 Real abs2() const
105 { return x*x + y*y + z*z; }
107 Real abs() const
108 { return _sqrt(abs2()); }
109
114 std::istream& assign(std::istream& i);
116 std::ostream& print(std::ostream& o) const;
118 std::ostream& printXyz(std::ostream& o) const;
119
121 Real3Proxy& add(Real3 b) { x+=b.x; y+=b.y; z+=b.z; return (*this); }
123 Real3Proxy& sub(Real3 b) { x-=b.x; y-=b.y; z-=b.z; return (*this); }
125 Real3Proxy& mul(Real3 b) { x*=b.x; y*=b.y; z*=b.z; return (*this); }
127 Real3Proxy& div(Real3 b) { x/=b.x; y/=b.y; z/=b.z; return (*this); }
129 Real3Proxy& addSame(Real b) { x+=b; y+=b; z+=b; return (*this); }
131 Real3Proxy& subSame(Real b) { x-=b; y-=b; z-=b; return (*this); }
133 Real3Proxy& mulSame(Real b) { x*=b; y*=b; z*=b; return (*this); }
135 Real3Proxy& divSame(Real b) { x/=b; y/=b; z/=b; return (*this); }
137 Real3Proxy& operator+= (Real3 b) { return add(b); }
139 Real3Proxy& operator-= (Real3 b) { return sub(b); }
141 Real3Proxy& operator*= (Real3 b) { return mul(b); }
143 void operator*= (Real b) { x*=b; y*=b; z*=b; }
145 Real3Proxy& operator/= (Real3 b) { return div(b); }
147 void operator/= (Real b) { x/=b; y/=b; z/=b; }
149 Real3 operator+ (Real3 b) const { return Real3(x+b.x,y+b.y,z+b.z); }
151 Real3 operator- (Real3 b) const { return Real3(x-b.x,y-b.y,z-b.z); }
153 Real3 operator-() const { return Real3(-x,-y,-z); }
158 Real3 operator*(Real3 b) const { return Real3(x*b.x,y*b.y,z*b.z); }
163 Real3 operator/(Real3 b) const { return Real3(x/b.x,y/b.y,z/b.z); }
164
173 {
174 Real d = abs();
175 if (!math::isZero(d))
176 divSame(d);
177 return (*this);
178 }
179
197 { return _eq(a.x,b.x) && _eq(a.y,b.y) && _eq(a.z,b.z); }
205 { return !(a==b); }
206
207 public:
208 Real3 getValue() const
209 {
210 m_info.setRead();
211 return m_value;
212 }
213 Real3& getValueMutable()
214 {
215 m_info.setReadOrWrite();
216 return m_value;
217 }
218 private:
224 static bool _eq(Real a,Real b)
225 { return math::isEqual(a,b); }
227 static Real _sqrt(Real a)
228 { return math::sqrt(a); }
229};
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
236inline Real3 operator*(Real sca,Real3Proxy vec)
237{
238 return Real3(vec.x*sca,vec.y*sca,vec.z*sca);
239}
240
241/*---------------------------------------------------------------------------*/
242/*---------------------------------------------------------------------------*/
246inline Real3
247operator*(Real3Proxy vec,Real sca)
248{
249 return Real3(vec.x*sca,vec.y*sca,vec.z*sca);
250}
251
252/*---------------------------------------------------------------------------*/
253/*---------------------------------------------------------------------------*/
257inline Real3
259{
260 return Real3(vec.x/sca,vec.y/sca,vec.z/sca);
261}
262
263/*---------------------------------------------------------------------------*/
264/*---------------------------------------------------------------------------*/
271inline bool
272operator<(const Real3Proxy v1,const Real3Proxy v2)
273{
274 return v1.getValue()<v2.getValue();
275}
276
277/*---------------------------------------------------------------------------*/
278/*---------------------------------------------------------------------------*/
283inline std::ostream&
284operator<< (std::ostream& o,Real3Proxy t)
285{
286 return t.printXyz(o);
287}
292inline std::istream&
293operator>> (std::istream& i,Real3Proxy& t)
294{
295 return t.assign(i);
296}
297
298/*---------------------------------------------------------------------------*/
299/*---------------------------------------------------------------------------*/
300
301/*---------------------------------------------------------------------------*/
302/*---------------------------------------------------------------------------*/
303
304ARCANE_END_NAMESPACE
305
306/*---------------------------------------------------------------------------*/
307/*---------------------------------------------------------------------------*/
308
309#endif
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Proxy d'un Real3.
Definition Real3Proxy.h:37
Real3Proxy & assign(Real3 f)
Copie le triplet f.
Definition Real3Proxy.h:82
RealProxy x
première composante du triplet
Definition Real3Proxy.h:63
Real3Proxy & reset()
Réinitialise le triplet avec les constructeurs par défaut.
Definition Real3Proxy.h:77
Real abs2() const
Retourne la norme au carré du triplet .
Definition Real3Proxy.h:104
friend bool operator!=(Real3Proxy a, Real3Proxy b)
Compare deux triplets. Pour la notion d'égalité, voir operator==()
Definition Real3Proxy.h:204
RealProxy z
troisième composante du triplet
Definition Real3Proxy.h:65
Real3 operator/(Real3 b) const
Créé un triplet qui vaut ce triplet dont chaque composant a été divisée par la composante corresponda...
Definition Real3Proxy.h:163
bool isNearlyZero() const
Compare le triplet avec le triplet nul.
Definition Real3Proxy.h:99
Real3 copy() const
Retourne une copie du triplet.
Definition Real3Proxy.h:75
Real3Proxy(Real3 &value, const MemoryAccessInfo &info)
Construit le triplet (ax,ay,az)
Definition Real3Proxy.h:41
RealProxy y
deuxième composante du triplet
Definition Real3Proxy.h:64
Real3Proxy & addSame(Real b)
Ajoute b à chaque composante du triplet.
Definition Real3Proxy.h:129
Real3 operator-() const
Créé un triplet opposé au triplet actuel.
Definition Real3Proxy.h:153
Real3Proxy & assign(Real ax, Real ay, Real az)
Affecte à l'instance le triplet (ax,ay,az)
Definition Real3Proxy.h:79
static bool _eq(Real a, Real b)
Compare les valeurs de a et b avec le comparateur TypeEqualT.
Definition Real3Proxy.h:224
Real abs() const
Retourne la norme du triplet .
Definition Real3Proxy.h:107
Real3Proxy & add(Real3 b)
Ajoute b au triplet.
Definition Real3Proxy.h:121
Real3Proxy & divSame(Real b)
Divise chaque composante du triplet par b.
Definition Real3Proxy.h:135
Real3Proxy & sub(Real3 b)
Soustrait b au triplet.
Definition Real3Proxy.h:123
Real3Proxy(const Real3Proxy &f)
Construit un triplet identique à f.
Definition Real3Proxy.h:44
friend bool operator==(Real3Proxy a, Real3Proxy b)
Compare le triplet à b.
Definition Real3Proxy.h:196
Real3Proxy & mul(Real3 b)
Multiple chaque composante du triplet par la composant correspondant de b.
Definition Real3Proxy.h:125
Real3Proxy & div(Real3 b)
Divise chaque composante du triplet par la composant correspondant de b.
Definition Real3Proxy.h:127
Real3Proxy & mulSame(Real b)
Multiplie chaque composante du triplet par b.
Definition Real3Proxy.h:133
static Real _sqrt(Real a)
Retourne la racine carrée de a.
Definition Real3Proxy.h:227
Real3 operator*(Real3 b) const
Créé un triplet qui vaut ce triplet dont chaque composant a été multipliée par la composante correspo...
Definition Real3Proxy.h:158
Real3Proxy & normalize()
Normalise le triplet.
Definition Real3Proxy.h:172
Real3Proxy & subSame(Real b)
Soustrait b à chaque composante du triplet.
Definition Real3Proxy.h:131
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Espace de nom pour l'utilisation des accélérateurs.
constexpr ARCCORE_HOST_DEVICE bool isEqual(const _Type &a, const _Type &b)
Teste l'égalité bit à bit entre deux valeurs.
Definition Numeric.h:253
ARCCORE_HOST_DEVICE double sqrt(double v)
Racine carrée de v.
Definition Math.h:135
Real2 operator/(const Real2Proxy &vec, Real sca)
Division par un scalaire.
Definition Real2Proxy.h:263
Real y
deuxième composante du triplet
Definition Real3.h:36
Real z
troisième composante du triplet
Definition Real3.h:37
Real x
première composante du triplet
Definition Real3.h:35