LifeV
EvaluationScalar.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 EvaluationScalar class.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 
37 #ifndef EVALUATION_SCALAR_HPP
38 #define EVALUATION_SCALAR_HPP
39 
40 #include <lifev/core/LifeV.hpp>
41 
42 #include <lifev/eta/fem/ETCurrentFE.hpp>
43 #include <lifev/eta/fem/ETCurrentFlag.hpp>
44 #include <lifev/core/fem/QuadratureRule.hpp>
45 
46 #include <lifev/eta/expression/ExpressionScalar.hpp>
47 
48 
49 namespace LifeV
50 {
51 
52 namespace ExpressionAssembly
53 {
54 
55 //! Evaluation for a scalar constant
56 /*!
57  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
58 
59  This class aims at representing a scalar constant 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 class EvaluationScalar
65 {
66 public:
67 
68  //! @name Public Types
69  //@{
70 
71  //! Type returned by this class
72  typedef Real return_Type;
73 
74  //@}
75 
76 
77  //! @name Static constants
78  //@{
79 
80  //! Flag for the global current FE
81  const static flag_Type S_globalUpdateFlag = ET_UPDATE_NONE;
82 
83  //! Flag for the test current FE
84  const static flag_Type S_testUpdateFlag = ET_UPDATE_NONE;
85 
86  //! Flag for the solution current FE
87  const static flag_Type S_solutionUpdateFlag = ET_UPDATE_NONE;
88 
89  //@}
90 
91 
92  //! @name Constructors, destructor
93  //@{
94 
95  //! Empty constructor
96  EvaluationScalar()
97  {}
98 
99  //! Copy constructor
100  EvaluationScalar (const EvaluationScalar& evaluation)
101  : M_value (evaluation.M_value)
102  {}
103 
104  //! Expression-based constructor
105  explicit EvaluationScalar (const ExpressionScalar& expression)
106  : M_value (expression.value() )
107  {}
108 
109  //! Destructor
110  ~EvaluationScalar()
111  {}
112 
113  //@}
114 
115 
116  //! @name Methods
117  //@{
118 
119  //! Do nothing internal update
120  void update (const UInt& /*iElement*/)
121  {}
122 
123  //! Display method
124  static void display (std::ostream& out = std::cout)
125  {
126  out << "scalar";
127  }
128 
129  //@}
130 
131 
132  //! @name Set Methods
133  //@{
134 
135  //! Do nothing setter for the global current FE
136  template< typename CFEType >
137  void setGlobalCFE (const CFEType* /*globalCFE*/)
138  {}
139 
140  //! Do nothing setter for the test current FE
141  template< typename CFEType >
142  void setTestCFE (const CFEType* /*testCFE*/)
143  {}
144 
145  //! Do nothing setter for the solution current FE
146  template< typename CFEType >
147  void setSolutionCFE (const CFEType* /*solutionCFE*/)
148  {}
149 
150  //! Do nothing setter for the quadrature rule
151  void setQuadrature (const QuadratureRule&)
152  {}
153 
154  //@}
155 
156 
157  //! @name Get Methods
158  //@{
159 
160  //! Getter for a value
161  return_Type value_q (const UInt& /*q*/) const
162  {
163  return M_value;
164  }
165 
166  //! Getter for the value for a vector
167  return_Type value_qi (const UInt& /*q*/, const UInt& /*i*/) const
168  {
169  return M_value;
170  }
171 
172  //! Getter for the value for a matrix
173  return_Type value_qij (const UInt& /*q*/, const UInt& /*i*/, const UInt& /*j*/) const
174  {
175  return M_value;
176  }
177 
178  //@}
179 
180 private:
181 
182  // Value stored
183  Real M_value;
184 };
185 
186 
187 template <typename VectorType>
188 class EvaluationExtractScalar
189 {
190 public:
191 
192  //! @name Public Types
193  //@{
194 
195  //! Type returned by this class
196  typedef Real return_Type;
197  typedef std::shared_ptr<VectorType> containerPtr_Type;
198  //@}
199 
200 
201  //! @name Static constants
202  //@{
203 
204  //! Flag for the global current FE
205  const static flag_Type S_globalUpdateFlag = ET_UPDATE_NONE;
206 
207  //! Flag for the test current FE
208  const static flag_Type S_testUpdateFlag = ET_UPDATE_NONE;
209 
210  //! Flag for the solution current FE
211  const static flag_Type S_solutionUpdateFlag = ET_UPDATE_NONE;
212 
213  //@}
214 
215 
216  //! @name Constructors, destructor
217  //@{
218 
219  //! Empty constructor
220  EvaluationExtractScalar()
221  {}
222 
223  //! Copy constructor
224  EvaluationExtractScalar (const EvaluationExtractScalar& evaluation)
225  : M_vector (evaluation.M_vector)
226  {}
227 
228  //! Expression-based constructor
229  template<typename Vector>
230  explicit EvaluationExtractScalar (const ExpressionExtractScalar<Vector>& expression)
231  : M_vector ( expression.vector() )
232  {}
233 
234  //! Destructor
235  ~EvaluationExtractScalar()
236  {}
237 
238  //@}
239 
240 
241  //! @name Methods
242  //@{
243 
244  //! Do nothing internal update
245  void update (const UInt& iElement)
246  {
247  M_value = 0;
248  M_value = (*M_vector) [ iElement ];
249  }
250 
251  //! Display method
252  static void display (std::ostream& out = std::cout)
253  {
254  out << "scalar from a vector";
255  }
256 
257  //@}
258 
259 
260  //! @name Set Methods
261  //@{
262 
263  //! Do nothing setter for the global current FE
264  template< typename CFEType >
265  void setGlobalCFE (const CFEType* /*globalCFE*/)
266  {}
267 
268  //! Do nothing setter for the test current FE
269  template< typename CFEType >
270  void setTestCFE (const CFEType* /*testCFE*/)
271  {}
272 
273  //! Do nothing setter for the solution current FE
274  template< typename CFEType >
275  void setSolutionCFE (const CFEType* /*solutionCFE*/)
276  {}
277 
278  //! Do nothing setter for the quadrature rule
279  void setQuadrature (const QuadratureRule&)
280  {}
281 
282  //@}
283 
284 
285  //! @name Get Methods
286  //@{
287 
288  //! Getter for a value
289  return_Type value_q (const UInt& /*q*/) const
290  {
291  return M_value;
292  }
293 
294  //! Getter for the value for a vector
295  return_Type value_qi (const UInt& /*q*/, const UInt& /*i*/) const
296  {
297  return M_value;
298  }
299 
300  //! Getter for the value for a matrix
301  return_Type value_qij (const UInt& /*q*/, const UInt& /*i*/, const UInt& /*j*/) const
302  {
303  return M_value;
304  }
305 
306  //@}
307 
308 private:
309 
310  // Value stored
311  Real M_value;
312 
313  // new members
314  containerPtr_Type M_vector;
315 
316 };
317 
318 
319 } // Namespace ExpressionAssembly
320 
321 } // Namespace LifeV
322 #endif
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
void updateInverseJacobian(const UInt &iQuadPt)
double Real
Generic real data.
Definition: LifeV.hpp:175
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191