Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Real3x3Proxy.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* Real3x3Proxy.h (C) 2000-2008 */
9/* */
10/* Proxy for a 'Real3x3'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_REAL3X3PROXY_H
13#define ARCANE_UTILS_REAL3X3PROXY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Real3x3.h"
18#include "arcane/utils/Real3Proxy.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
32class ARCANE_UTILS_EXPORT Real3x3Proxy
33{
34 public:
35
38 : x(value.x, info)
39 , y(value.y, info)
40 , z(value.z, info)
41 , m_value(value)
42 , m_info(info)
43 {}
44
47 : x(f.x)
48 , y(f.y)
49 , z(f.z)
50 , m_value(f.m_value)
51 , m_info(f.m_info)
52 {}
53 const Real3x3& operator=(const Real3x3Proxy f)
54 {
55 x = f.x;
56 y = f.y;
57 z = f.z;
58 return m_value;
59 }
60 const Real3x3& operator=(Real3x3 f)
61 {
62 x = f.x;
63 y = f.y;
64 z = f.z;
65 return m_value;
66 }
67
70 {
71 x = y = z = v;
72 return m_value;
73 }
74 operator const Real3x3&() const
75 {
76 return getValue();
77 }
78 //operator Real3x3()
79 //{
80 // return getValueMutable();
81 //}
82
83 public:
84
88
89 private:
90
91 Real3x3& m_value;
92 MemoryAccessInfo m_info;
93
94 public:
95
97 Real3x3 copy() const { return m_value; }
98
101 {
102 x.reset();
103 y.reset();
104 z.reset();
105 return (*this);
106 }
107
110 {
111 x = ax;
112 y = ay;
113 z = az;
114 return (*this);
115 }
116
119 {
120 x = f.x;
121 y = f.y;
122 z = f.z;
123 return (*this);
124 }
125
137 bool isNearlyZero() const
138 {
139 return x.isNearlyZero() && y.isNearlyZero() && z.isNearlyZero();
140 }
141
146 std::istream& assign(std::istream& i);
147
149 std::ostream& print(std::ostream& o) const;
150
152 std::ostream& printXyz(std::ostream& o) const;
153
156 {
157 x += b.x;
158 y += b.y;
159 z += b.z;
160 return (*this);
161 }
162
165 {
166 x -= b.x;
167 y -= b.y;
168 z -= b.z;
169 return (*this);
170 }
171
174 {
175 x += b;
176 y += b;
177 z += b;
178 return (*this);
179 }
180
183 {
184 x -= b;
185 y -= b;
186 z -= b;
187 return (*this);
188 }
189
192 {
193 x *= b;
194 y *= b;
195 z *= b;
196 return (*this);
197 }
198
201 {
202 x /= b;
203 y /= b;
204 z /= b;
205 return (*this);
206 }
207
210
213
216 {
217 x *= b;
218 y *= b;
219 z *= b;
220 }
221
224 {
225 x /= b;
226 y /= b;
227 z /= b;
228 }
229
231 Real3x3 operator+(Real3x3 b) const { return Real3x3(x + b.x, y + b.y, z + b.z); }
232
234 Real3x3 operator-(Real3x3 b) const { return Real3x3(x - b.x, y - b.y, z - b.z); }
235
237 Real3x3 operator-() const { return Real3x3(-x, -y, -z); }
238
239 public:
240
241 const Real3x3& getValue() const
242 {
243 m_info.setRead();
244 return m_value;
245 }
246 Real3x3& getValueMutable()
247 {
248 m_info.setReadOrWrite();
249 return m_value;
250 }
251
252 private:
253
259 static bool _eq(Real a, Real b)
260 {
261 return TypeEqualT<Real>::isEqual(a, b);
262 }
263};
264
265/*---------------------------------------------------------------------------*/
266/*---------------------------------------------------------------------------*/
267
272inline std::ostream&
273operator<<(std::ostream& o, Real3x3Proxy t)
274{
275 return t.printXyz(o);
276}
277
282inline std::istream&
283operator>>(std::istream& i, Real3x3Proxy& t)
284{
285 return t.assign(i);
286}
287
288/*---------------------------------------------------------------------------*/
289/*---------------------------------------------------------------------------*/
290
291inline bool
292operator==(const Real3x3& a, const Real3x3Proxy& b)
293{
294 return a == b.getValue();
295}
296inline bool
297operator==(const Real3x3Proxy& a, const Real3x3& b)
298{
299 return a.getValue() == b;
300}
301inline bool
302operator==(const Real3x3Proxy& a, const Real3x3Proxy& b)
303{
304 return a.getValue() == b.getValue();
305}
306
307/*---------------------------------------------------------------------------*/
308/*---------------------------------------------------------------------------*/
309
310inline bool
311operator!=(const Real3x3& a, const Real3x3Proxy& b)
312{
313 return a != b.getValue();
314}
315inline bool
316operator!=(const Real3x3Proxy& a, const Real3x3& b)
317{
318 return a.getValue() != b;
319}
320inline bool
321operator!=(const Real3x3Proxy& a, const Real3x3Proxy& b)
322{
323 return a.getValue() != b.getValue();
324}
325
326/*---------------------------------------------------------------------------*/
327/*---------------------------------------------------------------------------*/
328
330inline Real3x3
331operator*(Real sca, Real3x3Proxy vec)
332{
333 return Real3x3(vec.x * sca, vec.y * sca, vec.z * sca);
334}
335
336/*---------------------------------------------------------------------------*/
337/*---------------------------------------------------------------------------*/
338
340inline Real3x3
341operator*(const Real3x3Proxy& vec, Real sca)
342{
343 return Real3x3(vec.x * sca, vec.y * sca, vec.z * sca);
344}
345
346/*---------------------------------------------------------------------------*/
347/*---------------------------------------------------------------------------*/
348
350inline Real3x3
352{
353 return Real3x3(vec.x / sca, vec.y / sca, vec.z / sca);
354}
355
356/*---------------------------------------------------------------------------*/
357/*---------------------------------------------------------------------------*/
358
365inline bool
367{
368 if (v1.x == v2.x) {
369 if (v1.y == v2.y)
370 return v1.z < v2.z;
371 else
372 return v1.y < v2.y;
373 }
374 return (v1.x < v2.x);
375}
376
377/*---------------------------------------------------------------------------*/
378/*---------------------------------------------------------------------------*/
379
380} // namespace Arcane
381
382/*---------------------------------------------------------------------------*/
383/*---------------------------------------------------------------------------*/
384
385#endif
Proxy for a Real3.
Definition Real3Proxy.h:39
RealProxy x
first component of the triplet
Definition Real3Proxy.h:92
Class managing a 3-dimensional real vector.
Definition Real3.h:132
std::istream & operator>>(std::istream &i, Real3x3Proxy &t)
Reads the triplet t from the stream o.
friend std::ostream & operator<<(std::ostream &o, Real3 t)
Writes the triplet t to the stream o.
Definition Real3.h:421
Proxy for a 'Real3x3'.
Real3x3Proxy & subSame(Real3 b)
Subtracts b from each component of the triplet.
void operator/=(Real b)
Divides each component of the matrix by the real b.
Real3x3Proxy & operator-=(Real3x3 b)
Subtracts b from the triplet.
std::ostream & printXyz(std::ostream &o) const
Writes the triplet to the stream o in the form (x,y,z).
Definition Real3x3.cc:81
Real3x3Proxy & addSame(Real3 b)
Adds b to each component of the triplet.
Real3x3Proxy & divSame(Real3 b)
Divides each component of the triplet by b.
Real3x3Proxy(const Real3x3Proxy &f)
Constructs a triplet identical to f.
Real3Proxy z
first element of the triplet
Real3x3Proxy & add(Real3x3 b)
Adds b to the triplet.
const Real3x3 & operator=(Real v)
Assigns the triplet (v,v,v) to the instance.
Real3x3Proxy & mulSame(Real3 b)
Multiplies each component of the triplet by b.
Real3x3Proxy & reset()
Resets the triplet using default constructors.
Real3x3Proxy & sub(Real3x3 b)
Subtracts b from the triplet.
Real3x3Proxy(Real3x3 &value, const MemoryAccessInfo &info)
Constructs the triplet (ax,ay,az).
Real3x3 operator+(Real3x3 b) const
Creates a triplet that equals this triplet added to b.
Real3x3Proxy & assign(Real3x3 f)
Copies the triplet f.
Real3Proxy x
first element of the triplet
Real3x3 copy() const
Returns a copy of the triplet.
Real3x3 operator-(Real3x3 b) const
Creates a triplet that equals b subtracted from this triplet.
Real3Proxy y
first element of the triplet
Real3x3 operator-() const
Creates a tensor opposite to the current tensor.
bool isNearlyZero() const
Compares the matrix with the zero matrix.
Real3x3Proxy & assign(Real3 ax, Real3 ay, Real3 az)
Assigns the triplet (ax,ay,az) to the instance.
void operator*=(Real b)
Multiplies each component of the matrix by the real b.
Real3x3Proxy & operator+=(Real3x3 b)
Adds b to the triplet.
static bool _eq(Real a, Real b)
Compares the values of a and b with the TypeEqualT comparator.
Class managing a 3x3 real matrix.
Definition Real3x3.h:67
Real3 z
first element of the triplet
Definition Real3x3.h:131
Real3 y
first element of the triplet
Definition Real3x3.h:130
Real3 x
first element of the triplet
Definition Real3x3.h:129
constexpr __host__ static __device__ bool isEqual(const T &a, const T &b)
Compares a to b.
Definition Numeric.h:94
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
bool operator<(const Item &item1, const Item &item2)
Compare two entities.
Definition Item.h:566
double Real
Type representing a real number.
Real2 operator/(const Real2Proxy &vec, Real sca)
Division by a scalar.
Definition Real2Proxy.h:388