Reference documentation for deal.II version 9.0.0
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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #include <deal.II/fe/fe_nothing.h>
18 #include <deal.II/base/std_cxx14/memory.h>
19 
20 DEAL_II_NAMESPACE_OPEN
21 
22 namespace internal
23 {
24  namespace FE_Nothing
25  {
26  namespace
27  {
28  const char *
29  zero_dof_message = "This element has no shape functions.";
30  }
31  }
32 }
33 
34 
35 
36 
37 template <int dim, int spacedim>
39  const bool dominate)
40  :
41  FiniteElement<dim,spacedim>
42  (FiniteElementData<dim>(std::vector<unsigned>(dim+1,0),
43  n_components, 0,
44  FiniteElementData<dim>::unknown),
45  std::vector<bool>(),
46  std::vector<ComponentMask>() ),
47  dominate(dominate)
48 {
49 // in most other elements we have to set up all sorts of stuff
50 // here. there isn't much that we have to do here; in particular,
51 // we can simply leave the restriction and prolongation matrices
52 // empty since their proper size is in fact zero given that the
53 // element here has no degrees of freedom
54 }
55 
56 
57 template <int dim, int spacedim>
58 std::unique_ptr<FiniteElement<dim,spacedim> >
60 {
61  return std_cxx14::make_unique<FE_Nothing<dim,spacedim>>(*this);
62 }
63 
64 
65 
66 template <int dim, int spacedim>
67 std::string
69 {
70  std::ostringstream namebuf;
71  namebuf << "FE_Nothing<" << dim << ">(";
72  if (this->n_components() > 1)
73  {
74  namebuf << this->n_components();
75  if (dominate)
76  namebuf << ", dominating";
77  }
78  else if (dominate)
79  namebuf << "dominating";
80  namebuf << ")";
81  return namebuf.str();
82 }
83 
84 
85 
86 template <int dim, int spacedim>
89 {
90  return flags;
91 }
92 
93 
94 
95 template <int dim, int spacedim>
96 double
97 FE_Nothing<dim,spacedim>::shape_value (const unsigned int /*i*/,
98  const Point<dim> & /*p*/) const
99 {
100  (void)internal::FE_Nothing::zero_dof_message;
101  Assert(false,ExcMessage(internal::FE_Nothing::zero_dof_message));
102  return 0;
103 }
104 
105 
106 
107 template <int dim, int spacedim>
108 std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase>
110  const Mapping<dim,spacedim> &/*mapping*/,
111  const Quadrature<dim> &/*quadrature*/,
113 {
114  // Create a default data object. Normally we would then
115  // need to resize things to hold the appropriate numbers
116  // of dofs, but in this case all data fields are empty.
117  return std_cxx14::make_unique<typename FiniteElement<dim,spacedim>::InternalDataBase>();
118 }
119 
120 
121 
122 template <int dim, int spacedim>
123 void
127  const Quadrature<dim> &,
128  const Mapping<dim,spacedim> &,
130  const ::internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
133 {
134  // leave data fields empty
135 }
136 
137 
138 
139 template <int dim, int spacedim>
140 void
143  const unsigned int,
144  const Quadrature<dim-1> &,
145  const Mapping<dim,spacedim> &,
147  const ::internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
150 {
151  // leave data fields empty
152 }
153 
154 
155 
156 template <int dim, int spacedim>
157 void
160  const unsigned int,
161  const unsigned int,
162  const Quadrature<dim-1> &,
163  const Mapping<dim,spacedim> &,
165  const ::internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
168 {
169  // leave data fields empty
170 }
171 
172 
173 
174 template <int dim, int spacedim>
175 bool
177 {
178  return dominate;
179 }
180 
181 
182 
183 template <int dim, int spacedim>
184 bool
186 {
187  // Compare fields stored in the base class
188  if (! (this->FiniteElement<dim,spacedim>::operator== (f)))
189  return false;
190 
191  // Then make sure the other object is really of type FE_Nothing,
192  // and compare the data that has been passed to both objects'
193  // constructors.
194  if (const FE_Nothing<dim,spacedim> *f_nothing
195  = dynamic_cast<const FE_Nothing<dim,spacedim> *>(&f))
196  return ((dominate == f_nothing->dominate)
197  &&
198  (this->components == f_nothing->components));
199  else
200  return false;
201 }
202 
203 
204 
205 template <int dim, int spacedim>
209 {
210  // if FE_Nothing does not dominate, there are no requirements
211  if (!dominate)
212  {
214  }
215  // if it does and the other is FE_Nothing, either can dominate
216  else if (dynamic_cast<const FE_Nothing<dim>*>(&fe) != nullptr)
217  {
219  }
220  // otherwise we dominate whatever fe is provided
221  else
222  {
224  }
225 }
226 
227 
228 template <int dim, int spacedim>
229 std::vector<std::pair<unsigned int, unsigned int> >
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> >
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> >
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
271 {
272  return true;
273 }
274 
275 
276 
277 template <int dim, int spacedim>
278 void
281  FullMatrix<double> &interpolation_matrix) const
282 {
283  // Since this element has no dofs,
284  // the interpolation matrix is necessarily empty.
285  (void)interpolation_matrix;
286 
287  Assert (interpolation_matrix.m() == 0,
288  ExcDimensionMismatch (interpolation_matrix.m(),
289  0));
290  Assert (interpolation_matrix.n() == 0,
291  ExcDimensionMismatch (interpolation_matrix.n(),
292  0));
293 }
294 
295 
296 
297 template <int dim, int spacedim>
298 void
301  FullMatrix<double> &interpolation_matrix) const
302 {
303  // since this element has no face dofs, the
304  // interpolation matrix is necessarily empty
305  (void)interpolation_matrix;
306 
307  Assert (interpolation_matrix.m() == 0,
308  ExcDimensionMismatch (interpolation_matrix.m(),
309  0));
310  Assert (interpolation_matrix.n() == 0,
311  ExcDimensionMismatch (interpolation_matrix.m(),
312  0));
313 }
314 
315 
316 template <int dim, int spacedim>
317 void
320  const unsigned int /*index*/,
321  FullMatrix<double> &interpolation_matrix) const
322 {
323  // since this element has no face dofs, the
324  // interpolation matrix is necessarily empty
325 
326  (void)interpolation_matrix;
327  Assert (interpolation_matrix.m() == 0,
328  ExcDimensionMismatch (interpolation_matrix.m(),
329  0));
330  Assert (interpolation_matrix.n() == 0,
331  ExcDimensionMismatch (interpolation_matrix.m(),
332  0));
333 }
334 
335 
336 
337 // explicit instantiations
338 #include "fe_nothing.inst"
339 
340 
341 DEAL_II_NAMESPACE_CLOSE
bool is_dominating() const
Definition: fe_nothing.cc:176
size_type m() const
virtual double shape_value(const unsigned int i, const Point< dim > &p) const override
Definition: fe_nothing.cc:97
virtual FiniteElementDomination::Domination compare_for_face_domination(const FiniteElement< dim, spacedim > &fe_other) const override
Definition: fe_nothing.cc:208
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:244
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:231
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:257
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source_fe, FullMatrix< double > &interpolation_matrix) const override
Definition: fe_nothing.cc:300
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:88
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:319
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:109
static ::ExceptionBase & ExcMessage(std::string arg1)
size_type n() const
#define Assert(cond, exc)
Definition: exceptions.h:1142
UpdateFlags
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual bool hp_constraints_are_implemented() const override
Definition: fe_nothing.cc:270
Abstract base class for mapping classes.
Definition: dof_tools.h:46
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition: fe_nothing.cc:59
virtual std::string get_name() const override
Definition: fe_nothing.cc:68
virtual bool operator==(const FiniteElement< dim, spacedim > &fe) const override
Definition: fe_nothing.cc:185
FE_Nothing(const unsigned int n_components=1, const bool dominate=false)
Definition: fe_nothing.cc:38
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)