Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
fe_dgp.cc
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 
17 #include <deal.II/base/std_cxx14/memory.h>
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 
26 DEAL_II_NAMESPACE_OPEN
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 
298 DEAL_II_NAMESPACE_CLOSE
size_type m() const
virtual std::size_t memory_consumption() const override
Definition: fe_dgp.cc:286
std::vector< std::vector< FullMatrix< double > > > restriction
Definition: fe.h:2442
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
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)
FE_DGP(const unsigned int p)
Definition: fe_dgp.cc:29
STL namespace.
#define AssertThrow(cond, exc)
Definition: exceptions.h:1519
Definition: fe_dgp.h:311
void compute_projection_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number >>> &matrices, const bool isotropic_only=false)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
virtual std::string get_name() const override
Definition: fe_dgp.cc:59
size_type n() const
std::vector< std::vector< FullMatrix< double > > > prolongation
Definition: fe.h:2456
#define Assert(cond, exc)
Definition: exceptions.h:1407
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
Definition: fe_dgp.cc:90
virtual std::string get_name() const =0
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
Definition: fe_dgp.cc:263
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:457
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition: fe_dgp.cc:274
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
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
Definition: fe.cc:276
static ::ExceptionBase & ExcNotImplemented()
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
Definition: table.h:37
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const override
Definition: fe_dgp.cc:106
virtual bool hp_constraints_are_implemented() const override
Definition: fe_dgp.cc:157
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
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
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_dgp.cc:76