37 face_midpoint(
const unsigned int face_no)
40 const auto face_reference_cell =
44 for (
const auto face_vertex_no : face_reference_cell.
vertex_indices())
46 const auto vertex_no = reference_cell.face_to_cell_vertices(
51 midpoint += reference_cell.template vertex<dim>(vertex_no);
54 midpoint /= reference_cell.face_reference_cell(0).n_vertices();
62 std::vector<unsigned int>
63 get_dpo_vector_fe_p(
const unsigned int dim,
const unsigned int degree)
116 std::vector<Point<dim>>
117 unit_support_points_fe_p(
const unsigned int degree)
121 std::vector<Point<dim>> unit_points;
122 const auto reference_cell = ReferenceCells::get_simplex<dim>();
128 unit_points.emplace_back(reference_cell.template barycenter<dim>());
133 const auto dpo = get_dpo_vector_fe_p(dim, degree);
146 for (
unsigned int p = 0; p < dpo[1]; ++p)
147 unit_points.push_back((
double(dpo[1] - p) / (dpo[1] + 1)) * p0 +
148 (
double(p + 1) / (dpo[1] + 1)) * p1);
151 if (dim > 1 && dpo[2] > 0)
158 unit_points.push_back(face_midpoint<dim>(f));
165 std::vector<Point<0>>
166 unit_support_points_fe_p(
const unsigned int )
176 std::vector<std::vector<
Point<dim - 1>>>
177 unit_face_support_points_fe_p(
178 const unsigned int degree,
189 std::vector<std::vector<
Point<dim - 1>>> unit_face_points;
195 unit_face_points.emplace_back(
196 unit_support_points_fe_p<dim - 1>(degree));
199 return unit_face_points;
209 constraints_fe_p(
const unsigned int )
218 constraints_fe_p<2>(
const unsigned int degree)
220 constexpr int dim = 2;
228 std::vector<
Point<dim - 1>> constraint_points;
230 constraint_points.emplace_back(0.5);
232 for (
unsigned int i = 1; i < degree; ++i)
233 constraint_points.push_back(
237 for (
unsigned int i = 1; i < degree; ++i)
238 constraint_points.push_back(
245 const unsigned int n_dofs_constrained = constraint_points.size();
246 unsigned int n_dofs_per_face = degree + 1;
252 for (
unsigned int i = 0; i < n_dofs_constrained; ++i)
253 for (
unsigned int j = 0; j < n_dofs_per_face; ++j)
255 interface_constraints(i, j) =
256 poly.compute_value(j, constraint_points[i]);
262 if (std::fabs(interface_constraints(i, j)) < 1e-13)
263 interface_constraints(i, j) = 0;
265 return interface_constraints;
274 std::vector<unsigned int>
275 get_dpo_vector_fe_dgp(
const unsigned int dim,
const unsigned int degree)
280 std::vector<unsigned int> dpo(dim + 1, 0U);
291 const auto continuous_dpo = get_dpo_vector_fe_p(dim, degree);
298 continuous_dpo[dim]};
306 continuous_dpo[dim]};
316 continuous_dpo[dim]};
327template <
int dim,
int spacedim>
331 const bool prolongation_is_additive,
332 const std::vector<
Point<dim>> &unit_support_points,
333 const std::vector<std::vector<
Point<dim - 1>>> unit_face_support_points,
338 std::vector<
bool>(fe_data.dofs_per_cell, prolongation_is_additive),
349template <
int dim,
int spacedim>
350std::pair<Table<2, bool>, std::vector<unsigned int>>
354 constant_modes.fill(
true);
355 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
356 constant_modes, std::vector<unsigned int>(1, 0));
361template <
int dim,
int spacedim>
364 const unsigned int child,
385 if (this->prolongation[refinement_case - 1][child].n() == 0)
387 std::lock_guard<std::mutex> lock(prolongation_matrix_mutex);
390 if (this->prolongation[refinement_case - 1][child].n() ==
391 this->n_dofs_per_cell())
392 return this->prolongation[refinement_case - 1][child];
400 std::vector<std::vector<FullMatrix<double>>> isotropic_matrices(
402 isotropic_matrices.back().resize(
403 this->reference_cell().n_children(
406 this->n_dofs_per_cell()));
410 this_nonconst.prolongation[refinement_case - 1] =
411 std::move(isotropic_matrices.back());
415 std::vector<std::vector<FullMatrix<double>>> matrices(
418 this->reference_cell().n_children(
421 this->n_dofs_per_cell())));
423 for (
unsigned int refinement_direction =
static_cast<unsigned int>(
425 refinement_direction <=
427 refinement_direction++)
428 this_nonconst.prolongation[refinement_direction - 1] =
429 std::move(matrices[refinement_direction - 1]);
436 return this->prolongation[refinement_case - 1][child];
441template <
int dim,
int spacedim>
444 const unsigned int child,
464 if (this->restriction[refinement_case - 1][child].n() == 0)
466 std::lock_guard<std::mutex> lock(restriction_matrix_mutex);
469 if (this->restriction[refinement_case - 1][child].n() ==
470 this->n_dofs_per_cell())
471 return this->restriction[refinement_case - 1][child];
481 const double eps = 1e-12;
483 this->n_dofs_per_cell());
486 const std::vector<Point<dim>> unit_support_points =
487 this->get_unit_support_points();
495 tria.
begin_active()->set_refine_choice(refinement_case);
498 const auto &child_cell = tria.
begin(0)->child(child);
502 for (
unsigned int i = 0; i < unit_support_points.size(); i++)
504 std::vector<Point<dim>> transformed_point(1);
505 const std::vector<Point<spacedim>> unit_support_point = {
507 unit_support_points[i][1]) :
509 unit_support_points[i][1],
510 unit_support_points[i][2])};
511 this->reference_cell()
512 .template get_default_linear_mapping<dim, spacedim>()
513 .transform_points_real_to_unit_cell(
519 if (this->reference_cell().contains_point(transformed_point[0], eps))
520 for (
unsigned int j = 0; j < this->n_dofs_per_cell(); j++)
521 restriction_mat[i][j] =
522 this->shape_value(j, transformed_point[0]);
525 for (
unsigned int i = 0; i < this->n_dofs_per_cell(); i++)
529 for (
unsigned int j = 0; j < this->n_dofs_per_cell(); j++)
530 sum += restriction_mat[i][j];
532 Assert(std::fabs(sum - 1) < eps || std::fabs(sum) < eps,
534 "The entries in a row of the local "
535 "restriction matrix do not add to zero or one. "
536 "This typically indicates that the "
537 "polynomial interpolation is "
538 "ill-conditioned such that round-off "
539 "prevents the sum to be one."));
544 for (
unsigned int i = 0; i < restriction_mat.
m(); ++i)
545 for (
unsigned int j = 0; j < restriction_mat.
n(); ++j)
547 if (std::fabs(restriction_mat(i, j)) < eps)
548 restriction_mat(i, j) = 0.;
549 if (std::fabs(restriction_mat(i, j) - 1) < eps)
550 restriction_mat(i, j) = 1.;
554 this->restriction[refinement_case - 1][child]) =
555 std::move(restriction_mat);
559 return this->restriction[refinement_case - 1][child];
564template <
int dim,
int spacedim>
569 const unsigned int face_no)
const
583 const double eps = 2e-13 * this->degree * (dim - 1);
585 std::vector<Point<dim>> face_quadrature_points(quad_face_support.size());
589 face_quadrature_points);
592 for (
unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
594 double matrix_entry =
595 this->shape_value(this->face_to_cell_index(j, 0),
596 face_quadrature_points[i]);
601 if (std::fabs(matrix_entry - 1.0) < eps)
603 if (std::fabs(matrix_entry) < eps)
606 interpolation_matrix(i, j) = matrix_entry;
614 for (
unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
615 sum += interpolation_matrix(j, i);
629 spacedim>::ExcInterpolationNotImplemented()));
634template <
int dim,
int spacedim>
638 const unsigned int subface,
640 const unsigned int face_no)
const
654 const double eps = 2e-13 * this->degree * (dim - 1);
656 std::vector<Point<dim>> subface_quadrature_points(
657 quad_face_support.size());
662 subface_quadrature_points);
665 for (
unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
667 double matrix_entry =
668 this->shape_value(this->face_to_cell_index(j, 0),
669 subface_quadrature_points[i]);
674 if (std::fabs(matrix_entry - 1.0) < eps)
676 if (std::fabs(matrix_entry) < eps)
679 interpolation_matrix(i, j) = matrix_entry;
687 for (
unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
688 sum += interpolation_matrix(j, i);
702 spacedim>::ExcInterpolationNotImplemented()));
707template <
int dim,
int spacedim>
716template <
int dim,
int spacedim>
721 std::vector<double> &nodal_values)
const
724 this->get_unit_support_points().size());
728 for (
unsigned int i = 0; i < this->dofs_per_cell; ++i)
732 nodal_values[i] = support_point_values[i](0);
738template <
int dim,
int spacedim>
748 unit_support_points_fe_p<dim>(degree),
750 constraints_fe_p<dim>(degree))
762template <
int dim,
int spacedim>
763std::unique_ptr<FiniteElement<dim, spacedim>>
766 return std::make_unique<FE_SimplexP<dim, spacedim>>(*this);
771template <
int dim,
int spacedim>
775 std::ostringstream namebuf;
777 << this->degree <<
")";
779 return namebuf.str();
784template <
int dim,
int spacedim>
788 const unsigned int codim)
const
809 if (this->degree < fe_p_other->degree)
811 else if (this->degree == fe_p_other->degree)
819 if (this->degree < fe_q_other->degree)
821 else if (this->degree == fe_q_other->degree)
829 if (fe_nothing->is_dominating())
844template <
int dim,
int spacedim>
845std::vector<std::pair<unsigned int, unsigned int>>
889template <
int dim,
int spacedim>
890std::vector<std::pair<unsigned int, unsigned int>>
906 std::vector<std::pair<unsigned int, unsigned int>> identities;
908 for (
unsigned int i = 0; i < this->degree - 1; ++i)
909 for (
unsigned int j = 0; j < fe_p_other->degree - 1; ++j)
910 if (std::fabs(this->unit_support_points[i + 3][0] -
911 fe_p_other->unit_support_points[i + 3][0]) < 1e-14)
912 identities.emplace_back(i, j);
940 const std::vector<unsigned int> &index_map_inverse_q_other =
941 fe_q_other->get_poly_space_numbering_inverse();
943 std::vector<std::pair<unsigned int, unsigned int>> identities;
945 for (
unsigned int i = 0; i < this->degree - 1; ++i)
946 for (
unsigned int j = 0; j < fe_q_other->degree - 1; ++j)
947 if (std::fabs(this->unit_support_points[i + 3][0] -
948 fe_q_other->get_unit_support_points()
949 [index_map_inverse_q_other[j + 1]][0]) < 1e-14)
950 identities.emplace_back(i, j);
993template <
int dim,
int spacedim>
1003 unit_support_points_fe_p<dim>(degree),
1005 constraints_fe_p<dim>(degree))
1010template <
int dim,
int spacedim>
1011std::unique_ptr<FiniteElement<dim, spacedim>>
1014 return std::make_unique<FE_SimplexDGP<dim, spacedim>>(*this);
1019template <
int dim,
int spacedim>
1023 std::ostringstream namebuf;
1025 << this->degree <<
")";
1027 return namebuf.str();
1031template <
int dim,
int spacedim>
1035 const unsigned int codim)
const
1052 if (this->degree < fe_dgp_other->degree)
1054 else if (this->degree == fe_dgp_other->degree)
1062 if (this->degree < fe_dgq_other->degree)
1064 else if (this->degree == fe_dgq_other->degree)
1072 if (fe_nothing->is_dominating())
1087template <
int dim,
int spacedim>
1088std::vector<std::pair<unsigned int, unsigned int>>
1099template <
int dim,
int spacedim>
1100std::vector<std::pair<unsigned int, unsigned int>>
1111template <
int dim,
int spacedim>
1114 const unsigned int child,
1134 if (this->restriction[refinement_case - 1][child].n() == 0)
1136 std::lock_guard<std::mutex> lock(this->restriction_matrix_mutex);
1139 if (this->restriction[refinement_case - 1][child].n() ==
1140 this->n_dofs_per_cell())
1141 return this->restriction[refinement_case - 1][child];
1149 std::vector<std::vector<FullMatrix<double>>> isotropic_matrices(
1151 isotropic_matrices.back().resize(
1152 this->reference_cell().n_children(
1155 this->n_dofs_per_cell()));
1159 this_nonconst.restriction[refinement_case - 1] =
1160 std::move(isotropic_matrices.back());
1164 std::vector<std::vector<FullMatrix<double>>> matrices(
1167 this->reference_cell().n_children(
1170 this->n_dofs_per_cell())));
1172 for (
unsigned int refinement_direction =
static_cast<unsigned int>(
1174 refinement_direction <=
1176 refinement_direction++)
1177 this_nonconst.restriction[refinement_direction - 1] =
1178 std::move(matrices[refinement_direction - 1]);
1185 return this->restriction[refinement_case - 1][child];
1189#include "fe_simplex_p.inst"
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
static BarycentricPolynomials< dim > get_fe_p_basis(const unsigned int degree)
FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim) const override
std::string get_name() const override
std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
FE_SimplexDGP(const unsigned int degree)
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
FE_SimplexP(const unsigned int degree)
std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim) const override
std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
std::string get_name() const override
std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
FE_SimplexPoly(const BarycentricPolynomials< dim > polynomials, const FiniteElementData< dim > &fe_data, const bool prolongation_is_additive, const std::vector< Point< dim > > &unit_support_points, const std::vector< std::vector< Point< dim - 1 > > > unit_face_support_points, const FullMatrix< double > &interface_constraints)
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &x_source_fe, const unsigned int subface, FullMatrix< double > &interpolation_matrix, const unsigned int face_no) const override
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const override
bool hp_constraints_are_implemented() const override
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix, const unsigned int face_no) const override
const unsigned int degree
unsigned int n_dofs_per_line() const
unsigned int n_dofs_per_face(unsigned int face_no=0, unsigned int child=0) const
unsigned int n_unique_faces() const
std::vector< std::vector< Point< dim - 1 > > > unit_face_support_points
const std::vector< Point< dim - 1 > > & get_unit_face_support_points(const unsigned int face_no=0) const
std::vector< int > adjust_line_dof_index_for_line_orientation_table
std::vector< Point< dim > > unit_support_points
FullMatrix< double > interface_constraints
static void project_to_subface(const ReferenceCell &reference_cell, const SubQuadrature &quadrature, const unsigned int face_no, const unsigned int subface_no, std::vector< Point< dim > > &q_points, const RefinementCase< dim - 1 > &ref_case=RefinementCase< dim - 1 >::isotropic_refinement)
static void project_to_face(const ReferenceCell &reference_cell, const SubQuadrature &quadrature, const unsigned int face_no, std::vector< Point< dim > > &q_points)
unsigned int n_vertices() const
static constexpr unsigned char default_combined_face_orientation()
unsigned int n_faces() const
unsigned int n_lines() const
cell_iterator begin(const unsigned int level=0) const
virtual void execute_coarsening_and_refinement()
active_cell_iterator begin_active(const unsigned int level=0) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define AssertThrow(cond, exc)
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
@ either_element_can_dominate
@ other_element_dominates
@ neither_element_dominates
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell &reference_cell)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Line
constexpr const ReferenceCell & get_simplex()
std::string dim_string(const int dim, const int spacedim)