27 #ifndef ASSEMBLE_DG_HPP_
28 #define ASSEMBLE_DG_HPP_
30 #include <deal.II/base/parameter_handler.h>
32 #include <deal.II/fe/mapping_q1_eulerian.h>
34 #include <deal.II/lac/full_matrix.h>
42 #include "source/core_model.hpp"
43 #include "source/geometry/mesh_handler.hpp"
44 #include "source/init.hpp"
45 #include "source/io/data_writer.hpp"
46 #include "source/numerics/bc_handler.hpp"
47 #include "source/numerics/linear_solver_handler.hpp"
48 #include "source/numerics/preconditioner_handler.hpp"
49 #include "source/numerics/tools.hpp"
67 template <
class basis>
104 :
basis_ptr(std::make_unique<basis>(degree))
130 const unsigned int new_edge);
143 dealii::FullMatrix<double>
149 dealii::FullMatrix<double>
150 local_V(
const dealii::Tensor<2, lifex::dim> &Sigma)
const;
155 dealii::FullMatrix<double>
163 dealii::Vector<double>
164 local_rhs(
const std::shared_ptr<dealii::Function<lifex::dim>> &f_ex)
const;
171 dealii::Vector<double>
173 const double stability_coefficient,
175 const std::shared_ptr<lifex::utils::FunctionDirichlet> &u_ex)
const;
180 dealii::Vector<double>
182 const std::shared_ptr<dealii::Function<lifex::dim>> &g)
const;
188 dealii::FullMatrix<double>
189 local_SC(
const double stability_coefficient)
const;
196 dealii::FullMatrix<double>
197 local_SC(
const double stability_coefficient,
198 const dealii::Tensor<2, lifex::dim> &Sigma)
const;
204 dealii::FullMatrix<double>
205 local_SN(
const double stability_coefficient)
const;
212 dealii::FullMatrix<double>
213 local_SN(
const double stability_coefficient,
214 const dealii::Tensor<2, lifex::dim> &Sigma)
const;
225 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
240 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
242 const dealii::Tensor<2, lifex::dim> &Sigma)
const;
251 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
264 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
266 const dealii::Tensor<2, lifex::dim> &Sigma)
const;
275 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
287 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
289 const dealii::Tensor<2, lifex::dim> &Sigma)
const;
295 dealii::Vector<double>
297 const lifex::LinAlg::MPI::Vector &u0,
298 const std::vector<dealii::types::global_dof_index> &dof_indices)
const;
306 dealii::Vector<double>
308 const lifex::LinAlg::MPI::Vector &u0,
309 const std::vector<dealii::types::global_dof_index> &dof_indices)
const;
316 dealii::FullMatrix<double>
318 const lifex::LinAlg::MPI::Vector &u0,
320 const std::vector<dealii::types::global_dof_index> &dof_indices)
const;
326 template <
class basis>
330 const unsigned int new_edge)
333 face_handler.reinit(new_cell, new_edge);
335 if (!cell->at_boundary(new_edge))
337 const auto neighcell = cell->neighbor(new_edge);
338 const auto neighedge = cell->neighbor_face_no(new_edge);
340 face_handler_neigh.reinit(neighcell, neighedge);
344 template <
class basis>
350 vol_handler.reinit(new_cell);
353 template <
class basis>
361 unsigned int denominator = 1;
362 unsigned int nominator = 1;
364 for (
unsigned int i = 1; i <= lifex::dim; i++)
367 nominator *= poly_degree + i;
370 return (
int)(nominator / denominator);
374 template <
class basis>
375 dealii::FullMatrix<double>
378 dealii::FullMatrix<double> V(dofs_per_cell, dofs_per_cell);
379 const dealii::Tensor<2, lifex::dim> BJinv =
380 vol_handler.get_jacobian_inverse();
381 const double det = 1 / determinant(BJinv);
383 for (
unsigned int q = 0; q < n_quad_points; ++q)
385 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
387 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
390 (basis_ptr->shape_grad(i, vol_handler.quadrature_ref(q)) *
392 (basis_ptr->shape_grad(j, vol_handler.quadrature_ref(q)) *
394 vol_handler.quadrature_weight(q) * det;
403 template <
class basis>
404 dealii::FullMatrix<double>
407 dealii::FullMatrix<double> V(dofs_per_cell, dofs_per_cell);
408 const dealii::Tensor<2, lifex::dim> BJinv =
409 vol_handler.get_jacobian_inverse();
410 const double det = 1 / determinant(BJinv);
412 const dealii::Tensor<2, lifex::dim> Sigma_tr = transpose(Sigma);
414 for (
unsigned int q = 0; q < n_quad_points; ++q)
416 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
418 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
421 (basis_ptr->shape_grad(i, vol_handler.quadrature_ref(q)) *
423 (basis_ptr->shape_grad(j, vol_handler.quadrature_ref(q)) *
425 vol_handler.quadrature_weight(q) * det;
433 template <
class basis>
434 dealii::FullMatrix<double>
437 dealii::FullMatrix<double> M(dofs_per_cell, dofs_per_cell);
438 const dealii::Tensor<2, lifex::dim> BJinv =
439 vol_handler.get_jacobian_inverse();
440 const double det = 1 / determinant(BJinv);
442 for (
unsigned int q = 0; q < n_quad_points; ++q)
444 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
446 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
449 (basis_ptr->shape_value(i, vol_handler.quadrature_ref(q))) *
450 (basis_ptr->shape_value(j, vol_handler.quadrature_ref(q))) *
451 vol_handler.quadrature_weight(q) * det;
459 template <
class basis>
460 dealii::Vector<double>
462 const std::shared_ptr<dealii::Function<lifex::dim>> &f_ex)
const
464 AssertThrow(f_ex !=
nullptr,
465 dealii::StandardExceptions::ExcMessage(
466 "Not valid pointer to the source term."));
468 dealii::Vector<double> cell_rhs(dofs_per_cell);
469 const dealii::Tensor<2, lifex::dim> BJinv =
470 vol_handler.get_jacobian_inverse();
471 const double det = 1 / determinant(BJinv);
473 for (
unsigned int q = 0; q < n_quad_points; ++q)
475 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
478 f_ex->value(vol_handler.quadrature_real(q)) *
479 basis_ptr->shape_value(i, vol_handler.quadrature_ref(q)) *
480 vol_handler.quadrature_weight(q) * det;
487 template <
class basis>
488 dealii::Vector<double>
490 const double stability_coefficient,
492 const std::shared_ptr<lifex::utils::FunctionDirichlet> &u_ex)
const
494 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
495 dealii::StandardExceptions::ExcMessage(
496 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
497 "or -1 (NIP method)."));
499 AssertThrow(u_ex !=
nullptr,
500 dealii::StandardExceptions::ExcMessage(
501 "Not valid pointer to the exact solution."));
503 dealii::Vector<double> cell_rhs(dofs_per_cell);
504 const dealii::Tensor<2, lifex::dim> BJinv =
505 face_handler.get_jacobian_inverse();
507 const double face_measure = face_handler.get_measure();
508 const double unit_face_measure = (4.0 - lifex::dim) / 2;
509 const double measure_ratio = face_measure / unit_face_measure;
510 const double h_local = (cell->measure()) / face_measure;
512 const double local_pen_coeff =
513 (stability_coefficient * pow(poly_degree, 2)) / h_local;
515 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
517 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
521 basis_ptr->shape_value(i, face_handler.quadrature_ref(q)) *
522 u_ex->value(face_handler.quadrature_real(q)) *
523 face_handler.quadrature_weight(q) * measure_ratio;
527 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
529 face_handler.get_normal()) *
530 u_ex->value(face_handler.quadrature_real(q)) *
531 face_handler.quadrature_weight(q) * measure_ratio;
538 template <
class basis>
539 dealii::Vector<double>
541 const std::shared_ptr<dealii::Function<lifex::dim>> &g)
const
543 AssertThrow(g !=
nullptr,
544 dealii::StandardExceptions::ExcMessage(
545 "Not valid pointer to the Neumann function."));
547 dealii::Vector<double> cell_rhs(dofs_per_cell);
549 const double face_measure = face_handler.get_measure();
550 const double unit_face_measure = (4.0 - lifex::dim) / 2;
551 const double measure_ratio = face_measure / unit_face_measure;
553 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
555 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
558 basis_ptr->shape_value(i, face_handler.quadrature_ref(q)) *
559 g->value(face_handler.quadrature_real(q)) *
560 face_handler.quadrature_weight(q) * measure_ratio;
567 template <
class basis>
568 dealii::FullMatrix<double>
571 const double face_measure = face_handler.get_measure();
572 const double unit_face_measure = (4.0 - lifex::dim) / 2;
573 const double measure_ratio = face_measure / unit_face_measure;
574 const double h_local = (cell->measure()) / face_measure;
576 const double local_pen_coeff =
577 (stability_coefficient * pow(poly_degree, 2)) / h_local;
579 dealii::FullMatrix<double> SC(dofs_per_cell, dofs_per_cell);
581 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
583 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
585 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
589 basis_ptr->shape_value(i, face_handler.quadrature_ref(q)) *
590 basis_ptr->shape_value(j, face_handler.quadrature_ref(q)) *
591 face_handler.quadrature_weight(q) * measure_ratio;
599 template <
class basis>
600 dealii::FullMatrix<double>
602 const dealii::Tensor<2, lifex::dim> &Sigma)
const
604 const double face_measure = face_handler.get_measure();
605 const double unit_face_measure = (4.0 - lifex::dim) / 2;
606 const double measure_ratio = face_measure / unit_face_measure;
607 const double h_local = (cell->measure()) / face_measure;
609 const double local_pen_coeff =
610 (stability_coefficient * pow(poly_degree, 2)) / h_local;
612 const double penalty_sigma =
613 std::abs(face_handler.get_normal() * Sigma * face_handler.get_normal());
615 dealii::FullMatrix<double> SC(dofs_per_cell, dofs_per_cell);
617 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
619 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
621 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
624 local_pen_coeff * penalty_sigma *
625 basis_ptr->shape_value(i, face_handler.quadrature_ref(q)) *
626 basis_ptr->shape_value(j, face_handler.quadrature_ref(q)) *
627 face_handler.quadrature_weight(q) * measure_ratio;
636 template <
class basis>
637 dealii::FullMatrix<double>
640 const double face_measure = face_handler.get_measure();
641 const double unit_face_measure = (4.0 - lifex::dim) / 2;
642 const double measure_ratio = face_measure / unit_face_measure;
643 const double h_local = (cell->measure()) / face_measure;
645 const double local_pen_coeff =
646 (stability_coefficient * pow(poly_degree, 2)) / h_local;
648 dealii::FullMatrix<double> SN(dofs_per_cell, dofs_per_cell);
650 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
652 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
654 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
656 const unsigned int nq =
657 face_handler.corresponding_neigh_index(q, face_handler_neigh);
661 basis_ptr->shape_value(i, face_handler.quadrature_ref(q)) *
662 basis_ptr->shape_value(j,
663 face_handler_neigh.quadrature_ref(nq)) *
664 face_handler.quadrature_weight(q) * measure_ratio;
672 template <
class basis>
673 dealii::FullMatrix<double>
675 const dealii::Tensor<2, lifex::dim> &Sigma)
const
677 const double face_measure = face_handler.get_measure();
678 const double unit_face_measure = (4.0 - lifex::dim) / 2;
679 const double measure_ratio = face_measure / unit_face_measure;
680 const double h_local = (cell->measure()) / face_measure;
682 const double local_pen_coeff =
683 (stability_coefficient * pow(poly_degree, 2)) / h_local;
685 const double penalty_sigma =
686 std::abs(face_handler.get_normal() * Sigma * face_handler.get_normal());
688 dealii::FullMatrix<double> SN(dofs_per_cell, dofs_per_cell);
690 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
692 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
694 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
696 const unsigned int nq =
697 face_handler.corresponding_neigh_index(q, face_handler_neigh);
700 local_pen_coeff * penalty_sigma *
701 basis_ptr->shape_value(i, face_handler.quadrature_ref(q)) *
702 basis_ptr->shape_value(j,
703 face_handler_neigh.quadrature_ref(nq)) *
704 face_handler.quadrature_weight(q) * measure_ratio;
712 template <
class basis>
713 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
716 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
717 dealii::StandardExceptions::ExcMessage(
718 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
719 "or -1 (NIP method)."));
721 const dealii::Tensor<2, lifex::dim> BJinv =
722 face_handler.get_jacobian_inverse();
724 const double face_measure = face_handler.get_measure();
725 const double unit_face_measure = (4.0 - lifex::dim) / 2;
726 const double measure_ratio = face_measure / unit_face_measure;
728 dealii::FullMatrix<double> IC(dofs_per_cell, dofs_per_cell);
729 dealii::FullMatrix<double> IC_t(dofs_per_cell, dofs_per_cell);
731 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
733 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
735 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
739 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
741 face_handler.get_normal()) *
742 basis_ptr->shape_value(j, face_handler.quadrature_ref(q)) *
743 face_handler.quadrature_weight(q) * measure_ratio;
749 IC_t.copy_transposed(IC);
755 template <
class basis>
756 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
758 const dealii::Tensor<2, lifex::dim> &Sigma)
const
760 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
761 dealii::StandardExceptions::ExcMessage(
762 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
763 "or -1 (NIP method)."));
765 const dealii::Tensor<2, lifex::dim> BJinv =
766 face_handler.get_jacobian_inverse();
768 const double face_measure = face_handler.get_measure();
769 const double unit_face_measure = (4.0 - lifex::dim) / 2;
770 const double measure_ratio = face_measure / unit_face_measure;
772 const dealii::Tensor<2, lifex::dim> Sigma_tr = transpose(Sigma);
774 dealii::FullMatrix<double> IC(dofs_per_cell, dofs_per_cell);
775 dealii::FullMatrix<double> IC_t(dofs_per_cell, dofs_per_cell);
777 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
779 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
781 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
785 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
787 face_handler.get_normal()) *
788 basis_ptr->shape_value(j, face_handler.quadrature_ref(q)) *
789 face_handler.quadrature_weight(q) * measure_ratio;
795 IC_t.copy_transposed(IC);
801 template <
class basis>
802 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
805 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
806 dealii::StandardExceptions::ExcMessage(
807 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
808 "or -1 (NIP method)."));
810 const dealii::Tensor<2, lifex::dim> BJinv =
811 face_handler.get_jacobian_inverse();
813 const double face_measure = face_handler.get_measure();
814 const double unit_face_measure = (4.0 - lifex::dim) / 2;
815 const double measure_ratio = face_measure / unit_face_measure;
817 dealii::FullMatrix<double> IB(dofs_per_cell, dofs_per_cell);
818 dealii::FullMatrix<double> IB_t(dofs_per_cell, dofs_per_cell);
820 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
822 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
824 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
827 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
829 face_handler.get_normal()) *
830 basis_ptr->shape_value(j, face_handler.quadrature_ref(q)) *
831 face_handler.quadrature_weight(q) * measure_ratio;
837 IB_t.copy_transposed(IB);
843 template <
class basis>
844 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
846 const dealii::Tensor<2, lifex::dim> &Sigma)
const
848 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
849 dealii::StandardExceptions::ExcMessage(
850 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
851 "or -1 (NIP method)."));
853 const dealii::Tensor<2, lifex::dim> BJinv =
854 face_handler.get_jacobian_inverse();
856 const double face_measure = face_handler.get_measure();
857 const double unit_face_measure = (4.0 - lifex::dim) / 2;
858 const double measure_ratio = face_measure / unit_face_measure;
860 const dealii::Tensor<2, lifex::dim> Sigma_tr = transpose(Sigma);
862 dealii::FullMatrix<double> IB(dofs_per_cell, dofs_per_cell);
863 dealii::FullMatrix<double> IB_t(dofs_per_cell, dofs_per_cell);
865 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
867 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
869 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
872 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
874 face_handler.get_normal()) *
875 basis_ptr->shape_value(j, face_handler.quadrature_ref(q)) *
876 face_handler.quadrature_weight(q) * measure_ratio;
882 IB_t.copy_transposed(IB);
888 template <
class basis>
889 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
892 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
893 dealii::StandardExceptions::ExcMessage(
894 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
895 "or -1 (NIP method)."));
897 const dealii::Tensor<2, lifex::dim> BJinv =
898 face_handler.get_jacobian_inverse();
900 const double face_measure = face_handler.get_measure();
901 const double unit_face_measure = (4.0 - lifex::dim) / 2;
902 const double measure_ratio = face_measure / unit_face_measure;
904 dealii::FullMatrix<double> IN(dofs_per_cell, dofs_per_cell);
905 dealii::FullMatrix<double> IN_t(dofs_per_cell, dofs_per_cell);
907 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
909 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
911 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
913 const unsigned int nq =
914 face_handler.corresponding_neigh_index(q, face_handler_neigh);
918 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
920 face_handler.get_normal()) *
921 basis_ptr->shape_value(j,
922 face_handler_neigh.quadrature_ref(nq)) *
923 face_handler.quadrature_weight(q) * measure_ratio;
928 IN_t.copy_transposed(IN);
934 template <
class basis>
935 std::pair<dealii::FullMatrix<double>, dealii::FullMatrix<double>>
937 const dealii::Tensor<2, lifex::dim> &Sigma)
const
939 AssertThrow(theta == 1. || theta == 0. || theta == -1.,
940 dealii::StandardExceptions::ExcMessage(
941 "Penalty coefficient must be 1 (SIP method) or 0 (IIP method) "
942 "or -1 (NIP method)."));
944 const dealii::Tensor<2, lifex::dim> BJinv =
945 face_handler.get_jacobian_inverse();
947 const double face_measure = face_handler.get_measure();
948 const double unit_face_measure = (4.0 - lifex::dim) / 2;
949 const double measure_ratio = face_measure / unit_face_measure;
951 const dealii::Tensor<2, lifex::dim> Sigma_tr = transpose(Sigma);
953 dealii::FullMatrix<double> IN(dofs_per_cell, dofs_per_cell);
954 dealii::FullMatrix<double> IN_t(dofs_per_cell, dofs_per_cell);
956 for (
unsigned int q = 0; q < n_quad_points_face; ++q)
958 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
960 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
962 const unsigned int nq =
963 face_handler.corresponding_neigh_index(q, face_handler_neigh);
967 ((basis_ptr->shape_grad(i, face_handler.quadrature_ref(q)) *
969 face_handler.get_normal()) *
970 basis_ptr->shape_value(j,
971 face_handler_neigh.quadrature_ref(nq)) *
972 face_handler.quadrature_weight(q) * measure_ratio;
977 IN_t.copy_transposed(IN);
983 template <
class basis>
984 dealii::Vector<double>
986 const lifex::LinAlg::MPI::Vector &u0,
987 const std::vector<dealii::types::global_dof_index> &dof_indices)
const
989 std::vector<double> u_bdf_loc(n_quad_points);
990 std::fill(u_bdf_loc.begin(), u_bdf_loc.end(), 0);
992 for (
unsigned int q = 0; q < n_quad_points; ++q)
994 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
998 basis_ptr->shape_value(i, vol_handler.quadrature_ref(q));
1002 dealii::Vector<double> cell_rhs(dofs_per_cell);
1003 const dealii::Tensor<2, lifex::dim> BJinv =
1004 vol_handler.get_jacobian_inverse();
1005 const double det = 1 / determinant(BJinv);
1007 for (
unsigned int q = 0; q < n_quad_points; ++q)
1009 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1013 basis_ptr->shape_value(i, vol_handler.quadrature_ref(q)) *
1014 vol_handler.quadrature_weight(q) * det;
1021 template <
class basis>
1022 dealii::Vector<double>
1024 const lifex::LinAlg::MPI::Vector &u0,
1025 const std::vector<dealii::types::global_dof_index> &dof_indices)
const
1027 dealii::Vector<double> cell_rhs(dofs_per_cell);
1028 const dealii::Tensor<2, lifex::dim> BJinv =
1029 vol_handler.get_jacobian_inverse();
1030 const double det = 1 / determinant(BJinv);
1032 for (
unsigned int q = 0; q < n_quad_points; ++q)
1034 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1036 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1039 (basis_ptr->shape_value(i, vol_handler.quadrature_ref(q))) *
1040 (basis_ptr->shape_value(j, vol_handler.quadrature_ref(q))) *
1041 vol_handler.quadrature_weight(q) * det * u0[dof_indices[j]];
1049 template <
class basis>
1050 dealii::FullMatrix<double>
1052 const lifex::LinAlg::MPI::Vector &u0,
1054 const std::vector<dealii::types::global_dof_index> &dof_indices)
const
1056 dealii::FullMatrix<double> C(dofs_per_cell, dofs_per_cell);
1057 const dealii::Tensor<2, lifex::dim> BJinv =
1058 vol_handler.get_jacobian_inverse();
1059 const double det = 1 / determinant(BJinv);
1065 for (
unsigned int q = 0; q < n_quad_points; ++q)
1069 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1071 non_lu += u0[dof_indices[i]] *
1072 basis_ptr->shape_value(i, vol_handler.quadrature_ref(q));
1075 non_lin = (non_lu - 1) * (non_lu - a);
1077 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1079 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1083 basis_ptr->shape_value(i, vol_handler.quadrature_ref(q)) *
1084 basis_ptr->shape_value(j, vol_handler.quadrature_ref(q)) *
1085 vol_handler.quadrature_weight(q) * det;
Class for the assembly of the main local matrices for discontinuous Galerkin methods.
FaceHandlerDG< lifex::dim > face_handler
Face element handler.
dealii::FullMatrix< double > local_M() const
Assembly of local mass matrix:
dealii::FullMatrix< double > local_SN(const double stability_coefficient) const
Assembly of the component of the local matrix S that is evaluated on the two sides of the edge:
dealii::FullMatrix< double > local_non_linear_fitzhugh(const lifex::LinAlg::MPI::Vector &u0, const double a, const std::vector< dealii::types::global_dof_index > &dof_indices) const
Assembly of the non-linear local matrix of the Fitzhugh-Nagumo model:
dealii::FullMatrix< double > local_V() const
Assembly of stiffness matrix:
dealii::FullMatrix< double > local_SC(const double stability_coefficient) const
Assembly of the component of the local matrix S that is evaluated on the same side of the edge:
std::pair< dealii::FullMatrix< double >, dealii::FullMatrix< double > > local_IN(const double theta) const
Assembly of the component of the local matrix I that is evaluated on the two sides of the edge.
dealii::Vector< double > local_rhs(const std::shared_ptr< dealii::Function< lifex::dim >> &f_ex) const
Assembly of the local forcing term:
const unsigned int n_quad_points_1D
Number of quadrature points in 1D.
dealii::Vector< double > local_rhs_edge_dirichlet(const double stability_coefficient, const double theta, const std::shared_ptr< lifex::utils::FunctionDirichlet > &u_ex) const
Assembly of the local matrix associated to non-homogeneous Dirichlet boundary conditions:
FaceHandlerDG< lifex::dim > face_handler_neigh
Face element handler of the neighbor face.
virtual ~AssembleDG()=default
Destructor.
unsigned int dofs_per_cell
Degree of freedom for each cell.
std::pair< dealii::FullMatrix< double >, dealii::FullMatrix< double > > local_IC(const double theta) const
Assembly of the component of the local matrix I that is evaluated on the same side of the edge.
const std::unique_ptr< basis > basis_ptr
Basis function class.
const unsigned int poly_degree
Polynomial degree.
dealii::Vector< double > local_u0_M_rhs(const lifex::LinAlg::MPI::Vector &u0, const std::vector< dealii::types::global_dof_index > &dof_indices) const
Assembly of the right hand side term associated to the previous time-step solution in time-dependent ...
dealii::Vector< double > local_rhs_edge_neumann(const std::shared_ptr< dealii::Function< lifex::dim >> &g) const
Assembly of the right hand side term associated to non-homogeneous Neumann boundary conditions:
dealii::DoFHandler< lifex::dim >::active_cell_iterator cell
Cell object.
dealii::Vector< double > local_w0_M_rhs(const lifex::LinAlg::MPI::Vector &u0, const std::vector< dealii::types::global_dof_index > &dof_indices) const
Assembly of the right hand side term associated to the previous time-step gating variable solution (f...
const unsigned int n_quad_points_face
Number of quadrature points in the face: (n_quad_points_1D)^(dim-1).
VolumeHandlerDG< lifex::dim > vol_handler
Volume element handler.
unsigned int get_dofs_per_cell() const
Return the number of degrees of freedom per element.
void reinit(const typename dealii::DoFHandler< lifex::dim >::active_cell_iterator &new_cell, const unsigned int new_edge)
Reinitialize object on the current new_edge of the new_cell.
std::pair< dealii::FullMatrix< double >, dealii::FullMatrix< double > > local_IB(const double theta) const
Assembly of the component of the local matrix I that is evaluated on the boundary edges.
const unsigned int n_quad_points
Number of quadrature points in the volume: (n_quad_points_1D)^(dim).
typename ActiveSelector::active_cell_iterator active_cell_iterator