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