libMesh
dof_map_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_DOF_MAP_BASE_H
19 #define LIBMESH_DOF_MAP_BASE_H
20 
21 #include "libmesh/id_types.h"
22 #include "libmesh/parallel_object.h"
23 #include <vector>
24 
25 namespace libMesh
26 {
27 class Variable;
28 class Elem;
29 class Node;
30 
51 class DofMapBase : public ParallelObject
52 {
53 public:
55 
61  virtual unsigned int n_variables() const = 0;
62 
66  virtual const Variable & variable(const unsigned int c) const = 0;
67 
71  dof_id_type first_dof(const processor_id_type proc) const;
72 
73  dof_id_type first_dof() const { return this->first_dof(this->processor_id()); }
74 
81  dof_id_type end_dof(const processor_id_type proc) const;
82 
83  dof_id_type end_dof() const { return this->end_dof(this->processor_id()); }
84 
90  virtual void dof_indices(const Elem * const elem,
91  std::vector<dof_id_type> & di,
92  const unsigned int vn,
93  int p_level = -12345) const = 0;
94 
99  virtual void dof_indices(const Node * const node,
100  std::vector<dof_id_type> & di,
101  const unsigned int vn) const = 0;
105  dof_id_type n_dofs() const { return _n_dfs; }
106 
111 
115  dof_id_type n_local_dofs() const { return this->n_dofs_on_processor(this->processor_id()); }
116 
117  virtual void clear();
118 
119 #ifdef LIBMESH_ENABLE_AMR
120 
123  dof_id_type n_old_dofs() const { return _n_old_dfs; }
124 
128  dof_id_type first_old_dof(const processor_id_type proc) const;
129 
130  dof_id_type first_old_dof() const { return this->first_old_dof(this->processor_id()); }
131 
138  dof_id_type end_old_dof(const processor_id_type proc) const;
139 
140  dof_id_type end_old_dof() const { return this->end_old_dof(this->processor_id()); }
141 #endif // LIBMESH_ENABLE_AMR
142 
143 protected:
150 
154  std::vector<dof_id_type> _first_df;
155 
159  std::vector<dof_id_type> _end_df;
160 
165 
166 #ifdef LIBMESH_ENABLE_AMR
167 
172 
176  std::vector<dof_id_type> _first_old_df;
177 
181  std::vector<dof_id_type> _end_old_df;
182 #endif
183 };
184 
186 {
187  libmesh_assert_less(proc, _first_df.size());
188  return _first_df[proc];
189 }
190 
192 {
193  libmesh_assert_less(proc, _end_df.size());
194  return _end_df[proc];
195 }
196 
198 {
199  libmesh_assert_less(proc, _first_df.size());
200  return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
201 }
202 
203 #ifdef LIBMESH_ENABLE_AMR
205 {
206  libmesh_assert_less(proc, _first_old_df.size());
207  return _first_old_df[proc];
208 }
209 
211 {
212  libmesh_assert_less(proc, _end_old_df.size());
213  return _end_old_df[proc];
214 }
215 #endif // LIBMESH_ENABLE_AMR
216 }
217 #endif // LIBMESH_DOF_MAP_BASE_H
virtual void clear()
Definition: dof_map_base.C:71
A Node is like a Point, but with more information.
Definition: node.h:52
dof_id_type n_dofs() const
Definition: dof_map_base.h:105
virtual unsigned int n_variables() const =0
std::vector< dof_id_type > _first_df
First DOF index on processor p.
Definition: dof_map_base.h:154
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
const Parallel::Communicator & comm() const
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t processor_id_type
Definition: id_types.h:104
dof_id_type end_dof() const
Definition: dof_map_base.h:83
dof_id_type first_dof() const
Definition: dof_map_base.h:73
This class defines the notion of a variable in the system.
Definition: variable.h:50
virtual const Variable & variable(const unsigned int c) const =0
This base class provides a minimal set of interfaces for satisfying user requests for...
Definition: dof_map_base.h:51
dof_id_type n_old_dofs() const
Definition: dof_map_base.h:123
dof_id_type _n_dfs
Total number of degrees of freedom.
Definition: dof_map_base.h:164
DofMapBase(const Parallel::Communicator &comm)
Definition: dof_map_base.C:23
dof_id_type first_old_dof() const
Definition: dof_map_base.h:130
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map_base.h:197
An object whose state is distributed along a set of processors.
std::vector< dof_id_type > _end_old_df
Last old DOF index (plus 1) on processor p.
Definition: dof_map_base.h:181
std::size_t compute_dof_info(dof_id_type n_local_dofs)
compute the key degree of freedom information given the local number of degrees of freedom on this pr...
dof_id_type n_local_dofs() const
Definition: dof_map_base.h:115
dof_id_type end_old_dof() const
Definition: dof_map_base.h:140
processor_id_type processor_id() const
dof_id_type _n_old_dfs
Total number of degrees of freedom on old dof objects.
Definition: dof_map_base.h:171
std::vector< dof_id_type > _first_old_df
First old DOF index on processor p.
Definition: dof_map_base.h:176
uint8_t dof_id_type
Definition: id_types.h:67
std::vector< dof_id_type > _end_df
Last DOF index (plus 1) on processor p.
Definition: dof_map_base.h:159
virtual void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di, const unsigned int vn, int p_level=-12345) const =0
Fills the vector di with the global degree of freedom indices for the element.