LifeV
EvaluateAtQuadraturePoint.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 evaluation of vectors at quadrature points.
31 
32  @date 06/2011
33  @author Davide Forti <davide.forti@epfl.ch>
34  */
35 
36 #ifndef EVALUATE_QUAD_PT_HPP
37 #define EVALUATE_QUAD_PT_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/core/fem/QuadratureRule.hpp>
42 #include <lifev/eta/fem/ETCurrentFE.hpp>
43 #include <lifev/eta/fem/MeshGeometricMap.hpp>
44 #include <lifev/eta/fem/QRAdapterBase.hpp>
45 
46 #include <lifev/eta/expression/ExpressionToEvaluation.hpp>
47 #include <lifev/eta/expression/EvaluationPhiI.hpp>
48 
49 #include <lifev/eta/array/ETVectorElemental.hpp>
50 
51 namespace LifeV
52 {
53 
54 namespace ExpressionAssembly
55 {
56 
57 //! The class to actually perform the loop over the elements to compute the stresses at the center of each element
58 /*!
59  @author Davide Forti <davide.forti@epfl.ch>
60 
61  */
62 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
64 {
65 public:
66 
67  //! @name Public Types
68  //@{
69 
70  //! Type of the Evaluation
71  typedef typename ExpressionToEvaluation < ExpressionType,
72  TestSpaceType::field_dim,
73  0,
74  MeshType::S_geoDimensions >::evaluation_Type evaluation_Type;
75 
76  //@}
77 
78 
79  //! @name Constructors, destructor
80  //@{
81 
82  //! Full data constructor
83  EvaluateAtQuadraturePoint (const std::shared_ptr<MeshType>& mesh,
84  const QRAdapterType& qrAdapter,
85  const std::shared_ptr<TestSpaceType>& testSpace,
86  const ExpressionType& expression,
87  const UInt offset = 0);
88 
89  //! Copy constructor
90  EvaluateAtQuadraturePoint ( const IntegrateVectorElement < MeshType, TestSpaceType, ExpressionType, QRAdapterType>& integrator);
91 
92  //! Destructor
94 
95  //@}
96 
97 
98  //! @name Operator
99  //@{
100 
101  //! Operator wrapping the addTo method
103  {
104  evaluate (vector);
105  }
106  //@}
107 
108  //! @name Methods
109  //@{
110 
111  //! Ouput method
112  void check (std::ostream& out = std::cout);
113 
114  //! Method that performs the assembly
115  /*!
116  The loop over the elements is located right
117  in this method. Everything for the assembly is then
118  performed: update the values, update the local vector,
119  sum over the quadrature nodes, assemble in the global
120  vector.
121  */
122 
123  void evaluate (std::vector<std::vector<VectorSmall<TestSpaceType::field_dim>>>& vec); // for 3D field
124 
125  //@}
126 
127 private:
128 
129  //! @name Private Methods
130  //@{
131 
132  // No default constructor
134 
135  //@}
136 
137  // Pointer on the mesh
139 
140  // Quadrature to be used
141  QRAdapterType M_qrAdapter;
142 
143  // Shared pointer on the Space
145 
146  // Tree to compute the values for the assembly
148 
149  ETCurrentFE<MeshType::S_geoDimensions, 1>* M_globalCFE_std;
150  ETCurrentFE<MeshType::S_geoDimensions, 1>* M_globalCFE_adapted;
151 
152  ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim>* M_testCFE_std;
153  ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim>* M_testCFE_adapted;
154 
156 
157  // Offset
159 };
160 
161 
162 // ===================================================
163 // IMPLEMENTATION
164 // ===================================================
165 
166 // ===================================================
167 // Constructors & Destructor
168 // ===================================================
169 
170 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
171 EvaluateAtQuadraturePoint < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
172 EvaluateAtQuadraturePoint (const std::shared_ptr<MeshType>& mesh,
173  const QRAdapterType& qrAdapter,
174  const std::shared_ptr<TestSpaceType>& testSpace,
175  const ExpressionType& expression,
176  const UInt offset)
177 : M_mesh (mesh),
178 M_qrAdapter (qrAdapter),
180 M_evaluation (expression),
181 
184 
186 
187 M_offset (offset)
188 {
189  switch (MeshType::geoShape_Type::BasRefSha::S_shape)
190  {
191  case LINE:
192  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
193  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
194  break;
195  case TRIANGLE:
196  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
197  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
198  break;
199  case QUAD:
200  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
201  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
202  break;
203  case TETRA:
204  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
205  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
206  break;
207  case HEXA:
208  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
209  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
210  break;
211  default:
212  ERROR_MSG ("Unrecognized element shape");
213  }
214  M_evaluation.setQuadrature ( qrAdapter.standardQR() );
215 
216  M_evaluation.setGlobalCFE (M_globalCFE_std);
217  M_evaluation.setTestCFE (M_testCFE_std);
218 }
219 
220 
221 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
222 EvaluateAtQuadraturePoint < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
223 EvaluateAtQuadraturePoint ( const IntegrateVectorElement < MeshType, TestSpaceType, ExpressionType, QRAdapterType>& integrator)
225 M_qrAdapter (integrator.M_qrAdapter),
227 M_evaluation (integrator.M_evaluation),
228 
231 
233 M_offset (integrator.M_offset)
234 {
235  switch (MeshType::geoShape_Type::BasRefSha::S_shape)
236  {
237  case LINE:
238  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
239  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
240  break;
241  case TRIANGLE:
242  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
243  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
244  break;
245  case QUAD:
246  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
247  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
248  break;
249  case TETRA:
250  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
251  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
252  break;
253  case HEXA:
254  M_globalCFE_std = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
255  M_globalCFE_adapted = new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
256  break;
257  default:
258  ERROR_MSG ("Unrecognized element shape");
259  }
260  M_evaluation.setQuadrature (integrator.M_qrAdapter.standardQR() );
261  M_evaluation.setGlobalCFE (M_globalCFE_std);
262  M_evaluation.setTestCFE (M_testCFE_std);
263 }
264 
265 
266 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
267 EvaluateAtQuadraturePoint < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
269 {
270  delete M_globalCFE_std;
271  delete M_globalCFE_adapted;
272  delete M_testCFE_std;
273  delete M_testCFE_adapted;
274 }
275 
276 // ===================================================
277 // Methods
278 // ===================================================
279 
280 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
281 void
282 EvaluateAtQuadraturePoint < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
283 check (std::ostream& out)
284 {
285  out << " Checking the integration : " << std::endl;
286  M_evaluation.display (out);
287  out << std::endl;
288  out << " Elemental vector : " << std::endl;
289  M_elementalVector.showMe (out);
290  out << std::endl;
291 }
292 
293 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
294 void
295 EvaluateAtQuadraturePoint < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
296 evaluate (std::vector<std::vector<VectorSmall<TestSpaceType::field_dim>>>& vec)
297 {
298  UInt nbElements (M_mesh->numElements() );
299  UInt nbQuadPt_std (M_qrAdapter.standardQR().nbQuadPt() );
300  UInt nbTestDof (M_testSpace->refFE().nbDof() );
301 
302  // Defaulted to true for security
303  bool isPreviousAdapted (true);
304 
305  for (UInt iElement (0); iElement < nbElements; ++iElement)
306  {
307 
308  // Update the quadrature rule adapter
309  M_qrAdapter.update (iElement);
310 
311  // Check if the last one was adapted
312  if (isPreviousAdapted)
313  {
314  M_evaluation.setQuadrature ( M_qrAdapter.standardQR() );
315  M_evaluation.setGlobalCFE ( M_globalCFE_std );
316  M_evaluation.setTestCFE ( M_testCFE_std );
317 
318  isPreviousAdapted = false;
319  }
320 
321  // Update the currentFEs
322  M_globalCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
323  M_testCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag);
324 
325  // Update the evaluation
326  M_evaluation.update (iElement);
327 
328  for (UInt iQuadPt (0); iQuadPt < nbQuadPt_std; ++iQuadPt)
329  {
330  vec[iElement][iQuadPt] = M_evaluation.value_qi (iQuadPt, 0);
331  }
332  }
333 
334 }
335 
336 /*
337 template < typename MeshType, typename TestSpaceType, typename ExpressionType, typename QRAdapterType>
338 void
339 EvaluateAtQuadraturePoint < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
340 evaluate (std::vector<std::vector<VectorSmall<3>>>& vec)
341 {
342  UInt nbElements (M_mesh->numElements() );
343  UInt nbQuadPt_std (M_qrAdapter.standardQR().nbQuadPt() );
344  UInt nbTestDof (M_testSpace->refFE().nbDof() );
345 
346  // Defaulted to true for security
347  bool isPreviousAdapted (true);
348 
349  for (UInt iElement (0); iElement < nbElements; ++iElement)
350  {
351  // Update the quadrature rule adapter
352  M_qrAdapter.update (iElement);
353 
354  // Check if the last one was adapted
355  if (isPreviousAdapted)
356  {
357  M_evaluation.setQuadrature ( M_qrAdapter.standardQR() );
358  M_evaluation.setGlobalCFE ( M_globalCFE_std );
359  M_evaluation.setTestCFE ( M_testCFE_std );
360 
361  isPreviousAdapted = false;
362  }
363 
364  // Update the currentFEs
365  M_globalCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
366  M_testCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag);
367 
368  // Update the evaluation
369  M_evaluation.update (iElement);
370 
371  for (UInt iQuadPt (0); iQuadPt < nbQuadPt_std; ++iQuadPt)
372  {
373  vec[iElement][iQuadPt] = M_evaluation.value_qi (iQuadPt , 1 );
374  }
375  }
376 
377 }
378 */
379 
380 } // Namespace ExpressionAssembly
381 
382 } // Namespace LifeV
383 
384 #endif
void evaluate(std::vector< std::vector< VectorSmall< TestSpaceType::field_dim >>> &vec)
Method that performs the assembly.
ETCurrentFE< MeshType::S_geoDimensions, 1 > * M_globalCFE_adapted
const ReferenceFEScalar feHexaQ0("Lagrange Q0 on a hexaedra", FE_Q0_3D, HEXA, 0, 0, 0, 1, 1, 3, fct_Q0_3D, derfct_Q0_3D, der2fct_Q0_3D, refcoor_Q0_3D, STANDARD_PATTERN, &feQuadQ0, &lagrangianTransform)
class ETVectorElemental A class for describing an elemental vector
void check(std::ostream &out=std::cout)
Ouput method.
const ReferenceFEScalar feSegP0("Lagrange P0 on a segment", FE_P0_1D, LINE, 0, 1, 0, 0, 1, 1, fct_P0_1D, derfct_P0_1D, der2fct_P0_1D, refcoor_P0_1D, STANDARD_PATTERN, &fePointP0, &lagrangianTransform)
EvaluateAtQuadraturePoint(const IntegrateVectorElement< MeshType, TestSpaceType, ExpressionType, QRAdapterType > &integrator)
Copy constructor.
const ReferenceFEScalar feTetraP0("Lagrange P0 on a tetraedra", FE_P0_3D, TETRA, 0, 0, 0, 1, 1, 3, fct_P0_3D, derfct_P0_3D, der2fct_P0_3D, refcoor_P0_3D, STANDARD_PATTERN, &feTriaP0, &lagrangianTransform)
const ReferenceFEScalar feTriaP0("Lagrange P0 on a triangle", FE_P0_2D, TRIANGLE, 0, 0, 1, 0, 1, 2, fct_P0_2D, derfct_P0_2D, der2fct_P0_2D, refcoor_P0_2D, STANDARD_PATTERN, &feSegP0, &lagrangianTransform)
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
class ExpressionToEvaluation A class to pass from an Expression (Tree) to the corresponding Evaluatio...
ExpressionToEvaluation< ExpressionType, TestSpaceType::field_dim, 0, MeshType::S_geoDimensions >::evaluation_Type evaluation_Type
Type of the Evaluation.
void operator>>(std::vector< std::vector< VectorSmall< TestSpaceType::field_dim >>> &vector)
Operator wrapping the addTo method.
The class to actually perform the loop over the elements to assemble a vector.
const ReferenceFEScalar feQuadQ0("Lagrange Q0 on a quadrangle", FE_Q0_2D, QUAD, 0, 0, 1, 0, 1, 2, fct_Q0_2D, derfct_Q0_2D, der2fct_Q0_2D, refcoor_Q0_2D, STANDARD_PATTERN, &feSegP0, &lagrangianTransform)
ETCurrentFE< TestSpaceType::space_dim, TestSpaceType::field_dim > * M_testCFE_std
ETCurrentFE< MeshType::S_geoDimensions, 1 > * M_globalCFE_std
EvaluateAtQuadraturePoint(const std::shared_ptr< MeshType > &mesh, const QRAdapterType &qrAdapter, const std::shared_ptr< TestSpaceType > &testSpace, const ExpressionType &expression, const UInt offset=0)
Full data constructor.
ETCurrentFE< TestSpaceType::space_dim, TestSpaceType::field_dim > * M_testCFE_adapted
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191