36 #ifndef EVALUATENODALEXPRESSION_VECTOR_ELEMENT_HPP 37 #define EVALUATENODALEXPRESSION_VECTOR_ELEMENT_HPP 39 #include <lifev/core/LifeV.hpp> 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> 46 #include <lifev/eta/expression/ExpressionToEvaluation.hpp> 48 #include <lifev/eta/array/ETVectorElemental.hpp> 67 template <
typename MeshType,
typename SolutionSpaceType,
typename ExpressionType,
typename QRAdapterType>
68 class EvaluateNodalExpressionVectorElement
76 typedef typename ExpressionToEvaluation < ExpressionType,
77 SolutionSpaceType::field_dim,
79 MeshType::S_geoDimensions >::evaluation_Type evaluation_Type;
88 EvaluateNodalExpressionVectorElement (
const std::shared_ptr<MeshType>& mesh,
89 const QRAdapterType& qrAdapter,
90 const std::shared_ptr<SolutionSpaceType>& testSpace,
91 const ExpressionType& expression);
94 EvaluateNodalExpressionVectorElement (
const EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>& integrator);
97 ~EvaluateNodalExpressionVectorElement();
106 template <
typename VectorType>
107 inline void operator>> (VectorType& vector)
113 template <
typename VectorType>
114 inline void operator>> (std::shared_ptr<VectorType> vector)
126 void check (std::ostream& out = std::cout);
136 template <
typename VectorType>
137 void addTo (VectorType& vec);
147 EvaluateNodalExpressionVectorElement();
152 std::shared_ptr<MeshType> M_mesh;
155 QRAdapterType M_qrAdapter;
158 std::shared_ptr<SolutionSpaceType> M_solutionSpace;
161 evaluation_Type M_evaluation;
166 ETCurrentFE<SolutionSpaceType::space_dim, SolutionSpaceType::field_dim>* M_testCFE_std;
167 ETCurrentFE<SolutionSpaceType::space_dim, SolutionSpaceType::field_dim>* M_testCFE_adapted;
169 ETVectorElemental M_elementalVector;
181 template <
typename MeshType,
typename SolutionSpaceType,
typename ExpressionType,
typename QRAdapterType>
182 EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>::
183 EvaluateNodalExpressionVectorElement (
const std::shared_ptr<MeshType>& mesh,
184 const QRAdapterType& qrAdapter,
185 const std::shared_ptr<SolutionSpaceType>& solutionSpace,
186 const ExpressionType& expression)
188 M_qrAdapter (qrAdapter),
189 M_solutionSpace (solutionSpace),
190 M_evaluation (expression),
192 M_testCFE_std (
new ETCurrentFE<SolutionSpaceType::space_dim, SolutionSpaceType::field_dim> (solutionSpace->refFE(), solutionSpace->geoMap(), qrAdapter.standardQR() ) ),
193 M_testCFE_adapted (
new ETCurrentFE<SolutionSpaceType::space_dim, SolutionSpaceType::field_dim> (solutionSpace->refFE(), solutionSpace->geoMap(), qrAdapter.standardQR() ) ),
195 M_elementalVector (SolutionSpaceType::field_dim * solutionSpace->refFE().nbDof() )
198 switch (MeshType::geoShape_Type::BasRefSha::S_shape)
201 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feSegP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
202 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feSegP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
205 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTriaP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
206 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTriaP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
209 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feQuadQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
210 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feQuadQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
213 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
214 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
217 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feHexaQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
218 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feHexaQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR());
221 ERROR_MSG (
"Unrecognized element shape");
224 M_evaluation.setQuadrature (qrAdapter.standardQR() );
225 M_evaluation.setGlobalCFE (M_globalCFE_std);
226 M_evaluation.setTestCFE (M_testCFE_std);
230 template <
typename MeshType,
typename SolutionSpaceType,
typename ExpressionType,
typename QRAdapterType>
231 EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>::
232 EvaluateNodalExpressionVectorElement (
const EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>& integrator)
233 : M_mesh (integrator.M_mesh),
234 M_qrAdapter (integrator.M_qrAdapter),
235 M_solutionSpace (integrator.M_solutionSpace),
236 M_evaluation (integrator.M_evaluation),
238 M_testCFE_std (
new ETCurrentFE<SolutionSpaceType::space_dim, SolutionSpaceType::field_dim> (M_solutionSpace->refFE(), M_solutionSpace->geoMap(), integrator.M_qrAdapter.standardQR() ) ),
239 M_testCFE_adapted (
new ETCurrentFE<SolutionSpaceType::space_dim, SolutionSpaceType::field_dim> (M_solutionSpace->refFE(), M_solutionSpace->geoMap(), integrator.M_qrAdapter.standardQR() ) ),
241 M_elementalVector (integrator.M_elementalVector)
243 switch (MeshType::geoShape_Type::BasRefSha::S_shape)
246 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feSegP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
247 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feSegP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
250 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTriaP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
251 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTriaP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
254 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feQuadQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
255 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feQuadQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
258 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
259 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
262 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feHexaQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
263 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (
feHexaQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR());
266 ERROR_MSG (
"Unrecognized element shape");
268 M_evaluation.setQuadrature (integrator.M_qrAdapter.standardQR() );
269 M_evaluation.setGlobalCFE (M_globalCFE_std);
270 M_evaluation.setTestCFE (M_testCFE_std);
274 template <
typename MeshType,
typename SolutionSpaceType,
typename ExpressionType,
typename QRAdapterType>
275 EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>::
276 ~EvaluateNodalExpressionVectorElement()
278 delete M_globalCFE_std;
279 delete M_globalCFE_adapted;
280 delete M_testCFE_std;
281 delete M_testCFE_adapted;
288 template <
typename MeshType,
typename SolutionSpaceType,
typename ExpressionType,
typename QRAdapterType>
290 EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>::
291 check (std::ostream& out)
293 out <<
" Checking the integration : " << std::endl;
294 M_evaluation.display (out);
296 out <<
" Elemental vector : " << std::endl;
297 M_elementalVector.showMe (out);
302 template <
typename VectorType>
304 EvaluateNodalExpressionVectorElement < MeshType, SolutionSpaceType, ExpressionType, QRAdapterType>::
305 addTo (VectorType& vec)
307 UInt nbElements (M_mesh->numElements() );
308 UInt nbQuadPt_std (M_qrAdapter.standardQR().nbQuadPt() );
309 UInt nbSolDof (M_solutionSpace->refFE().nbDof() );
312 bool isPreviousAdapted (
true);
314 for (
UInt iElement (0); iElement < nbElements; ++iElement)
317 M_elementalVector.zero();
320 M_qrAdapter.update (iElement);
323 if (M_qrAdapter.isAdaptedElement() )
326 M_evaluation.setQuadrature ( M_qrAdapter.adaptedQR() );
327 M_globalCFE_adapted -> setQuadratureRule ( M_qrAdapter.adaptedQR() );
328 M_testCFE_adapted -> setQuadratureRule ( M_qrAdapter.adaptedQR() );
331 M_evaluation.setGlobalCFE ( M_globalCFE_adapted );
332 M_evaluation.setTestCFE ( M_testCFE_adapted );
335 M_evaluation.update (iElement);
338 M_globalCFE_adapted->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
339 M_testCFE_adapted->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag);
343 for (
UInt iblock (0); iblock < SolutionSpaceType::field_dim; ++iblock)
346 for (
UInt i (0); i < nbSolDof; ++i)
348 M_elementalVector.setRowIndex
349 (i + iblock * nbSolDof,
350 M_solutionSpace->dof().localToGlobalMap (iElement, i) + iblock * M_solutionSpace->dof().numTotalDof() );
354 for (
UInt iQuadPt (0); iQuadPt < M_qrAdapter.adaptedQR().nbQuadPt(); ++iQuadPt)
356 for (
UInt i (0); i < nbSolDof; ++i)
358 M_elementalVector.element (i + iblock * nbSolDof) +=
359 M_evaluation.value_qi (iQuadPt, i + iblock * nbSolDof);
366 isPreviousAdapted =
true;
371 if (isPreviousAdapted)
373 M_evaluation.setQuadrature ( M_qrAdapter.standardQR() );
374 M_evaluation.setGlobalCFE ( M_globalCFE_std );
375 M_evaluation.setTestCFE ( M_testCFE_std );
377 isPreviousAdapted =
false;
382 M_globalCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
383 M_testCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag );
386 M_evaluation.update (iElement);
389 for (
UInt iblock (0); iblock < SolutionSpaceType::field_dim; ++iblock)
392 for (
UInt i (0); i < nbSolDof; ++i)
394 M_elementalVector.setRowIndex
395 (i + iblock * nbSolDof,
396 M_solutionSpace->dof().localToGlobalMap (iElement, i) + iblock * M_solutionSpace->dof().numTotalDof() );
400 for (
UInt iQuadPt (0); iQuadPt < nbQuadPt_std; ++iQuadPt)
402 for (
UInt i (0); i < nbSolDof; ++i)
404 M_elementalVector.element (i + iblock * nbSolDof) +=
405 M_evaluation.value_qi (iQuadPt, i + iblock * nbSolDof);
413 M_elementalVector.pushToGlobal (vec);
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)
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)
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)
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)
uint32_type UInt
generic unsigned integer (used mainly for addressing)