DOLFINx 0.10.0.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
DofMap.h
Go to the documentation of this file.
1// Copyright (C) 2007-2020 Anders Logg 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
9
10#pragma once
11
12#include "ElementDofLayout.h"
13#include <basix/mdspan.hpp>
14#include <concepts>
15#include <cstdlib>
16#include <dolfinx/common/MPI.h>
17#include <dolfinx/graph/AdjacencyList.h>
18#include <dolfinx/graph/ordering.h>
19#include <functional>
20#include <memory>
21#include <mpi.h>
22#include <span>
23#include <utility>
24#include <vector>
25
26namespace dolfinx::common
27{
28class IndexMap;
29}
30
32{
33class Topology;
34}
35
36namespace dolfinx::fem
37{
38
63transpose_dofmap(MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
64 const std::int32_t,
65 MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
66 dofmap,
67 std::int32_t num_cells);
68
75class DofMap
76{
77public:
91 template <typename E, typename U>
92 requires std::is_convertible_v<std::remove_cvref_t<E>,
94 and std::is_convertible_v<std::remove_cvref_t<U>,
95 std::vector<std::int32_t>>
96 DofMap(E&& element, std::shared_ptr<const common::IndexMap> index_map,
97 int index_map_bs, U&& dofmap, int bs)
98 : index_map(index_map), _index_map_bs(index_map_bs),
99 _element_dof_layout(std::forward<E>(element)),
100 _dofmap(std::forward<U>(dofmap)), _bs(bs),
101 _shape1(_element_dof_layout.num_dofs()
102 * _element_dof_layout.block_size() / _bs)
103 {
104 // Do nothing
105 }
106
107 // Copy constructor
108 DofMap(const DofMap& dofmap) = delete;
109
111 DofMap(DofMap&& dofmap) = default;
112
113 // Destructor
114 ~DofMap() = default;
115
116 // Copy assignment
117 DofMap& operator=(const DofMap& dofmap) = delete;
118
120 DofMap& operator=(DofMap&& dofmap) = default;
121
124 bool operator==(const DofMap& map) const;
125
130 std::span<const std::int32_t> cell_dofs(std::int32_t c) const
131 {
132 return std::span<const std::int32_t>(_dofmap.data() + _shape1 * c, _shape1);
133 }
134
136 int bs() const noexcept;
137
141 DofMap extract_sub_dofmap(std::span<const int> component) const;
142
149 std::pair<DofMap, std::vector<std::int32_t>>
150 collapse(MPI_Comm comm, const mesh::Topology& topology,
151 std::function<std::vector<int>(
152 const graph::AdjacencyList<std::int32_t>&)>&& reorder_fn
153 = nullptr) const;
154
157 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
158 const std::int32_t,
159 MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
160 map() const;
161
164 {
165 return _element_dof_layout;
166 }
167
170 std::shared_ptr<const common::IndexMap> index_map;
171
173 int index_map_bs() const;
174
175private:
176 // Block size for the IndexMap
177 int _index_map_bs = -1;
178
179 // Layout of dofs on a cell
180 ElementDofLayout _element_dof_layout;
181
182 // Cell local-to-dof map
183 std::vector<std::int32_t> _dofmap;
184
185 // Block size for the dofmap
186 int _bs = -1;
187
188 // Number of columns in _dofmap
189 int _shape1 = -1;
190};
191} // namespace dolfinx::fem
Degree-of-freedom map.
Definition DofMap.h:76
DofMap(DofMap &&dofmap)=default
Move constructor.
DofMap & operator=(DofMap &&dofmap)=default
Move assignment.
std::shared_ptr< const common::IndexMap > index_map
Index map that describes the parallel distribution of the dofmap.
Definition DofMap.h:170
DofMap extract_sub_dofmap(std::span< const int > component) const
Extract subdofmap component.
Definition DofMap.cpp:175
DofMap(E &&element, std::shared_ptr< const common::IndexMap > index_map, int index_map_bs, U &&dofmap, int bs)
Create a DofMap from the layout of dofs on a reference element, an IndexMap defining the distribution...
Definition DofMap.h:96
MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const std::int32_t, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 > > map() const
Get dofmap data.
Definition DofMap.cpp:278
std::pair< DofMap, std::vector< std::int32_t > > collapse(MPI_Comm comm, const mesh::Topology &topology, std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &&reorder_fn=nullptr) const
Create a "collapsed" dofmap (collapses a sub-dofmap)
Definition DofMap.cpp:209
std::span< const std::int32_t > cell_dofs(std::int32_t c) const
Local-to-global mapping of dofs on a cell.
Definition DofMap.h:130
const ElementDofLayout & element_dof_layout() const
Layout of dofs on an element.
Definition DofMap.h:163
int index_map_bs() const
Block size associated with the index_map.
Definition DofMap.cpp:286
bool operator==(const DofMap &map) const
Equality operator.
Definition DofMap.cpp:167
int bs() const noexcept
Return the block size for the dofmap.
Definition DofMap.cpp:173
Definition ElementDofLayout.h:30
Definition topologycomputation.h:24
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition Topology.h:45
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8
Finite element method functionality.
Definition assemble_matrix_impl.h:26
graph::AdjacencyList< std::int32_t > transpose_dofmap(MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const std::int32_t, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 > > dofmap, std::int32_t num_cells)
Create an adjacency list that maps a global index (process-wise) to the 'unassembled' cell-wise contr...
Definition DofMap.cpp:118
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32