Reference documentation for deal.II version Git 3419e36555 2021-03-01 19:22:27 +0100
\(\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\}}\)
fe_nothing.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 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/fe/fe_nothing.h>
18 
19 #include <memory>
20 
22 
23 
24 template <int dim, int spacedim>
26  const unsigned int n_components,
27  const bool dominate)
28  : FiniteElement<dim, spacedim>(
29  FiniteElementData<dim>(std::vector<unsigned>(dim + 1, 0),
30  type,
31  n_components,
32  0,
33  FiniteElementData<dim>::unknown),
34  std::vector<bool>(),
35  std::vector<ComponentMask>())
36  , dominate(dominate)
37 {
38  Assert(n_components >= 1,
39  ExcMessage("A finite element needs to have at least one "
40  "vector component."));
41 
42  // in most other elements we have to set up all sorts of stuff
43  // here. there isn't much that we have to do here; in particular,
44  // we can simply leave the restriction and prolongation matrices
45  // empty since their proper size is in fact zero given that the
46  // element here has no degrees of freedom
47 }
48 
49 
50 
51 template <int dim, int spacedim>
53  const bool dominate)
54  : FE_Nothing<dim, spacedim>(ReferenceCells::get_hypercube<dim>(),
55  n_components,
56  dominate)
57 {}
58 
59 
60 
61 template <int dim, int spacedim>
62 std::unique_ptr<FiniteElement<dim, spacedim>>
64 {
65  return std::make_unique<FE_Nothing<dim, spacedim>>(*this);
66 }
67 
68 
69 
70 template <int dim, int spacedim>
71 std::string
73 {
74  std::ostringstream namebuf;
75  namebuf << "FE_Nothing<" << Utilities::dim_string(dim, spacedim) << ">(";
76 
77  std::vector<std::string> name_components;
78  if (this->reference_cell() != ReferenceCells::get_hypercube<dim>())
79  name_components.push_back(this->reference_cell().to_string());
80  if (this->n_components() > 1)
81  name_components.push_back(std::to_string(this->n_components()));
82  if (dominate)
83  name_components.emplace_back("dominating");
84 
85  for (const std::string &comp : name_components)
86  {
87  namebuf << comp;
88  if (comp != name_components.back())
89  namebuf << ", ";
90  }
91  namebuf << ")";
92 
93  return namebuf.str();
94 }
95 
96 
97 
98 template <int dim, int spacedim>
101 {
102  return flags;
103 }
104 
105 
106 
107 template <int dim, int spacedim>
108 double
109 FE_Nothing<dim, spacedim>::shape_value(const unsigned int /*i*/,
110  const Point<dim> & /*p*/) const
111 {
112  Assert(false, ExcMessage("This element has no shape functions."));
113  return 0;
114 }
115 
116 
117 
118 template <int dim, int spacedim>
119 std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
121  const UpdateFlags /*update_flags*/,
122  const Mapping<dim, spacedim> & /*mapping*/,
123  const Quadrature<dim> & /*quadrature*/,
125  spacedim>
126  & /*output_data*/) const
127 {
128  // Create a default data object. Normally we would then
129  // need to resize things to hold the appropriate numbers
130  // of dofs, but in this case all data fields are empty.
131  return std::make_unique<
133 }
134 
135 
136 
137 template <int dim, int spacedim>
138 void
142  const Quadrature<dim> &,
143  const Mapping<dim, spacedim> &,
145  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
146  spacedim>
147  &,
150  spacedim>
151  &) const
152 {
153  // leave data fields empty
154 }
155 
156 
157 
158 template <int dim, int spacedim>
159 void
162  const unsigned int,
163  const hp::QCollection<dim - 1> &,
164  const Mapping<dim, spacedim> &,
166  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
167  spacedim>
168  &,
171  spacedim>
172  &) const
173 {
174  // leave data fields empty
175 }
176 
177 
178 
179 template <int dim, int spacedim>
180 void
183  const unsigned int,
184  const unsigned int,
185  const Quadrature<dim - 1> &,
186  const Mapping<dim, spacedim> &,
188  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
189  spacedim>
190  &,
193  spacedim>
194  &) const
195 {
196  // leave data fields empty
197 }
198 
199 
200 
201 template <int dim, int spacedim>
202 bool
204 {
205  return dominate;
206 }
207 
208 
209 
210 template <int dim, int spacedim>
214  const unsigned int codim) const
215 {
216  Assert(codim <= dim, ExcImpossibleInDim(dim));
217  (void)codim;
218 
219  if (!dominate)
220  // if FE_Nothing does not dominate, there are no requirements
222  else if (dynamic_cast<const FE_Nothing<dim> *>(&fe) != nullptr)
223  // if it does and the other is FE_Nothing, either can dominate
225  else
226  // otherwise we dominate whatever FE is provided
228 }
229 
230 
231 
232 template <int dim, int spacedim>
233 std::vector<std::pair<unsigned int, unsigned int>>
235  const FiniteElement<dim, spacedim> & /*fe_other*/) const
236 {
237  // the FE_Nothing has no
238  // degrees of freedom, so there
239  // are no equivalencies to be
240  // recorded
241  return std::vector<std::pair<unsigned int, unsigned int>>();
242 }
243 
244 
245 template <int dim, int spacedim>
246 std::vector<std::pair<unsigned int, unsigned int>>
248  const FiniteElement<dim, spacedim> & /*fe_other*/) const
249 {
250  // the FE_Nothing has no
251  // degrees of freedom, so there
252  // are no equivalencies to be
253  // recorded
254  return std::vector<std::pair<unsigned int, unsigned int>>();
255 }
256 
257 
258 template <int dim, int spacedim>
259 std::vector<std::pair<unsigned int, unsigned int>>
261  const FiniteElement<dim, spacedim> & /*fe_other*/,
262  const unsigned int) const
263 {
264  // the FE_Nothing has no
265  // degrees of freedom, so there
266  // are no equivalencies to be
267  // recorded
268  return std::vector<std::pair<unsigned int, unsigned int>>();
269 }
270 
271 
272 template <int dim, int spacedim>
273 bool
275 {
276  return true;
277 }
278 
279 
280 
281 template <int dim, int spacedim>
282 void
284  const FiniteElement<dim, spacedim> & /*source_fe*/,
285  FullMatrix<double> &interpolation_matrix) const
286 {
287  // Since this element has no dofs,
288  // the interpolation matrix is necessarily empty.
289  (void)interpolation_matrix;
290 
291  Assert(interpolation_matrix.m() == 0,
292  ExcDimensionMismatch(interpolation_matrix.m(), 0));
293  Assert(interpolation_matrix.n() == 0,
294  ExcDimensionMismatch(interpolation_matrix.n(), 0));
295 }
296 
297 
298 
299 template <int dim, int spacedim>
300 void
302  const FiniteElement<dim, spacedim> & /*source_fe*/,
303  FullMatrix<double> &interpolation_matrix,
304  const unsigned int) const
305 {
306  // since this element has no face dofs, the
307  // interpolation matrix is necessarily empty
308  (void)interpolation_matrix;
309 
310  Assert(interpolation_matrix.m() == 0,
311  ExcDimensionMismatch(interpolation_matrix.m(), 0));
312  Assert(interpolation_matrix.n() == 0,
313  ExcDimensionMismatch(interpolation_matrix.m(), 0));
314 }
315 
316 
317 template <int dim, int spacedim>
318 void
320  const FiniteElement<dim, spacedim> & /*source_fe*/,
321  const unsigned int /*index*/,
322  FullMatrix<double> &interpolation_matrix,
323  const unsigned int) const
324 {
325  // since this element has no face dofs, the
326  // interpolation matrix is necessarily empty
327 
328  (void)interpolation_matrix;
329  Assert(interpolation_matrix.m() == 0,
330  ExcDimensionMismatch(interpolation_matrix.m(), 0));
331  Assert(interpolation_matrix.n() == 0,
332  ExcDimensionMismatch(interpolation_matrix.m(), 0));
333 }
334 
335 
336 
337 // explicit instantiations
338 #include "fe_nothing.inst"
339 
340 
bool is_dominating() const
Definition: fe_nothing.cc:203
size_type m() const
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition: fe_nothing.cc:212
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_nothing.cc:109
virtual void fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const ::internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
Definition: fe_nothing.cc:139
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_nothing.cc:247
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_nothing.cc:234
constexpr const ReferenceCell & get_hypercube()
STL namespace.
virtual void fill_fe_face_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const hp::QCollection< dim - 1 > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const ::internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
Definition: fe_nothing.cc:160
virtual void get_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:283
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, const unsigned int index, FullMatrix< double > &interpolation_matrix, const unsigned int face_no=0) const override
Definition: fe_nothing.cc:319
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
Definition: fe_nothing.cc:100
virtual void fill_fe_subface_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int sub_no, const Quadrature< dim - 1 > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const ::internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
Definition: fe_nothing.cc:181
virtual std::unique_ptr< typename FiniteElement< dim, spacedim >::InternalDataBase > get_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim > &quadrature, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
Definition: fe_nothing.cc:120
FE_Nothing(const ReferenceCell &type, const unsigned int n_components=1, const bool dominate=false)
Definition: fe_nothing.cc:25
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
size_type n() const
#define Assert(cond, exc)
Definition: exceptions.h:1466
UpdateFlags
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual bool hp_constraints_are_implemented() const override
Definition: fe_nothing.cc:274
Abstract base class for mapping classes.
Definition: mapping.h:303
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_nothing.cc:63
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:394
std::string to_string(const T &t)
Definition: patterns.h:2329
virtual std::string get_name() const override
Definition: fe_nothing.cc:72
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:558
unsigned int n_components() const
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_nothing.cc:260
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix, const unsigned int face_no=0) const override
Definition: fe_nothing.cc:301
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:393
const bool dominate
Definition: fe_nothing.h:342
ReferenceCell reference_cell() const