47 template <
int dim,
int spacedim>
49 compute_embedding_matrices(
50 const ::FE_Q_Bubbles<dim, spacedim> & fe,
52 const bool isotropic_only)
54 const unsigned int dpc = fe.n_dofs_per_cell();
55 const unsigned int degree = fe.degree;
58 std::unique_ptr<Quadrature<dim>> q_fine;
60 std::vector<double>(1, 1.));
65 q_fine = std::make_unique<QGauss<dim>>(degree + 1);
66 else if (spacedim == 2)
68 std::make_unique<QAnisotropic<dim>>(
QGauss<1>(degree + 1),
72 std::make_unique<QAnisotropic<dim>>(
QGauss<1>(degree + 1),
78 q_fine = std::make_unique<QGauss<dim>>(degree + 1);
81 std::make_unique<QAnisotropic<dim>>(
QGauss<1>(degree + 1),
86 q_fine = std::make_unique<QGauss<dim>>(degree + 1);
93 const unsigned int nq = q_fine->size();
96 unsigned int ref_case = (isotropic_only) ?
99 for (; ref_case <= RefinementCase<dim>::isotropic_refinement;
102 const unsigned int nc =
105 for (
unsigned int i = 0; i < nc; ++i)
107 Assert(matrices[ref_case - 1][i].n() == dpc,
110 Assert(matrices[ref_case - 1][i].m() == dpc,
131 const unsigned int n_dofs = dh.
n_dofs();
136 std::vector<std::vector<types::global_dof_index>> child_ldi(
137 nc, std::vector<types::global_dof_index>(fe.n_dofs_per_cell()));
140 unsigned int child_no = 0;
141 typename ::DoFHandler<dim>::active_cell_iterator cell =
143 for (; cell != dh.
end(); ++cell, ++child_no)
146 cell->get_dof_indices(child_ldi[child_no]);
148 for (
unsigned int q = 0; q < nq; ++q)
149 for (
unsigned int i = 0; i < dpc; ++i)
150 for (
unsigned int j = 0; j < dpc; ++j)
152 const unsigned int gdi = child_ldi[child_no][i];
153 const unsigned int gdj = child_ldi[child_no][j];
158 for (
unsigned int k = 0; k < dim; ++k)
160 coarse_rhs_matrix(gdi, j) +=
161 fine.
shape_value(i, q) * fe.shape_value(j, quad_tmp) *
169 fine_mass.
mmult(solution, coarse_rhs_matrix);
172 for (
unsigned int child_no = 0; child_no < nc; ++child_no)
173 for (
unsigned int i = 0; i < dpc; ++i)
174 for (
unsigned int j = 0; j < dpc; ++j)
176 const unsigned int gdi = child_ldi[child_no][i];
178 if (std::fabs(solution(gdi, j)) > 1.e-12)
179 matrices[ref_case - 1][child_no](i, j) = solution(gdi, j);
188template <
int dim,
int spacedim>
197 get_riaf_vector(q_degree))
198 , n_bubbles((q_degree <= 1) ? 1 : dim)
201 ExcMessage(
"This element can only be used for polynomial degrees "
202 "greater than zero"));
208 for (
unsigned int d = 0; d < dim; ++d)
210 for (
unsigned int i = 0; i <
n_bubbles; ++i)
217 internal::FE_Q_Bubbles::compute_embedding_matrices(*
this,
227template <
int dim,
int spacedim>
231 Polynomials::generate_complete_Lagrange_basis(points.get_points())),
236 get_riaf_vector(points.size() - 1))
237 , n_bubbles((points.size() - 1 <= 1) ? 1 : dim)
240 ExcMessage(
"This element can only be used for polynomial degrees "
247 for (
unsigned int d = 0; d < dim; ++d)
249 for (
unsigned int i = 0; i <
n_bubbles; ++i)
256 internal::FE_Q_Bubbles::compute_embedding_matrices(*
this,
266template <
int dim,
int spacedim>
274 std::ostringstream namebuf;
276 const unsigned int n_points = this->degree;
277 std::vector<double> points(n_points);
278 const unsigned int dofs_per_cell = this->n_dofs_per_cell();
279 const std::vector<Point<dim>> &unit_support_points =
280 this->unit_support_points;
281 unsigned int index = 0;
284 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
286 if ((dim > 1) ? (unit_support_points[j](1) == 0 &&
287 ((dim > 2) ? unit_support_points[j](2) == 0 :
true)) :
291 points[index] = unit_support_points[j](0);
293 points[n_points - 1] = unit_support_points[j](0);
295 points[index - 1] = unit_support_points[j](0);
301 Assert(index == n_points || (dim == 1 && index == n_points + n_bubbles),
303 "Could not decode support points in one coordinate direction."));
306 for (
unsigned int j = 0; j < n_points; ++j)
307 if (std::fabs(points[j] -
static_cast<double>(j) / (this->degree - 1)) >
316 if (this->degree > 3)
318 <<
">(QIterated(QTrapezoid()," << this->degree - 1 <<
"))";
321 <<
">(" << this->degree - 1 <<
")";
328 for (
unsigned int j = 0; j < n_points; ++j)
329 if (points[j] != points_gl.
point(j)(0))
335 namebuf <<
"FE_Q_Bubbles<" << dim <<
">(" << this->degree - 1 <<
")";
337 namebuf <<
"FE_Q_Bubbles<" << dim <<
">(QUnknownNodes(" << this->degree
340 return namebuf.str();
345template <
int dim,
int spacedim>
346std::unique_ptr<FiniteElement<dim, spacedim>>
349 return std::make_unique<FE_Q_Bubbles<dim, spacedim>>(*this);
354template <
int dim,
int spacedim>
359 std::vector<double> & nodal_values)
const
361 Assert(support_point_values.size() == this->unit_support_points.size(),
363 this->unit_support_points.size()));
364 Assert(nodal_values.size() == this->n_dofs_per_cell(),
366 Assert(support_point_values[0].size() == this->n_components(),
368 this->n_components()));
370 for (
unsigned int i = 0; i < this->n_dofs_per_cell() - 1; ++i)
372 const std::pair<unsigned int, unsigned int> index =
373 this->system_to_component_index(i);
374 nodal_values[i] = support_point_values[i](index.first);
378 for (
unsigned int i = 0; i < n_bubbles; ++i)
379 nodal_values[nodal_values.size() - i - 1] = 0.;
384template <
int dim,
int spacedim>
396 (x_source_fe.
get_name().find(
"FE_Q_Bubbles<") == 0) ||
397 (
dynamic_cast<const FEQBUBBLES *
>(&x_source_fe) !=
nullptr),
399 Assert(interpolation_matrix.
m() == this->n_dofs_per_cell(),
401 this->n_dofs_per_cell()));
407 auto casted_fe =
dynamic_cast<const FEQBUBBLES *
>(&x_source_fe);
408 if (casted_fe !=
nullptr && casted_fe->degree == this->degree)
409 for (
unsigned int i = 0; i < interpolation_matrix.
m(); ++i)
410 interpolation_matrix.
set(i, i, 1.);
416 spacedim>::ExcInterpolationNotImplemented()));
421template <
int dim,
int spacedim>
425 const unsigned int n_cont_dofs = Utilities::fixed_power<dim>(q_deg + 1);
426 const unsigned int n_bubbles = (q_deg <= 1 ? 1 : dim);
427 return std::vector<bool>(n_cont_dofs + n_bubbles,
true);
432template <
int dim,
int spacedim>
433std::vector<unsigned int>
436 std::vector<unsigned int> dpo(dim + 1, 1U);
437 for (
unsigned int i = 1; i < dpo.size(); ++i)
438 dpo[i] = dpo[i - 1] * (q_deg - 1);
442 dpo[dim] += (q_deg <= 1 ? 1 : dim);
448template <
int dim,
int spacedim>
451 const unsigned int shape_index,
452 const unsigned int face_index)
const
455 if (shape_index >= this->n_dofs_per_cell() - n_bubbles)
464template <
int dim,
int spacedim>
467 const unsigned int child,
474 "Prolongation matrices are only available for refined cells!"));
477 Assert(this->prolongation[refinement_case - 1][child].n() != 0,
478 ExcMessage(
"This prolongation matrix has not been computed yet!"));
480 return this->prolongation[refinement_case - 1][child];
485template <
int dim,
int spacedim>
488 const unsigned int child,
495 "Restriction matrices are only available for refined cells!"));
498 Assert(this->restriction[refinement_case - 1][child].n() != 0,
499 ExcMessage(
"This restriction matrix has not been computed yet!"));
502 return this->restriction[refinement_case - 1][child];
507template <
int dim,
int spacedim>
511 const unsigned int codim)
const
530 if (this->degree < fe_bubbles_other->degree)
532 else if (this->degree == fe_bubbles_other->degree)
540 if (fe_nothing->is_dominating())
555#include "fe_q_bubbles.inst"
cell_iterator end() const
void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
active_cell_iterator begin_active(const unsigned int level=0) const
types::global_dof_index n_dofs() const
double JxW(const unsigned int quadrature_point) const
const Point< spacedim > & quadrature_point(const unsigned int q) const
const double & shape_value(const unsigned int function_no, const unsigned int point_no) const
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell)
const unsigned int q_degree
void initialize(const std::vector< Point< 1 > > &support_points_1d)
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
static std::vector< bool > get_riaf_vector(const unsigned int degree)
virtual void get_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const override
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case) const override
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case) const override
const unsigned int n_bubbles
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
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
FE_Q_Bubbles(const unsigned int p)
virtual std::string get_name() const override
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
unsigned int n_dofs_per_cell() const
virtual std::string get_name() const =0
std::vector< std::vector< FullMatrix< double > > > restriction
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
std::vector< Point< dim > > unit_support_points
std::vector< std::vector< FullMatrix< double > > > prolongation
void mmult(FullMatrix< number2 > &C, const FullMatrix< number2 > &B, const bool adding=false) const
void set(const size_type i, const size_type j, const number value)
const Point< dim > & point(const unsigned int i) const
const std::vector< Point< dim > > & get_points() const
unsigned int size() 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
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_quadrature_points
Transformed quadrature points.
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)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
@ either_element_can_dominate
@ other_element_dominates
@ neither_element_dominates
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
std::string dim_string(const int dim, const int spacedim)
static unsigned int n_children(const RefinementCase< dim > &refinement_case)