deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
fe_dgp.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2002 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#include <deal.II/fe/fe_dgp.h>
16#include <deal.II/fe/fe_tools.h>
17
18#include <memory>
19#include <sstream>
20
21
23
24template <int dim, int spacedim>
25FE_DGP<dim, spacedim>::FE_DGP(const unsigned int degree)
26 : FE_Poly<dim, spacedim>(
27 PolynomialSpace<dim>(
28 Polynomials::Legendre::generate_complete_basis(degree)),
29 FiniteElementData<dim>(get_dpo_vector(degree),
30 1,
31 degree,
32 FiniteElementData<dim>::L2),
33 std::vector<bool>(
34 FiniteElementData<dim>(get_dpo_vector(degree), 1, degree)
35 .n_dofs_per_cell(),
36 true),
37 std::vector<ComponentMask>(
38 FiniteElementData<dim>(get_dpo_vector(degree), 1, degree)
39 .n_dofs_per_cell(),
40 ComponentMask(std::vector<bool>(1, true))))
41{
42 // Reinit the vectors of restriction and prolongation matrices to the right
43 // sizes
45 // Fill prolongation matrices with embedding operators
46 if (dim == spacedim)
47 {
49 // Fill restriction matrices with L2-projection
51 }
52}
53
54
55template <int dim, int spacedim>
56std::string
58{
59 // note that the FETools::get_fe_by_name function depends on the
60 // particular format of the string this function returns, so they have to be
61 // kept in sync
62
63 std::ostringstream namebuf;
64 namebuf << "FE_DGP<" << Utilities::dim_string(dim, spacedim) << ">("
65 << this->degree << ")";
66
67 return namebuf.str();
68}
69
70
71
72template <int dim, int spacedim>
73std::unique_ptr<FiniteElement<dim, spacedim>>
75{
76 return std::make_unique<FE_DGP<dim, spacedim>>(*this);
77}
78
79
80
81//---------------------------------------------------------------------------
82// Auxiliary functions
83//---------------------------------------------------------------------------
84
85
86template <int dim, int spacedim>
87std::vector<unsigned int>
89{
90 std::vector<unsigned int> dpo(dim + 1, 0U);
91 dpo[dim] = deg + 1;
92 for (unsigned int i = 1; i < dim; ++i)
93 {
94 dpo[dim] *= deg + 1 + i;
95 dpo[dim] /= i + 1;
96 }
97 return dpo;
98}
99
100
101
102template <int dim, int spacedim>
103void
105 const FiniteElement<dim, spacedim> &x_source_fe,
106 FullMatrix<double> &interpolation_matrix,
107 const unsigned int) 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;
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
128template <int dim, int spacedim>
129void
131 const FiniteElement<dim, spacedim> &x_source_fe,
132 const unsigned int,
133 FullMatrix<double> &interpolation_matrix,
134 const unsigned int) 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;
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
155template <int dim, int spacedim>
156bool
161
162
163
164template <int dim, int spacedim>
165std::vector<std::pair<unsigned int, unsigned int>>
167 const FiniteElement<dim, spacedim> & /*fe_other*/) const
168{
169 // this element is discontinuous, so by definition there can
170 // be no identities between its dofs and those of any neighbor
171 // (of whichever type the neighbor may be -- after all, we have
172 // no face dofs on this side to begin with)
173 return std::vector<std::pair<unsigned int, unsigned int>>();
174}
175
176
177
178template <int dim, int spacedim>
179std::vector<std::pair<unsigned int, unsigned int>>
181 const FiniteElement<dim, spacedim> &fe_other) const
182{
183 // there are no such constraints for DGP elements at all
184 if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
185 return std::vector<std::pair<unsigned int, unsigned int>>();
186 else
187 {
189 return std::vector<std::pair<unsigned int, unsigned int>>();
190 }
191}
192
193
194
195template <int dim, int spacedim>
196std::vector<std::pair<unsigned int, unsigned int>>
198 const FiniteElement<dim, spacedim> &fe_other,
199 const unsigned int) const
200{
201 // there are no such constraints for DGP elements at all
202 if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
203 return std::vector<std::pair<unsigned int, unsigned int>>();
204 else
205 {
207 return std::vector<std::pair<unsigned int, unsigned int>>();
208 }
209}
210
211
212
213template <int dim, int spacedim>
216 const FiniteElement<dim, spacedim> &fe_other,
217 const unsigned int codim) const
218{
219 Assert(codim <= dim, ExcImpossibleInDim(dim));
220
221 // vertex/line/face domination
222 // ---------------------------
223 if (codim > 0)
224 // this is a discontinuous element, so by definition there will
225 // be no constraints wherever this element comes together with
226 // any other kind of element
228
229 // cell domination
230 // ---------------
231 if (const FE_DGP<dim, spacedim> *fe_dgp_other =
232 dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other))
233 {
234 if (this->degree < fe_dgp_other->degree)
236 else if (this->degree == fe_dgp_other->degree)
238 else
240 }
241 else if (const FE_Nothing<dim> *fe_nothing =
242 dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
243 {
244 if (fe_nothing->is_dominating())
246 else
247 // the FE_Nothing has no degrees of freedom and it is typically used
248 // in a context where we don't require any continuity along the
249 // interface
251 }
252
255}
256
257
258
259template <int dim, int spacedim>
260bool
262 const unsigned int) const
263{
264 // all shape functions have support on all faces
265 return true;
266}
267
268
269
270template <int dim, int spacedim>
271std::pair<Table<2, bool>, std::vector<unsigned int>>
273{
274 Table<2, bool> constant_modes(1, this->n_dofs_per_cell());
275 constant_modes(0, 0) = true;
276 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
277 constant_modes, std::vector<unsigned int>(1, 0));
278}
279
280
281
282template <int dim, int spacedim>
283std::size_t
289
290
291
292// explicit instantiations
293#include "fe/fe_dgp.inst"
294
295
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:180
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
Definition fe_dgp.cc:261
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition fe_dgp.cc:272
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source, const unsigned int subface, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
Definition fe_dgp.cc:130
virtual std::string get_name() const override
Definition fe_dgp.cc:57
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
Definition fe_dgp.cc:88
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
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
Definition fe_dgp.cc:104
FE_DGP(const unsigned int p)
Definition fe_dgp.cc:25
virtual std::size_t memory_consumption() const override
Definition fe_dgp.cc:284
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other, const unsigned int face_no=0) const override
Definition fe_dgp.cc:197
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition fe_dgp.cc:74
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition fe_dgp.cc:215
virtual bool hp_constraints_are_implemented() const override
Definition fe_dgp.cc:157
virtual std::string get_name() const =0
std::vector< std::vector< FullMatrix< double > > > restriction
Definition fe.h:2547
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
std::vector< std::vector< FullMatrix< double > > > prolongation
Definition fe.h:2561
size_type n() const
size_type m() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_NOT_IMPLEMENTED()
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define AssertThrow(cond, exc)
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)
void compute_projection_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number > > > &matrices, const bool isotropic_only=false)
std::string dim_string(const int dim, const int spacedim)
Definition utilities.cc:547
STL namespace.