LifeV
EvaluationScalarToVector.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  *
30  @file
31  @brief This file contains the definition of the EvaluationScalarToVector class.
32 
33  @date 02/2014
34  @author Davide Forti <davide.forti@epfl.ch>
35  */
36 
37 #ifndef EVALUTATION_SCALARTOVECTOR_HPP
38 #define EVALUTATION_SCALARTOVECTOR_HPP
39 
40 
41 #include <lifev/core/LifeV.hpp>
42 
43 #include <lifev/core/array/VectorSmall.hpp>
44 
45 #include <lifev/eta/expression/ExpressionScalarToVector.hpp>
46 
47 #include <lifev/core/fem/QuadratureRule.hpp>
48 
49 namespace LifeV
50 {
51 
52 namespace ExpressionAssembly
53 {
54 
55 //! Evaluation for the transpose of another Evaluation
56 /*!
57  @author Davide Forti <davide.forti@epfl.ch>
58 
59  */
60 
61 template <typename EvaluationType, UInt FieldDim>
62 class EvaluationScalarToVector
63 {
64 public:
65 
66 
67  //! @name Public Types
68  //@{
69 
70  //! Type of the value returned by the 'operand' to be transposed
71  // typedef typename EvaluationType::return_Type return_Type;
72 
73  //! Type of the value returned by this class
74  // NOTE: specialized for 3d problems
75  typedef VectorSmall<FieldDim> return_Type;
76 
77  //@}
78 
79 
80  //! @name Static constants
81  //@{
82 
83  //! Flag for the global current FE
84  const static flag_Type S_globalUpdateFlag;
85 
86  //! Flag for the test current FE
87  const static flag_Type S_testUpdateFlag;
88 
89  //! Flag for the solution current FE
90  const static flag_Type S_solutionUpdateFlag;
91 
92  //@}
93 
94 
95  //! @name Constructors, destructor
96  //@{
97 
98  //! Copy constructor
99  EvaluationScalarToVector (const EvaluationScalarToVector& eval)
100  : M_evaluation1 (eval.M_evaluation1),
101  M_evaluation2 (eval.M_evaluation2),
102  M_evaluation3 (eval.M_evaluation3),
103  M_outputVector ( )
104  {}
105 
106  //! Constructor from the corresponding expression
107  template< typename Expression>
108  explicit EvaluationScalarToVector (const ExpressionScalarToVector<Expression, FieldDim>& expression)
109  : M_evaluation1 (expression.exprEx1() ),
110  M_evaluation2 (expression.exprEx2() ),
111  M_evaluation3 (expression.exprEx3() ),
112  M_outputVector ( )
113  {}
114 
115  //! Destructor
116  ~EvaluationScalarToVector()
117  {}
118 
119  //@}
120 
121 
122  //! @name Methods
123  //@{
124 
125  //! Internal update method
126  void update (const UInt& iElement)
127  {
128  M_evaluation1.update (iElement);
129  M_evaluation2.update (iElement);
130  M_evaluation3.update (iElement);
131  }
132 
133  //! Display method
134  static void display (std::ostream& out = std::cout)
135  {
136  out << " vector from scalar expression ";
137  EvaluationType::display (out);
138  }
139 
140  //@}
141 
142 
143  //! @name Set Methods
144  //@{
145 
146  //! Setter for the global current FE
147  template< typename CFEType >
148  void setGlobalCFE (const CFEType* globalCFE)
149  {
150  M_evaluation1.setGlobalCFE (globalCFE);
151  M_evaluation2.setGlobalCFE (globalCFE);
152  M_evaluation3.setGlobalCFE (globalCFE);
153  }
154 
155  //! Setter for the test current FE
156  template< typename CFEType >
157  void setTestCFE (const CFEType* testCFE)
158  {
159  M_evaluation1.setTestCFE (testCFE);
160  M_evaluation2.setTestCFE (testCFE);
161  M_evaluation3.setTestCFE (testCFE);
162  }
163 
164  //! Setter for the solution FE
165  template< typename CFEType >
166  void setSolutionCFE (const CFEType* solutionCFE)
167  {
168  M_evaluation1.setSolutionCFE (solutionCFE);
169  M_evaluation2.setSolutionCFE (solutionCFE);
170  M_evaluation3.setSolutionCFE (solutionCFE);
171  }
172 
173  //! Setter for the quadrature rule
174  void setQuadrature (const QuadratureRule& qr)
175  {
176  M_evaluation1.setQuadrature (qr);
177  M_evaluation2.setQuadrature (qr);
178  M_evaluation3.setQuadrature (qr);
179  }
180 
181  //@}
182 
183 
184  //! @name Get Methods
185  //@{
186 
187  //! Getter for a value
188  return_Type value_q (const UInt& q) const
189  {
190  M_outputVector[0] = M_evaluation1.value_q( q ) ;
191  M_outputVector[1] = M_evaluation2.value_q( q ) ;
192  M_outputVector[2] = M_evaluation3.value_q( q ) ;
193  return M_outputVector;
194  }
195 
196  //! Getter for the value for a vector
197  return_Type value_qi (const UInt& q, const UInt& i) const
198  {
199 
200  M_outputVector[0] = M_evaluation1.value_q( q ,i) ;
201  M_outputVector[1] = M_evaluation2.value_q( q ,i) ;
202  M_outputVector[2] = M_evaluation3.value_q( q ,i) ;
203  return M_outputVector;
204  }
205 
206  //! Getter for the value for a matrix
207  return_Type value_qij (const UInt& q, const UInt& i, const UInt& j) const
208  {
209  M_outputVector[0] = M_evaluation1.value_q( q,i,j ) ;
210  M_outputVector[1] = M_evaluation2.value_q( q,i,j ) ;
211  M_outputVector[2] = M_evaluation3.value_q( q,i,j ) ;
212  return M_outputVector;
213  }
214 
215  //@}
216 
217 private:
218 
219  //! @name Private Methods
220  //@{
221 
222  //! No default
223  EvaluationScalarToVector();
224 
225  //@}
226 
227  // Internal storage
228  EvaluationType M_evaluation1;
229  EvaluationType M_evaluation2;
230  EvaluationType M_evaluation3;
231  VectorSmall<FieldDim> M_outputVector;
232 };
233 
234 
235 
236 template< typename EvaluationType, UInt FieldDim >
237 const flag_Type EvaluationScalarToVector<EvaluationType, FieldDim>::S_globalUpdateFlag
238 = EvaluationType::S_globalUpdateFlag;
239 
240 template< typename EvaluationType, UInt FieldDim >
241 const flag_Type EvaluationScalarToVector<EvaluationType, FieldDim>::S_testUpdateFlag
242 = EvaluationType::S_testUpdateFlag;
243 
244 template< typename EvaluationType, UInt FieldDim >
245 const flag_Type EvaluationScalarToVector<EvaluationType, FieldDim>::S_solutionUpdateFlag
246 = EvaluationType::S_solutionUpdateFlag;
247 
248 } // Namespace ExpressionAssembly
249 
250 } // Namespace LifeV
251 #endif
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
void updateInverseJacobian(const UInt &iQuadPt)
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191