Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestNumVector.cc
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#include <gtest/gtest.h>
9
10#include "arcane/utils/ValueConvert.h"
11#include "arcane/utils/NumVector.h"
12#include "arcane/utils/NumMatrix.h"
13
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17using namespace Arcane;
18
20{
21 std::cout << " sizeof(NumVector<double,2>) = " << sizeof(NumVector<double,2>) << "\n";
22 std::cout << " sizeof(NumVector<double,3>) = " << sizeof(NumVector<double,3>) << "\n";
23 {
24 RealN2 v1;
25 ASSERT_EQ(v1.vx(),0.0);
26 ASSERT_EQ(v1.vy(),0.0);
27 }
28 {
29 double value = 0.2;
30 RealN2 v1(value);
31 ASSERT_EQ(v1.vx(),value);
32 ASSERT_EQ(v1.vy(),value);
33 RealN2 v2(v1);
34 ASSERT_EQ(v2.vx(),value);
35 ASSERT_EQ(v2.vy(),value);
36 v2.vx() = 3.5;
37 v2.vy() = 1.2;
38 v1 = v2;
39 ASSERT_EQ(v1.vx(),3.5);
40 ASSERT_EQ(v1.vy(),1.2);
41 ASSERT_EQ(v1,v2);
42 }
43 {
44 double value = 0.3;
45 RealN2 v2;
46 v2 = value;
47 ASSERT_EQ(v2.vx(),value);
48 ASSERT_EQ(v2.vx(),value);
49 }
50 // Operator + and -
51 {
52 RealN2 v2(1.2,4.5);
53 RealN2 v1(1.3,2.3);
54 RealN2 v3 = v1 + v2;
55 ASSERT_EQ(v3.vx(),2.5);
56 ASSERT_EQ(v3.vy(),6.8);
57 RealN2 v4 = v3 - v2;
58 ASSERT_EQ(v4,v1);
59 }
60 // Operator * and /
61 {
62 RealN2 v2(1.2,4.5);
63 RealN2 v4 = v2 * 2.3;
64 ASSERT_EQ(v4.vx(),v2.vx()*2.3);
65 ASSERT_EQ(v4.vy(),v2.vy()*2.3);
66 RealN2 v5 = v4 / 2.4;
67 ASSERT_EQ(v5.vx(),v4.vx()/2.4);
68 ASSERT_EQ(v5.vy(),v4.vy()/2.4);
69 }
70}
71
73{
74 {
75 RealN3 v1;
76 ASSERT_EQ(v1.vx(),0.0);
77 ASSERT_EQ(v1.vy(),0.0);
78 ASSERT_EQ(v1.vz(),0.0);
79 }
80 {
81 double value = 0.2;
82 RealN3 v1(value);
83 ASSERT_EQ(v1.vx(),value);
84 ASSERT_EQ(v1.vy(),value);
85 ASSERT_EQ(v1.vz(),value);
86 RealN3 v2(v1);
87 ASSERT_EQ(v2.vx(),value);
88 ASSERT_EQ(v2.vy(),value);
89 ASSERT_EQ(v2.vz(),value);
90 v2.vx() = 3.5;
91 v2.vy() = 1.2;
92 v2.vz() = -1.5;
93 v1 = v2;
94 ASSERT_EQ(v1.vx(),3.5);
95 ASSERT_EQ(v1.vy(),1.2);
96 ASSERT_EQ(v1.vz(),-1.5);
97 ASSERT_EQ(v1,v2);
98 }
99}
100
102{
103 RealN2 zero;
104 {
105 RealN2x2 v1;
106 ASSERT_EQ(v1.vx(),zero);
107 ASSERT_EQ(v1.vy(),zero);
108 }
109 {
110 double value = 0.2;
111 RealN2 r2_value(value);
112 RealN2x2 v1(value);
113 ASSERT_EQ(v1.vx(),r2_value);
114 ASSERT_EQ(v1.vy(),r2_value);
115 RealN2x2 v2(v1);
116 ASSERT_EQ(v2.vx(),v1.vx());
117 ASSERT_EQ(v2.vy(),v1.vy());
118 RealN2 rx(3.5, 1.2);
119 RealN2 ry(1.6, 2.1);
120 v2.vx() = rx;
121 v2.vy() = ry;
122 v1 = v2;
123 ASSERT_EQ(v1.vx(),rx);
124 ASSERT_EQ(v1.vy(),ry);
125 ASSERT_EQ(v1,v2);
126 }
127}
128
130{
131 RealN3 zero;
132 {
133 RealN3x3 v1;
134 ASSERT_EQ(v1.vx(),zero);
135 ASSERT_EQ(v1.vy(),zero);
136 ASSERT_EQ(v1.vz(),zero);
137 }
138 {
139 double value = 0.2;
140 RealN3 r3_value(value);
141 RealN3x3 v1(value);
142 ASSERT_EQ(v1.vx(),r3_value);
143 ASSERT_EQ(v1.vy(),r3_value);
144 ASSERT_EQ(v1.vz(),r3_value);
145 RealN3x3 v2(v1);
146 ASSERT_EQ(v2.vx(),v1.vx());
147 ASSERT_EQ(v2.vy(),v1.vy());
148 ASSERT_EQ(v2.vz(),v1.vz());
149 RealN3 rx(3.5, 1.2, -1.5);
150 RealN3 ry(1.6, 2.1, -2.3);
151 RealN3 rz(-2.3, 1.8, 9.4);
152 v2.vx() = rx;
153 v2.vy() = ry;
154 v2.vz() = rz;
155 v1 = v2;
156 ASSERT_EQ(v1.vx(),rx);
157 ASSERT_EQ(v1.vy(),ry);
158 ASSERT_EQ(v1.vz(),rz);
159 ASSERT_EQ(v1,v2);
160 }
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166namespace Arcane
167{
168template class NumVector<Real,2>;
169template class NumVector<Real,3>;
170}
171
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
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
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-