17 #include <deal.II/base/qprojector.h> 18 #include <deal.II/base/quadrature.h> 19 #include <deal.II/base/quadrature_lib.h> 20 #include <deal.II/base/std_cxx14/memory.h> 21 #include <deal.II/base/table.h> 22 #include <deal.II/base/utilities.h> 24 #include <deal.II/dofs/dof_accessor.h> 26 #include <deal.II/fe/fe.h> 27 #include <deal.II/fe/fe_abf.h> 28 #include <deal.II/fe/fe_tools.h> 29 #include <deal.II/fe/fe_values.h> 30 #include <deal.II/fe/mapping.h> 32 #include <deal.II/grid/tria.h> 33 #include <deal.II/grid/tria_iterator.h> 44 DEAL_II_NAMESPACE_OPEN
57 std::vector<bool>(dim, true)))
93 std::vector<FullMatrix<double>> face_embeddings(
102 unsigned int target_row = 0;
103 for (
const auto &face_embedding : face_embeddings)
104 for (
unsigned int i = 0; i < face_embedding.m(); ++i)
106 for (
unsigned int j = 0; j < face_embedding.n(); ++j)
125 std::ostringstream namebuf;
127 namebuf <<
"FE_ABF<" << dim <<
">(" << rt_order <<
")";
129 return namebuf.str();
135 std::unique_ptr<FiniteElement<dim, dim>>
138 return std_cxx14::make_unique<FE_ABF<dim>>(rt_order);
154 const unsigned int n_interior_points = cell_quadrature.
size();
156 unsigned int n_face_points = (dim > 1) ? 1 : 0;
158 for (
unsigned int d = 1; d < dim; ++d)
159 n_face_points *= deg + 1;
161 this->generalized_support_points.resize(
163 this->generalized_face_support_points.resize(n_face_points);
168 std::vector<AnisotropicPolynomials<dim> *> polynomials_abf(dim);
171 for (
unsigned int dd = 0; dd < dim; ++dd)
173 std::vector<std::vector<Polynomials::Polynomial<double>>> poly(dim);
174 for (
unsigned int d = 0; d < dim; ++d)
182 unsigned int current = 0;
186 QGauss<dim - 1> face_points(deg + 1);
190 boundary_weights.reinit(n_face_points, legendre.n());
195 for (
unsigned int k = 0; k < n_face_points; ++k)
197 this->generalized_face_support_points[k] = face_points.point(k);
201 for (
unsigned int i = 0; i < legendre.n(); ++i)
203 boundary_weights(k, i) =
204 face_points.weight(k) *
205 legendre.compute_value(i, face_points.point(k));
211 for (; current < GeometryInfo<dim>::faces_per_cell * n_face_points;
216 this->generalized_support_points[current] = faces.
point(current);
225 boundary_weights_abf.reinit(faces.
size(), polynomials_abf[0]->n() * dim);
226 for (
unsigned int k = 0; k < faces.
size(); ++k)
228 for (
unsigned int i = 0; i < polynomials_abf[0]->n() * dim; ++i)
230 boundary_weights_abf(k, i) =
231 polynomials_abf[i % dim]->compute_value(i / dim,
242 std::vector<AnisotropicPolynomials<dim> *> polynomials(dim);
244 for (
unsigned int dd = 0; dd < dim; ++dd)
246 std::vector<std::vector<Polynomials::Polynomial<double>>> poly(dim);
247 for (
unsigned int d = 0; d < dim; ++d)
254 interior_weights.reinit(
257 for (
unsigned int k = 0; k < cell_quadrature.
size(); ++k)
259 for (
unsigned int i = 0; i < polynomials[0]->n(); ++i)
260 for (
unsigned int d = 0; d < dim; ++d)
261 interior_weights(k, i, d) =
262 cell_quadrature.
weight(k) *
263 polynomials[d]->compute_value(i, cell_quadrature.
point(k));
266 for (
unsigned int d = 0; d < dim; ++d)
267 delete polynomials[d];
273 for (
unsigned int k = 0; k < cell_quadrature.
size(); ++k)
274 this->generalized_support_points[current++] = cell_quadrature.
point(k);
281 polynomials_abf[0]->n() * dim,
285 for (
unsigned int k = 0; k < cell_quadrature.
size(); ++k)
287 for (
unsigned int i = 0; i < polynomials_abf[0]->n() * dim; ++i)
290 polynomials_abf[i % dim]->compute_grad(i / dim,
291 cell_quadrature.
point(k)) *
292 cell_quadrature.
weight(k);
295 for (
unsigned int d = 0; d < dim; ++d)
296 interior_weights_abf(k, i, d) = -poly_grad[d];
300 for (
unsigned int d = 0; d < dim; ++d)
301 delete polynomials_abf[d];
303 Assert(current == this->generalized_support_points.size(),
326 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_cell;
328 this->restriction[iso][i].reinit(0, 0);
332 QGauss<dim - 1> q_base(rt_order + 1);
333 const unsigned int n_face_points = q_base.size();
336 for (
unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
347 for (
unsigned int k = 0; k < q_face.
size(); ++k)
348 for (
unsigned int i = 0; i < this->dofs_per_cell; ++i)
349 cached_values_face(i, k) = this->shape_value_component(
352 for (
unsigned int sub = 0; sub < GeometryInfo<dim>::max_children_per_face;
376 for (
unsigned int k = 0; k < n_face_points; ++k)
377 for (
unsigned int i_child = 0; i_child < this->dofs_per_cell;
379 for (
unsigned int i_face = 0; i_face < this->dofs_per_face;
387 this->restriction[iso][child](face * this->dofs_per_face +
390 Utilities::fixed_power<dim - 1>(.5) * q_sub.
weight(k) *
391 cached_values_face(i_child, k) *
392 this->shape_value_component(
393 face * this->dofs_per_face + i_face,
406 std::vector<AnisotropicPolynomials<dim> *> polynomials(dim);
407 for (
unsigned int dd = 0; dd < dim; ++dd)
409 std::vector<std::vector<Polynomials::Polynomial<double>>> poly(dim);
410 for (
unsigned int d = 0; d < dim; ++d)
418 const unsigned int start_cell_dofs =
425 for (
unsigned int k = 0; k < q_cell.
size(); ++k)
426 for (
unsigned int i = 0; i < this->dofs_per_cell; ++i)
427 for (
unsigned int d = 0; d < dim; ++d)
428 cached_values_cell(i, k, d) =
429 this->shape_value_component(i, q_cell.
point(k), d);
431 for (
unsigned int child = 0; child < GeometryInfo<dim>::max_children_per_cell;
436 for (
unsigned int k = 0; k < q_sub.
size(); ++k)
437 for (
unsigned int i_child = 0; i_child < this->dofs_per_cell; ++i_child)
438 for (
unsigned int d = 0; d < dim; ++d)
439 for (
unsigned int i_weight = 0; i_weight < polynomials[d]->n();
442 this->restriction[iso][child](start_cell_dofs + i_weight * dim +
445 q_sub.
weight(k) * cached_values_cell(i_child, k, d) *
446 polynomials[d]->compute_value(i_weight, q_sub.
point(k));
450 for (
unsigned int d = 0; d < dim; ++d)
451 delete polynomials[d];
457 std::vector<unsigned int>
463 return std::vector<unsigned int>();
471 unsigned int dofs_per_face = 1;
472 for (
int d = 0; d < dim - 1; ++d)
473 dofs_per_face *= rt_order + 1;
476 const unsigned int interior_dofs = dim * (rt_order + 1) * dofs_per_face;
478 std::vector<unsigned int> dpo(dim + 1);
479 dpo[dim - 1] = dofs_per_face;
480 dpo[dim] = interior_dofs;
492 const unsigned int face_index)
const 494 Assert(shape_index < this->dofs_per_cell,
515 return (face_index !=
537 std::vector<double> & nodal_values)
const 539 Assert(support_point_values.size() == this->generalized_support_points.size(),
541 this->generalized_support_points.size()));
545 Assert(nodal_values.size() == this->dofs_per_cell,
548 std::fill(nodal_values.begin(), nodal_values.end(), 0.);
550 const unsigned int n_face_points = boundary_weights.size(0);
551 for (
unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
552 for (
unsigned int k = 0; k < n_face_points; ++k)
553 for (
unsigned int i = 0; i < boundary_weights.size(1); ++i)
555 nodal_values[i + face * this->dofs_per_face] +=
556 boundary_weights(k, i) *
557 support_point_values[face * n_face_points + k][
GeometryInfo<
558 dim>::unit_normal_direction[face]];
561 const unsigned int start_cell_dofs =
563 const unsigned int start_cell_points =
566 for (
unsigned int k = 0; k < interior_weights.size(0); ++k)
567 for (
unsigned int i = 0; i < interior_weights.size(1); ++i)
568 for (
unsigned int d = 0; d < dim; ++d)
569 nodal_values[start_cell_dofs + i * dim + d] +=
570 interior_weights(k, i, d) *
571 support_point_values[k + start_cell_points][d];
573 const unsigned int start_abf_dofs =
574 start_cell_dofs + interior_weights.size(1) * dim;
577 for (
unsigned int k = 0; k < interior_weights_abf.size(0); ++k)
578 for (
unsigned int i = 0; i < interior_weights_abf.size(1); ++i)
579 for (
unsigned int d = 0; d < dim; ++d)
580 nodal_values[start_abf_dofs + i] +=
581 interior_weights_abf(k, i, d) *
582 support_point_values[k + start_cell_points][d];
585 for (
unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
588 for (
unsigned int fp = 0; fp < n_face_points; ++fp)
593 face,
false,
false,
false, n_face_points);
594 for (
unsigned int i = 0; i < boundary_weights_abf.size(1); ++i)
595 nodal_values[start_abf_dofs + i] +=
596 n_orient * boundary_weights_abf(k + fp, i) *
597 support_point_values[face * n_face_points + fp][
GeometryInfo<
598 dim>::unit_normal_direction[face]];
603 for (
unsigned int i = 0; i < boundary_weights_abf.size(1); ++i)
604 if (std::fabs(nodal_values[start_abf_dofs + i]) < 1.0e-16)
605 nodal_values[start_abf_dofs + i] = 0.0;
621 #include "fe_abf.inst" 623 DEAL_II_NAMESPACE_CLOSE
void initialize_restriction()
static Quadrature< dim > project_to_child(const Quadrature< dim > &quadrature, const unsigned int child_no)
FullMatrix< double > interface_constraints
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
static void project_to_subface(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)
virtual std::string get_name() const override
static std::vector< Polynomial< double > > generate_complete_basis(const unsigned int degree)
const Point< dim > & point(const unsigned int i) const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
virtual std::unique_ptr< FiniteElement< dim, dim > > clone() const override
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
std::vector< std::vector< FullMatrix< double > > > prolongation
void invert(const FullMatrix< number2 > &M)
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static std::vector< Polynomial< number > > generate_complete_basis(const unsigned int degree)
unsigned int size() const
const unsigned int dofs_per_cell
static Quadrature< dim > project_to_all_faces(const SubQuadrature &quadrature)
static void project_to_face(const SubQuadrature &quadrature, const unsigned int face_no, std::vector< Point< dim >> &q_points)
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim - 1 > &face_refinement_case=RefinementCase< dim - 1 >::isotropic_refinement)
virtual std::size_t memory_consumption() const override
const unsigned int dofs_per_face
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
void initialize_support_points(const unsigned int rt_degree)
FullMatrix< double > inverse_node_matrix
double weight(const unsigned int i) const
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
static ::ExceptionBase & ExcInternalError()
static DataSetDescriptor face(const unsigned int face_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points)