43 template <
int dim,
int spacedim>
45 compute_embedding_matrices(
46 const ::FE_Q_Bubbles<dim, spacedim> &fe,
48 const bool isotropic_only)
50 const unsigned int dpc = fe.n_dofs_per_cell();
51 const unsigned int degree = fe.degree;
54 std::unique_ptr<Quadrature<dim>> q_fine;
56 std::vector<double>(1, 1.));
61 q_fine = std::make_unique<QGauss<dim>>(degree + 1);
62 else if (spacedim == 2)
64 std::make_unique<QAnisotropic<dim>>(
QGauss<1>(degree + 1),
68 std::make_unique<QAnisotropic<dim>>(
QGauss<1>(degree + 1),
74 q_fine = std::make_unique<QGauss<dim>>(degree + 1);
77 std::make_unique<QAnisotropic<dim>>(
QGauss<1>(degree + 1),
82 q_fine = std::make_unique<QGauss<dim>>(degree + 1);
89 const unsigned int nq = q_fine->size();
92 for (
unsigned int ref_case =
95 ref_case <= RefinementCase<dim>::isotropic_refinement;
98 const unsigned int nc =
101 for (
unsigned int i = 0; i < nc; ++i)
103 Assert(matrices[ref_case - 1][i].n() == dpc,
106 Assert(matrices[ref_case - 1][i].m() == dpc,
127 const unsigned int n_dofs = dh.
n_dofs();
132 std::vector<std::vector<types::global_dof_index>> child_ldi(
133 nc, std::vector<types::global_dof_index>(fe.n_dofs_per_cell()));
136 unsigned int child_no = 0;
139 for (; cell != dh.
end(); ++cell, ++child_no)
142 cell->get_dof_indices(child_ldi[child_no]);
144 for (
unsigned int q = 0; q < nq; ++q)
145 for (
unsigned int i = 0; i < dpc; ++i)
146 for (
unsigned int j = 0; j < dpc; ++j)
148 const unsigned int gdi = child_ldi[child_no][i];
149 const unsigned int gdj = child_ldi[child_no][j];
154 for (
unsigned int k = 0; k < dim; ++k)
156 coarse_rhs_matrix(gdi, j) +=
157 fine.
shape_value(i, q) * fe.shape_value(j, quad_tmp) *
165 fine_mass.
mmult(solution, coarse_rhs_matrix);
168 for (
unsigned int child_no = 0; child_no < nc; ++child_no)
169 for (
unsigned int i = 0; i < dpc; ++i)
170 for (
unsigned int j = 0; j < dpc; ++j)
172 const unsigned int gdi = child_ldi[child_no][i];
174 if (std::fabs(solution(gdi, j)) > 1.e-12)
175 matrices[ref_case - 1][child_no](i, j) = solution(gdi, j);
184template <
int dim,
int spacedim>
193 get_riaf_vector(q_degree))
194 , n_bubbles((q_degree <= 1) ? 1 : dim)
197 ExcMessage(
"This element can only be used for polynomial degrees "
198 "greater than zero"));
204 for (
unsigned int d = 0; d < dim; ++d)
206 for (
unsigned int i = 0; i <
n_bubbles; ++i)
213 internal::FE_Q_Bubbles::compute_embedding_matrices(*
this,
223template <
int dim,
int spacedim>
227 Polynomials::generate_complete_Lagrange_basis(points.get_points())),
232 get_riaf_vector(points.
size() - 1))
233 , n_bubbles((points.
size() - 1 <= 1) ? 1 : dim)
236 ExcMessage(
"This element can only be used for polynomial degrees "
243 for (
unsigned int d = 0; d < dim; ++d)
245 for (
unsigned int i = 0; i <
n_bubbles; ++i)
252 internal::FE_Q_Bubbles::compute_embedding_matrices(*
this,
262template <
int dim,
int spacedim>
270 std::ostringstream namebuf;
272 const unsigned int n_points = this->degree;
273 std::vector<double> points(n_points);
274 const unsigned int dofs_per_cell = this->n_dofs_per_cell();
275 const std::vector<Point<dim>> &unit_support_points =
276 this->unit_support_points;
277 unsigned int index = 0;
280 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
282 if ((dim > 1) ? (unit_support_points[j][1] == 0 &&
283 ((dim > 2) ? unit_support_points[j][2] == 0 :
true)) :
287 points[index] = unit_support_points[j][0];
289 points[n_points - 1] = unit_support_points[j][0];
291 points[index - 1] = unit_support_points[j][0];
297 Assert(index == n_points || (dim == 1 && index == n_points + n_bubbles),
299 "Could not decode support points in one coordinate direction."));
302 for (
unsigned int j = 0; j < n_points; ++j)
303 if (std::fabs(points[j] -
static_cast<double>(j) / (this->degree - 1)) >
312 if (this->degree > 3)
314 <<
">(QIterated(QTrapezoid()," << this->degree - 1 <<
"))";
317 <<
">(" << this->degree - 1 <<
")";
324 for (
unsigned int j = 0; j < n_points; ++j)
325 if (points[j] != points_gl.point(j)[0])
332 <<
">(" << this->degree - 1 <<
")";
335 <<
">(QUnknownNodes(" << this->degree <<
"))";
337 return namebuf.str();
342template <
int dim,
int spacedim>
343std::unique_ptr<FiniteElement<dim, spacedim>>
346 return std::make_unique<FE_Q_Bubbles<dim, spacedim>>(*this);
351template <
int dim,
int spacedim>
356 std::vector<double> &nodal_values)
const
358 Assert(support_point_values.size() == this->unit_support_points.size(),
360 this->unit_support_points.size()));
361 Assert(nodal_values.size() == this->n_dofs_per_cell(),
363 Assert(support_point_values[0].
size() == this->n_components(),
365 this->n_components()));
367 for (
unsigned int i = 0; i < this->n_dofs_per_cell() - 1; ++i)
369 const std::pair<unsigned int, unsigned int> index =
370 this->system_to_component_index(i);
371 nodal_values[i] = support_point_values[i](index.first);
375 for (
unsigned int i = 0; i < n_bubbles; ++i)
376 nodal_values[nodal_values.size() - i - 1] = 0.;
381template <
int dim,
int spacedim>
393 (x_source_fe.
get_name().find(
"FE_Q_Bubbles<") == 0) ||
394 (
dynamic_cast<const FEQBUBBLES *
>(&x_source_fe) !=
nullptr),
396 Assert(interpolation_matrix.
m() == this->n_dofs_per_cell(),
398 this->n_dofs_per_cell()));
404 auto casted_fe =
dynamic_cast<const FEQBUBBLES *
>(&x_source_fe);
405 if (casted_fe !=
nullptr && casted_fe->degree == this->degree)
406 for (
unsigned int i = 0; i < interpolation_matrix.
m(); ++i)
407 interpolation_matrix.
set(i, i, 1.);
413 spacedim>::ExcInterpolationNotImplemented()));
418template <
int dim,
int spacedim>
422 const unsigned int n_cont_dofs = Utilities::fixed_power<dim>(q_deg + 1);
423 const unsigned int n_bubbles = (q_deg <= 1 ? 1 : dim);
424 return std::vector<bool>(n_cont_dofs + n_bubbles,
true);
429template <
int dim,
int spacedim>
430std::vector<unsigned int>
433 std::vector<unsigned int> dpo(dim + 1, 1U);
434 for (
unsigned int i = 1; i < dpo.size(); ++i)
435 dpo[i] = dpo[i - 1] * (q_deg - 1);
439 dpo[dim] += (q_deg <= 1 ? 1 : dim);
445template <
int dim,
int spacedim>
448 const unsigned int shape_index,
449 const unsigned int face_index)
const
452 if (shape_index >= this->n_dofs_per_cell() - n_bubbles)
461template <
int dim,
int spacedim>
464 const unsigned int child,
471 "Prolongation matrices are only available for refined cells!"));
472 AssertIndexRange(child, this->reference_cell().n_children(refinement_case));
474 Assert(this->prolongation[refinement_case - 1][child].n() != 0,
475 ExcMessage(
"This prolongation matrix has not been computed yet!"));
477 return this->prolongation[refinement_case - 1][child];
482template <
int dim,
int spacedim>
485 const unsigned int child,
492 "Restriction matrices are only available for refined cells!"));
493 AssertIndexRange(child, this->reference_cell().n_children(refinement_case));
495 Assert(this->restriction[refinement_case - 1][child].n() != 0,
496 ExcMessage(
"This restriction matrix has not been computed yet!"));
499 return this->restriction[refinement_case - 1][child];
504template <
int dim,
int spacedim>
508 const unsigned int codim)
const
527 if (this->degree < fe_bubbles_other->degree)
529 else if (this->degree == fe_bubbles_other->degree)
537 if (fe_nothing->is_dominating())
552#include "fe/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
const Point< spacedim > & quadrature_point(const unsigned int q_point) const
double JxW(const unsigned int q_point) const
const double & shape_value(const unsigned int i, const unsigned int q_point) 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 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
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
#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)
typename ActiveSelector::active_cell_iterator active_cell_iterator
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_quadrature_points
Transformed quadrature points.
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)