Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/da/ded/DofMap_8h_source.html
DOLFINx 0.6.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 <concepts>
14#include <cstdlib>
15#include <dolfinx/common/MPI.h>
16#include <dolfinx/graph/AdjacencyList.h>
17#include <dolfinx/graph/ordering.h>
18#include <functional>
19#include <memory>
20#include <mpi.h>
21#include <span>
22#include <utility>
23#include <vector>
24
25namespace dolfinx::common
26{
27class IndexMap;
28}
29
31{
32class Topology;
33}
34
35namespace dolfinx::fem
36{
37
63 std::int32_t num_cells);
64
71class DofMap
72{
73public:
87 template <std::convertible_to<fem::ElementDofLayout> E,
88 std::convertible_to<graph::AdjacencyList<std::int32_t>> U>
89 DofMap(E&& element, std::shared_ptr<const common::IndexMap> index_map,
90 int index_map_bs, U&& dofmap, int bs)
91 : index_map(index_map), _index_map_bs(index_map_bs),
92 _element_dof_layout(std::forward<E>(element)),
93 _dofmap(std::forward<U>(dofmap)), _bs(bs)
94 {
95 // Do nothing
96 }
97
98 // Copy constructor
99 DofMap(const DofMap& dofmap) = delete;
100
102 DofMap(DofMap&& dofmap) = default;
103
104 // Destructor
105 virtual ~DofMap() = default;
106
107 // Copy assignment
108 DofMap& operator=(const DofMap& dofmap) = delete;
109
111 DofMap& operator=(DofMap&& dofmap) = default;
112
115 bool operator==(const DofMap& map) const;
116
121 std::span<const std::int32_t> cell_dofs(int cell) const
122 {
123 return _dofmap.links(cell);
124 }
125
127 int bs() const noexcept;
128
132 DofMap extract_sub_dofmap(const std::vector<int>& component) const;
133
141 std::pair<DofMap, std::vector<std::int32_t>> collapse(
142 MPI_Comm comm, const mesh::Topology& topology,
143 const std::function<std::vector<int>(
144 const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
145 = [](const graph::AdjacencyList<std::int32_t>& g)
146 { return graph::reorder_gps(g); }) const;
147
151
154 {
155 return _element_dof_layout;
156 }
157
160 std::shared_ptr<const common::IndexMap> index_map;
161
163 int index_map_bs() const;
164
165private:
166 // Block size for the IndexMap
167 int _index_map_bs = -1;
168
169 // Layout of dofs on a cell
170 ElementDofLayout _element_dof_layout;
171
172 // Cell-local-to-dof map (dofs for cell dofmap[cell])
174
175 // Block size for the dofmap
176 int _bs = -1;
177};
178} // namespace dolfinx::fem
Degree-of-freedom map.
Definition: DofMap.h:72
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:160
std::span< const std::int32_t > cell_dofs(int cell) const
Local-to-global mapping of dofs on a cell.
Definition: DofMap.h:121
DofMap extract_sub_dofmap(const std::vector< int > &component) const
Extract subdofmap component.
Definition: DofMap.cpp:185
std::pair< DofMap, std::vector< std::int32_t > > collapse(MPI_Comm comm, const mesh::Topology &topology, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn=[](const graph::AdjacencyList< std::int32_t > &g) { return graph::reorder_gps(g);}) const
Create a "collapsed" dofmap (collapses a sub-dofmap)
Definition: DofMap.cpp:220
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:89
const ElementDofLayout & element_dof_layout() const
Layout of dofs on an element.
Definition: DofMap.h:153
int index_map_bs() const
Block size associated with the index_map.
Definition: DofMap.cpp:287
bool operator==(const DofMap &map) const
Equality operator.
Definition: DofMap.cpp:177
const graph::AdjacencyList< std::int32_t > & list() const
Get dofmap data.
Definition: DofMap.cpp:282
int bs() const noexcept
Return the block size for the dofmap.
Definition: DofMap.cpp:183
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:31
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:27
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:43
Miscellaneous classes, functions and types.
Finite element method functionality.
Definition: assemble_matrix_impl.h:25
graph::AdjacencyList< std::int32_t > transpose_dofmap(const graph::AdjacencyList< std::int32_t > &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:134
std::vector< std::int32_t > reorder_gps(const graph::AdjacencyList< std::int32_t > &graph)
Re-order a graph using the Gibbs-Poole-Stockmeyer algorithm.
Definition: ordering.cpp:360
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:31