40 std::vector<unsigned int>
41 get_dpo_vector_fe_p(
const unsigned int dim,
const unsigned int degree)
48 return {1, degree - 1};
52 return {1, degree - 1, (degree - 2) * (degree - 1) / 2};
58 (degree - 2) * (degree - 1) / 2,
59 (degree - 3) * (degree - 2) * (degree - 1) / 6};
73 std::vector<Point<dim>>
74 unit_support_points_fe_p(
const unsigned int degree)
77 std::vector<Point<dim>> unit_points;
78 const auto reference_cell = ReferenceCells::get_simplex<dim>();
84 unit_points.emplace_back(reference_cell.barycenter());
89 const auto dpo = get_dpo_vector_fe_p(dim, degree);
95 unit_points.
push_back(reference_cell.vertex(d));
98 for (
const unsigned int l : reference_cell.line_indices())
101 unit_points[reference_cell.line_to_cell_vertices(l, 0)];
103 unit_points[reference_cell.line_to_cell_vertices(l, 1)];
104 for (
unsigned int p = 0; p < dpo[1]; ++p)
105 unit_points.push_back((
double(dpo[1] - p) / (dpo[1] + 1)) * p0 +
106 (
double(p + 1) / (dpo[1] + 1)) * p1);
110 if constexpr (dim == 2)
112 unsigned int counter = 0;
113 for (
unsigned int i = 1; i < degree; ++i)
114 for (
unsigned int j = 1; j < degree - i; ++j, ++counter)
116 const double x =
static_cast<double>(j) / degree;
117 const double y =
static_cast<double>(i) / degree;
124 if constexpr (dim == 3)
125 for (
const unsigned int f : reference_cell.face_indices())
128 unit_points[reference_cell.face_to_cell_vertices(
131 unit_points[reference_cell.face_to_cell_vertices(
134 unit_points[reference_cell.face_to_cell_vertices(
137 unsigned int counter = 0;
138 for (
unsigned int i = 1; i < degree; ++i)
139 for (
unsigned int j = 1; j < degree - i; ++j, ++counter)
141 const double a =
static_cast<double>(j) / degree;
142 const double b =
static_cast<double>(i) / degree;
143 const double c = 1.0 - a - b;
144 unit_points.push_back(c * p0 + a * p1 + b * p2);
150 if constexpr (dim == 3)
152 unsigned int counter = 0;
153 for (
unsigned int i = 1; i < degree; ++i)
154 for (
unsigned int j = 1; j < degree - i; ++j)
155 for (
unsigned int k = 1; k < degree - i - j; ++k, ++counter)
157 const double x =
static_cast<double>(i) / degree;
158 const double y =
static_cast<double>(j) / degree;
159 const double z =
static_cast<double>(k) / degree;
170 std::vector<Point<0>>
171 unit_support_points_fe_p(
const unsigned int )
181 std::vector<std::vector<
Point<dim - 1>>>
182 unit_face_support_points_fe_p(
183 const unsigned int degree,
194 std::vector<std::vector<
Point<dim - 1>>> unit_face_points;
200 unit_face_points.emplace_back(
201 unit_support_points_fe_p<dim - 1>(degree));
204 return unit_face_points;
214 constraints_fe_p(
const unsigned int )
223 constraints_fe_p<2>(
const unsigned int degree)
225 constexpr int dim = 2;
233 std::vector<
Point<dim - 1>> constraint_points;
235 constraint_points.emplace_back(0.5);
237 for (
unsigned int i = 1; i < degree; ++i)
238 constraint_points.push_back(
242 for (
unsigned int i = 1; i < degree; ++i)
243 constraint_points.push_back(
250 const unsigned int n_dofs_constrained = constraint_points.size();
251 unsigned int n_dofs_per_face = degree + 1;
257 for (
unsigned int i = 0; i < n_dofs_constrained; ++i)
258 for (
unsigned int j = 0; j < n_dofs_per_face; ++j)
260 interface_constraints(i, j) =
261 poly.compute_value(j, constraint_points[i]);
267 if (std::fabs(interface_constraints(i, j)) < 1e-13)
268 interface_constraints(i, j) = 0;
270 return interface_constraints;
279 std::vector<unsigned int>
280 get_dpo_vector_fe_dgp(
const unsigned int dim,
const unsigned int degree)
285 std::vector<unsigned int> dpo(dim + 1, 0U);
296 const auto continuous_dpo = get_dpo_vector_fe_p(dim, degree);
303 continuous_dpo[dim]};
311 continuous_dpo[dim]};
321 continuous_dpo[dim]};
332template <
int dim,
int spacedim>
336 const bool prolongation_is_additive,
337 const std::vector<
Point<dim>> &unit_support_points,
338 const std::vector<std::vector<
Point<dim - 1>>> unit_face_support_points,
343 std::vector<
bool>(fe_data.dofs_per_cell, prolongation_is_additive),
354template <
int dim,
int spacedim>
355std::pair<Table<2, bool>, std::vector<unsigned int>>
359 constant_modes.fill(
true);
360 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
361 constant_modes, std::vector<unsigned int>(1, 0));
366template <
int dim,
int spacedim>
369 const unsigned int child,
390 if (this->prolongation[refinement_case - 1][child].n() == 0)
392 std::scoped_lock lock(prolongation_matrix_mutex);
395 if (this->prolongation[refinement_case - 1][child].n() ==
396 this->n_dofs_per_cell())
397 return this->prolongation[refinement_case - 1][child];
405 std::vector<std::vector<FullMatrix<double>>> isotropic_matrices(
407 isotropic_matrices.back().resize(
408 this->reference_cell().n_children(
411 this->n_dofs_per_cell()));
415 this_nonconst.prolongation[refinement_case - 1] =
416 std::move(isotropic_matrices.back());
420 std::vector<std::vector<FullMatrix<double>>> matrices(
423 this->reference_cell().n_children(
426 this->n_dofs_per_cell())));
428 for (
unsigned int refinement_direction =
static_cast<unsigned int>(
430 refinement_direction <=
432 refinement_direction++)
433 this_nonconst.prolongation[refinement_direction - 1] =
434 std::move(matrices[refinement_direction - 1]);
441 return this->prolongation[refinement_case - 1][child];
446template <
int dim,
int spacedim>
449 const unsigned int shape_index,
450 const unsigned int face_index)
const
461 const auto offset = this->unit_support_points[shape_index] -
462 reference_cell.face_vertex_location(face_index, 0);
463 const auto normal = reference_cell.face_normal_vector(face_index);
465 return std::abs(offset * normal) < 1e-10;
470template <
int dim,
int spacedim>
473 const unsigned int face_dof_index,
474 const unsigned int face,
480 combined_orientation);
485template <
int dim,
int spacedim>
488 const unsigned int child,
508 if (this->restriction[refinement_case - 1][child].n() == 0)
510 std::scoped_lock lock(restriction_matrix_mutex);
513 if (this->restriction[refinement_case - 1][child].n() ==
514 this->n_dofs_per_cell())
515 return this->restriction[refinement_case - 1][child];
525 const double eps = 1e-12;
527 this->n_dofs_per_cell());
530 const std::vector<Point<dim>> unit_support_points =
531 this->get_unit_support_points();
539 tria.
begin_active()->set_refine_choice(refinement_case);
542 const auto &child_cell = tria.
begin(0)->child(child);
546 for (
unsigned int i = 0; i < unit_support_points.size(); i++)
548 std::vector<Point<dim>> transformed_point(1);
549 const std::vector<Point<spacedim>> unit_support_point = {
551 unit_support_points[i][1]) :
553 unit_support_points[i][1],
554 unit_support_points[i][2])};
555 this->reference_cell()
556 .template get_default_linear_mapping<spacedim>()
557 .transform_points_real_to_unit_cell(
563 if (this->reference_cell().contains_point(transformed_point[0], eps))
564 for (
unsigned int j = 0; j < this->n_dofs_per_cell(); j++)
565 restriction_mat[i][j] =
566 this->shape_value(j, transformed_point[0]);
570 for (
unsigned int i = 0; i < this->n_dofs_per_cell(); i++)
574 for (
unsigned int j = 0; j < this->n_dofs_per_cell(); j++)
575 sum += restriction_mat[i][j];
577 Assert(std::fabs(sum - 1) < eps || std::fabs(sum) < eps,
579 "The entries in a row of the local "
580 "restriction matrix do not add to zero or one. "
581 "This typically indicates that the "
582 "polynomial interpolation is "
583 "ill-conditioned such that round-off "
584 "prevents the sum to be one."));
589 for (
unsigned int i = 0; i < restriction_mat.
m(); ++i)
590 for (
unsigned int j = 0; j < restriction_mat.
n(); ++j)
592 if (std::fabs(restriction_mat(i, j)) < eps)
593 restriction_mat(i, j) = 0.;
594 if (std::fabs(restriction_mat(i, j) - 1) < eps)
595 restriction_mat(i, j) = 1.;
599 this->restriction[refinement_case - 1][child]) =
600 std::move(restriction_mat);
604 return this->restriction[refinement_case - 1][child];
609template <
int dim,
int spacedim>
614 const unsigned int face_no)
const
628 const double eps = 2e-13 * this->degree * (dim - 1);
630 const std::vector<Point<dim>> face_quadrature_points =
638 for (
unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
640 double matrix_entry =
641 this->shape_value(this->face_to_cell_index(j, 0),
642 face_quadrature_points[i]);
647 if (std::fabs(matrix_entry - 1.0) < eps)
649 if (std::fabs(matrix_entry) < eps)
652 interpolation_matrix(i, j) = matrix_entry;
661 for (
unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
662 sum += interpolation_matrix(j, i);
676 spacedim>::ExcInterpolationNotImplemented()));
681template <
int dim,
int spacedim>
685 const unsigned int subface,
687 const unsigned int face_no)
const
701 const double eps = 2e-13 * this->degree * (dim - 1);
705 this->reference_cell(),
713 for (
unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
715 double matrix_entry =
716 this->shape_value(this->face_to_cell_index(j, 0),
717 subface_quadrature.point(i));
722 if (std::fabs(matrix_entry - 1.0) < eps)
724 if (std::fabs(matrix_entry) < eps)
727 interpolation_matrix(i, j) = matrix_entry;
736 for (
unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
737 sum += interpolation_matrix(j, i);
751 spacedim>::ExcInterpolationNotImplemented()));
756template <
int dim,
int spacedim>
765template <
int dim,
int spacedim>
770 std::vector<double> &nodal_values)
const
773 this->get_unit_support_points().size());
777 for (
unsigned int i = 0; i < this->dofs_per_cell; ++i)
781 nodal_values[i] = support_point_values[i](0);
787template <
int dim,
int spacedim>
797 unit_support_points_fe_p<dim>(degree),
799 constraints_fe_p<dim>(degree))
808 if (dim < 3 ||
degree < 3)
813 const unsigned int face_no = 0;
824 const auto face_reference_cell =
828 const unsigned int r =
degree - 3;
832 for (
unsigned int j = 0, dof_index = 0; j <= r; ++j)
833 for (
unsigned int i = 0; i <= r - j; ++i, ++dof_index)
837 const std::array<unsigned int, 3> local_indices{{r - i - j, i, j}};
841 orientation < this->
reference_cell().n_face_orientations(face_no);
845 const auto permuted_indices =
846 face_reference_cell.permute_by_combined_orientation(
848 face_reference_cell.get_inverse_combined_orientation(
854 const unsigned int k =
855 permuted_indices[1] + permuted_indices[2] * (r + 1) -
856 (permuted_indices[2] * (permuted_indices[2] - 1)) / 2;
859 static_cast<int>(k) -
static_cast<int>(dof_index);
861 dof_index, orientation) = offset;
868template <
int dim,
int spacedim>
869std::unique_ptr<FiniteElement<dim, spacedim>>
872 return std::make_unique<FE_SimplexP<dim, spacedim>>(*this);
877template <
int dim,
int spacedim>
881 std::ostringstream namebuf;
883 << this->degree <<
")";
885 return namebuf.str();
890template <
int dim,
int spacedim>
894 const unsigned int codim)
const
915 if (this->degree < fe_p_other->degree)
917 else if (this->degree == fe_p_other->degree)
925 if (this->degree < fe_q_other->degree)
927 else if (this->degree == fe_q_other->degree)
935 if (this->degree < fe_p_other->degree)
937 else if (this->degree == fe_p_other->degree)
945 if (this->degree < fe_p_other->degree)
947 else if (this->degree == fe_p_other->degree)
955 if (fe_nothing->is_dominating())
970template <
int dim,
int spacedim>
971std::vector<std::pair<unsigned int, unsigned int>>
1012template <
int dim,
int spacedim>
1013std::vector<std::pair<unsigned int, unsigned int>>
1022 std::vector<std::pair<unsigned int, unsigned int>> identities;
1025 const auto &face_support_points = this->get_unit_face_support_points(0);
1026 const auto &face_support_points_other =
1034 const unsigned int offset =
1035 this->reference_cell().face_reference_cell(0).n_vertices();
1037 const unsigned int offset_other =
1044 for (
unsigned int i = 0; i < this->degree - 1; ++i)
1045 for (
unsigned int j = 0; j < fe_other.
degree - 1; ++j)
1046 if (face_support_points[i + offset].distance(
1047 face_support_points_other[j + offset_other]) < 1e-14)
1048 identities.emplace_back(i, j);
1080template <
int dim,
int spacedim>
1081std::vector<std::pair<unsigned int, unsigned int>>
1084 const unsigned int)
const
1092 std::vector<std::pair<unsigned int, unsigned int>> result;
1093 const unsigned int face_no_neighbor =
1097 const auto &face_support_points = this->get_unit_face_support_points(0);
1098 const auto &face_support_points_other =
1103 const auto face_reference_cell =
1104 this->reference_cell().face_reference_cell(0);
1106 Assert(face_reference_cell ==
1110 const unsigned int offset =
1111 face_reference_cell.n_vertices() +
1112 face_reference_cell.n_lines() * this->n_dofs_per_line();
1114 const unsigned int offset_other =
1115 face_reference_cell.n_vertices() +
1119 for (
unsigned int i = 0; i < this->n_dofs_per_quad(0); ++i)
1120 for (
unsigned int j = 0; j < fe_other.
n_dofs_per_quad(face_no_neighbor);
1122 if (face_support_points[i + offset].distance(
1123 face_support_points_other[j + offset_other]) < 1e-14)
1124 result.emplace_back(i, j);
1132 return std::vector<std::pair<unsigned int, unsigned int>>();
1143 return std::vector<std::pair<unsigned int, unsigned int>>();
1148 return std::vector<std::pair<unsigned int, unsigned int>>();
1154template <
int dim,
int spacedim>
1164 unit_support_points_fe_p<dim>(degree),
1166 constraints_fe_p<dim>(degree))
1171template <
int dim,
int spacedim>
1172std::unique_ptr<FiniteElement<dim, spacedim>>
1175 return std::make_unique<FE_SimplexDGP<dim, spacedim>>(*this);
1180template <
int dim,
int spacedim>
1184 std::ostringstream namebuf;
1186 << this->degree <<
")";
1188 return namebuf.str();
1192template <
int dim,
int spacedim>
1196 const unsigned int codim)
const
1213 if (this->degree < fe_dgp_other->degree)
1215 else if (this->degree == fe_dgp_other->degree)
1223 if (this->degree < fe_dgq_other->degree)
1225 else if (this->degree == fe_dgq_other->degree)
1233 if (fe_nothing->is_dominating())
1248template <
int dim,
int spacedim>
1249std::vector<std::pair<unsigned int, unsigned int>>
1260template <
int dim,
int spacedim>
1261std::vector<std::pair<unsigned int, unsigned int>>
1272template <
int dim,
int spacedim>
1275 const unsigned int child,
1295 if (this->restriction[refinement_case - 1][child].n() == 0)
1297 std::scoped_lock lock(this->restriction_matrix_mutex);
1300 if (this->restriction[refinement_case - 1][child].n() ==
1301 this->n_dofs_per_cell())
1302 return this->restriction[refinement_case - 1][child];
1310 std::vector<std::vector<FullMatrix<double>>> isotropic_matrices(
1312 isotropic_matrices.back().resize(
1313 this->reference_cell().n_children(
1316 this->n_dofs_per_cell()));
1320 this_nonconst.restriction[refinement_case - 1] =
1321 std::move(isotropic_matrices.back());
1325 std::vector<std::vector<FullMatrix<double>>> matrices(
1328 this->reference_cell().n_children(
1331 this->n_dofs_per_cell())));
1333 for (
unsigned int refinement_direction =
static_cast<unsigned int>(
1335 refinement_direction <=
1337 refinement_direction++)
1338 this_nonconst.restriction[refinement_direction - 1] =
1339 std::move(matrices[refinement_direction - 1]);
1346 return this->restriction[refinement_case - 1][child];
1350#include "fe/fe_simplex_p.inst"
***mech_lbc_system increment_interpolation_handlers push_back(scale_z_handler)
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
std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other, const unsigned int face_no=0) 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 bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) 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
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const types::geometric_orientation combined_orientation=numbers::default_geometric_orientation) 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
unsigned int n_dofs_per_quad(unsigned int face_no=0) const
ReferenceCell< dim > reference_cell() const
std::vector< std::vector< Point< dim - 1 > > > unit_face_support_points
std::vector< Table< 2, int > > adjust_quad_dof_index_for_face_orientation_table
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 Quadrature< dim > project_to_face(const ReferenceCell< dim > &reference_cell, const SubQuadrature &quadrature, const unsigned int face_no, const types::geometric_orientation combined_orientation)
static Quadrature< dim > project_to_subface(const ReferenceCell< dim > &reference_cell, const SubQuadrature &quadrature, const unsigned int face_no, const unsigned int subface_no, const types::geometric_orientation combined_orientation, const RefinementCase< dim - 1 > &ref_case)
constexpr unsigned int n_vertices() const
constexpr 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
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define AssertThrow(cond, exc)
@ either_element_can_dominate
@ other_element_dominates
@ neither_element_dominates
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell< dim > &reference_cell)
constexpr ReferenceCell< 1 > Line
constexpr ReferenceCell< 2 > Triangle
constexpr ReferenceCell< 3 > Tetrahedron
constexpr const ReferenceCell< dim > & get_simplex()
std::string dim_string(const int dim, const int spacedim)
constexpr types::geometric_orientation default_geometric_orientation
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
std::uint8_t geometric_orientation