Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
fe_nothing.cc
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/base/std_cxx14/memory.h>
18 
19 #include <deal.II/fe/fe_nothing.h>
20 
21 DEAL_II_NAMESPACE_OPEN
22 
23 
24 template <int dim, int spacedim>
26  const bool dominate)
27  : FiniteElement<dim, spacedim>(
28  FiniteElementData<dim>(std::vector<unsigned>(dim + 1, 0),
30  0,
31  FiniteElementData<dim>::unknown),
32  std::vector<bool>(),
33  std::vector<ComponentMask>())
34  , dominate(dominate)
35 {
36  // in most other elements we have to set up all sorts of stuff
37  // here. there isn't much that we have to do here; in particular,
38  // we can simply leave the restriction and prolongation matrices
39  // empty since their proper size is in fact zero given that the
40  // element here has no degrees of freedom
41 }
42 
43 
44 template <int dim, int spacedim>
45 std::unique_ptr<FiniteElement<dim, spacedim>>
47 {
48  return std_cxx14::make_unique<FE_Nothing<dim, spacedim>>(*this);
49 }
50 
51 
52 
53 template <int dim, int spacedim>
54 std::string
56 {
57  std::ostringstream namebuf;
58  namebuf << "FE_Nothing<" << dim << ">(";
59  if (this->n_components() > 1)
60  {
61  namebuf << this->n_components();
62  if (dominate)
63  namebuf << ", dominating";
64  }
65  else if (dominate)
66  namebuf << "dominating";
67  namebuf << ")";
68  return namebuf.str();
69 }
70 
71 
72 
73 template <int dim, int spacedim>
76 {
77  return flags;
78 }
79 
80 
81 
82 template <int dim, int spacedim>
83 double
84 FE_Nothing<dim, spacedim>::shape_value(const unsigned int /*i*/,
85  const Point<dim> & /*p*/) const
86 {
87  Assert(false, ExcMessage("This element has no shape functions."));
88  return 0;
89 }
90 
91 
92 
93 template <int dim, int spacedim>
94 std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
96  const UpdateFlags /*update_flags*/,
97  const Mapping<dim, spacedim> & /*mapping*/,
98  const Quadrature<dim> & /*quadrature*/,
100  spacedim>
101  & /*output_data*/) const
102 {
103  // Create a default data object. Normally we would then
104  // need to resize things to hold the appropriate numbers
105  // of dofs, but in this case all data fields are empty.
106  return std_cxx14::make_unique<
108 }
109 
110 
111 
112 template <int dim, int spacedim>
113 void
117  const Quadrature<dim> &,
118  const Mapping<dim, spacedim> &,
120  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
121  spacedim>
122  &,
125  spacedim>
126  &) const
127 {
128  // leave data fields empty
129 }
130 
131 
132 
133 template <int dim, int spacedim>
134 void
137  const unsigned int,
138  const Quadrature<dim - 1> &,
139  const Mapping<dim, spacedim> &,
141  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
142  spacedim>
143  &,
146  spacedim>
147  &) const
148 {
149  // leave data fields empty
150 }
151 
152 
153 
154 template <int dim, int spacedim>
155 void
158  const unsigned int,
159  const unsigned int,
160  const Quadrature<dim - 1> &,
161  const Mapping<dim, spacedim> &,
163  const ::internal::FEValuesImplementation::MappingRelatedData<dim,
164  spacedim>
165  &,
168  spacedim>
169  &) const
170 {
171  // leave data fields empty
172 }
173 
174 
175 
176 template <int dim, int spacedim>
177 bool
179 {
180  return dominate;
181 }
182 
183 
184 
185 template <int dim, int spacedim>
186 bool
189 {
190  // Compare fields stored in the base class
191  if (!(this->FiniteElement<dim, spacedim>::operator==(f)))
192  return false;
193 
194  // Then make sure the other object is really of type FE_Nothing,
195  // and compare the data that has been passed to both objects'
196  // constructors.
197  if (const FE_Nothing<dim, spacedim> *f_nothing =
198  dynamic_cast<const FE_Nothing<dim, spacedim> *>(&f))
199  return ((dominate == f_nothing->dominate) &&
200  (this->components == f_nothing->components));
201  else
202  return false;
203 }
204 
205 
206 
207 template <int dim, int spacedim>
211  const unsigned int codim) const
212 {
213  Assert(codim <= dim, ExcImpossibleInDim(dim));
214  (void)codim;
215 
216  if (!dominate)
217  // if FE_Nothing does not dominate, there are no requirements
219  else if (dynamic_cast<const FE_Nothing<dim> *>(&fe) != nullptr)
220  // if it does and the other is FE_Nothing, either can dominate
222  else
223  // otherwise we dominate whatever fe is provided
225 }
226 
227 
228 template <int dim, int spacedim>
229 std::vector<std::pair<unsigned int, unsigned int>>
231  const FiniteElement<dim, spacedim> & /*fe_other*/) const
232 {
233  // the FE_Nothing has no
234  // degrees of freedom, so there
235  // are no equivalencies to be
236  // recorded
237  return std::vector<std::pair<unsigned int, unsigned int>>();
238 }
239 
240 
241 template <int dim, int spacedim>
242 std::vector<std::pair<unsigned int, unsigned int>>
244  const FiniteElement<dim, spacedim> & /*fe_other*/) const
245 {
246  // the FE_Nothing has no
247  // degrees of freedom, so there
248  // are no equivalencies to be
249  // recorded
250  return std::vector<std::pair<unsigned int, unsigned int>>();
251 }
252 
253 
254 template <int dim, int spacedim>
255 std::vector<std::pair<unsigned int, unsigned int>>
257  const FiniteElement<dim, spacedim> & /*fe_other*/) const
258 {
259  // the FE_Nothing has no
260  // degrees of freedom, so there
261  // are no equivalencies to be
262  // recorded
263  return std::vector<std::pair<unsigned int, unsigned int>>();
264 }
265 
266 
267 template <int dim, int spacedim>
268 bool
270 {
271  return true;
272 }
273 
274 
275 
276 template <int dim, int spacedim>
277 void
279  const FiniteElement<dim, spacedim> & /*source_fe*/,
280  FullMatrix<double> &interpolation_matrix) const
281 {
282  // Since this element has no dofs,
283  // the interpolation matrix is necessarily empty.
284  (void)interpolation_matrix;
285 
286  Assert(interpolation_matrix.m() == 0,
287  ExcDimensionMismatch(interpolation_matrix.m(), 0));
288  Assert(interpolation_matrix.n() == 0,
289  ExcDimensionMismatch(interpolation_matrix.n(), 0));
290 }
291 
292 
293 
294 template <int dim, int spacedim>
295 void
297  const FiniteElement<dim, spacedim> & /*source_fe*/,
298  FullMatrix<double> &interpolation_matrix) const
299 {
300  // since this element has no face dofs, the
301  // interpolation matrix is necessarily empty
302  (void)interpolation_matrix;
303 
304  Assert(interpolation_matrix.m() == 0,
305  ExcDimensionMismatch(interpolation_matrix.m(), 0));
306  Assert(interpolation_matrix.n() == 0,
307  ExcDimensionMismatch(interpolation_matrix.m(), 0));
308 }
309 
310 
311 template <int dim, int spacedim>
312 void
314  const FiniteElement<dim, spacedim> & /*source_fe*/,
315  const unsigned int /*index*/,
316  FullMatrix<double> &interpolation_matrix) const
317 {
318  // since this element has no face dofs, the
319  // interpolation matrix is necessarily empty
320 
321  (void)interpolation_matrix;
322  Assert(interpolation_matrix.m() == 0,
323  ExcDimensionMismatch(interpolation_matrix.m(), 0));
324  Assert(interpolation_matrix.n() == 0,
325  ExcDimensionMismatch(interpolation_matrix.m(), 0));
326 }
327 
328 
329 
330 // explicit instantiations
331 #include "fe_nothing.inst"
332 
333 
334 DEAL_II_NAMESPACE_CLOSE
bool is_dominating() const
Definition: fe_nothing.cc:178
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:209
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_nothing.cc:84
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:243
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:230
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_nothing.cc:256
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:296
STL namespace.
virtual void get_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:278
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
Definition: fe_nothing.cc:75
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, const unsigned int index, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:313
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:95
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
size_type n() const
#define Assert(cond, exc)
Definition: exceptions.h:1407
UpdateFlags
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual bool hp_constraints_are_implemented() const override
Definition: fe_nothing.cc:269
Abstract base class for mapping classes.
Definition: dof_tools.h:57
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_nothing.cc:46
virtual std::string get_name() const override
Definition: fe_nothing.cc:55
virtual bool operator==(const FiniteElement< dim, spacedim > &fe) const override
Definition: fe_nothing.cc:188
FE_Nothing(const unsigned int n_components=1, const bool dominate=false)
Definition: fe_nothing.cc:25
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)