Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
dof_objects.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2006 - 2019 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 #ifndef dealii_dof_objects_h
17 #define dealii_dof_objects_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/exceptions.h>
23 
24 #include <vector>
25 
26 DEAL_II_NAMESPACE_OPEN
27 
28 template <int, int>
29 class DoFHandler;
30 
31 namespace internal
32 {
33  namespace DoFHandlerImplementation
34  {
35  template <int>
36  class DoFLevel;
37  template <int>
38  class DoFFaces;
39 
40 
65  template <int dim>
66  class DoFObjects
67  {
68  public:
72  std::vector<types::global_dof_index> dofs;
73 
74  public:
88  template <int dh_dim, int spacedim>
89  void
90  set_dof_index(const ::DoFHandler<dh_dim, spacedim> &dof_handler,
91  const unsigned int obj_index,
92  const unsigned int fe_index,
93  const unsigned int local_index,
94  const types::global_dof_index global_index);
95 
108  template <int dh_dim, int spacedim>
110  get_dof_index(const ::DoFHandler<dh_dim, spacedim> &dof_handler,
111  const unsigned int obj_index,
112  const unsigned int fe_index,
113  const unsigned int local_index) const;
114 
120  template <int dh_dim, int spacedim>
121  unsigned int
123  const ::DoFHandler<dh_dim, spacedim> &dof_handler,
124  const types::global_dof_index index) const;
125 
130  template <int dh_dim, int spacedim>
131  bool
133  const ::DoFHandler<dh_dim, spacedim> &dof_handler,
134  const types::global_dof_index index,
135  const unsigned int fe_index) const;
136 
141  std::size_t
142  memory_consumption() const;
143 
148  template <class Archive>
149  void
150  serialize(Archive &ar, const unsigned int version);
151 
156  template <int>
157  friend class DoFLevel;
158  template <int>
159  friend class DoFFaces;
160  };
161 
162 
163  // --------------------- template and inline functions ------------------
164 
165  template <int dim>
166  template <int dh_dim, int spacedim>
167  inline unsigned int
169  const ::DoFHandler<dh_dim, spacedim> &,
170  const types::global_dof_index) const
171  {
172  return 1;
173  }
174 
175 
176 
177  template <int dim>
178  template <int dh_dim, int spacedim>
179  inline bool
181  const ::DoFHandler<dh_dim, spacedim> &,
183  const unsigned int fe_index) const
184  {
185  (void)fe_index;
186  Assert(fe_index == 0,
187  ExcMessage("Only zero fe_index values are allowed for "
188  "non-hp DoFHandlers."));
189  return true;
190  }
191 
192 
193 
194  template <int dim>
195  template <int dh_dim, int spacedim>
198  const ::DoFHandler<dh_dim, spacedim> &dof_handler,
199  const unsigned int obj_index,
200  const unsigned int fe_index,
201  const unsigned int local_index) const
202  {
203  (void)fe_index;
204  Assert(
206  ExcMessage(
207  "Only the default FE index is allowed for non-hp DoFHandler objects"));
208  Assert(
209  local_index < dof_handler.get_fe().template n_dofs_per_object<dim>(),
210  ExcIndexRange(local_index,
211  0,
212  dof_handler.get_fe().template n_dofs_per_object<dim>()));
213  Assert(obj_index *
214  dof_handler.get_fe().template n_dofs_per_object<dim>() +
215  local_index <
216  dofs.size(),
217  ExcInternalError());
218 
219  return dofs[obj_index *
220  dof_handler.get_fe().template n_dofs_per_object<dim>() +
221  local_index];
222  }
223 
224 
225  template <int dim>
226  template <class Archive>
227  void
228  DoFObjects<dim>::serialize(Archive &ar, const unsigned int)
229  {
230  ar &dofs;
231  }
232 
233  } // namespace DoFHandlerImplementation
234 } // namespace internal
235 
236 DEAL_II_NAMESPACE_CLOSE
237 
238 #endif
void serialize(Archive &ar, const unsigned int version)
Definition: dof_objects.h:228
types::global_dof_index get_dof_index(const ::DoFHandler< dh_dim, spacedim > &dof_handler, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const
Definition: dof_objects.h:197
void set_dof_index(const ::DoFHandler< dh_dim, spacedim > &dof_handler, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index)
Definition: dof_objects.cc:42
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
bool fe_index_is_active(const ::DoFHandler< dh_dim, spacedim > &dof_handler, const types::global_dof_index index, const unsigned int fe_index) const
Definition: dof_objects.h:180
#define Assert(cond, exc)
Definition: exceptions.h:1407
unsigned int n_active_fe_indices(const ::DoFHandler< dh_dim, spacedim > &dof_handler, const types::global_dof_index index) const
Definition: dof_objects.h:168
unsigned int global_dof_index
Definition: types.h:89
std::vector< types::global_dof_index > dofs
Definition: dof_objects.h:72
static ::ExceptionBase & ExcInternalError()