40 #ifndef ADRASSEMBLERIP_H 41 #define ADRASSEMBLERIP_H 1
44 #include <boost/scoped_ptr.hpp> 47 #include <lifev/core/LifeV.hpp> 49 #include <lifev/core/util/LifeChrono.hpp> 51 #include <lifev/core/fem/Assembly.hpp> 52 #include <lifev/core/fem/FESpace.hpp> 53 #include <lifev/core/fem/AssemblyElemental.hpp> 138 template<
typename mesh_type,
typename matrix_type,
typename vector_type>
148 typedef FESpace<mesh_type, map_Type> fespace_type;
149 typedef std::shared_ptr<fespace_type> fespace_ptrType;
151 typedef std::shared_ptr<matrix_type> matrix_ptrType;
163 ~ADRAssemblerIP() {};
173 void setup (
const fespace_ptrType& fespace,
const fespace_ptrType& betaFEspace);
183 void addIPStabilizationStencil (
const matrix_ptrType& matrixGalerkin,
184 const matrix_ptrType& matrixExtended,
185 const vector_type& beta,
192 void addIPStabilizationStencil (
const matrix_ptrType& matrixGalerkin,
193 const matrix_ptrType& matrixExtended,
201 void addIPStabilization (
const matrix_ptrType& matrix,
202 const vector_type& beta,
205 addIPStabilizationStencil (matrix, matrix, beta, coef);
213 void addIPStabilization (
const matrix_ptrType& matrix,
216 addIPStabilizationStencil (matrix, matrix, coef);
223 typedef MatrixElemental localMatrix_type;
224 typedef std::unique_ptr<localMatrix_type> localMatrix_ptrType;
227 typedef std::unique_ptr<currentFE_type> currentFE_ptrType;
230 typedef std::unique_ptr<currentBdFE_type> currentBdFE_ptrType;
234 fespace_ptrType M_fespace;
237 fespace_ptrType M_betaFESpace;
239 currentBdFE_ptrType M_IPFaceCFE;
241 currentFE_ptrType M_IPQuad1CFE;
242 currentFE_ptrType M_IPQuad2CFE;
244 currentFE_ptrType M_IP1CFE;
245 currentFE_ptrType M_IP2CFE;
247 currentFE_ptrType M_IPBetaCFE;
250 localMatrix_ptrType M_localIPGalerkin_11;
251 localMatrix_ptrType M_localIPGalerkin_22;
254 localMatrix_ptrType M_localIPExtended_12;
255 localMatrix_ptrType M_localIPExtended_21;
262 template<
typename mesh_type,
typename matrix_type,
typename vector_type>
263 ADRAssemblerIP< mesh_type, matrix_type, vector_type>::
279 M_localIPGalerkin_11(),
280 M_localIPGalerkin_22(),
281 M_localIPExtended_12(),
282 M_localIPExtended_21()
289 template<
typename mesh_type,
typename matrix_type,
typename vector_type>
291 ADRAssemblerIP< mesh_type, matrix_type, vector_type>::
292 setup (
const fespace_ptrType& fespace,
const fespace_ptrType& betaFESpace )
295 M_betaFESpace = betaFESpace;
297 M_IPFaceCFE.reset (
new CurrentFEManifold (M_fespace->feBd().refFE(), M_fespace->feBd().geoMap(), M_fespace->feBd().quadRule() ) );
300 M_IPQuad1CFE.reset (
new CurrentFE (M_fespace->refFE(), M_fespace->fe().geoMap(), M_fespace->qr() ) );
301 M_IPQuad2CFE.reset (
new CurrentFE (M_fespace->refFE(), M_fespace->fe().geoMap(), M_fespace->qr() ) );
305 M_IP1CFE.reset (
new CurrentFE (M_fespace->refFE(), M_fespace->fe().geoMap(), M_fespace->qr() ) );
306 M_IP2CFE.reset (
new CurrentFE (M_fespace->refFE(), M_fespace->fe().geoMap(), M_fespace->qr() ) );
307 M_IPBetaCFE.reset (
new CurrentFE (M_betaFESpace->refFE(), M_fespace->fe().geoMap(), M_fespace->qr() ) );
310 M_localIPGalerkin_11.reset (
new localMatrix_type (M_fespace->fe().nbFEDof()
311 , M_fespace->fieldDim()
312 , M_fespace->fieldDim() ) );
313 M_localIPGalerkin_22.reset (
new localMatrix_type (M_fespace->fe().nbFEDof()
314 , M_fespace->fieldDim()
315 , M_fespace->fieldDim() ) );
316 M_localIPExtended_12.reset (
new localMatrix_type (M_fespace->fe().nbFEDof()
317 , M_fespace->fieldDim()
318 , M_fespace->fieldDim() ) );
319 M_localIPExtended_21.reset (
new localMatrix_type (M_fespace->fe().nbFEDof()
320 , M_fespace->fieldDim()
321 , M_fespace->fieldDim() ) );
324 template<
typename mesh_type,
typename matrix_type,
typename vector_type>
326 ADRAssemblerIP< mesh_type, matrix_type, vector_type>::
327 addIPStabilizationStencil (
const matrix_ptrType& matrixGalerkin,
328 const matrix_ptrType& matrixExtended,
329 const vector_type& beta,
334 addIPStabilizationStencil (matrixGalerkin, matrixExtended, vector_type (beta,
Repeated), coef);
338 ASSERT (M_fespace != 0,
"No FE space for building the IP stabilization! ");
339 ASSERT (M_betaFESpace != 0,
"No FE space (beta) for building the IP stabilization! ");
342 const UInt nbBoundaryFaces (M_fespace->mesh()->numBFaces() );
343 const UInt nbFaces (M_fespace->mesh()->numFaces() );
344 const UInt nbQuadPt (M_fespace->bdQr().nbQuadPt() );
345 const UInt nbLocalDof (M_fespace->fe().nbFEDof() );
346 const UInt nbLocalBetaDof (M_betaFESpace->fe().nbFEDof() );
347 const UInt nbComponents (M_fespace->fieldDim() );
348 const UInt betaTotalDof (M_betaFESpace->dof().numTotalDof() );
352 Real localValue_11 (0.0);
353 Real localValue_22 (0.0);
354 Real localValue_12 (0.0);
355 Real localValue_21 (0.0);
356 std::vector<Real> betaN (nbQuadPt, 0.0);
360 for (
UInt iFace (nbBoundaryFaces); iFace < nbFaces; ++iFace)
363 const UInt adjacentElement1 (M_fespace->mesh()->face (iFace).firstAdjacentElementIdentity() );
364 const UInt adjacentElement2 (M_fespace->mesh()->face (iFace).secondAdjacentElementIdentity() );
372 if ( Flag::testOneSet ( M_fespace->mesh()->face (iFace).flag(), EntityFlags::SUBDOMAIN_INTERFACE | EntityFlags::PHYSICAL_BOUNDARY ) )
382 M_IPFaceCFE->update (M_fespace->mesh()->face (iFace), UPDATE_W_ROOT_DET_METRIC | UPDATE_NORMALS | UPDATE_QUAD_NODES);
383 hFace2 = M_IPFaceCFE->measure();
388 M_IPQuad1CFE->update ( M_fespace->mesh()->element (adjacentElement1), UPDATE_ONLY_CELL_NODES );
391 for (
UInt iQuad (0); iQuad < nbQuadPt; ++iQuad)
393 Real x (0.0), y (0.0), z (0.0);
394 M_IPQuad1CFE->coorBackMap ( M_IPFaceCFE->quadPt (iQuad, 0),
395 M_IPFaceCFE->quadPt (iQuad, 1),
396 M_IPFaceCFE->quadPt (iQuad, 2),
399 faceQR1.addPoint (newPoint);
402 M_IPQuad2CFE->update ( M_fespace->mesh()->element (adjacentElement2), UPDATE_ONLY_CELL_NODES );
404 for (
UInt iQuad (0); iQuad < nbQuadPt; ++iQuad)
406 Real x (0.0), y (0.0), z (0.0);
407 M_IPQuad2CFE->coorBackMap ( M_IPFaceCFE->quadPt (iQuad, 0),
408 M_IPFaceCFE->quadPt (iQuad, 1),
409 M_IPFaceCFE->quadPt (iQuad, 2),
412 faceQR2.addPoint (newPoint);
417 M_IP1CFE->setQuadRule (faceQR1);
418 M_IP2CFE->setQuadRule (faceQR2);
419 M_IPBetaCFE->setQuadRule (faceQR1);
424 M_IP1CFE->update (M_fespace->mesh()->element (adjacentElement1), UPDATE_DPHI | UPDATE_WDET);
425 M_IP2CFE->update (M_fespace->mesh()->element (adjacentElement2), UPDATE_DPHI | UPDATE_WDET);
430 for (
UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
432 betaN[iQuadPt] = 0.0;
433 for (
UInt iDof (0); iDof < nbLocalBetaDof; ++iDof)
435 for (
UInt iDim (0); iDim < 3; ++iDim)
437 betaN[iQuadPt] += beta[M_betaFESpace->dof().localToGlobalMap (adjacentElement1, iDof)
438 + betaTotalDof * iDim]
439 * M_IPBetaCFE->phi (iDof, iQuadPt)
440 * M_IPFaceCFE->normal (iDim, iQuadPt);
443 betaN[iQuadPt] = std::fabs (betaN[iQuadPt]);
452 M_localIPGalerkin_11->zero();
453 M_localIPGalerkin_22->zero();
454 M_localIPExtended_12->zero();
455 M_localIPExtended_21->zero();
458 for (
UInt iFieldDim (0); iFieldDim < nbComponents; ++iFieldDim)
461 localMatrix_type::matrix_view viewIPGalerkin_11 = M_localIPGalerkin_11->block (iFieldDim, iFieldDim);
462 localMatrix_type::matrix_view viewIPGalerkin_22 = M_localIPGalerkin_22->block (iFieldDim, iFieldDim);
463 localMatrix_type::matrix_view viewIPExtended_12 = M_localIPExtended_12->block (iFieldDim, iFieldDim);
464 localMatrix_type::matrix_view viewIPExtended_21 = M_localIPExtended_21->block (iFieldDim, iFieldDim);
466 for (
UInt iDof (0); iDof < nbLocalDof; ++iDof)
468 for (
UInt jDof (0); jDof < nbLocalDof; ++jDof)
475 for (
UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
477 for (
UInt iDim (0); iDim < 3; ++iDim)
479 localValue_11 += betaN[iQuadPt]
480 * M_IP1CFE->dphi (iDof, iDim, iQuadPt)
481 * M_IP1CFE->dphi (jDof, iDim, iQuadPt)
482 * M_IP1CFE->wDetJacobian (iQuadPt);
484 localValue_22 += betaN[iQuadPt]
485 * M_IP2CFE->dphi (iDof, iDim, iQuadPt)
486 * M_IP2CFE->dphi (jDof, iDim, iQuadPt)
487 * M_IP2CFE->wDetJacobian (iQuadPt);
489 localValue_12 += betaN[iQuadPt]
490 * M_IP1CFE->dphi (iDof, iDim, iQuadPt)
491 * M_IP2CFE->dphi (jDof, iDim, iQuadPt)
492 * M_IP1CFE->wDetJacobian (iQuadPt);
494 localValue_21 += betaN[iQuadPt]
495 * M_IP2CFE->dphi (iDof, iDim, iQuadPt)
496 * M_IP1CFE->dphi (jDof, iDim, iQuadPt)
497 * M_IP1CFE->wDetJacobian (iQuadPt);
504 viewIPGalerkin_11 (iDof, jDof) += coef * hFace2 * localValue_11;
505 viewIPGalerkin_22 (iDof, jDof) += coef * hFace2 * localValue_22;
506 viewIPExtended_12 (iDof, jDof) += -coef * hFace2 * localValue_12;
507 viewIPExtended_21 (iDof, jDof) += -coef * hFace2 * localValue_21;
517 for (
UInt iFieldDim (0); iFieldDim < nbComponents; ++iFieldDim)
519 assembleMatrix ( *matrixGalerkin,
520 *M_localIPGalerkin_11,
525 iFieldDim, iFieldDim,
526 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
528 assembleMatrix ( *matrixGalerkin,
529 *M_localIPGalerkin_22,
534 iFieldDim, iFieldDim,
535 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
537 assembleMatrix ( *matrixExtended,
538 *M_localIPExtended_12,
543 iFieldDim, iFieldDim,
544 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
546 assembleMatrix ( *matrixExtended,
547 *M_localIPExtended_21,
552 iFieldDim, iFieldDim,
553 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
559 template<
typename mesh_type,
typename matrix_type,
typename vector_type>
561 ADRAssemblerIP< mesh_type, matrix_type, vector_type>::
562 addIPStabilizationStencil (
const matrix_ptrType& matrixGalerkin,
563 const matrix_ptrType& matrixExtended,
566 ASSERT (M_fespace != 0,
"No FE space for building the IP stabilization! ");
569 const UInt nbBoundaryFaces (M_fespace->mesh()->numBFaces() );
570 const UInt nbFaces (M_fespace->mesh()->numFaces() );
571 const UInt nbQuadPt (M_fespace->bdQr().nbQuadPt() );
572 const UInt nbLocalDof (M_fespace->fe().nbFEDof() );
573 const UInt nbComponents (M_fespace->fieldDim() );
577 Real localValue_11 (0.0);
578 Real localValue_22 (0.0);
579 Real localValue_12 (0.0);
580 Real localValue_21 (0.0);
584 for (
UInt iFace (nbBoundaryFaces); iFace < nbFaces; ++iFace)
587 const UInt adjacentElement1 (M_fespace->mesh()->face (iFace).firstAdjacentElementIdentity() );
588 const UInt adjacentElement2 (M_fespace->mesh()->face (iFace).secondAdjacentElementIdentity() );
596 if ( (adjacentElement1 ==
NotAnId) || (adjacentElement2 ==
NotAnId) || (adjacentElement1 == adjacentElement2) )
606 M_IPFaceCFE->update (M_fespace->mesh()->face (iFace), UPDATE_W_ROOT_DET_METRIC | UPDATE_QUAD_NODES);
607 hFace2 = M_IPFaceCFE->measure();
612 M_IPQuad1CFE->update ( M_fespace->mesh()->element (adjacentElement1), UPDATE_ONLY_CELL_NODES );
615 for (
int iQuad (0); iQuad < nbQuadPt; ++iQuad)
617 Real x (0.0), y (0.0), z (0.0);
618 M_IPQuad1CFE->coorBackMap ( M_IPFaceCFE->quadPt (iQuad, 0),
619 M_IPFaceCFE->quadPt (iQuad, 1),
620 M_IPFaceCFE->quadPt (iQuad, 2),
623 faceQR1.addPoint (newPoint);
626 M_IPQuad2CFE->update ( M_fespace->mesh()->element (adjacentElement2), UPDATE_ONLY_CELL_NODES );
628 for (
int iQuad (0); iQuad < nbQuadPt; ++iQuad)
630 Real x (0.0), y (0.0), z (0.0);
631 M_IPQuad2CFE->coorBackMap ( M_IPFaceCFE->quadPt (iQuad, 0),
632 M_IPFaceCFE->quadPt (iQuad, 1),
633 M_IPFaceCFE->quadPt (iQuad, 2),
636 faceQR2.addPoint (newPoint);
641 M_IP1CFE->setQuadRule (faceQR1);
642 M_IP2CFE->setQuadRule (faceQR2);
647 M_IP1CFE->update (M_fespace->mesh()->element (adjacentElement1), UPDATE_DPHI | UPDATE_WDET);
648 M_IP2CFE->update (M_fespace->mesh()->element (adjacentElement2), UPDATE_DPHI | UPDATE_WDET);
656 M_localIPGalerkin_11->zero();
657 M_localIPGalerkin_22->zero();
658 M_localIPExtended_12->zero();
659 M_localIPExtended_21->zero();
662 for (
UInt iFieldDim (0); iFieldDim < nbComponents; ++iFieldDim)
665 localMatrix_type::matrix_view viewIPGalerkin_11 = M_localIPGalerkin_11->block (iFieldDim, iFieldDim);
666 localMatrix_type::matrix_view viewIPGalerkin_22 = M_localIPGalerkin_22->block (iFieldDim, iFieldDim);
667 localMatrix_type::matrix_view viewIPExtended_12 = M_localIPExtended_12->block (iFieldDim, iFieldDim);
668 localMatrix_type::matrix_view viewIPExtended_21 = M_localIPExtended_21->block (iFieldDim, iFieldDim);
670 for (
UInt iDof (0); iDof < nbLocalDof; ++iDof)
672 for (
UInt jDof (0); jDof < nbLocalDof; ++jDof)
679 for (
UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
681 for (
UInt iDim (0); iDim < 3; ++iDim)
684 * M_IP1CFE->dphi (iDof, iDim, iQuadPt)
685 * M_IP1CFE->dphi (jDof, iDim, iQuadPt)
686 * M_IP1CFE->wDetJacobian (iQuadPt);
689 * M_IP2CFE->dphi (iDof, iDim, iQuadPt)
690 * M_IP2CFE->dphi (jDof, iDim, iQuadPt)
691 * M_IP2CFE->wDetJacobian (iQuadPt);
694 * M_IP1CFE->dphi (iDof, iDim, iQuadPt)
695 * M_IP2CFE->dphi (jDof, iDim, iQuadPt)
696 * M_IP1CFE->wDetJacobian (iQuadPt);
699 * M_IP2CFE->dphi (iDof, iDim, iQuadPt)
700 * M_IP1CFE->dphi (jDof, iDim, iQuadPt)
701 * M_IP1CFE->wDetJacobian (iQuadPt);
708 viewIPGalerkin_11 (iDof, jDof) += coef * hFace2 * localValue_11;
709 viewIPGalerkin_22 (iDof, jDof) += coef * hFace2 * localValue_22;
710 viewIPExtended_12 (iDof, jDof) += -coef * hFace2 * localValue_12;
711 viewIPExtended_21 (iDof, jDof) += -coef * hFace2 * localValue_21;
721 for (
UInt iFieldDim (0); iFieldDim < nbComponents; ++iFieldDim)
723 assembleMatrix ( *matrixGalerkin,
724 *M_localIPGalerkin_11,
729 iFieldDim, iFieldDim,
730 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
732 assembleMatrix ( *matrixGalerkin,
733 *M_localIPGalerkin_22,
738 iFieldDim, iFieldDim,
739 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
741 assembleMatrix ( *matrixExtended,
742 *M_localIPExtended_12,
747 iFieldDim, iFieldDim,
748 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
750 assembleMatrix ( *matrixExtended,
751 *M_localIPExtended_21,
756 iFieldDim, iFieldDim,
757 iFieldDim * M_fespace->dof().numTotalDof(), iFieldDim * M_fespace->dof().numTotalDof() );
A class for a finite element on a manifold.
Epetra_Import const & importer()
Getter for the Epetra_Import.
QuadraturePoint - Simple container for a point of a quadrature rule.
double Real
Generic real data.
CurrentFE - A primordial class for the assembly of the local matrices/vectors retaining the values on...
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)