LifeV
EvaluationSubstraction.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 EvaluationSubstraction class.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 
37 #ifndef EVALUTATION_SUBSTRACTION_HPP
38 #define EVALUTATION_SUBSTRACTION_HPP
39 
40 #include <lifev/core/LifeV.hpp>
41 
42 #include <lifev/eta/array/OperationSmallSubstraction.hpp>
43 
44 #include <lifev/eta/expression/ExpressionSubstraction.hpp>
45 
46 #include <lifev/core/fem/QuadratureRule.hpp>
47 
48 namespace LifeV
49 {
50 
51 namespace ExpressionAssembly
52 {
53 
54 //! Evaluation for the difference of two other Evaluations
55 /*!
56  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
57 
58  This class aims at representing a substraction operation during the assembly
59 
60  This class is an Evaluation class, and therefore, has all the methods
61  required to work within the Evaluation trees.
62  */
63 template <typename EvaluationLType, typename EvaluationRType>
64 class EvaluationSubstraction
65 {
66 public:
67 
68  //! @name Public Types
69  //@{
70 
71  //! Type of the value returned by the left operand
72  typedef typename EvaluationLType::return_Type Lreturn_Type;
73 
74  //! Type of the value returned by the right operand
75  typedef typename EvaluationRType::return_Type Rreturn_Type;
76 
77  //! Type of the value returned by this class
78  typedef typename OperationSmallSubstraction<Lreturn_Type, Rreturn_Type>::result_Type return_Type;
79 
80  //@}
81 
82 
83  //! @name Static constants
84  //@{
85 
86  //! Flag for the global current FE
87  const static flag_Type S_globalUpdateFlag;
88 
89  //! Flag for the test current FE
90  const static flag_Type S_testUpdateFlag;
91 
92  //! Flag for the solution current FE
93  const static flag_Type S_solutionUpdateFlag;
94 
95  //@}
96 
97 
98  //! @name Constructors, destructor
99  //@{
100 
101  //! Copy constructor
102  EvaluationSubstraction (const EvaluationSubstraction& eval)
103  : M_evaluationL (eval.M_evaluationL),
104  M_evaluationR (eval.M_evaluationR)
105  {}
106 
107  //! Constructor from the corresponding expression
108  template <typename L, typename R>
109  explicit EvaluationSubstraction (const ExpressionSubstraction<L, R>& expression)
110  : M_evaluationL (expression.left() ),
111  M_evaluationR (expression.right() )
112  {}
113 
114  //! Destructor
115  ~EvaluationSubstraction() {}
116 
117  //@}
118 
119 
120  //! @name Methods
121  //@{
122 
123  //! Internal update method
124  void update (const UInt& iElement)
125  {
126  M_evaluationL.update (iElement);
127  M_evaluationR.update (iElement);
128  }
129 
130  //! Display method
131  static void display ( std::ostream& out = std::cout)
132  {
133  EvaluationLType::display (out);
134  out << " - ";
135  EvaluationRType::display (out);
136  }
137 
138  //@}
139 
140 
141  //! @name Set Methods
142  //@{
143 
144  //! Setter for the global current FE
145  template< typename CFEType >
146  void setGlobalCFE (const CFEType* globalCFE)
147  {
148  M_evaluationL.setGlobalCFE (globalCFE);
149  M_evaluationR.setGlobalCFE (globalCFE);
150  }
151 
152  //! Setter for the test current FE
153  template< typename CFEType >
154  void setTestCFE (const CFEType* testCFE)
155  {
156  M_evaluationL.setTestCFE (testCFE);
157  M_evaluationR.setTestCFE (testCFE);
158  }
159 
160  //! Setter for the solution current FE
161  template< typename CFEType >
162  void setSolutionCFE (const CFEType* solutionCFE)
163  {
164  M_evaluationL.setSolutionCFE (solutionCFE);
165  M_evaluationR.setSolutionCFE (solutionCFE);
166  }
167 
168  //! Setter for the quadrature rule
169  void setQuadrature (const QuadratureRule& qr)
170  {
171  M_evaluationL.setQuadrature (qr);
172  M_evaluationR.setQuadrature (qr);
173  }
174 
175  //@}
176 
177 
178  //! @name Get Methods
179  //@{
180 
181  //! Getter for a value
182  return_Type value_q (const UInt& q) const
183  {
184  return M_evaluationL.value_q (q) - M_evaluationR.value_q (q);
185  }
186 
187  //! Getter for the value for a vector
188  return_Type value_qi (const UInt& q, const UInt& i) const
189  {
190  return M_evaluationL.value_qi (q, i) - M_evaluationR.value_qi (q, i);
191  }
192 
193  //! Getter for the value for a matrix
194  return_Type value_qij (const UInt& q, const UInt& i, const UInt& j) const
195  {
196  return M_evaluationL.value_qij (q, i, j) - M_evaluationR.value_qij (q, i, j);
197  }
198 
199  //@}
200 
201 private:
202 
203  //! @name Private Methods
204  //@{
205 
206  //! No empty constructor
207  EvaluationSubstraction();
208 
209  //@}
210 
211  // Internal storage
212  EvaluationLType M_evaluationL;
213  EvaluationRType M_evaluationR;
214 };
215 
216 
217 template< typename EvaluationLType, typename EvaluationRType>
218 const flag_Type EvaluationSubstraction<EvaluationLType, EvaluationRType>::S_globalUpdateFlag
219  = EvaluationLType::S_globalUpdateFlag | EvaluationRType::S_globalUpdateFlag;
220 
221 template< typename EvaluationLType, typename EvaluationRType>
222 const flag_Type EvaluationSubstraction<EvaluationLType, EvaluationRType>::S_testUpdateFlag
223  = EvaluationLType::S_testUpdateFlag | EvaluationRType::S_testUpdateFlag;
224 
225 template< typename EvaluationLType, typename EvaluationRType>
226 const flag_Type EvaluationSubstraction<EvaluationLType, EvaluationRType>::S_solutionUpdateFlag
227  = EvaluationLType::S_solutionUpdateFlag | EvaluationRType::S_solutionUpdateFlag;
228 
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 OperationSmallSubstraction Class containing information about the substraction operation betwee...
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191