Reference documentation for deal.II version 9.1.0-pre
fe_dgp.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2002 - 2017 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_tools.h>
21 
22 #include <sstream>
23 
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 template <int dim, int spacedim>
28 FE_DGP<dim, spacedim>::FE_DGP(const unsigned int degree)
29  : FE_Poly<PolynomialSpace<dim>, dim, spacedim>(
30  PolynomialSpace<dim>(
31  Polynomials::Legendre::generate_complete_basis(degree)),
32  FiniteElementData<dim>(get_dpo_vector(degree),
33  1,
34  degree,
35  FiniteElementData<dim>::L2),
36  std::vector<bool>(
37  FiniteElementData<dim>(get_dpo_vector(degree), 1, degree).dofs_per_cell,
38  true),
39  std::vector<ComponentMask>(
40  FiniteElementData<dim>(get_dpo_vector(degree), 1, degree).dofs_per_cell,
41  std::vector<bool>(1, true)))
42 {
43  // Reinit the vectors of restriction and prolongation matrices to the right
44  // sizes
46  // Fill prolongation matrices with embedding operators
47  if (dim == spacedim)
48  {
50  // Fill restriction matrices with L2-projection
52  }
53 }
54 
55 
56 template <int dim, int spacedim>
57 std::string
59 {
60  // note that the FETools::get_fe_by_name function depends on the
61  // particular format of the string this function returns, so they have to be
62  // kept in sync
63 
64  std::ostringstream namebuf;
65  namebuf << "FE_DGP<" << Utilities::dim_string(dim, spacedim) << ">("
66  << this->degree << ")";
67 
68  return namebuf.str();
69 }
70 
71 
72 
73 template <int dim, int spacedim>
74 std::unique_ptr<FiniteElement<dim, spacedim>>
76 {
77  return std_cxx14::make_unique<FE_DGP<dim, spacedim>>(*this);
78 }
79 
80 
81 
82 //---------------------------------------------------------------------------
83 // Auxiliary functions
84 //---------------------------------------------------------------------------
85 
86 
87 template <int dim, int spacedim>
88 std::vector<unsigned int>
90 {
91  std::vector<unsigned int> dpo(dim + 1, 0U);
92  dpo[dim] = deg + 1;
93  for (unsigned int i = 1; i < dim; ++i)
94  {
95  dpo[dim] *= deg + 1 + i;
96  dpo[dim] /= i + 1;
97  }
98  return dpo;
99 }
100 
101 
102 
103 template <int dim, int spacedim>
104 void
106  const FiniteElement<dim, spacedim> &x_source_fe,
107  FullMatrix<double> & interpolation_matrix) const
108 {
109  // this is only implemented, if the source FE is also a DGP element. in that
110  // case, both elements have no dofs on their faces and the face
111  // interpolation matrix is necessarily empty -- i.e. there isn't much we
112  // need to do here.
113  (void)interpolation_matrix;
114  using FE = FiniteElement<dim, spacedim>;
115  using FEDGP = FE_DGP<dim, spacedim>;
116  AssertThrow((x_source_fe.get_name().find("FE_DGP<") == 0) ||
117  (dynamic_cast<const FEDGP *>(&x_source_fe) != nullptr),
118  typename FE::ExcInterpolationNotImplemented());
119 
120  Assert(interpolation_matrix.m() == 0,
121  ExcDimensionMismatch(interpolation_matrix.m(), 0));
122  Assert(interpolation_matrix.n() == 0,
123  ExcDimensionMismatch(interpolation_matrix.n(), 0));
124 }
125 
126 
127 
128 template <int dim, int spacedim>
129 void
131  const FiniteElement<dim, spacedim> &x_source_fe,
132  const unsigned int,
133  FullMatrix<double> &interpolation_matrix) const
134 {
135  // this is only implemented, if the source FE is also a DGP element. in that
136  // case, both elements have no dofs on their faces and the face
137  // interpolation matrix is necessarily empty -- i.e. there isn't much we
138  // need to do here.
139  (void)interpolation_matrix;
140  using FE = FiniteElement<dim, spacedim>;
141  using FEDGP = FE_DGP<dim, spacedim>;
142  AssertThrow((x_source_fe.get_name().find("FE_DGP<") == 0) ||
143  (dynamic_cast<const FEDGP *>(&x_source_fe) != nullptr),
144  typename FE::ExcInterpolationNotImplemented());
145 
146  Assert(interpolation_matrix.m() == 0,
147  ExcDimensionMismatch(interpolation_matrix.m(), 0));
148  Assert(interpolation_matrix.n() == 0,
149  ExcDimensionMismatch(interpolation_matrix.n(), 0));
150 }
151 
152 
153 
154 template <int dim, int spacedim>
155 bool
157 {
158  return true;
159 }
160 
161 
162 
163 template <int dim, int spacedim>
164 std::vector<std::pair<unsigned int, unsigned int>>
166  const FiniteElement<dim, spacedim> &fe_other) const
167 {
168  // there are no such constraints for DGP elements at all
169  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
170  return std::vector<std::pair<unsigned int, unsigned int>>();
171  else
172  {
173  Assert(false, ExcNotImplemented());
174  return std::vector<std::pair<unsigned int, unsigned int>>();
175  }
176 }
177 
178 
179 
180 template <int dim, int spacedim>
181 std::vector<std::pair<unsigned int, unsigned int>>
183  const FiniteElement<dim, spacedim> &fe_other) const
184 {
185  // there are no such constraints for DGP elements at all
186  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
187  return std::vector<std::pair<unsigned int, unsigned int>>();
188  else
189  {
190  Assert(false, ExcNotImplemented());
191  return std::vector<std::pair<unsigned int, unsigned int>>();
192  }
193 }
194 
195 
196 
197 template <int dim, int spacedim>
198 std::vector<std::pair<unsigned int, unsigned int>>
200  const FiniteElement<dim, spacedim> &fe_other) const
201 {
202  // there are no such constraints for DGP elements at all
203  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
204  return std::vector<std::pair<unsigned int, unsigned int>>();
205  else
206  {
207  Assert(false, ExcNotImplemented());
208  return std::vector<std::pair<unsigned int, unsigned int>>();
209  }
210 }
211 
212 
213 
214 template <int dim, int spacedim>
217  const FiniteElement<dim, spacedim> &fe_other) const
218 {
219  // check whether both are discontinuous elements, see the description of
220  // FiniteElementDomination::Domination
221  if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
223 
224  Assert(false, ExcNotImplemented());
226 }
227 
228 
229 
230 template <int dim, int spacedim>
231 bool
233  const unsigned int) const
234 {
235  // all shape functions have support on all faces
236  return true;
237 }
238 
239 
240 
241 template <int dim, int spacedim>
242 std::pair<Table<2, bool>, std::vector<unsigned int>>
244 {
245  Table<2, bool> constant_modes(1, this->dofs_per_cell);
246  constant_modes(0, 0) = true;
247  return std::pair<Table<2, bool>, std::vector<unsigned int>>(
248  constant_modes, std::vector<unsigned int>(1, 0));
249 }
250 
251 
252 
253 template <int dim, int spacedim>
254 std::size_t
256 {
257  Assert(false, ExcNotImplemented());
258  return 0;
259 }
260 
261 
262 
263 // explicit instantiations
264 #include "fe_dgp.inst"
265 
266 
267 DEAL_II_NAMESPACE_CLOSE
virtual std::size_t memory_consumption() const override
Definition: fe_dgp.cc:255
std::vector< std::vector< FullMatrix< double > > > restriction
Definition: fe.h:2419
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:165
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)
const unsigned int degree
Definition: fe_base.h:313
FE_DGP(const unsigned int p)
Definition: fe_dgp.cc:28
STL namespace.
#define AssertThrow(cond, exc)
Definition: exceptions.h:1329
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)
size_type n() const
virtual std::string get_name() const override
Definition: fe_dgp.cc:58
std::vector< std::vector< FullMatrix< double > > > prolongation
Definition: fe.h:2433
#define Assert(cond, exc)
Definition: exceptions.h:1227
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:89
virtual FiniteElementDomination::Domination compare_for_face_domination(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_dgp.cc:216
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:232
size_type m() const
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:170
const unsigned int dofs_per_cell
Definition: fe_base.h:297
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition: fe_dgp.cc:243
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:130
Definition: table.h:37
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const override
Definition: fe_dgp.cc:105
virtual bool hp_constraints_are_implemented() const override
Definition: fe_dgp.cc:156
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:182
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:199
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_dgp.cc:75