Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
fe_dgp.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2002 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
18 
19 #include <deal.II/fe/fe_dgp.h>
20 #include <deal.II/fe/fe_nothing.h>
21 #include <deal.II/fe/fe_tools.h>
22 
23 #include <sstream>
24 
25 
27 
28 template <int dim, int spacedim>
29 FE_DGP<dim, spacedim>::FE_DGP(const unsigned int degree)
30  : FE_Poly<PolynomialSpace<dim>, dim, spacedim>(
31  PolynomialSpace<dim>(
32  Polynomials::Legendre::generate_complete_basis(degree)),
33  FiniteElementData<dim>(get_dpo_vector(degree),
34  1,
35  degree,
36  FiniteElementData<dim>::L2),
37  std::vector<bool>(
38  FiniteElementData<dim>(get_dpo_vector(degree), 1, degree).dofs_per_cell,
39  true),
40  std::vector<ComponentMask>(
41  FiniteElementData<dim>(get_dpo_vector(degree), 1, degree).dofs_per_cell,
42  std::vector<bool>(1, true)))
43 {
44  // Reinit the vectors of restriction and prolongation matrices to the right
45  // sizes
47  // Fill prolongation matrices with embedding operators
48  if (dim == spacedim)
49  {
51  // Fill restriction matrices with L2-projection
53  }
54 }
55 
56 
57 template <int dim, int spacedim>
58 std::string
60 {
61  // note that the FETools::get_fe_by_name function depends on the
62  // particular format of the string this function returns, so they have to be
63  // kept in sync
64 
65  std::ostringstream namebuf;
66  namebuf << "FE_DGP<" << Utilities::dim_string(dim, spacedim) << ">("
67  << this->degree << ")";
68 
69  return namebuf.str();
70 }
71 
72 
73 
74 template <int dim, int spacedim>
75 std::unique_ptr<FiniteElement<dim, spacedim>>
77 {
78  return std_cxx14::make_unique<FE_DGP<dim, spacedim>>(*this);
79 }
80 
81 
82 
83 //---------------------------------------------------------------------------
84 // Auxiliary functions
85 //---------------------------------------------------------------------------
86 
87 
88 template <int dim, int spacedim>
89 std::vector<unsigned int>
91 {
92  std::vector<unsigned int> dpo(dim + 1, 0U);
93  dpo[dim] = deg + 1;
94  for (unsigned int i = 1; i < dim; ++i)
95  {
96  dpo[dim] *= deg + 1 + i;
97  dpo[dim] /= i + 1;
98  }
99  return dpo;
100 }
101 
102 
103 
104 template <int dim, int spacedim>
105 void
107  const FiniteElement<dim, spacedim> &x_source_fe,
108  FullMatrix<double> & interpolation_matrix) const
109 {
110  // this is only implemented, if the source FE is also a DGP element. in that
111  // case, both elements have no dofs on their faces and the face
112  // interpolation matrix is necessarily empty -- i.e. there isn't much we
113  // need to do here.
114  (void)interpolation_matrix;
115  using FE = FiniteElement<dim, spacedim>;
116  using FEDGP = FE_DGP<dim, spacedim>;
117  AssertThrow((x_source_fe.get_name().find("FE_DGP<") == 0) ||
118  (dynamic_cast<const FEDGP *>(&x_source_fe) != nullptr),
119  typename FE::ExcInterpolationNotImplemented());
120 
121  Assert(interpolation_matrix.m() == 0,
122  ExcDimensionMismatch(interpolation_matrix.m(), 0));
123  Assert(interpolation_matrix.n() == 0,
124  ExcDimensionMismatch(interpolation_matrix.n(), 0));
125 }
126 
127 
128 
129 template <int dim, int spacedim>
130 void
132  const FiniteElement<dim, spacedim> &x_source_fe,
133  const unsigned int,
134  FullMatrix<double> &interpolation_matrix) const
135 {
136  // this is only implemented, if the source FE is also a DGP element. in that
137  // case, both elements have no dofs on their faces and the face
138  // interpolation matrix is necessarily empty -- i.e. there isn't much we
139  // need to do here.
140  (void)interpolation_matrix;
141  using FE = FiniteElement<dim, spacedim>;
142  using FEDGP = FE_DGP<dim, spacedim>;
143  AssertThrow((x_source_fe.get_name().find("FE_DGP<") == 0) ||
144  (dynamic_cast<const FEDGP *>(&x_source_fe) != nullptr),
145  typename FE::ExcInterpolationNotImplemented());
146 
147  Assert(interpolation_matrix.m() == 0,
148  ExcDimensionMismatch(interpolation_matrix.m(), 0));
149  Assert(interpolation_matrix.n() == 0,
150  ExcDimensionMismatch(interpolation_matrix.n(), 0));
151 }
152 
153 
154 
155 template <int dim, int spacedim>
156 bool
158 {
159  return true;
160 }
161 
162 
163 
164 template <int dim, int spacedim>
165 std::vector<std::pair<unsigned int, unsigned int>>
167  const FiniteElement<dim, spacedim> &fe_other) const
168 {
169  // there are no such constraints for DGP elements at all
170  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
171  return std::vector<std::pair<unsigned int, unsigned int>>();
172  else
173  {
174  Assert(false, ExcNotImplemented());
175  return std::vector<std::pair<unsigned int, unsigned int>>();
176  }
177 }
178 
179 
180 
181 template <int dim, int spacedim>
182 std::vector<std::pair<unsigned int, unsigned int>>
184  const FiniteElement<dim, spacedim> &fe_other) const
185 {
186  // there are no such constraints for DGP elements at all
187  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
188  return std::vector<std::pair<unsigned int, unsigned int>>();
189  else
190  {
191  Assert(false, ExcNotImplemented());
192  return std::vector<std::pair<unsigned int, unsigned int>>();
193  }
194 }
195 
196 
197 
198 template <int dim, int spacedim>
199 std::vector<std::pair<unsigned int, unsigned int>>
201  const FiniteElement<dim, spacedim> &fe_other) const
202 {
203  // there are no such constraints for DGP elements at all
204  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
205  return std::vector<std::pair<unsigned int, unsigned int>>();
206  else
207  {
208  Assert(false, ExcNotImplemented());
209  return std::vector<std::pair<unsigned int, unsigned int>>();
210  }
211 }
212 
213 
214 
215 template <int dim, int spacedim>
218  const FiniteElement<dim, spacedim> &fe_other,
219  const unsigned int codim) const
220 {
221  Assert(codim <= dim, ExcImpossibleInDim(dim));
222 
223  // vertex/line/face domination
224  // ---------------------------
225  if (codim > 0)
226  // this is a discontinuous element, so by definition there will
227  // be no constraints wherever this element comes together with
228  // any other kind of element
230 
231  // cell domination
232  // ---------------
233  if (const FE_DGP<dim, spacedim> *fe_dgp_other =
234  dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other))
235  {
236  if (this->degree < fe_dgp_other->degree)
238  else if (this->degree == fe_dgp_other->degree)
240  else
242  }
243  else if (const FE_Nothing<dim> *fe_nothing =
244  dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
245  {
246  if (fe_nothing->is_dominating())
248  else
249  // the FE_Nothing has no degrees of freedom and it is typically used
250  // in a context where we don't require any continuity along the
251  // interface
253  }
254 
255  Assert(false, ExcNotImplemented());
257 }
258 
259 
260 
261 template <int dim, int spacedim>
262 bool
264  const unsigned int) const
265 {
266  // all shape functions have support on all faces
267  return true;
268 }
269 
270 
271 
272 template <int dim, int spacedim>
273 std::pair<Table<2, bool>, std::vector<unsigned int>>
275 {
276  Table<2, bool> constant_modes(1, this->dofs_per_cell);
277  constant_modes(0, 0) = true;
278  return std::pair<Table<2, bool>, std::vector<unsigned int>>(
279  constant_modes, std::vector<unsigned int>(1, 0));
280 }
281 
282 
283 
284 template <int dim, int spacedim>
285 std::size_t
287 {
288  Assert(false, ExcNotImplemented());
289  return 0;
290 }
291 
292 
293 
294 // explicit instantiations
295 #include "fe_dgp.inst"
296 
297 
FE_DGP::hp_quad_dof_identities
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_dgp.cc:200
FE_Nothing< dim >
FE_DGP::has_support_on_face
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
Definition: fe_dgp.cc:263
Polynomials
Definition: polynomial.h:41
StandardExceptions::ExcNotImplemented
static ::ExceptionBase & ExcNotImplemented()
FiniteElementData
Definition: fe_base.h:147
FullMatrix::m
size_type m() const
FE_DGP::hp_vertex_dof_identities
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_dgp.cc:166
LAPACKSupport::U
static const char U
Definition: lapack_support.h:167
ComponentMask
Definition: component_mask.h:83
FullMatrix::n
size_type n() const
FETools::compute_embedding_matrices
void compute_embedding_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number >>> &matrices, const bool isotropic_only=false, const double threshold=1.e-12)
FETools::compute_projection_matrices
void compute_projection_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number >>> &matrices, const bool isotropic_only=false)
FE_DGP::compare_for_domination
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition: fe_dgp.cc:217
FE_DGP::FE_DGP
FE_DGP(const unsigned int p)
Definition: fe_dgp.cc:29
fe_nothing.h
FiniteElementDomination::either_element_can_dominate
@ either_element_can_dominate
Definition: fe_base.h:100
Table
Definition: table.h:699
bool
FiniteElementDomination::no_requirements
@ no_requirements
Definition: fe_base.h:104
FE_DGP::get_face_interpolation_matrix
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const override
Definition: fe_dgp.cc:106
FiniteElementDomination::neither_element_dominates
@ neither_element_dominates
Definition: fe_base.h:96
FiniteElementDomination::other_element_dominates
@ other_element_dominates
Definition: fe_base.h:92
FE_DGP::hp_constraints_are_implemented
virtual bool hp_constraints_are_implemented() const override
Definition: fe_dgp.cc:157
FiniteElementDomination::Domination
Domination
Definition: fe_base.h:83
Utilities::dim_string
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:559
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
FiniteElement::prolongation
std::vector< std::vector< FullMatrix< double > > > prolongation
Definition: fe.h:2428
fe_dgp.h
FE_DGP::get_name
virtual std::string get_name() const override
Definition: fe_dgp.cc:59
FE_DGP::get_subface_interpolation_matrix
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source, const unsigned int subface, FullMatrix< double > &matrix) const override
Definition: fe_dgp.cc:131
FiniteElement
Definition: fe.h:648
FE_DGP::get_dpo_vector
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
Definition: fe_dgp.cc:90
fe_tools.h
LocalIntegrators::L2::L2
void L2(Vector< number > &result, const FEValuesBase< dim > &fe, const std::vector< double > &input, const double factor=1.)
Definition: l2.h:171
FE_DGP::clone
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_dgp.cc:76
FE_DGP::memory_consumption
virtual std::size_t memory_consumption() const override
Definition: fe_dgp.cc:286
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
FE_DGP
Definition: fe_dgp.h:311
FiniteElement::restriction
std::vector< std::vector< FullMatrix< double > > > restriction
Definition: fe.h:2414
StandardExceptions::ExcImpossibleInDim
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
FE_DGP::get_constant_modes
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition: fe_dgp.cc:274
FE_Poly
Definition: fe_poly.h:76
StandardExceptions::ExcDimensionMismatch
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
FiniteElement::get_name
virtual std::string get_name() const =0
FiniteElementDomination::this_element_dominates
@ this_element_dominates
Definition: fe_base.h:88
FullMatrix< double >
memory.h
FiniteElement::reinit_restriction_and_prolongation_matrices
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
Definition: fe.cc:275
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
FE_DGP::hp_line_dof_identities
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_dgp.cc:183
AssertThrow
#define AssertThrow(cond, exc)
Definition: exceptions.h:1531
PolynomialSpace
Definition: polynomial_space.h:99