Reference documentation for deal.II version GIT relicensing-837-gaf73e64026 2024-06-15 22:40:02+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: LGPL-2.1-or-later
4// Copyright (C) 2002 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15
16#include <deal.II/fe/fe_dgp.h>
18#include <deal.II/fe/fe_tools.h>
19
20#include <memory>
21#include <sstream>
22
23
25
26template <int dim, int spacedim>
27FE_DGP<dim, spacedim>::FE_DGP(const unsigned int degree)
28 : FE_Poly<dim, spacedim>(
29 PolynomialSpace<dim>(
30 Polynomials::Legendre::generate_complete_basis(degree)),
31 FiniteElementData<dim>(get_dpo_vector(degree),
32 1,
33 degree,
34 FiniteElementData<dim>::L2),
35 std::vector<bool>(
36 FiniteElementData<dim>(get_dpo_vector(degree), 1, degree)
37 .n_dofs_per_cell(),
38 true),
39 std::vector<ComponentMask>(
40 FiniteElementData<dim>(get_dpo_vector(degree), 1, degree)
41 .n_dofs_per_cell(),
42 ComponentMask(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
57template <int dim, int spacedim>
58std::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
74template <int dim, int spacedim>
75std::unique_ptr<FiniteElement<dim, spacedim>>
77{
78 return std::make_unique<FE_DGP<dim, spacedim>>(*this);
79}
80
81
82
83//---------------------------------------------------------------------------
84// Auxiliary functions
85//---------------------------------------------------------------------------
86
87
88template <int dim, int spacedim>
89std::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
104template <int dim, int spacedim>
105void
107 const FiniteElement<dim, spacedim> &x_source_fe,
108 FullMatrix<double> &interpolation_matrix,
109 const unsigned int) const
110{
111 // this is only implemented, if the source FE is also a DGP element. in that
112 // case, both elements have no dofs on their faces and the face
113 // interpolation matrix is necessarily empty -- i.e. there isn't much we
114 // need to do here.
115 (void)interpolation_matrix;
117 using FEDGP = FE_DGP<dim, spacedim>;
118 AssertThrow((x_source_fe.get_name().find("FE_DGP<") == 0) ||
119 (dynamic_cast<const FEDGP *>(&x_source_fe) != nullptr),
120 typename FE::ExcInterpolationNotImplemented());
121
122 Assert(interpolation_matrix.m() == 0,
123 ExcDimensionMismatch(interpolation_matrix.m(), 0));
124 Assert(interpolation_matrix.n() == 0,
125 ExcDimensionMismatch(interpolation_matrix.n(), 0));
126}
127
128
129
130template <int dim, int spacedim>
131void
133 const FiniteElement<dim, spacedim> &x_source_fe,
134 const unsigned int,
135 FullMatrix<double> &interpolation_matrix,
136 const unsigned int) const
137{
138 // this is only implemented, if the source FE is also a DGP element. in that
139 // case, both elements have no dofs on their faces and the face
140 // interpolation matrix is necessarily empty -- i.e. there isn't much we
141 // need to do here.
142 (void)interpolation_matrix;
144 using FEDGP = FE_DGP<dim, spacedim>;
145 AssertThrow((x_source_fe.get_name().find("FE_DGP<") == 0) ||
146 (dynamic_cast<const FEDGP *>(&x_source_fe) != nullptr),
147 typename FE::ExcInterpolationNotImplemented());
148
149 Assert(interpolation_matrix.m() == 0,
150 ExcDimensionMismatch(interpolation_matrix.m(), 0));
151 Assert(interpolation_matrix.n() == 0,
152 ExcDimensionMismatch(interpolation_matrix.n(), 0));
153}
154
155
156
157template <int dim, int spacedim>
158bool
163
164
165
166template <int dim, int spacedim>
167std::vector<std::pair<unsigned int, unsigned int>>
169 const FiniteElement<dim, spacedim> &fe_other) const
170{
171 // there are no such constraints for DGP elements at all
172 if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
173 return std::vector<std::pair<unsigned int, unsigned int>>();
174 else
175 {
177 return std::vector<std::pair<unsigned int, unsigned int>>();
178 }
179}
180
181
182
183template <int dim, int spacedim>
184std::vector<std::pair<unsigned int, unsigned int>>
186 const FiniteElement<dim, spacedim> &fe_other) const
187{
188 // there are no such constraints for DGP elements at all
189 if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
190 return std::vector<std::pair<unsigned int, unsigned int>>();
191 else
192 {
194 return std::vector<std::pair<unsigned int, unsigned int>>();
195 }
196}
197
198
199
200template <int dim, int spacedim>
201std::vector<std::pair<unsigned int, unsigned int>>
203 const FiniteElement<dim, spacedim> &fe_other,
204 const unsigned int) const
205{
206 // there are no such constraints for DGP elements at all
207 if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
208 return std::vector<std::pair<unsigned int, unsigned int>>();
209 else
210 {
212 return std::vector<std::pair<unsigned int, unsigned int>>();
213 }
214}
215
216
217
218template <int dim, int spacedim>
221 const FiniteElement<dim, spacedim> &fe_other,
222 const unsigned int codim) const
223{
224 Assert(codim <= dim, ExcImpossibleInDim(dim));
225
226 // vertex/line/face domination
227 // ---------------------------
228 if (codim > 0)
229 // this is a discontinuous element, so by definition there will
230 // be no constraints wherever this element comes together with
231 // any other kind of element
233
234 // cell domination
235 // ---------------
236 if (const FE_DGP<dim, spacedim> *fe_dgp_other =
237 dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other))
238 {
239 if (this->degree < fe_dgp_other->degree)
241 else if (this->degree == fe_dgp_other->degree)
243 else
245 }
246 else if (const FE_Nothing<dim> *fe_nothing =
247 dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
248 {
249 if (fe_nothing->is_dominating())
251 else
252 // the FE_Nothing has no degrees of freedom and it is typically used
253 // in a context where we don't require any continuity along the
254 // interface
256 }
257
260}
261
262
263
264template <int dim, int spacedim>
265bool
267 const unsigned int) const
268{
269 // all shape functions have support on all faces
270 return true;
271}
272
273
274
275template <int dim, int spacedim>
276std::pair<Table<2, bool>, std::vector<unsigned int>>
278{
279 Table<2, bool> constant_modes(1, this->n_dofs_per_cell());
280 constant_modes(0, 0) = true;
281 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
282 constant_modes, std::vector<unsigned int>(1, 0));
283}
284
285
286
287template <int dim, int spacedim>
288std::size_t
294
295
296
297// explicit instantiations
298#include "fe_dgp.inst"
299
300
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:185
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
Definition fe_dgp.cc:266
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition fe_dgp.cc:277
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:132
virtual std::string get_name() const override
Definition fe_dgp.cc:59
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
Definition fe_dgp.cc:90
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:168
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:106
FE_DGP(const unsigned int p)
Definition fe_dgp.cc:27
virtual std::size_t memory_consumption() const override
Definition fe_dgp.cc:289
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:202
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition fe_dgp.cc:76
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition fe_dgp.cc:220
virtual bool hp_constraints_are_implemented() const override
Definition fe_dgp.cc:159
virtual std::string get_name() const =0
std::vector< std::vector< FullMatrix< double > > > restriction
Definition fe.h:2413
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:2427
size_type n() const
size_type m() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define AssertThrow(cond, exc)
#define DEAL_II_NOT_IMPLEMENTED()
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:555
STL namespace.