36 #ifndef INTEGRATE_VECTOR_ELEMENT_LS_ADAPTED_HPP 37 #define INTEGRATE_VECTOR_ELEMENT_LS_ADAPTED_HPP 39 #include <lifev/core/LifeV.hpp> 41 #include <lifev/level_set/fem/LevelSetQRAdapter.hpp> 42 #include <lifev/eta/fem/ETCurrentFE.hpp> 43 #include <lifev/eta/fem/MeshGeometricMap.hpp> 45 #include <lifev/eta/expression/ExpressionToEvaluation.hpp> 47 #include <lifev/eta/array/ETVectorElemental.hpp> 49 #include <boost/shared_ptr.hpp> 56 namespace ExpressionAssembly
71 template <
typename MeshType,
72 typename TestSpaceType,
73 typename ExpressionType,
74 typename LSFESpaceType,
75 typename LSVectorType >
76 class IntegrateVectorElementLSAdapted
84 typedef typename ExpressionToEvaluation < ExpressionType,
85 TestSpaceType::S_fieldDim,
87 3 >::evaluation_Type evaluation_Type;
89 typedef LevelSetQRAdapter<LSFESpaceType, LSVectorType> QRAdapter_Type;
98 IntegrateVectorElementLSAdapted (
const std::shared_ptr<MeshType>& mesh,
99 const QRAdapter_Type& QRAdapter,
100 const std::shared_ptr<TestSpaceType>& testSpace,
101 const ExpressionType& expression);
104 IntegrateVectorElementLSAdapted (
const IntegrateVectorElementLSAdapted
105 < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>& integrator);
108 ~IntegrateVectorElementLSAdapted();
117 template <
typename VectorType>
118 inline void operator>> (VectorType& vector)
123 template <
typename VectorType>
124 inline void operator>> (std::shared_ptr<VectorType> vector)
135 void check (std::ostream& out = std::cout);
145 template <
typename VectorType>
146 void addTo (VectorType& vec);
148 template <
typename VectorType>
149 void addTo (std::shared_ptr<VectorType> vec)
162 IntegrateVectorElementLSAdapted();
167 std::shared_ptr<MeshType> M_mesh;
170 QRAdapter_Type M_QRAdapter;
173 std::shared_ptr<TestSpaceType> M_testSpace;
176 evaluation_Type M_evaluation;
180 ETCurrentFE<3, 1>* M_globalCFE_unadapted;
181 ETCurrentFE<3, 1>* M_globalCFE_adapted;
183 ETCurrentFE<3, TestSpaceType::S_fieldDim>* M_testCFE_unadapted;
184 ETCurrentFE<3, TestSpaceType::S_fieldDim>* M_testCFE_adapted;
187 ETVectorElemental M_elementalVector;
199 template <
typename MeshType,
200 typename TestSpaceType,
201 typename ExpressionType,
202 typename LSFESpaceType,
203 typename LSVectorType >
204 IntegrateVectorElementLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
205 IntegrateVectorElementLSAdapted (
const std::shared_ptr<MeshType>& mesh,
206 const QRAdapter_Type& QRAdapter,
207 const std::shared_ptr<TestSpaceType>& testSpace,
208 const ExpressionType& expression)
210 M_QRAdapter (QRAdapter),
211 M_testSpace (testSpace),
212 M_evaluation (expression),
214 M_globalCFE_unadapted (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), M_QRAdapter.standardQR() ) ),
215 M_globalCFE_adapted (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), M_QRAdapter.standardQR() ) ),
217 M_testCFE_unadapted (
new ETCurrentFE<3, TestSpaceType::S_fieldDim> (testSpace->refFE(), testSpace->geoMap(), M_QRAdapter.standardQR() ) ),
218 M_testCFE_adapted (
new ETCurrentFE<3, TestSpaceType::S_fieldDim> (testSpace->refFE(), testSpace->geoMap(), M_QRAdapter.standardQR() ) ),
220 M_elementalVector (TestSpaceType::S_fieldDim * testSpace->refFE().nbDof() )
222 M_evaluation.setQuadrature (M_QRAdapter.standardQR() );
223 M_evaluation.setGlobalCFE (M_globalCFE_unadapted);
224 M_evaluation.setTestCFE (M_testCFE_unadapted);
228 template <
typename MeshType,
229 typename TestSpaceType,
230 typename ExpressionType,
231 typename LSFESpaceType,
232 typename LSVectorType >
233 IntegrateVectorElementLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
234 IntegrateVectorElementLSAdapted (
const IntegrateVectorElementLSAdapted
235 < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>& integrator)
236 : M_mesh (integrator.M_mesh),
237 M_QRAdapter (integrator.M_QRAdapter),
238 M_testSpace (integrator.M_testSpace),
239 M_evaluation (integrator.M_evaluation),
241 M_globalCFE_unadapted (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), M_QRAdapter.standardQR() ) ),
242 M_globalCFE_adapted (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), M_QRAdapter.standardQR() ) ),
244 M_testCFE_unadapted (
new ETCurrentFE<3, TestSpaceType::S_fieldDim> (M_testSpace->refFE(), M_testSpace->geoMap(), M_QRAdapter.standardQR() ) ),
245 M_testCFE_adapted (
new ETCurrentFE<3, TestSpaceType::S_fieldDim> (M_testSpace->refFE(), M_testSpace->geoMap(), M_QRAdapter.standardQR() ) ),
247 M_elementalVector (integrator.M_elementalVector)
249 M_evaluation.setQuadrature (M_QRAdapter.standardQR() );
250 M_evaluation.setGlobalCFE (M_globalCFE_unadapted);
251 M_evaluation.setTestCFE (M_testCFE_unadapted);
255 template <
typename MeshType,
256 typename TestSpaceType,
257 typename ExpressionType,
258 typename LSFESpaceType,
259 typename LSVectorType >
260 IntegrateVectorElementLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
261 ~IntegrateVectorElementLSAdapted()
263 delete M_globalCFE_unadapted;
264 delete M_globalCFE_adapted;
265 delete M_testCFE_unadapted;
266 delete M_testCFE_adapted;
273 template <
typename MeshType,
274 typename TestSpaceType,
275 typename ExpressionType,
276 typename LSFESpaceType,
277 typename LSVectorType >
279 IntegrateVectorElementLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
280 check (std::ostream& out)
282 out <<
" Checking the integration : " << std::endl;
283 M_evaluation.display (out);
285 out <<
" Elemental vector : " << std::endl;
286 M_elementalVector.showMe (out);
290 template <
typename MeshType,
291 typename TestSpaceType,
292 typename ExpressionType,
293 typename LSFESpaceType,
294 typename LSVectorType >
295 template <
typename VectorType>
297 IntegrateVectorElementLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
298 addTo (VectorType& vec)
300 const UInt nbElements (M_mesh->numElements() );
301 const UInt nbQuadPt_unadapted (M_QRAdapter.standardQR().nbQuadPt() );
302 const UInt nbTestDof (M_testSpace->refFE().nbDof() );
307 bool isPreviousAdapted (
true);
309 for (UInt iElement (0); iElement < nbElements; ++iElement)
312 M_elementalVector.zero();
315 M_QRAdapter.update (iElement);
318 if (M_QRAdapter.isAdaptedElement() )
321 M_evaluation.setQuadrature ( M_QRAdapter.adaptedQR() );
322 M_globalCFE_adapted->setQuadratureRule ( M_QRAdapter.adaptedQR() );
323 M_testCFE_adapted->setQuadratureRule ( M_QRAdapter.adaptedQR() );
326 M_evaluation.setGlobalCFE ( M_globalCFE_adapted );
327 M_evaluation.setTestCFE ( M_testCFE_adapted );
330 M_globalCFE_adapted->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
331 M_testCFE_adapted->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag);
334 M_evaluation.update (iElement);
338 for (UInt iblock (0); iblock < TestSpaceType::S_fieldDim; ++iblock)
341 for (UInt i (0); i < nbTestDof; ++i)
343 M_elementalVector.setRowIndex
344 (i + iblock * nbTestDof,
345 M_testSpace->dof().localToGlobalMap (iElement, i) + iblock * M_testSpace->dof().numTotalDof() );
349 for (UInt iQuadPt (0); iQuadPt < M_QRAdapter.adaptedQR().nbQuadPt(); ++iQuadPt)
351 for (UInt i (0); i < nbTestDof; ++i)
353 M_elementalVector.element (i + iblock * nbTestDof) +=
354 M_evaluation.value_qi (iQuadPt, i + iblock * nbTestDof)
355 * M_globalCFE_adapted->wDet (iQuadPt);
360 M_elementalVector.pushToGlobal (vec);
362 isPreviousAdapted =
true;
367 if (isPreviousAdapted)
369 M_evaluation.setQuadrature ( M_QRAdapter.standardQR() );
370 M_evaluation.setGlobalCFE ( M_globalCFE_unadapted );
371 M_evaluation.setTestCFE ( M_testCFE_unadapted );
375 M_globalCFE_unadapted->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
376 M_testCFE_unadapted->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag);
379 M_evaluation.update (iElement);
383 for (UInt iblock (0); iblock < TestSpaceType::S_fieldDim; ++iblock)
386 for (UInt i (0); i < nbTestDof; ++i)
388 M_elementalVector.setRowIndex
389 (i + iblock * nbTestDof,
390 M_testSpace->dof().localToGlobalMap (iElement, i) + iblock * M_testSpace->dof().numTotalDof() );
394 for (UInt iQuadPt (0); iQuadPt < nbQuadPt_unadapted; ++iQuadPt)
396 for (UInt i (0); i < nbTestDof; ++i)
398 M_elementalVector.element (i + iblock * nbTestDof) +=
399 M_evaluation.value_qi (iQuadPt, i + iblock * nbTestDof)
400 * M_globalCFE_unadapted->wDet (iQuadPt);
405 M_elementalVector.pushToGlobal (vec);
407 isPreviousAdapted =
false;