Reference documentation for deal.II version 9.1.0-pre
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),
29  n_components,
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>
210  const FiniteElement<dim, spacedim> &fe) const
211 {
212  // if FE_Nothing does not dominate, there are no requirements
213  if (!dominate)
214  {
216  }
217  // if it does and the other is FE_Nothing, either can dominate
218  else if (dynamic_cast<const FE_Nothing<dim> *>(&fe) != nullptr)
219  {
221  }
222  // otherwise we dominate whatever fe is provided
223  else
224  {
226  }
227 }
228 
229 
230 template <int dim, int spacedim>
231 std::vector<std::pair<unsigned int, unsigned int>>
233  const FiniteElement<dim, spacedim> & /*fe_other*/) const
234 {
235  // the FE_Nothing has no
236  // degrees of freedom, so there
237  // are no equivalencies to be
238  // recorded
239  return std::vector<std::pair<unsigned int, unsigned int>>();
240 }
241 
242 
243 template <int dim, int spacedim>
244 std::vector<std::pair<unsigned int, unsigned int>>
246  const FiniteElement<dim, spacedim> & /*fe_other*/) const
247 {
248  // the FE_Nothing has no
249  // degrees of freedom, so there
250  // are no equivalencies to be
251  // recorded
252  return std::vector<std::pair<unsigned int, unsigned int>>();
253 }
254 
255 
256 template <int dim, int spacedim>
257 std::vector<std::pair<unsigned int, unsigned int>>
259  const FiniteElement<dim, spacedim> & /*fe_other*/) const
260 {
261  // the FE_Nothing has no
262  // degrees of freedom, so there
263  // are no equivalencies to be
264  // recorded
265  return std::vector<std::pair<unsigned int, unsigned int>>();
266 }
267 
268 
269 template <int dim, int spacedim>
270 bool
272 {
273  return true;
274 }
275 
276 
277 
278 template <int dim, int spacedim>
279 void
281  const FiniteElement<dim, spacedim> & /*source_fe*/,
282  FullMatrix<double> &interpolation_matrix) const
283 {
284  // Since this element has no dofs,
285  // the interpolation matrix is necessarily empty.
286  (void)interpolation_matrix;
287 
288  Assert(interpolation_matrix.m() == 0,
289  ExcDimensionMismatch(interpolation_matrix.m(), 0));
290  Assert(interpolation_matrix.n() == 0,
291  ExcDimensionMismatch(interpolation_matrix.n(), 0));
292 }
293 
294 
295 
296 template <int dim, int spacedim>
297 void
299  const FiniteElement<dim, spacedim> & /*source_fe*/,
300  FullMatrix<double> &interpolation_matrix) const
301 {
302  // since this element has no face dofs, the
303  // interpolation matrix is necessarily empty
304  (void)interpolation_matrix;
305 
306  Assert(interpolation_matrix.m() == 0,
307  ExcDimensionMismatch(interpolation_matrix.m(), 0));
308  Assert(interpolation_matrix.n() == 0,
309  ExcDimensionMismatch(interpolation_matrix.m(), 0));
310 }
311 
312 
313 template <int dim, int spacedim>
314 void
316  const FiniteElement<dim, spacedim> & /*source_fe*/,
317  const unsigned int /*index*/,
318  FullMatrix<double> &interpolation_matrix) const
319 {
320  // since this element has no face dofs, the
321  // interpolation matrix is necessarily empty
322 
323  (void)interpolation_matrix;
324  Assert(interpolation_matrix.m() == 0,
325  ExcDimensionMismatch(interpolation_matrix.m(), 0));
326  Assert(interpolation_matrix.n() == 0,
327  ExcDimensionMismatch(interpolation_matrix.m(), 0));
328 }
329 
330 
331 
332 // explicit instantiations
333 #include "fe_nothing.inst"
334 
335 
336 DEAL_II_NAMESPACE_CLOSE
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_nothing.cc:84
virtual FiniteElementDomination::Domination compare_for_face_domination(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_nothing.cc:209
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:245
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:232
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
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:258
bool is_dominating() const
Definition: fe_nothing.cc:178
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:298
STL namespace.
virtual void get_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:280
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:315
static::ExceptionBase & ExcMessage(std::string arg1)
size_type n() const
#define Assert(cond, exc)
Definition: exceptions.h:1227
UpdateFlags
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual bool hp_constraints_are_implemented() const override
Definition: fe_nothing.cc:271
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
unsigned int n_components() const
size_type m() const
virtual bool operator==(const FiniteElement< dim, spacedim > &fe) const override
Definition: fe_nothing.cc:188
const bool dominate
Definition: fe_nothing.h:282
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)