DOLFINx
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 <span>
11#include <vector>
12
13namespace dolfinx::mesh
14{
15enum class CellType;
16}
17
18namespace dolfinx::fem
19{
20
24
25// TODO: For this class/concept to be robust, the topology of the
26// reference cell needs to be defined.
27
28// TODO: Handle block dofmaps properly
29
31{
32public:
43 int block_size,
44 const std::vector<std::vector<std::vector<int>>>& entity_dofs,
45 const std::vector<std::vector<std::vector<int>>>& entity_closure_dofs,
46 const std::vector<int>& parent_map,
47 const std::vector<ElementDofLayout>& sub_layouts);
48
50 ElementDofLayout copy() const;
51
53 ElementDofLayout(const ElementDofLayout& dofmap) = default;
54
57
59 ~ElementDofLayout() = default;
60
62 ElementDofLayout& operator=(const ElementDofLayout& dofmap) = default;
63
66
71 bool operator==(const ElementDofLayout& layout) const;
72
76 int num_dofs() const;
77
81 int num_entity_dofs(int dim) const;
82
87 int num_entity_closure_dofs(int dim) const;
88
93 const std::vector<int>& entity_dofs(int dim, int entity_index) const;
94
99 const std::vector<int>& entity_closure_dofs(int dim, int entity_index) const;
100
102 const std::vector<std::vector<std::vector<int>>>& entity_dofs_all() const;
103
106 const std::vector<std::vector<std::vector<int>>>&
108
110 int num_sub_dofmaps() const;
111
113 const ElementDofLayout&
114 sub_layout(const std::span<const int>& component) const;
115
119 std::vector<int> sub_view(const std::span<const int>& component) const;
120
122 int block_size() const;
123
127 bool is_view() const;
128
129private:
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::vector<int>>> _entity_dofs;
149
150 // List of dofs with connected entities of lower dimension
151 std::vector<std::vector<std::vector<int>>> _entity_closure_dofs;
152
153 // List of sub dofmaps
154 // std::vector<std::shared_ptr<const ElementDofLayout>> _sub_dofmaps;
155 std::vector<ElementDofLayout> _sub_dofmaps;
156};
157
158} // namespace dolfinx::fem
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:31
const std::vector< int > & entity_closure_dofs(int dim, int entity_index) const
Local-local closure dofs on entity of cell.
Definition: ElementDofLayout.cpp:80
ElementDofLayout copy() const
Copy the DOF layout, discarding any parent information.
Definition: ElementDofLayout.cpp:45
int num_entity_dofs(int dim) const
Return the number of dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:63
const std::vector< int > & entity_dofs(int dim, int entity_index) const
Local-local mapping of dofs on entity of cell.
Definition: ElementDofLayout.cpp:73
const std::vector< std::vector< std::vector< int > > > & entity_closure_dofs_all() const
Direct access to all entity closure dofs (dof = _entity_dofs[dim][entity][i])
Definition: ElementDofLayout.cpp:92
ElementDofLayout(ElementDofLayout &&dofmap)=default
Move constructor.
const ElementDofLayout & sub_layout(const std::span< const int > &component) const
Get sub-dofmap given by list of components, one for each level.
Definition: ElementDofLayout.cpp:100
bool is_view() const
True iff dof map is a view into another map.
Definition: ElementDofLayout.cpp:140
ElementDofLayout(int block_size, const std::vector< std::vector< std::vector< int > > > &entity_dofs, const std::vector< std::vector< std::vector< int > > > &entity_closure_dofs, const std::vector< int > &parent_map, const std::vector< ElementDofLayout > &sub_layouts)
Constructor.
Definition: ElementDofLayout.cpp:18
int num_entity_closure_dofs(int dim) const
Return the number of closure dofs for a given entity dimension.
Definition: ElementDofLayout.cpp:68
std::vector< int > sub_view(const std::span< const int > &component) const
Get view for a sub-layout, defined by the component list (as for sub_layour()), into this dofmap....
Definition: ElementDofLayout.cpp:113
~ElementDofLayout()=default
Destructor.
ElementDofLayout & operator=(ElementDofLayout &&dofmap)=default
Move assignment.
int block_size() const
Block size.
Definition: ElementDofLayout.cpp:138
ElementDofLayout(const ElementDofLayout &dofmap)=default
Copy constructor.
ElementDofLayout & operator=(const ElementDofLayout &dofmap)=default
Copy assignment.
bool operator==(const ElementDofLayout &layout) const
Equality operator.
Definition: ElementDofLayout.cpp:52
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:61
const std::vector< std::vector< std::vector< int > > > & entity_dofs_all() const
Direct access to all entity dofs (dof = _entity_dofs[dim][entity][i])
Definition: ElementDofLayout.cpp:86
int num_sub_dofmaps() const
Get number of sub-dofmaps.
Definition: ElementDofLayout.cpp:97
Finite element method functionality.
Definition: assemble_matrix_impl.h:25
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30
CellType
Cell type identifier.
Definition: cell_types.h:22