36 #ifndef INTEGRATE_MATRIX_FACE_ID_LSADAPTED_HPP 37 #define INTEGRATE_MATRIX_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/ETMatrixElemental.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 SolutionSpaceType,
75 typename ExpressionType,
76 typename LSFESpaceType,
77 typename LSVectorType >
78 class IntegrateMatrixFaceIDLSAdapted
86 typedef typename ExpressionToEvaluation < ExpressionType,
87 TestSpaceType::field_dim,
88 SolutionSpaceType::field_dim,
89 3 >::evaluation_Type evaluation_Type;
91 typedef LevelSetBDQRAdapter<LSFESpaceType, LSVectorType> BDQRAdapter_Type;
100 IntegrateMatrixFaceIDLSAdapted (
const std::shared_ptr<MeshType>& mesh,
101 const UInt boundaryID,
102 const BDQRAdapter_Type& quadratureBD,
103 const std::shared_ptr<TestSpaceType> testSpace,
104 const std::shared_ptr<SolutionSpaceType> solutionSpace,
105 const ExpressionType& expression);
108 IntegrateMatrixFaceIDLSAdapted (
const IntegrateMatrixFaceIDLSAdapted
109 < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>& integrator);
112 ~IntegrateMatrixFaceIDLSAdapted();
121 template <
typename MatrixType>
122 inline void operator>> (MatrixType& mat)
128 template <
typename MatrixType>
129 inline void operator>> (std::shared_ptr<MatrixType> mat)
141 void check (std::ostream& out = std::cout);
151 template <
typename MatrixType>
152 void addTo (MatrixType& mat);
154 template <
typename MatrixType>
155 inline void addTo (std::shared_ptr<MatrixType> mat)
157 ASSERT (mat != 0,
" Cannot assemble with an empty matrix");
169 IntegrateMatrixFaceIDLSAdapted();
174 std::shared_ptr<MeshType> M_mesh;
180 BDQRAdapter_Type M_qrAdapter;
183 std::shared_ptr<TestSpaceType> M_testSpace;
184 std::shared_ptr<SolutionSpaceType> M_solutionSpace;
187 evaluation_Type M_evaluation;
189 std::vector<ETCurrentBDFE<3>*> M_globalCFE;
191 std::vector<ETCurrentFE<3, TestSpaceType::field_dim>*> M_testCFE;
192 std::vector<ETCurrentFE<3, SolutionSpaceType::field_dim>*> M_solutionCFE;
194 ETMatrixElemental M_elementalMatrix;
206 template <
typename MeshType,
207 typename TestSpaceType,
208 typename SolutionSpaceType,
209 typename ExpressionType,
210 typename LSFESpaceType,
211 typename LSVectorType >
212 IntegrateMatrixFaceIDLSAdapted < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
213 IntegrateMatrixFaceIDLSAdapted (
const std::shared_ptr<MeshType>& mesh,
214 const UInt boundaryID,
215 const BDQRAdapter_Type& quadratureBD,
216 const std::shared_ptr<TestSpaceType> testSpace,
217 const std::shared_ptr<SolutionSpaceType> solutionSpace,
218 const ExpressionType& expression)
220 M_boundaryId (boundaryID),
221 M_qrAdapter (quadratureBD),
222 M_testSpace (testSpace),
223 M_solutionSpace (solutionSpace),
224 M_evaluation (expression),
230 M_elementalMatrix (TestSpaceType::field_dim * testSpace->refFE().nbDof(), SolutionSpaceType::field_dim * solutionSpace->refFE().nbDof() )
232 for (UInt i (0); i < 4; ++i)
234 M_globalCFE[i] =
new ETCurrentBDFE<3> (geometricMapFromMesh<MeshType>()
235 , M_qrAdapter.adaptedBdQR (i) );
236 M_testCFE[i] =
new ETCurrentFE<3, TestSpaceType::field_dim> (testSpace->refFE()
237 , testSpace->geoMap()
238 , M_qrAdapter.adaptedBdQR (i) );
239 M_solutionCFE[i] =
new ETCurrentFE<3, SolutionSpaceType::field_dim> (solutionSpace->refFE()
240 , solutionSpace->geoMap()
241 , M_qrAdapter.adaptedBdQR (i) );
246 std::vector< VectorSmall<3> > t0 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
253 std::vector< VectorSmall<3> > t1 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
260 std::vector< VectorSmall<3> > t2 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
270 std::vector< VectorSmall<3> > t3 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
278 M_globalCFE[0]->setRefTangents (t0);
279 M_globalCFE[1]->setRefTangents (t1);
280 M_globalCFE[2]->setRefTangents (t2);
281 M_globalCFE[3]->setRefTangents (t3);
284 M_evaluation.setQuadrature (M_qrAdapter.adaptedBdQR (0) );
285 M_evaluation.setGlobalCFE (M_globalCFE[0]);
286 M_evaluation.setTestCFE (M_testCFE[0]);
287 M_evaluation.setSolutionCFE (M_solutionCFE[0]);
290 template <
typename MeshType,
291 typename TestSpaceType,
292 typename SolutionSpaceType,
293 typename ExpressionType,
294 typename LSFESpaceType,
295 typename LSVectorType >
296 IntegrateMatrixFaceIDLSAdapted < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
297 IntegrateMatrixFaceIDLSAdapted (
const IntegrateMatrixFaceIDLSAdapted < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>& integrator)
298 : M_mesh (integrator.M_mesh),
299 M_boundaryId (integrator.M_boundaryId),
300 M_qrAdapter (integrator.M_qrAdapter),
301 M_testSpace (integrator.M_testSpace),
302 M_solutionSpace (integrator.M_solutionSpace),
303 M_evaluation (integrator.M_evaluation),
309 M_elementalMatrix (integrator.M_elementalMatrix)
311 for (UInt i (0); i < 4; ++i)
313 M_globalCFE[i] =
new ETCurrentBDFE<3> (geometricMapFromMesh<MeshType>()
314 , M_qrAdapter.adaptedBdQR (i) );
315 M_testCFE[i] =
new ETCurrentFE<3, TestSpaceType::field_dim> (M_testSpace->refFE()
316 , M_testSpace->geoMap()
317 , M_qrAdapter.adaptedBdQR (i) );
318 M_solutionCFE[i] =
new ETCurrentFE<3, SolutionSpaceType::field_dim> (M_solutionSpace->refFE()
319 , M_solutionSpace->geoMap()
320 , M_qrAdapter.adaptedBdQR (i) );
324 std::vector< VectorSmall<3> > t0 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
331 std::vector< VectorSmall<3> > t1 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
338 std::vector< VectorSmall<3> > t2 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
348 std::vector< VectorSmall<3> > t3 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
356 M_globalCFE[0]->setRefTangents (t0);
357 M_globalCFE[1]->setRefTangents (t1);
358 M_globalCFE[2]->setRefTangents (t2);
359 M_globalCFE[3]->setRefTangents (t3);
362 M_evaluation.setQuadrature (M_qrAdapter.adaptedBdQR (0) );
363 M_evaluation.setGlobalCFE (M_globalCFE[0]);
364 M_evaluation.setTestCFE (M_testCFE[0]);
365 M_evaluation.setSolutionCFE (M_solutionCFE[0]);
369 template <
typename MeshType,
370 typename TestSpaceType,
371 typename SolutionSpaceType,
372 typename ExpressionType,
373 typename LSFESpaceType,
374 typename LSVectorType >
375 IntegrateMatrixFaceIDLSAdapted < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
376 ~IntegrateMatrixFaceIDLSAdapted()
378 for (UInt i (0); i < 4; ++i)
380 delete M_globalCFE[i];
382 delete M_solutionCFE[i];
390 template <
typename MeshType,
391 typename TestSpaceType,
392 typename SolutionSpaceType,
393 typename ExpressionType,
394 typename LSFESpaceType,
395 typename LSVectorType >
397 IntegrateMatrixFaceIDLSAdapted < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
398 check (std::ostream& out)
400 out <<
" Checking the integration : " << std::endl;
401 M_evaluation.display (out);
403 out <<
" Elemental matrix : " << std::endl;
404 M_elementalMatrix.showMe (out);
409 template <
typename MeshType,
410 typename TestSpaceType,
411 typename SolutionSpaceType,
412 typename ExpressionType,
413 typename LSFESpaceType,
414 typename LSVectorType >
415 template <
typename MatrixType>
417 IntegrateMatrixFaceIDLSAdapted < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType, LSFESpaceType, LSVectorType>::
418 addTo (MatrixType& mat)
420 UInt nbBoundaryFaces (M_mesh->numBFaces() );
421 UInt nbTestDof (M_testSpace->refFE().nbDof() );
422 UInt nbSolutionDof (M_solutionSpace->refFE().nbDof() );
424 for (UInt iFace (0); iFace < nbBoundaryFaces; ++iFace)
427 if ( M_mesh->face (iFace).markerID() != M_boundaryId )
433 M_elementalMatrix.zero();
436 UInt faceIDinAdjacentElement (M_mesh->face (iFace).firstAdjacentElementPosition() );
439 UInt adjacentElementID (M_mesh->face (iFace).firstAdjacentElementIdentity() );
442 M_qrAdapter.update (adjacentElementID, faceIDinAdjacentElement);
445 M_globalCFE[faceIDinAdjacentElement]->setQuadratureRule (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
446 M_testCFE[faceIDinAdjacentElement]->setQuadratureRule (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
447 M_solutionCFE[faceIDinAdjacentElement]->setQuadratureRule (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
450 M_globalCFE[faceIDinAdjacentElement]
451 ->update (M_mesh->element (adjacentElementID) );
452 M_testCFE[faceIDinAdjacentElement]
453 ->update (M_mesh->element (adjacentElementID), evaluation_Type::S_testUpdateFlag);
454 M_solutionCFE[faceIDinAdjacentElement]
455 ->update (M_mesh->element (adjacentElementID), evaluation_Type::S_solutionUpdateFlag);
459 M_evaluation.setQuadrature (M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement) );
460 M_evaluation.setGlobalCFE (M_globalCFE[faceIDinAdjacentElement]);
461 M_evaluation.setTestCFE (M_testCFE[faceIDinAdjacentElement]);
462 M_evaluation.setSolutionCFE (M_solutionCFE[faceIDinAdjacentElement]);
464 M_evaluation.update (adjacentElementID);
467 for (UInt iblock (0); iblock < TestSpaceType::field_dim; ++iblock)
469 for (UInt jblock (0); jblock < SolutionSpaceType::field_dim; ++jblock)
473 for (UInt i (0); i < nbTestDof; ++i)
475 M_elementalMatrix.setRowIndex
476 (i + iblock * nbTestDof,
477 M_testSpace->dof().localToGlobalMap (adjacentElementID, i) + iblock * M_testSpace->dof().numTotalDof() );
480 for (UInt j (0); j < nbSolutionDof; ++j)
482 M_elementalMatrix.setColumnIndex
483 (j + jblock * nbSolutionDof,
484 M_solutionSpace->dof().localToGlobalMap (adjacentElementID, j) + jblock * M_solutionSpace->dof().numTotalDof() );
489 for (UInt iQuadPt (0); iQuadPt < M_qrAdapter.adaptedBdQR (faceIDinAdjacentElement).nbQuadPt(); ++iQuadPt)
491 for (UInt i (0); i < nbTestDof; ++i)
493 for (UInt j (0); j < nbSolutionDof; ++j)
495 M_elementalMatrix.element (i + iblock * nbTestDof, j + jblock * nbSolutionDof) +=
496 M_evaluation.value_qij (iQuadPt, i + iblock * nbTestDof, j + jblock * nbSolutionDof)
497 * M_globalCFE[faceIDinAdjacentElement]->M_wMeas[iQuadPt];
504 M_elementalMatrix.pushToGlobal (mat);