DOLFIN
DOLFIN C++ interface
GenericDofMap.h
1 // Copyright (C) 2010-2015 Anders Logg and Garth N. Wells
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef __GENERIC_DOF_MAP_H
19 #define __GENERIC_DOF_MAP_H
20 
21 #include <map>
22 #include <utility>
23 #include <vector>
24 #include <memory>
25 #include <unordered_map>
26 #include <unordered_set>
27 #include <Eigen/Dense>
28 
29 #include <dolfin/common/types.h>
30 #include <dolfin/common/Variable.h>
31 #include <dolfin/la/IndexMap.h>
32 #include <dolfin/log/log.h>
33 
34 namespace ufc
35 {
36  class cell;
37 }
38 
39 namespace dolfin
40 {
41 
42  class Cell;
43  class GenericVector;
44  class Mesh;
45  class SubDomain;
46 
48 
49  class GenericDofMap : public Variable
50  {
51  public:
52 
55  {}
56 
58  virtual bool is_view() const = 0;
59 
62  virtual std::size_t global_dimension() const = 0;
63 
66  std::size_t cell_dimension(std::size_t index) const
67  {
68  // TODO: Add deprecation warning
69  return num_element_dofs(index);
70  }
71 
74  std::size_t max_cell_dimension() const
75  {
76  // TODO: Add deprecation warning
77  return max_element_dofs();
78  }
79 
82  virtual std::size_t num_element_dofs(std::size_t index) const = 0;
83 
86  virtual std::size_t max_element_dofs() const = 0;
87 
89  virtual std::size_t num_entity_dofs(std::size_t entity_dim) const = 0;
90 
92  virtual std::size_t num_entity_closure_dofs(std::size_t entity_dim) const = 0;
93 
95  virtual std::size_t num_facet_dofs() const = 0;
96 
99  virtual std::pair<std::size_t, std::size_t> ownership_range() const = 0;
100 
103  virtual const std::vector<int>& off_process_owner() const = 0;
104 
106  virtual Eigen::Map<const Eigen::Array<dolfin::la_index, Eigen::Dynamic, 1>>
107  cell_dofs(std::size_t cell_index) const = 0;
108 
110  virtual std::vector<dolfin::la_index>
111  entity_dofs(const Mesh& mesh, std::size_t entity_dim,
112  const std::vector<std::size_t> & entity_indices) const = 0;
113 
115  virtual std::vector<dolfin::la_index>
116  entity_dofs(const Mesh& mesh, std::size_t entity_dim) const = 0;
117 
120  virtual std::vector<dolfin::la_index>
121  entity_closure_dofs(const Mesh& mesh, std::size_t entity_dim,
122  const std::vector<std::size_t> & entity_indices) const = 0;
123 
126  virtual std::vector<dolfin::la_index>
127  entity_closure_dofs(const Mesh& mesh, std::size_t entity_dim) const = 0;
128 
130  virtual void tabulate_facet_dofs(std::vector<std::size_t>& element_dofs,
131  std::size_t cell_facet_index) const = 0;
132 
135  virtual void tabulate_entity_dofs(std::vector<std::size_t>& element_dofs,
136  std::size_t entity_dim,
137  std::size_t cell_entity_index) const = 0;
138 
141  virtual void tabulate_entity_closure_dofs(std::vector<std::size_t>& element_dofs,
142  std::size_t entity_dim,
143  std::size_t cell_entity_index) const = 0;
144 
146  virtual void tabulate_global_dofs(std::vector<std::size_t>& dofs) const = 0;
147 
149  virtual std::shared_ptr<GenericDofMap> copy() const = 0;
150 
152  virtual std::shared_ptr<GenericDofMap>
153  create(const Mesh& new_mesh) const = 0;
154 
156  virtual std::shared_ptr<GenericDofMap>
157  extract_sub_dofmap(const std::vector<std::size_t>& component,
158  const Mesh& mesh) const = 0;
159 
161  virtual std::shared_ptr<GenericDofMap>
162  collapse(std::unordered_map<std::size_t, std::size_t>& collapsed_map,
163  const Mesh& mesh) const = 0;
164 
167  virtual std::vector<dolfin::la_index> dofs(const Mesh& mesh,
168  std::size_t dim) const = 0;
169 
171  virtual std::vector<dolfin::la_index> dofs() const = 0;
172 
177  virtual void set(GenericVector& x, double value) const = 0;
178 
181  virtual const std::vector<std::size_t>& local_to_global_unowned() const = 0;
182 
184  virtual std::shared_ptr<const IndexMap> index_map() const = 0;
185 
187  virtual void tabulate_local_to_global_dofs(std::vector<std::size_t>& local_to_global_map) const = 0;
188 
190  virtual std::size_t local_to_global_index(int local_index) const = 0;
191 
194  virtual const std::unordered_map<int, std::vector<int>>&
195  shared_nodes() const = 0;
196 
198  virtual const std::set<int>& neighbours() const = 0;
199 
202  virtual void clear_sub_map_data() = 0;
203 
205  virtual std::string str(bool verbose) const = 0;
206 
208  virtual int block_size() const = 0;
209 
212  std::shared_ptr<const SubDomain> constrained_domain;
213 
214  };
215 
216 }
217 
218 #endif
Common base class for DOLFIN variables.
Definition: Variable.h:35
GenericDofMap()
Constructor.
Definition: GenericDofMap.h:54
This class provides a generic interface for dof maps.
Definition: GenericDofMap.h:49
Definition: adapt.h:29
Definition: Extrapolation.h:34
std::shared_ptr< const SubDomain > constrained_domain
Definition: GenericDofMap.h:212
std::size_t max_cell_dimension() const
Definition: GenericDofMap.h:74
This class defines a common interface for vectors.
Definition: GenericVector.h:47
std::size_t cell_dimension(std::size_t index) const
Definition: GenericDofMap.h:66
Definition: Mesh.h:82