Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ExpressionImpl.cc
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/* ExpressionImpl.cc (C) 2000-2014 */
9/* */
10/* Implementation of an expression. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/Iostream.h"
15#include "arcane/utils/Array.h"
16#include "arcane/expr/ExpressionImpl.h"
17#include "arcane/expr/OperatorMng.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28ExpressionImpl::
29ExpressionImpl()
30: m_op_mng(OperatorMng::instance())
31, m_nb_reference(0)
32, m_do_trace(false)
33{
34}
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39void ExpressionImpl::
40addRef()
41{
42 ++m_nb_reference;
43}
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48void ExpressionImpl::
49removeRef()
50{
51 --m_nb_reference;
52 if (m_nb_reference == 0) {
53 //cout << "** DELETE\n";
54 delete this;
55 }
56}
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
65void ExpressionImpl::
66dumpIf(IExpressionImpl* test_expr, Array<Expression>& add_exprs)
67{
68 UniqueArray<Expression> exprs(add_exprs.size() + 1);
69 exprs[0] = this;
70 for (Integer i = 0; i < add_exprs.size(); ++i)
71 exprs[i + 1] = add_exprs[i];
72
73 Integer size = vectorSize();
74 UniqueArray<bool> test_values(size);
75 // Le variant appartient ensuite à résult qui le détruira
76 ArrayVariant* test_variant = new ArrayVariant(test_values);
77 ExpressionResult test_expr_result(test_variant);
78
79 test_expr->apply(&test_expr_result);
80
81 Integer nb_expr = exprs.size();
82 SharedArray<SharedArray<Real>> display_values(nb_expr);
83 for (Integer i = 0; i < nb_expr; ++i) {
84 display_values[i].resize(size);
85 ArrayVariant* expr_variant = new ArrayVariant(display_values[i]);
86 ExpressionResult expr_result(expr_variant);
87 exprs[i]->apply(&expr_result);
88 }
89
90 cout.flags(std::ios::scientific);
91 std::streamsize ss = std::cout.precision();
92 cout.precision(10);
93
94 for (Integer i = 0; i < size; ++i) {
95 if (test_values[i]) {
96 cout << "valeur [" << i << "] ";
97 for (Integer j = 0; j < nb_expr; ++j) {
98 cout << ' ' << display_values[j][i];
99 }
100 cout << '\n';
101 }
102 }
103 std::cout.precision(ss);
104}
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109} // namespace Arcane
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
Integer size() const
Number of elements in the vector.
Polymorphic base type for arrays (dimension 1).
Base class for 1D data vectors.
void resize(Int64 s)
Changes the number of elements in the array to s.
Polymorphic base type of an expression.
Interface for the different implementations of an expression.
virtual Integer vectorSize() const =0
Number of elements in the vector.
Stores all possible operator types on expressions.
Definition OperatorMng.h:41
1D vector of data with reference semantics.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.