36 #ifndef INTEGRATE_MATRIX_FACE_ID_HPP 37 #define INTEGRATE_MATRIX_FACE_ID_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 <boost/shared_ptr.hpp> 58 namespace ExpressionAssembly
70 template <
typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
71 class IntegrateMatrixFaceID
79 typedef typename ExpressionToEvaluation < ExpressionType,
80 TestSpaceType::field_dim,
81 SolutionSpaceType::field_dim,
82 3 >::evaluation_Type evaluation_Type;
91 IntegrateMatrixFaceID (
const std::shared_ptr<MeshType>& mesh,
92 const UInt boundaryID,
93 const QuadratureBoundary& quadratureBD,
94 const std::shared_ptr<TestSpaceType> testSpace,
95 const std::shared_ptr<SolutionSpaceType> solutionSpace,
96 const ExpressionType& expression);
99 IntegrateMatrixFaceID (
const IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>& integrator);
102 ~IntegrateMatrixFaceID();
111 template <
typename MatrixType>
112 inline void operator>> (MatrixType& mat)
118 template <
typename MatrixType>
119 inline void operator>> (std::shared_ptr<MatrixType> mat)
131 void check (std::ostream& out = std::cout);
141 template <
typename MatrixType>
142 void addTo (MatrixType& mat);
144 template <
typename MatrixType>
145 inline void addTo (std::shared_ptr<MatrixType> mat)
147 ASSERT (mat != 0,
" Cannot assemble with an empty matrix");
159 IntegrateMatrixFaceID();
164 std::shared_ptr<MeshType> M_mesh;
170 QuadratureBoundary M_quadratureBoundary;
173 std::shared_ptr<TestSpaceType> M_testSpace;
174 std::shared_ptr<SolutionSpaceType> M_solutionSpace;
177 evaluation_Type M_evaluation;
179 std::vector<ETCurrentBDFE<3>*> M_globalCFE;
181 std::vector<ETCurrentFE<3, TestSpaceType::field_dim>*> M_testCFE;
182 std::vector<ETCurrentFE<3, SolutionSpaceType::field_dim>*> M_solutionCFE;
184 ETMatrixElemental M_elementalMatrix;
196 template <
typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
197 IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
198 IntegrateMatrixFaceID (
const std::shared_ptr<MeshType>& mesh,
199 const UInt boundaryID,
200 const QuadratureBoundary& quadratureBD,
201 const std::shared_ptr<TestSpaceType> testSpace,
202 const std::shared_ptr<SolutionSpaceType> solutionSpace,
203 const ExpressionType& expression)
205 M_boundaryId (boundaryID),
206 M_quadratureBoundary (quadratureBD),
207 M_testSpace (testSpace),
208 M_solutionSpace (solutionSpace),
209 M_evaluation (expression),
215 M_elementalMatrix (TestSpaceType::field_dim * testSpace->refFE().nbDof(), SolutionSpaceType::field_dim * solutionSpace->refFE().nbDof() )
217 for (UInt i (0); i < 4; ++i)
219 M_globalCFE[i] =
new ETCurrentBDFE<3> (geometricMapFromMesh<MeshType>()
220 , M_quadratureBoundary.qr (i) );
222 M_testCFE[i] =
new ETCurrentFE<3, TestSpaceType::field_dim> (testSpace->refFE()
223 , testSpace->geoMap()
224 , M_quadratureBoundary.qr (i) );
225 M_solutionCFE[i] =
new ETCurrentFE<3, SolutionSpaceType::field_dim> (solutionSpace->refFE()
226 , solutionSpace->geoMap()
227 , M_quadratureBoundary.qr (i) );
231 std::vector< VectorSmall<3> > t0 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
238 std::vector< VectorSmall<3> > t1 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
245 std::vector< VectorSmall<3> > t2 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
255 std::vector< VectorSmall<3> > t3 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
263 M_globalCFE[0]->setRefTangents (t0);
264 M_globalCFE[1]->setRefTangents (t1);
265 M_globalCFE[2]->setRefTangents (t2);
266 M_globalCFE[3]->setRefTangents (t3);
269 M_evaluation.setQuadrature (M_quadratureBoundary.qr (0) );
270 M_evaluation.setGlobalCFE (M_globalCFE[0]);
271 M_evaluation.setTestCFE (M_testCFE[0]);
272 M_evaluation.setSolutionCFE (M_solutionCFE[0]);
276 template <
typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
277 IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
278 IntegrateMatrixFaceID (
const IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>& integrator)
279 : M_mesh (integrator.M_mesh),
280 M_boundaryId (integrator.M_boundaryId),
281 M_quadratureBoundary (integrator.M_quadratureBoundary),
282 M_testSpace (integrator.M_testSpace),
283 M_solutionSpace (integrator.M_solutionSpace),
284 M_evaluation (integrator.M_evaluation),
290 M_elementalMatrix (integrator.M_elementalMatrix)
292 for (UInt i (0); i < 4; ++i)
294 M_globalCFE[i] =
new ETCurrentBDFE<3> (geometricMapFromMesh<MeshType>()
295 , M_quadratureBoundary.qr (i) );
296 M_testCFE[i] =
new ETCurrentFE<3, TestSpaceType::field_dim> (M_testSpace->refFE()
297 , M_testSpace->geoMap()
298 , M_quadratureBoundary.qr (i) );
299 M_solutionCFE[i] =
new ETCurrentFE<3, SolutionSpaceType::field_dim> (M_solutionSpace->refFE()
300 , M_solutionSpace->geoMap()
301 , M_quadratureBoundary.qr (i) );
305 std::vector< VectorSmall<3> > t0 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
312 std::vector< VectorSmall<3> > t1 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
319 std::vector< VectorSmall<3> > t2 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
329 std::vector< VectorSmall<3> > t3 (2, VectorSmall<3> (0.0, 0.0, 0.0) );
337 M_globalCFE[0]->setRefTangents (t0);
338 M_globalCFE[1]->setRefTangents (t1);
339 M_globalCFE[2]->setRefTangents (t2);
340 M_globalCFE[3]->setRefTangents (t3);
343 M_evaluation.setQuadrature (M_quadratureBoundary.qr (0) );
344 M_evaluation.setGlobalCFE (M_globalCFE[0]);
345 M_evaluation.setTestCFE (M_testCFE[0]);
346 M_evaluation.setSolutionCFE (M_solutionCFE[0]);
350 template <
typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
351 IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
352 ~IntegrateMatrixFaceID()
354 for (UInt i (0); i < 4; ++i)
356 delete M_globalCFE[i];
358 delete M_solutionCFE[i];
366 template <
typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
368 IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
369 check (std::ostream& out)
371 out <<
" Checking the integration : " << std::endl;
372 M_evaluation.display (out);
374 out <<
" Elemental matrix : " << std::endl;
375 M_elementalMatrix.showMe (out);
379 template <
typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
380 template <
typename MatrixType>
382 IntegrateMatrixFaceID < MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
383 addTo (MatrixType& mat)
385 UInt nbBoundaryFaces (M_mesh->numBFaces() );
386 UInt nbTestDof (M_testSpace->refFE().nbDof() );
387 UInt nbSolutionDof (M_solutionSpace->refFE().nbDof() );
389 for (UInt iFace (0); iFace < nbBoundaryFaces; ++iFace)
392 if ( M_mesh->face (iFace).markerID() != M_boundaryId )
398 M_elementalMatrix.zero();
401 UInt faceIDinAdjacentElement (M_mesh->face (iFace).firstAdjacentElementPosition() );
404 UInt adjacentElementID (M_mesh->face (iFace).firstAdjacentElementIdentity() );
407 M_globalCFE[faceIDinAdjacentElement]
408 ->update (M_mesh->element (adjacentElementID) );
409 M_testCFE[faceIDinAdjacentElement]
410 ->update (M_mesh->element (adjacentElementID), evaluation_Type::S_testUpdateFlag);
411 M_solutionCFE[faceIDinAdjacentElement]
412 ->update (M_mesh->element (adjacentElementID), evaluation_Type::S_solutionUpdateFlag);
416 M_evaluation.setQuadrature (M_quadratureBoundary.qr (faceIDinAdjacentElement) );
417 M_evaluation.setGlobalCFE (M_globalCFE[faceIDinAdjacentElement]);
418 M_evaluation.setTestCFE (M_testCFE[faceIDinAdjacentElement]);
419 M_evaluation.setSolutionCFE (M_solutionCFE[faceIDinAdjacentElement]);
421 M_evaluation.update (adjacentElementID);
424 for (UInt iblock (0); iblock < TestSpaceType::field_dim; ++iblock)
426 for (UInt jblock (0); jblock < SolutionSpaceType::field_dim; ++jblock)
430 for (UInt i (0); i < nbTestDof; ++i)
432 M_elementalMatrix.setRowIndex
433 (i + iblock * nbTestDof,
434 M_testSpace->dof().localToGlobalMap (adjacentElementID, i) + iblock * M_testSpace->dof().numTotalDof() );
437 for (UInt j (0); j < nbSolutionDof; ++j)
439 M_elementalMatrix.setColumnIndex
440 (j + jblock * nbSolutionDof,
441 M_solutionSpace->dof().localToGlobalMap (adjacentElementID, j) + jblock * M_solutionSpace->dof().numTotalDof() );
446 for (UInt iQuadPt (0); iQuadPt < M_quadratureBoundary.qr (faceIDinAdjacentElement).nbQuadPt(); ++iQuadPt)
448 for (UInt i (0); i < nbTestDof; ++i)
450 for (UInt j (0); j < nbSolutionDof; ++j)
452 M_elementalMatrix.element (i + iblock * nbTestDof, j + jblock * nbSolutionDof) +=
453 M_evaluation.value_qij (iQuadPt, i + iblock * nbTestDof, j + jblock * nbSolutionDof)
454 * M_globalCFE[faceIDinAdjacentElement]->M_wMeas[iQuadPt];
461 M_elementalMatrix.pushToGlobal (mat);