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.5.1
DOLFINx C++ interface
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 <cstdlib>
14 #include <dolfinx/common/MPI.h>
15 #include <dolfinx/graph/AdjacencyList.h>
16 #include <dolfinx/graph/ordering.h>
17 #include <functional>
18 #include <memory>
19 #include <mpi.h>
20 #include <span>
21 #include <utility>
22 #include <vector>
23 
24 namespace dolfinx::common
25 {
26 class IndexMap;
27 }
28 
29 namespace dolfinx::mesh
30 {
31 class Topology;
32 }
33 
34 namespace dolfinx::fem
35 {
36 
62  std::int32_t num_cells);
63 
65 //
70 class DofMap
71 {
72 public:
76  //
87  template <typename E, typename U,
88  typename = std::enable_if_t<std::is_same<
89  graph::AdjacencyList<std::int32_t>, std::decay_t<U>>::value>>
90  DofMap(E&& element, std::shared_ptr<const common::IndexMap> index_map,
91  int index_map_bs, U&& dofmap, int bs)
92  : index_map(index_map), _index_map_bs(index_map_bs),
93  _element_dof_layout(std::forward<E>(element)),
94  _dofmap(std::forward<U>(dofmap)), _bs(bs)
95  {
96  // Do nothing
97  }
98 
99  // Copy constructor
100  DofMap(const DofMap& dofmap) = delete;
101 
103  DofMap(DofMap&& dofmap) = default;
104 
105  // Destructor
106  virtual ~DofMap() = default;
107 
108  // Copy assignment
109  DofMap& operator=(const DofMap& dofmap) = delete;
110 
112  DofMap& operator=(DofMap&& dofmap) = default;
113 
116  bool operator==(const DofMap& map) const;
117 
122  std::span<const std::int32_t> cell_dofs(int cell) const
123  {
124  return _dofmap.links(cell);
125  }
126 
128  int bs() const noexcept;
129 
133  DofMap extract_sub_dofmap(const std::vector<int>& component) const;
134 
142  std::pair<DofMap, std::vector<std::int32_t>> collapse(
143  MPI_Comm comm, const mesh::Topology& topology,
144  const std::function<std::vector<int>(
145  const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
146  = [](const graph::AdjacencyList<std::int32_t>& g)
147  { return graph::reorder_gps(g); }) const;
148 
152 
155  {
156  return _element_dof_layout;
157  }
158 
161  std::shared_ptr<const common::IndexMap> index_map;
162 
164  int index_map_bs() const;
165 
166 private:
167  // Block size for the IndexMap
168  int _index_map_bs = -1;
169 
170  // Layout of dofs on a cell
171  ElementDofLayout _element_dof_layout;
172 
173  // Cell-local-to-dof map (dofs for cell dofmap[cell])
175 
176  // Block size for the dofmap
177  int _bs = -1;
178 };
179 } // namespace dolfinx::fem
Degree-of-freedom map.
Definition: DofMap.h:71
DofMap(DofMap &&dofmap)=default
Move constructor.
std::shared_ptr< const common::IndexMap > index_map
Index map that describes the parallel distribution of the dofmap.
Definition: DofMap.h:161
DofMap extract_sub_dofmap(const std::vector< int > &component) const
Extract subdofmap component.
Definition: DofMap.cpp:185
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:90
DofMap & operator=(DofMap &&dofmap)=default
Move assignment.
const ElementDofLayout & element_dof_layout() const
Layout of dofs on an element.
Definition: DofMap.h:154
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
std::span< const std::int32_t > cell_dofs(int cell) const
Local-to-global mapping of dofs on a cell.
Definition: DofMap.h:122
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:26
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:44
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:359
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30