LifeV
EvaluationAddition.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory UNiversity
7 
8  This file is part of the LifeV library
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, see <http://www.gnu.org/licenses/>
22 
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 /*!
29  * @file
30  @brief This file contains the definition of the EvaluationAddition class.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 #ifndef EVALUTATION_ADDITION_HPP
37 #define EVALUTATION_ADDITION_HPP
38 
39 
40 #include <lifev/core/LifeV.hpp>
41 
42 #include <lifev/eta/array/OperationSmallAddition.hpp>
43 
44 #include <lifev/eta/expression/ExpressionAddition.hpp>
45 
46 #include <lifev/core/fem/QuadratureRule.hpp>
47 
48 
49 namespace LifeV
50 {
51 
52 namespace ExpressionAssembly
53 {
54 
55 //! Evaluation for the addition of two other Evaluations
56 /*!
57  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
58 
59  This class aims at representing an addition operation during the assembly
60 
61  This class is an Evaluation class, and therefore, has all the methods
62  required to work within the Evaluation trees.
63  */
64 template <typename EvaluationLType, typename EvaluationRType>
65 class EvaluationAddition
66 {
67 public:
68 
69  //! @name Public Types
70  //@{
71 
72  //! Type of the value returned by the left operand
73  typedef typename EvaluationLType::return_Type Lreturn_Type;
74 
75  //! Type of the value returned by the right operand
76  typedef typename EvaluationRType::return_Type Rreturn_Type;
77 
78  //! Type of the value returned by this class
79  typedef typename OperationSmallAddition< Lreturn_Type, Rreturn_Type >::result_Type return_Type;
80 
81  //@}
82 
83 
84  //! @name Static constants
85  //@{
86 
87  //! Flag for the global current FE
88  const static flag_Type S_globalUpdateFlag;
89 
90  //! Flag for the test current FE
91  const static flag_Type S_testUpdateFlag;
92 
93  //! Flag for the solution current FE
94  const static flag_Type S_solutionUpdateFlag;
95 
96  //@}
97 
98 
99  //! @name Constructors, destructor
100  //@{
101 
102  //! Copy constructor
103  EvaluationAddition (const EvaluationAddition& eval)
104  : M_evaluationL (eval.M_evaluationL),
105  M_evaluationR (eval.M_evaluationR)
106  {}
107 
108  //! Constructor from the corresponding expression
109  template< typename ExpressionL, typename ExpressionR>
110  explicit EvaluationAddition (const ExpressionAddition<ExpressionL, ExpressionR>& expression)
111  : M_evaluationL (expression.left() ),
112  M_evaluationR (expression.right() )
113  {}
114 
115  //! Destructor
116  ~EvaluationAddition() {}
117 
118  //@}
119 
120 
121  //! @name Methods
122  //@{
123 
124  //! Internal update method
125  void update (const UInt& iElement)
126  {
127  M_evaluationL.update (iElement);
128  M_evaluationR.update (iElement);
129  }
130 
131  //! Display method
132  static void display (std::ostream& out = std::cout)
133  {
134  EvaluationLType::display (out);
135  out << " + ";
136  EvaluationRType::display (out);
137  }
138 
139  //@}
140 
141 
142  //! @name Set Methods
143  //@{
144 
145  //! Setter for the global current FE
146  template< typename CFEType >
147  void setGlobalCFE (const CFEType* globalCFE)
148  {
149  M_evaluationL.setGlobalCFE (globalCFE);
150  M_evaluationR.setGlobalCFE (globalCFE);
151  }
152 
153  //! Setter for the test current FE
154  template< typename CFEType >
155  void setTestCFE (const CFEType* testCFE)
156  {
157  M_evaluationL.setTestCFE (testCFE);
158  M_evaluationR.setTestCFE (testCFE);
159  }
160 
161  //! Setter for the solution current FE
162  template< typename CFEType >
163  void setSolutionCFE (const CFEType* solutionCFE)
164  {
165  M_evaluationL.setSolutionCFE (solutionCFE);
166  M_evaluationR.setSolutionCFE (solutionCFE);
167  }
168 
169  //! Setter for the quadrature
170  void setQuadrature (const QuadratureRule& qr)
171  {
172  M_evaluationL.setQuadrature (qr);
173  M_evaluationR.setQuadrature (qr);
174  }
175 
176  //@}
177 
178 
179  //! @name Get Methods
180  //@{
181 
182  //! Getter for a value
183  return_Type value_q (const UInt& q) const
184  {
185  return M_evaluationL.value_q (q) + M_evaluationR.value_q (q);
186  }
187 
188  //! Getter for the value for a vector
189  return_Type value_qi (const UInt& q, const UInt& i) const
190  {
191  return M_evaluationL.value_qi (q, i) + M_evaluationR.value_qi (q, i);
192  }
193 
194  //! Getter for the value for a matrix
195  return_Type value_qij (const UInt& q, const UInt& i, const UInt& j) const
196  {
197  return M_evaluationL.value_qij (q, i, j) + M_evaluationR.value_qij (q, i, j);
198  }
199 
200  //@}
201 
202 private:
203 
204  //! @name Private Methods
205  //@{
206 
207  //! No empty constructor
208  EvaluationAddition();
209 
210  //@}
211 
212  // Internal storage
213  EvaluationLType M_evaluationL;
214  EvaluationRType M_evaluationR;
215 };
216 
217 
218 template<typename EvaluationLType, typename EvaluationRType>
219 const flag_Type EvaluationAddition<EvaluationLType, EvaluationRType>::S_globalUpdateFlag
220  = EvaluationLType::S_globalUpdateFlag | EvaluationRType::S_globalUpdateFlag;
221 
222 template<typename EvaluationLType, typename EvaluationRType>
223 const flag_Type EvaluationAddition<EvaluationLType, EvaluationRType>::S_testUpdateFlag
224  = EvaluationLType::S_testUpdateFlag | EvaluationRType::S_testUpdateFlag;
225 
226 template<typename EvaluationLType, typename EvaluationRType>
227 const flag_Type EvaluationAddition<EvaluationLType, EvaluationRType>::S_solutionUpdateFlag
228  = EvaluationLType::S_solutionUpdateFlag | EvaluationRType::S_solutionUpdateFlag;
229 
230 } // namespace ExpressionAssembly
231 
232 } // namespace LifeV
233 #endif
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
void updateInverseJacobian(const UInt &iQuadPt)
class OperationSmallAddition Class containing information about the addition operation between the *S...
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191