Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
UnaryExpressionImpl.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/* UnaryExpressionImpl.cc (C) 2000-2007 */
9/* */
10/* Implementation of a unary expression. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/expr/UnaryExpressionImpl.h"
17#include "arcane/expr/OperatorMng.h"
18#include "arcane/expr/BadOperationException.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29UnaryExpressionImpl::
30UnaryExpressionImpl(IExpressionImpl* first, eOperationType operation)
32, m_first(first)
33, m_operation(operation)
34{
35}
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40String UnaryExpressionImpl::
41operationName(eOperationType type)
42{
43 switch (type) {
44 case UnarySubstract:
45 return "UnarySubstract";
46 case Inverse:
47 return "Inverse";
48 case Acos:
49 return "Acos";
50 case Asin:
51 return "Asin";
52 case Atan:
53 return "Atan";
54 case Ceil:
55 return "Ceil";
56 case Cos:
57 return "Cos";
58 case Cosh:
59 return "Cosh";
60 case Exp:
61 return "Exp";
62 case Fabs:
63 return "Fabs";
64 case Floor:
65 return "Floor";
66 case Log:
67 return "Log";
68 case Log10:
69 return "Log10";
70 case Sin:
71 return "Sin";
72 case Sinh:
73 return "Sinh";
74 case Sqrt:
75 return "Sqrt";
76 case Tan:
77 return "Tan";
78 case Tanh:
79 return "Tanh";
80 default:
81 return "Unknown";
82 }
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88void UnaryExpressionImpl::
89apply(ExpressionResult* result)
90{
91 /*
92 cerr << ">> BEGIN UNARY EXPRESSION "
93 << operationName() << " [" << *result << "]\n";
94 */
95
96 // calculate the expression
97 ExpressionResult first_op(result->indices());
98 m_first->apply(&first_op);
99
100 // search for the operator based on the expected type in the result
101 VariantBase::eType type = first_op.data()->type();
102 UnaryOperator* op = m_op_mng->find(this, type, m_operation);
103 if (!op)
104 throw BadOperationException("UnaryExpressionImpl::apply", operationName(), type);
105
106 op->evaluate(result, first_op.data());
107
108 /*
109 cerr << "<< END UNARY EXPRESSION "
110 << operationName() << " [" << *result << "]\n";
111 */
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117} // namespace Arcane
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
Base class for the expression implementation.
Interface for the different implementations of an expression.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --