Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.3.0/v0.9.0/cpp
DOLFINx  0.3.0
DOLFINx 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 <array>
10 #include <dolfinx/common/types.h>
11 #include <memory>
12 #include <set>
13 #include <ufc.h>
14 #include <vector>
15 
16 namespace dolfinx::mesh
17 {
18 enum class CellType;
19 }
20 
21 namespace dolfinx::fem
22 {
23 
27 
28 // TODO: For this class/concept to be robust, the topology of the
29 // reference cell needs to be defined.
30 
31 // TODO: Handle block dofmaps properly
32 
34 {
35 public:
46  int block_size,
47  const std::vector<std::vector<std::set<int>>>& entity_dofs,
48  const std::vector<std::vector<std::set<int>>>& entity_closure_dofs,
49  const std::vector<int>& parent_map,
50  const std::vector<std::shared_ptr<const ElementDofLayout>>& sub_dofmaps);
51 
53  ElementDofLayout copy() const;
54 
56  ElementDofLayout(const ElementDofLayout& dofmap) = default;
57 
59  ElementDofLayout(ElementDofLayout&& dofmap) = default;
60 
62  ~ElementDofLayout() = default;
63 
65  ElementDofLayout& operator=(const ElementDofLayout& dofmap) = default;
66 
69 
73  int num_dofs() const;
74 
78  int num_entity_dofs(int dim) const;
79 
84  int num_entity_closure_dofs(int dim) const;
85 
90  std::vector<int> entity_dofs(int entity_dim, int cell_entity_index) const;
91 
96  std::vector<int> entity_closure_dofs(int entity_dim,
97  int cell_entity_index) const;
98 
100  const std::vector<std::vector<std::set<int>>>& entity_dofs_all() const;
101 
104  const std::vector<std::vector<std::set<int>>>&
105  entity_closure_dofs_all() const;
106 
108  int num_sub_dofmaps() const;
109 
111  std::shared_ptr<const ElementDofLayout>
112  sub_dofmap(const std::vector<int>& component) const;
113 
117  std::vector<int> sub_view(const std::vector<int>& component) const;
118 
120  int block_size() const;
121 
126  bool is_view() const;
127 
128 private:
129  // Block size
130  int _block_size;
131 
132  // Mapping of dofs to this ElementDofLayout's immediate parent
133  std::vector<int> _parent_map;
134 
135  // Total number of dofs on this element dofmap
136  int _num_dofs;
137 
138  // The number of dofs associated with each entity type
139  std::array<int, 4> _num_entity_dofs;
140 
141  // The number of dofs associated with each entity type, including all
142  // connected entities of lower dimension.
143  std::array<int, 4> _num_entity_closure_dofs;
144 
145  // List of dofs per entity, ordered by dimension.
146  // dof = _entity_dofs[dim][entity][i]
147  std::vector<std::vector<std::set<int>>> _entity_dofs;
148 
149  // List of dofs with connected entities of lower dimension
150  std::vector<std::vector<std::set<int>>> _entity_closure_dofs;
151 
152  // List of sub dofmaps
153  std::vector<std::shared_ptr<const ElementDofLayout>> _sub_dofmaps;
154 };
155 
156 } // namespace dolfinx::fem
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:34
ElementDofLayout & operator=(ElementDofLayout &&dofmap)=default
Move assignment.
int num_entity_dofs(int dim) const
Return the number of dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:56
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:54
ElementDofLayout(int block_size, const std::vector< std::vector< std::set< int >>> &entity_dofs, const std::vector< std::vector< std::set< int >>> &entity_closure_dofs, const std::vector< int > &parent_map, const std::vector< std::shared_ptr< const ElementDofLayout >> &sub_dofmaps)
Constructor.
Definition: ElementDofLayout.cpp:19
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:75
~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:114
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:61
int block_size() const
Block size.
Definition: ElementDofLayout.cpp:139
int num_sub_dofmaps() const
Get number of sub-dofmaps.
Definition: ElementDofLayout.cpp:95
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:66
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:98
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:90
ElementDofLayout(ElementDofLayout &&dofmap)=default
Move constructor.
ElementDofLayout copy() const
Copy the DOF layout, discarding any parent information.
Definition: ElementDofLayout.cpp:47
bool is_view() const
True iff dof map is a view into another map.
Definition: ElementDofLayout.cpp:141
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:84
ElementDofLayout(const ElementDofLayout &dofmap)=default
Copy constructor.
Finite element method functionality.
Definition: assemble_matrix_impl.h:23
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:20
CellType
Cell type identifier.
Definition: cell_types.h:22