LifeV
EvaluationPatchArea.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 EvaluationInterpolateValue class.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 #ifndef EVALUATION_PATCHAREA_HPP
37 #define EVALUATION_PATCHAREA_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/core/array/VectorEpetra.hpp>
42 #include <lifev/core/array/VectorSmall.hpp>
43 
44 #include <lifev/eta/fem/ETCurrentFE.hpp>
45 #include <lifev/eta/fem/ETCurrentFlag.hpp>
46 #include <lifev/eta/fem/ETFESpace.hpp>
47 #include <lifev/core/fem/QuadratureRule.hpp>
48 
49 #include <lifev/eta/expression/ExpressionInterpolateValue.hpp>
50 
51 #include <boost/shared_ptr.hpp>
52 
53 
54 namespace LifeV
55 {
56 
57 namespace ExpressionAssembly
58 {
59 
60 //! Evaluation for the interpolation of a FE function
61 /*!
62  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
63 
64  This class aims at representing an interpolated FE value.
65 
66  This is the generic implementation, so representing a vectorial FE
67 
68  This class is an Evaluation class, and therefore, has all the methods
69  required to work within the Evaluation trees.
70  */
71 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
72 class EvaluationPatchArea
73 {
74 public:
75 
76  //! @name Public Types
77  //@{
78 
79  //! Type of the value returned by this class
80  typedef VectorSmall<FieldDim> return_Type;
81  typedef ETFESpace<MeshType, MapType, SpaceDim, FieldDim> ETFESpace_Type;
82  typedef boost::shared_ptr<ETFESpace_Type> ETFESpacePtr_Type;
83  //@}
84 
85 
86  //! @name Static constants
87  //@{
88 
89  //! Flag for the global current FE
90  const static flag_Type S_globalUpdateFlag;
91 
92  //! Flag for the test current FE
93  const static flag_Type S_testUpdateFlag;
94 
95  //! Flag for the solution current FE
96  const static flag_Type S_solutionUpdateFlag;
97 
98  //@}
99 
100 
101  //! @name Constructors, destructor
102  //@{
103 
104  //! Copy constructor
105  EvaluationPatchArea (const EvaluationPatchArea& evaluation)
106  :
107  M_fespace ( evaluation.M_fespace),
108  M_quadrature (0),
109  //M_currentFE(M_fespace->refFE(),M_fespace->geoMap()),
110  M_currentFE (evaluation.M_currentFE),
111  M_patchArea (evaluation.M_patchArea)
112  {
113  if (evaluation.M_quadrature != 0)
114  {
115  M_quadrature = new QuadratureRule (* (evaluation.M_quadrature) );
116  //M_currentFE.setQuadratureRule(*(evaluation.M_quadrature));
117  }
118  }
119 
120  //! Expression-based constructor
121  explicit EvaluationPatchArea (const ExpressionPatchArea<MeshType, MapType, SpaceDim, FieldDim>& expression)
122  :
123  M_fespace ( expression.fespace() ),
124  M_quadrature (0),
125  M_currentFE (M_fespace->refFE(), M_fespace->geoMap() ),
126  M_patchArea (0)
127  {}
128 
129  //! Destructor
130  ~EvaluationPatchArea()
131  {
132  if (M_quadrature != 0)
133  {
134  delete M_quadrature;
135  }
136  }
137 
138  //@}
139 
140 
141  //! @name Methods
142  //@{
143 
144  //! Interal update, computes the interpolated values.
145  void update (const UInt& iElement)
146  {
147  zero();
148 
149  M_currentFE.update (M_fespace->mesh()->element (iElement), ET_UPDATE_DPHI | ET_UPDATE_WDET );
150 
151  std::cout << "Measure! "<< M_currentFE.measure() << std::endl;
152  int n;
153  std::cin >> n;
154 
155  for (UInt q (0); q < M_quadrature->nbQuadPt(); ++q)
156  {
157  for (UInt iDim (0); iDim < FieldDim; ++iDim)
158  {
159  M_patchArea[q][iDim] += M_currentFE.measure();
160  }
161  }
162  }
163 
164 
165  //! Erase all the interpolated values stored internally
166  void zero()
167  {
168  for (UInt q (0); q < M_quadrature->nbQuadPt(); ++q)
169  {
170  for (UInt iDim (0); iDim < FieldDim; ++iDim)
171  {
172  M_patchArea[q][iDim] = 0.0;
173  }
174  }
175  }
176 
177  //! Show the values interpolated
178  void showValues() const
179  {
180  std::cout << " Values : " << std::endl;
181 
182  for (UInt i (0); i < M_quadrature->nbQuadPt(); ++i)
183  {
184  std::cout << M_patchArea[i] << std::endl;
185  }
186  }
187 
188  //! Display method
189  static void display (std::ostream& out = std::cout)
190  {
191  out << "patchAread" << "\n";
192  }
193 
194  //@}
195 
196 
197  //! @name Set Methods
198  //@{
199 
200  //! Do nothing setter for the global current FE
201  template< typename CFEType >
202  void setGlobalCFE (const CFEType* /*globalCFE*/)
203  {}
204 
205  //! Do nothing setter for the test current FE
206  template< typename CFEType >
207  void setTestCFE (const CFEType* /*testCFE*/)
208  {}
209 
210  //! Do nothing setter for the solution current FE
211  template< typename CFEType >
212  void setSolutionCFE (const CFEType* /*solutionCFE*/)
213  {}
214 
215  //! Setter for the quadrature rule (deep copy)
216  void setQuadrature (const QuadratureRule& qr)
217  {
218  if (M_quadrature != 0)
219  {
220  delete M_quadrature;
221  }
222  M_quadrature = new QuadratureRule (qr);
223  M_currentFE.setQuadratureRule (qr);
224  M_patchArea.resize (qr.nbQuadPt() );
225  }
226 
227  //@}
228 
229 
230  //! @name Get Methods
231  //@{
232 
233  //! Getter for a value
234  return_Type value_q (const UInt& q) const
235  {
236  return M_patchArea[q];
237  }
238 
239  //! Getter for the value for a vector
240  return_Type value_qi (const UInt& q, const UInt& /*i*/) const
241  {
242  return M_patchArea[q];
243  }
244 
245  //! Getter for the value for a matrix
246  return_Type value_qij (const UInt& q, const UInt& /*i*/, const UInt& /*j*/) const
247  {
248  return M_patchArea[q];
249  }
250 
251  //@}
252 
253 private:
254 
255  //! @name Private Methods
256  //@{
257 
258  //! No empty constructor
259  EvaluationPatchArea();
260 
261  //@}
262 
263  ETFESpacePtr_Type M_fespace;
264 
265  QuadratureRule* M_quadrature;
266  ETCurrentFE<SpaceDim, 1> M_currentFE;
267 
268  std::vector<return_Type> M_patchArea;
269 };
270 
271 
272 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
273 const flag_Type
274 EvaluationPatchArea<MeshType, MapType, SpaceDim, FieldDim>::
275 S_globalUpdateFlag = ET_UPDATE_NONE;
276 
277 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
278 const flag_Type
279 EvaluationPatchArea<MeshType, MapType, SpaceDim, FieldDim>::
280 S_testUpdateFlag = ET_UPDATE_NONE;
281 
282 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
283 const flag_Type
284 EvaluationPatchArea<MeshType, MapType, SpaceDim, FieldDim>::
285 S_solutionUpdateFlag = ET_UPDATE_NONE;
286 
287 } // Namespace ExpressionAssembly
288 
289 } // Namespace LifeV
290 #endif
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
QuadratureRule(const QuadratureRule &qr)
Copy constructor.
void updateInverseJacobian(const UInt &iQuadPt)
QuadratureRule - The basis class for storing and accessing quadrature rules.
const UInt & nbQuadPt() const
Getter for the number of quadrature points.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191