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:
60  int block_size,
61  const std::vector<std::vector<std::set<int>>>& entity_dofs,
62  const std::vector<int>& parent_map,
63  const std::vector<std::shared_ptr<const ElementDofLayout>>& sub_dofmaps,
64  const mesh::CellType cell_type,
65  const Eigen::Array<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&
67 
69  ElementDofLayout copy() const;
70 
72  ElementDofLayout(const ElementDofLayout& dofmap) = default;
73 
75  ElementDofLayout(ElementDofLayout&& dofmap) = default;
76 
78  ~ElementDofLayout() = default;
79 
81  ElementDofLayout& operator=(const ElementDofLayout& dofmap) = default;
82 
84  ElementDofLayout& operator=(ElementDofLayout&& dofmap) = default;
85 
89  int num_dofs() const;
90 
94  int num_entity_dofs(int dim) const;
95 
100  int num_entity_closure_dofs(int dim) const;
101 
106  Eigen::Array<int, Eigen::Dynamic, 1> entity_dofs(int entity_dim,
107  int cell_entity_index) const;
108 
113  Eigen::Array<int, Eigen::Dynamic, 1>
114  entity_closure_dofs(int entity_dim, int cell_entity_index) const;
115 
117  const std::vector<std::vector<std::set<int>>>& entity_dofs_all() const;
118 
121  const std::vector<std::vector<std::set<int>>>&
122  entity_closure_dofs_all() const;
123 
125  int num_sub_dofmaps() const;
126 
128  std::shared_ptr<const ElementDofLayout>
129  sub_dofmap(const std::vector<int>& component) const;
130 
134  std::vector<int> sub_view(const std::vector<int>& component) const;
135 
137  int block_size() const;
138 
143  bool is_view() const;
144 
146  Eigen::Array<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
148  {
149  return _base_permutations;
150  }
151 
152 private:
153  // Block size
154  int _block_size;
155 
156  // Mapping of dofs to this ElementDofLayout's immediate parent
157  std::vector<int> _parent_map;
158 
159  // Total number of dofs on this element dofmap
160  int _num_dofs;
161 
162  // The number of dofs associated with each entity type
163  std::array<int, 4> _num_entity_dofs;
164 
165  // The number of dofs associated with each entity type, including all
166  // connected entities of lower dimension.
167  std::array<int, 4> _num_entity_closure_dofs;
168 
169  // List of dofs per entity, ordered by dimension.
170  // dof = _entity_dofs[dim][entity][i]
171  std::vector<std::vector<std::set<int>>> _entity_dofs;
172 
173  // List of dofs with connected entities of lower dimension
174  std::vector<std::vector<std::set<int>>> _entity_closure_dofs;
175 
176  // List of sub dofmaps
177  std::vector<std::shared_ptr<const ElementDofLayout>> _sub_dofmaps;
178 
179  // The base permutations of the DoFs
180  Eigen::Array<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
181  _base_permutations;
182 };
183 
184 } // namespace fem
185 } // namespace dolfinx
dolfinx::fem::ElementDofLayout::num_entity_closure_dofs
int num_entity_closure_dofs(int dim) const
Return the number of closure dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:115
dolfinx::fem::ElementDofLayout::num_dofs
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:108
dolfinx::fem::ElementDofLayout::entity_dofs
Eigen::Array< int, Eigen::Dynamic, 1 > entity_dofs(int entity_dim, int cell_entity_index) const
Local-local mapping of dofs on entity of cell.
Definition: ElementDofLayout.cpp:121
dolfinx::fem::ElementDofLayout::block_size
int block_size() const
Block size.
Definition: ElementDofLayout.cpp:195
dolfinx::fem::ElementDofLayout::~ElementDofLayout
~ElementDofLayout()=default
Destructor.
dolfinx::fem::ElementDofLayout::num_entity_dofs
int num_entity_dofs(int dim) const
Return the number of dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:110
dolfinx::fem::ElementDofLayout::operator=
ElementDofLayout & operator=(const ElementDofLayout &dofmap)=default
Copy assignment.
dolfinx::mesh::CellType
CellType
Cell type identifier.
Definition: cell_types.h:22
dolfinx::fem::ElementDofLayout::sub_view
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:171
dolfinx::fem::ElementDofLayout::num_sub_dofmaps
int num_sub_dofmaps() const
Get number of sub-dofmaps.
Definition: ElementDofLayout.cpp:153
dolfinx::fem::ElementDofLayout::entity_dofs_all
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:142
dolfinx::fem::ElementDofLayout::copy
ElementDofLayout copy() const
Copy the DOF layout, discarding any parent information.
Definition: ElementDofLayout.cpp:101
dolfinx::fem::ElementDofLayout::ElementDofLayout
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, const Eigen::Array< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > &base_permutations)
Constructor.
Definition: ElementDofLayout.cpp:19
dolfinx::fem::ElementDofLayout::entity_closure_dofs
Eigen::Array< int, Eigen::Dynamic, 1 > entity_closure_dofs(int entity_dim, int cell_entity_index) const
Local-local closure dofs on entity of cell.
Definition: ElementDofLayout.cpp:131
dolfinx::fem::ElementDofLayout::base_permutations
Eigen::Array< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > base_permutations() const
Returns the base permutations of the DoFs, as computed by FFCx.
Definition: ElementDofLayout.h:147
dolfinx::fem::ElementDofLayout
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:36
dolfinx::fem::ElementDofLayout::sub_dofmap
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:156
dolfinx::fem::ElementDofLayout::is_view
bool is_view() const
True iff dof map is a view into another map.
Definition: ElementDofLayout.cpp:197
dolfinx::fem::ElementDofLayout::entity_closure_dofs_all
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:148