36 #ifndef INTEGRATE_VECTOR_FACE_ID_LSADAPTED_HPP 37 #define INTEGRATE_VECTOR_FACE_ID_LSADAPTED_HPP 39 #include <lifev/core/LifeV.hpp> 41 #include <lifev/eta/fem/QuadratureBoundary.hpp> 42 #include <lifev/eta/fem/ETCurrentFE.hpp> 43 #include <lifev/eta/fem/ETCurrentBDFE.hpp> 45 #include <lifev/eta/fem/MeshGeometricMap.hpp> 47 #include <lifev/eta/expression/ExpressionToEvaluation.hpp> 49 #include <lifev/eta/array/ETVectorElemental.hpp> 51 #include <lifev/eta/fem/LevelSetBDQRAdapter.hpp> 53 #include <boost/shared_ptr.hpp> 60 namespace ExpressionAssembly
72 template <
typename MeshType,
73 typename TestSpaceType,
74 typename ExpressionType,
75 typename LSFESpaceType,
76 typename LSVectorType >
77 class IntegrateVectorFaceIDLSAdapted
85 typedef typename ExpressionToEvaluation < ExpressionType,
86 TestSpaceType::field_dim,
88 3 >::evaluation_Type evaluation_Type;
90 typedef LevelSetBDQRAdapter<LSFESpaceType, LSVectorType> BDQRAdapter_Type;
99 IntegrateVectorFaceIDLSAdapted (
const std::shared_ptr<MeshType>& mesh,
100 const UInt boundaryID,
101 const BDQRAdapter_Type& quadratureBD,
102 const std::shared_ptr<TestSpaceType> testSpace,
103 const ExpressionType& expression);
106 IntegrateVectorFaceIDLSAdapted (
const IntegrateVectorFaceIDLSAdapted
107 < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>& integrator);
110 ~IntegrateVectorFaceIDLSAdapted();
119 template <
typename VectorType>
120 inline void operator>> (VectorType& vec)
126 template <
typename VectorType>
127 inline void operator>> (std::shared_ptr<VectorType> vec)
139 void check (std::ostream& out = std::cout);
149 template <
typename VectorType>
150 void addTo (VectorType& vec);
152 template <
typename VectorType>
153 inline void addTo (std::shared_ptr<VectorType> vec)
155 ASSERT (vec != 0,
" Cannot assemble with an empty vector");
167 IntegrateVectorFaceIDLSAdapted();
172 std::shared_ptr<MeshType> M_mesh;
178 BDQRAdapter_Type M_qrAdapter;
181 std::shared_ptr<TestSpaceType> M_testSpace;
184 evaluation_Type M_evaluation;
186 std::vector<ETCurrentBDFE<3>*> M_globalCFE;
188 std::vector<ETCurrentFE<3, TestSpaceType::field_dim>*> M_testCFE;
190 ETVectorElemental M_elementalVector;
202 template <
typename MeshType,
203 typename TestSpaceType,
204 typename ExpressionType,
205 typename LSFESpaceType,
206 typename LSVectorType >
207 IntegrateVectorFaceIDLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
208 IntegrateVectorFaceIDLSAdapted (
const std::shared_ptr<MeshType>& mesh,
209 const UInt boundaryID,
210 const BDQRAdapter_Type& quadratureBD,
211 const std::shared_ptr<TestSpaceType> testSpace,
212 const ExpressionType& expression)
214 M_boundaryId (boundaryID),
215 M_qrAdapter (quadratureBD),
216 M_testSpace (testSpace),
217 M_evaluation (expression),
222 M_elementalVector (TestSpaceType::field_dim * testSpace->refFE().nbDof() )
225 for (UInt i (0); i < 4; ++i)
227 M_globalCFE[i] =
new ETCurrentBDFE<3> (geometricMapFromMesh<MeshType>()
228 , M_qrAdapter.adaptedBdQR (i) );
230 M_testCFE[i] =
new ETCurrentFE<3, TestSpaceType::field_dim> (testSpace->refFE()
231 , testSpace->geoMap()
232 , M_qrAdapter.adaptedBdQR (i) );
236 std::vector< VectorSmall<3> > t0 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
243 std::vector< VectorSmall<3> > t1 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
250 std::vector< VectorSmall<3> > t2 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
260 std::vector< VectorSmall<3> > t3 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
268 M_globalCFE[0]->setRefTangents (t0);
269 M_globalCFE[1]->setRefTangents (t1);
270 M_globalCFE[2]->setRefTangents (t2);
271 M_globalCFE[3]->setRefTangents (t3);
274 M_evaluation.setQuadrature (M_qrAdapter.adaptedBdQR (0) );
275 M_evaluation.setGlobalCFE (M_globalCFE[0]);
276 M_evaluation.setTestCFE (M_testCFE[0]);
279 template <
typename MeshType,
280 typename TestSpaceType,
281 typename ExpressionType,
282 typename LSFESpaceType,
283 typename LSVectorType >
284 IntegrateVectorFaceIDLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
285 IntegrateVectorFaceIDLSAdapted (
const IntegrateVectorFaceIDLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>& integrator)
286 : M_mesh (integrator.M_mesh),
287 M_boundaryId (integrator.M_boundaryId),
288 M_qrAdapter (integrator.M_qrAdapter),
289 M_testSpace (integrator.M_testSpace),
290 M_evaluation (integrator.M_evaluation),
295 M_elementalVector (integrator.M_elementalVector)
297 for (UInt i (0); i < 4; ++i)
299 M_globalCFE[i] =
new ETCurrentBDFE<3> (geometricMapFromMesh<MeshType>()
300 , M_qrAdapter.adaptedBdQR (i) );
302 M_testCFE[i] =
new ETCurrentFE<3, TestSpaceType::field_dim> (M_testSpace->refFE()
303 , M_testSpace->geoMap()
304 , M_qrAdapter.adaptedBdQR (i) );
308 std::vector< VectorSmall<3> > t0 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
315 std::vector< VectorSmall<3> > t1 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
322 std::vector< VectorSmall<3> > t2 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
332 std::vector< VectorSmall<3> > t3 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
340 M_globalCFE[0]->setRefTangents (t0);
341 M_globalCFE[1]->setRefTangents (t1);
342 M_globalCFE[2]->setRefTangents (t2);
343 M_globalCFE[3]->setRefTangents (t3);
346 M_evaluation.setQuadrature (M_qrAdapter.adaptedBdQR (0) );
347 M_evaluation.setGlobalCFE (M_globalCFE[0]);
348 M_evaluation.setTestCFE (M_testCFE[0]);
352 template <
typename MeshType,
353 typename TestSpaceType,
354 typename ExpressionType,
355 typename LSFESpaceType,
356 typename LSVectorType >
357 IntegrateVectorFaceIDLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
358 ~IntegrateVectorFaceIDLSAdapted()
360 for (UInt i (0); i < 4; ++i)
362 delete M_globalCFE[i];
371 template <
typename MeshType,
372 typename TestSpaceType,
373 typename ExpressionType,
374 typename LSFESpaceType,
375 typename LSVectorType >
377 IntegrateVectorFaceIDLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
378 check (std::ostream& out)
380 out <<
" Checking the integration : " << std::endl;
381 M_evaluation.display (out);
383 out <<
" Elemental vector : " << std::endl;
384 M_elementalVector.showMe (out);
389 template <
typename MeshType,
390 typename TestSpaceType,
391 typename ExpressionType,
392 typename LSFESpaceType,
393 typename LSVectorType >
394 template <
typename VectorType>
396 IntegrateVectorFaceIDLSAdapted < MeshType, TestSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
397 addTo (VectorType& vec)
399 UInt nbBoundaryFaces (M_mesh->numBFaces() );
400 UInt nbTestDof (M_testSpace->refFE().nbDof() );
402 for (UInt iFace (0); iFace < nbBoundaryFaces; ++iFace)
405 if ( M_mesh->face (iFace).markerID() != M_boundaryId )
411 M_elementalVector.zero();
414 UInt faceIDinAdjacentElement (M_mesh->face (iFace).firstAdjacentElementPosition() );
417 UInt adjacentElementID (M_mesh->face (iFace).firstAdjacentElementIdentity() );
420 M_qrAdapter.update (adjacentElementID, faceIDinAdjacentElement);
423 M_globalCFE[faceIDinAdjacentElement]->setQuadratureRule (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
424 M_testCFE[faceIDinAdjacentElement]->setQuadratureRule (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
427 M_globalCFE[faceIDinAdjacentElement]
428 ->update (M_mesh->element (adjacentElementID) );
429 M_testCFE[faceIDinAdjacentElement]
430 ->update (M_mesh->element (adjacentElementID), evaluation_Type::S_testUpdateFlag);
433 M_evaluation.setQuadrature (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
434 M_evaluation.setGlobalCFE (M_globalCFE[faceIDinAdjacentElement]);
435 M_evaluation.setTestCFE (M_testCFE[faceIDinAdjacentElement]);
437 M_evaluation.update (adjacentElementID);
440 for (UInt iblock (0); iblock < TestSpaceType::field_dim; ++iblock)
444 for (UInt i (0); i < nbTestDof; ++i)
446 M_elementalVector.setRowIndex
447 (i + iblock * nbTestDof,
448 M_testSpace->dof().localToGlobalMap (adjacentElementID, i) + iblock * M_testSpace->dof().numTotalDof() );
453 for (UInt iQuadPt (0); iQuadPt < M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement).nbQuadPt(); ++iQuadPt)
455 for (UInt i (0); i < nbTestDof; ++i)
457 M_elementalVector.element (i + iblock * nbTestDof) +=
458 M_evaluation.value_qi (iQuadPt, i + iblock * nbTestDof)
459 * M_globalCFE[faceIDinAdjacentElement]->M_wMeas[iQuadPt];
464 M_elementalVector.pushToGlobal (vec);