Reference documentation for deal.II version 8.5.1
dof_objects.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2006 - 2015 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 #ifndef dealii__dof_objects_h
17 #define dealii__dof_objects_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <vector>
23 
24 DEAL_II_NAMESPACE_OPEN
25 
26 template <int, int> class DoFHandler;
27 
28 namespace internal
29 {
30  namespace DoFHandler
31  {
32  template <int> class DoFLevel;
33  template <int> class DoFFaces;
34 
35 
60  template <int dim>
61  class DoFObjects
62  {
63  public:
67  std::vector<types::global_dof_index> dofs;
68 
69  public:
83  template <int dh_dim, int spacedim>
84  void
85  set_dof_index (const ::DoFHandler<dh_dim,spacedim> &dof_handler,
86  const unsigned int obj_index,
87  const unsigned int fe_index,
88  const unsigned int local_index,
89  const types::global_dof_index global_index);
90 
103  template <int dh_dim, int spacedim>
105  get_dof_index (const ::DoFHandler<dh_dim,spacedim> &dof_handler,
106  const unsigned int obj_index,
107  const unsigned int fe_index,
108  const unsigned int local_index) const;
109 
115  template <int dh_dim, int spacedim>
116  unsigned int
117  n_active_fe_indices (const ::DoFHandler<dh_dim,spacedim> &dof_handler,
118  const types::global_dof_index index) const;
119 
124  template <int dh_dim, int spacedim>
125  bool
126  fe_index_is_active (const ::DoFHandler<dh_dim,spacedim> &dof_handler,
127  const types::global_dof_index index,
128  const unsigned int fe_index) const;
129 
134  std::size_t memory_consumption () const;
135 
140  template <class Archive>
141  void serialize(Archive &ar,
142  const unsigned int version);
143 
148  template <int> friend class DoFLevel;
149  template <int> friend class DoFFaces;
150  };
151 
152 
153 // --------------------- template and inline functions ------------------
154 
155  template <int dim>
156  template <int dh_dim, int spacedim>
157  inline
158  unsigned int
159  DoFObjects<dim>::n_active_fe_indices (const ::DoFHandler<dh_dim,spacedim> &,
160  const types::global_dof_index) const
161  {
162  return 1;
163  }
164 
165 
166 
167  template <int dim>
168  template <int dh_dim, int spacedim>
169  inline
170  bool
171  DoFObjects<dim>::fe_index_is_active (const ::DoFHandler<dh_dim,spacedim> &,
173  const unsigned int fe_index) const
174  {
175  (void)fe_index;
176  Assert (fe_index == 0,
177  ExcMessage ("Only zero fe_index values are allowed for "
178  "non-hp DoFHandlers."));
179  return true;
180  }
181 
182 
183 
184  template <int dim>
185  template <int dh_dim, int spacedim>
186  inline
189  get_dof_index (const ::DoFHandler<dh_dim,spacedim> &dof_handler,
190  const unsigned int obj_index,
191  const unsigned int fe_index,
192  const unsigned int local_index) const
193  {
194  (void)fe_index;
196  ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects"));
197  Assert (local_index<dof_handler.get_fe().template n_dofs_per_object<dim>(),
198  ExcIndexRange (local_index, 0, dof_handler.get_fe().template n_dofs_per_object<dim>()));
199  Assert (obj_index * dof_handler.get_fe().template n_dofs_per_object<dim>()+local_index
200  <
201  dofs.size(),
202  ExcInternalError());
203 
204  return dofs[obj_index * dof_handler.get_fe()
205  .template n_dofs_per_object<dim>() + local_index];
206  }
207 
208 
209  template <int dim>
210  template <class Archive>
211  void DoFObjects<dim>::serialize(Archive &ar,
212  const unsigned int)
213  {
214  ar &dofs;
215  }
216 
217  }
218 }
219 
220 DEAL_II_NAMESPACE_CLOSE
221 
222 #endif
std::vector< types::global_dof_index > dofs
Definition: dof_objects.h:67
void serialize(Archive &ar, const unsigned int version)
Definition: dof_objects.h:211
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
unsigned int global_dof_index
Definition: types.h:88
#define Assert(cond, exc)
Definition: exceptions.h:313
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:41
unsigned int n_active_fe_indices(const ::DoFHandler< dh_dim, spacedim > &dof_handler, const types::global_dof_index index) const
Definition: dof_objects.h:159
std::size_t memory_consumption() const
Definition: dof_objects.cc:30
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:189
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:171
static ::ExceptionBase & ExcInternalError()