Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Expression.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/* Expression.cc (C) 2000-2014 */
9/* */
10/* Référence à une expression. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14
15#include "arcane/utils/ArcanePrecomp.h"
16
17#include "arcane/utils/Array.h"
18#include "arcane/utils/Iostream.h"
19
20#include "arcane/expr/Expression.h"
21#include "arcane/expr/ExpressionImpl.h"
22#include "arcane/expr/ExpressionResult.h"
23#include "arcane/expr/BinaryExpressionImpl.h"
24#include "arcane/expr/UnaryExpressionImpl.h"
25#include "arcane/expr/LitteralExpressionImpl.h"
26#include "arcane/expr/WhereExpressionImpl.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31ARCANE_BEGIN_NAMESPACE
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36Expression::
37Expression()
38: m_expression(0)
39{
40}
41
43Expression(Real v)
44{
45 m_expression = new LitteralExpressionImpl(v);
46 m_expression->addRef();
47}
48
50Expression(IExpressionImpl* expr)
51: m_expression(expr)
52{
53 if (m_expression)
54 m_expression->addRef();
55}
56
59: m_expression(expr.m_expression)
60{
61 if (m_expression)
62 m_expression->addRef();
63}
64
65void Expression::
66operator=(const Expression& expr)
67{
68 IExpressionImpl* nex = expr.m_expression;
69 if (nex)
70 nex->addRef();
71 if (m_expression)
72 m_expression->removeRef();
73 m_expression = nex;
74}
75
76Expression::
77~Expression()
78{
79 if (m_expression)
80 m_expression->removeRef();
81}
82
83void Expression::
84assign(const Expression& expr)
85{
86 m_expression->assign(expr.m_expression);
87}
88
89void Expression::
90assign(const Expression& expr,const Array<Integer>& indices)
91{
92 m_expression->assign(expr.m_expression, indices);
93}
94
95void Expression::
96assign(Real val)
97{
98 Expression expr(literal(val));
99 m_expression->assign(expr.m_expression);
100}
101
102void Expression::
103apply(ExpressionResult* result)
104{
105 m_expression->apply(result);
106}
107
108void Expression::
109dumpIf(const Expression& test_expr,Array<Expression>& exprs)
110{
111 m_expression->dumpIf(test_expr.m_expression,exprs);
112}
113
114void Expression::
115dumpIf(const Expression& test_expr)
116{
117 UniqueArray<Expression> exprs;
118 m_expression->dumpIf(test_expr.m_expression,exprs);
119}
120
121IExpressionImpl* Expression::
122operator->() const { return m_expression;}
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
126
127Expression Expression::
128operator-()
129{
130 return new UnaryExpressionImpl(m_expression,
131 UnaryExpressionImpl::UnarySubstract);
132}
133
134Expression Expression::
135inverse()
136{
137 return new UnaryExpressionImpl(m_expression,
138 UnaryExpressionImpl::Inverse);
139}
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144Expression Expression::
145acos()
146{
147 return new UnaryExpressionImpl(m_expression,
148 UnaryExpressionImpl::Acos);
149}
150
151Expression Expression::
152asin()
153{
154 return new UnaryExpressionImpl(m_expression,
155 UnaryExpressionImpl::Asin);
156}
157
158Expression Expression::
159atan()
160{
161 return new UnaryExpressionImpl(m_expression,
162 UnaryExpressionImpl::Atan);
163}
164
165Expression Expression::
166ceil()
167{
168 return new UnaryExpressionImpl(m_expression,
169 UnaryExpressionImpl::Ceil);
170}
171
172Expression Expression::
173cos()
174{
175 return new UnaryExpressionImpl(m_expression,
176 UnaryExpressionImpl::Cos);
177}
178
179Expression Expression::
180cosh()
181{
182 return new UnaryExpressionImpl(m_expression,
183 UnaryExpressionImpl::Cosh);
184}
185
186Expression Expression::
187exp()
188{
189 return new UnaryExpressionImpl(m_expression,
190 UnaryExpressionImpl::Exp);
191}
192
193Expression Expression::
194fabs()
195{
196 return new UnaryExpressionImpl(m_expression,
197 UnaryExpressionImpl::Fabs);
198}
199
200Expression Expression::
201floor()
202{
203 return new UnaryExpressionImpl(m_expression,
204 UnaryExpressionImpl::Floor);
205}
206
207Expression Expression::
208log()
209{
210 return new UnaryExpressionImpl(m_expression,
211 UnaryExpressionImpl::Log);
212}
213
214Expression Expression::
215log10()
216{
217 return new UnaryExpressionImpl(m_expression,
218 UnaryExpressionImpl::Log10);
219}
220
221Expression Expression::
222sin()
223{
224 return new UnaryExpressionImpl(m_expression,
225 UnaryExpressionImpl::Sin);
226}
227
228Expression Expression::
229sinh()
230{
231 return new UnaryExpressionImpl(m_expression,
232 UnaryExpressionImpl::Sinh);
233}
234
235Expression Expression::
236sqrt()
237{
238 return new UnaryExpressionImpl(m_expression,
239 UnaryExpressionImpl::Sqrt);
240}
241
242Expression Expression::
243tan()
244{
245 return new UnaryExpressionImpl(m_expression,
246 UnaryExpressionImpl::Tan);
247}
248
249Expression Expression::
250tanh()
251{
252 return new UnaryExpressionImpl(m_expression,
253 UnaryExpressionImpl::Tanh);
254}
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
259Expression Expression::
260operator+(Expression ex1)
261{
262 return new BinaryExpressionImpl(m_expression,ex1. m_expression,
263 BinaryExpressionImpl::Add);
264}
265
266Expression Expression::
267operator-(Expression ex1)
268{
269 return new BinaryExpressionImpl(m_expression,ex1. m_expression,
270 BinaryExpressionImpl::Substract);
271}
272
273Expression Expression::
274operator*(Expression ex1)
275{
276 return new BinaryExpressionImpl(m_expression,ex1. m_expression,
277 BinaryExpressionImpl::Multiply);
278}
279
280Expression Expression::
281operator/(Expression ex1)
282{
283 return new BinaryExpressionImpl(m_expression,ex1. m_expression,
284 BinaryExpressionImpl::Divide);
285}
286
287Expression Expression::
288eq(Expression ex1)
289{
290 return new BinaryExpressionImpl(m_expression,ex1. m_expression,
291 BinaryExpressionImpl::Equal);
292}
293
294Expression Expression::
295lt(Expression ex1)
296{
297 return new BinaryExpressionImpl(m_expression,ex1. m_expression,
298 BinaryExpressionImpl::LessThan);
299}
300
301Expression Expression::
302gt(Expression ex1)
303{
304 return new BinaryExpressionImpl(m_expression, ex1.m_expression,
305 BinaryExpressionImpl::GreaterThan);
306}
307
308Expression Expression::
309lte(Expression ex1)
310{
311 return new BinaryExpressionImpl(m_expression, ex1.m_expression,
312 BinaryExpressionImpl::LessOrEqualThan);
313}
314
315Expression Expression::
316gte(Expression ex1)
317{
318 return new BinaryExpressionImpl(m_expression, ex1.m_expression,
319 BinaryExpressionImpl::GreaterOrEqualThan);
320}
321Expression Expression::
322eand(Expression ex1)
323{
324 return new BinaryExpressionImpl(m_expression, ex1.m_expression,
325 BinaryExpressionImpl::And);
326}
327Expression Expression::
328eor(Expression ex1)
329{
330 return new BinaryExpressionImpl(m_expression, ex1.m_expression,
331 BinaryExpressionImpl::Or);
332}
333
334/*---------------------------------------------------------------------------*/
335/*---------------------------------------------------------------------------*/
336
337Expression Expression::
338minimum(Expression ex1)
339{
340 return new BinaryExpressionImpl(m_expression,
341 ex1.m_expression,
342 BinaryExpressionImpl::Minimum);
343}
344
345Expression Expression::
346maximum(Expression ex1)
347{
348 return new BinaryExpressionImpl(m_expression,
349 ex1.m_expression,
350 BinaryExpressionImpl::Maximum);
351}
352
353Expression Expression::
354pow(Expression ex1)
355{
356 return new BinaryExpressionImpl(m_expression,
357 ex1.m_expression,
358 BinaryExpressionImpl::Pow);
359}
360
361/*---------------------------------------------------------------------------*/
362/*---------------------------------------------------------------------------*/
363
364Expression Expression::
365ifelse(Expression ex1,Expression ex2)
366{
367 return new WhereExpressionImpl(m_expression,
368 ex1.m_expression,
369 ex2.m_expression);
370}
371
372/*---------------------------------------------------------------------------*/
373/*---------------------------------------------------------------------------*/
374
375Expression Expression::
376literal(Real v)
377{
378 return new LitteralExpressionImpl(v);
379}
380
381/*---------------------------------------------------------------------------*/
382/*---------------------------------------------------------------------------*/
383
384void Expression::
385setTrace(bool v)
386{
387 m_expression->setTrace(v);
388}
389
390unsigned long Expression::
391vectorSize()
392{
393 return m_expression->vectorSize();
394}
395
396/*---------------------------------------------------------------------------*/
397/*---------------------------------------------------------------------------*/
398
399ARCANE_END_NAMESPACE
400
401/*---------------------------------------------------------------------------*/
402/*---------------------------------------------------------------------------*/
Référence à une expression.
Definition Expression.h:43
Expression()
Constructeur par défaut.
Definition Expression.cc:37
Interface pour les différentes implémentations d'une expression.
virtual Integer vectorSize() const =0
Nombre d'éléments du vecteur.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Implementation d'une expression litterale contenant un scalaire.