DOLFIN-X
DOLFIN-X C++ interface
ElementDofLayout.h
1 // Copyright (C) 2019 Chris Richardson and Garth N. Wells
2 //
3 // This file is part of DOLFINX (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <Eigen/Dense>
10 #include <array>
11 #include <dolfinx/common/types.h>
12 #include <memory>
13 #include <set>
14 #include <ufc.h>
15 #include <vector>
16 
17 namespace dolfinx
18 {
19 namespace mesh
20 {
21 enum class CellType;
22 }
23 
24 namespace fem
25 {
26 
30 
31 // TODO: For this class/concept to be robust, the topology of the
32 // reference cell needs to be defined.
33 
34 // TODO: Handle block dofmaps properly
35 
37 {
38 public:
47  int block_size,
48  const std::vector<std::vector<std::set<int>>>& entity_dofs,
49  const std::vector<int>& parent_map,
50  const std::vector<std::shared_ptr<const ElementDofLayout>>& sub_dofmaps,
51  const mesh::CellType cell_type);
52 
54  ElementDofLayout copy() const;
55 
57  ElementDofLayout(const ElementDofLayout& dofmap) = default;
58 
60  ElementDofLayout(ElementDofLayout&& dofmap) = default;
61 
63  ~ElementDofLayout() = default;
64 
66  ElementDofLayout& operator=(const ElementDofLayout& dofmap) = default;
67 
70 
74  int num_dofs() const;
75 
79  int num_entity_dofs(int dim) const;
80 
85  int num_entity_closure_dofs(int dim) const;
86 
91  std::vector<int> entity_dofs(int entity_dim, int cell_entity_index) const;
92 
97  std::vector<int> entity_closure_dofs(int entity_dim,
98  int cell_entity_index) const;
99 
101  const std::vector<std::vector<std::set<int>>>& entity_dofs_all() const;
102 
105  const std::vector<std::vector<std::set<int>>>&
106  entity_closure_dofs_all() const;
107 
109  int num_sub_dofmaps() const;
110 
112  std::shared_ptr<const ElementDofLayout>
113  sub_dofmap(const std::vector<int>& component) const;
114 
118  std::vector<int> sub_view(const std::vector<int>& component) const;
119 
121  int block_size() const;
122 
127  bool is_view() const;
128 
129 private:
130  // Block size
131  int _block_size;
132 
133  // Mapping of dofs to this ElementDofLayout's immediate parent
134  std::vector<int> _parent_map;
135 
136  // Total number of dofs on this element dofmap
137  int _num_dofs;
138 
139  // The number of dofs associated with each entity type
140  std::array<int, 4> _num_entity_dofs;
141 
142  // The number of dofs associated with each entity type, including all
143  // connected entities of lower dimension.
144  std::array<int, 4> _num_entity_closure_dofs;
145 
146  // List of dofs per entity, ordered by dimension.
147  // dof = _entity_dofs[dim][entity][i]
148  std::vector<std::vector<std::set<int>>> _entity_dofs;
149 
150  // List of dofs with connected entities of lower dimension
151  std::vector<std::vector<std::set<int>>> _entity_closure_dofs;
152 
153  // List of sub dofmaps
154  std::vector<std::shared_ptr<const ElementDofLayout>> _sub_dofmaps;
155 
156 };
157 
158 } // namespace fem
159 } // namespace dolfinx
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:37
ElementDofLayout & operator=(ElementDofLayout &&dofmap)=default
Move assignment.
ElementDofLayout(int block_size, const std::vector< std::vector< std::set< int >>> &entity_dofs, const std::vector< int > &parent_map, const std::vector< std::shared_ptr< const ElementDofLayout >> &sub_dofmaps, const mesh::CellType cell_type)
Constructor.
Definition: ElementDofLayout.cpp:19
int num_entity_dofs(int dim) const
Return the number of dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:84
int num_dofs() const
Return the dimension of the local finite element function space on a cell (number of dofs on element)
Definition: ElementDofLayout.cpp:82
std::vector< int > entity_closure_dofs(int entity_dim, int cell_entity_index) const
Local-local closure dofs on entity of cell.
Definition: ElementDofLayout.cpp:103
~ElementDofLayout()=default
Destructor.
std::vector< int > sub_view(const std::vector< int > &component) const
Get view for a sub dofmap, defined by the component list (as for sub_dofmap()), into this dofmap....
Definition: ElementDofLayout.cpp:142
ElementDofLayout & operator=(const ElementDofLayout &dofmap)=default
Copy assignment.
int num_entity_closure_dofs(int dim) const
Return the number of closure dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:89
int block_size() const
Block size.
Definition: ElementDofLayout.cpp:167
int num_sub_dofmaps() const
Get number of sub-dofmaps.
Definition: ElementDofLayout.cpp:123
std::vector< int > entity_dofs(int entity_dim, int cell_entity_index) const
Local-local mapping of dofs on entity of cell.
Definition: ElementDofLayout.cpp:94
std::shared_ptr< const ElementDofLayout > sub_dofmap(const std::vector< int > &component) const
Get sub-dofmap given by list of components, one for each level.
Definition: ElementDofLayout.cpp:126
const std::vector< std::vector< std::set< int > > > & entity_closure_dofs_all() const
Direct access to all entity closure dofs (dof = _entity_dofs[dim][entity][i])
Definition: ElementDofLayout.cpp:118
ElementDofLayout(ElementDofLayout &&dofmap)=default
Move constructor.
ElementDofLayout copy() const
Copy the DOF layout, discarding any parent information.
Definition: ElementDofLayout.cpp:75
bool is_view() const
True iff dof map is a view into another map.
Definition: ElementDofLayout.cpp:169
const std::vector< std::vector< std::set< int > > > & entity_dofs_all() const
Direct access to all entity dofs (dof = _entity_dofs[dim][entity][i])
Definition: ElementDofLayout.cpp:112
ElementDofLayout(const ElementDofLayout &dofmap)=default
Copy constructor.
CellType
Cell type identifier.
Definition: cell_types.h:21