Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.3.0/v0.9.0/cpp
DOLFINx  0.3.0
DOLFINx C++ interface
DofMap.h
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 
7 #pragma once
8 
9 #include <cstdlib>
10 #include <dolfinx/common/MPI.h>
11 #include <dolfinx/graph/AdjacencyList.h>
12 #include <dolfinx/graph/scotch.h>
13 #include <functional>
14 #include <memory>
15 #include <utility>
16 #include <vector>
17 #include <xtl/xspan.hpp>
18 
19 namespace dolfinx::common
20 {
21 class IndexMap;
22 }
23 
24 namespace dolfinx::mesh
25 {
26 class Topology;
27 }
28 
29 namespace dolfinx::fem
30 {
31 class ElementDofLayout;
32 
56 graph::AdjacencyList<std::int32_t>
57 transpose_dofmap(const graph::AdjacencyList<std::int32_t>& dofmap,
58  std::int32_t num_cells);
59 
66 
67 class DofMap
68 {
69 public:
82  template <typename U,
83  typename = std::enable_if_t<std::is_same<
84  graph::AdjacencyList<std::int32_t>, std::decay_t<U>>::value>>
85  DofMap(std::shared_ptr<const ElementDofLayout> element,
86  std::shared_ptr<const common::IndexMap> index_map, int index_map_bs,
87  U&& dofmap, int bs)
89  _index_map_bs(index_map_bs), _dofmap(std::forward<U>(dofmap)), _bs(bs)
90  {
91  // Do nothing
92  }
93 
94  // Copy constructor
95  DofMap(const DofMap& dofmap) = delete;
96 
98  DofMap(DofMap&& dofmap) = default;
99 
101  virtual ~DofMap() = default;
102 
103  // Copy assignment
104  DofMap& operator=(const DofMap& dofmap) = delete;
105 
107  DofMap& operator=(DofMap&& dofmap) = default;
108 
113  xtl::span<const std::int32_t> cell_dofs(int cell) const
114  {
115  return _dofmap.links(cell);
116  }
117 
119  int bs() const noexcept;
120 
124  DofMap extract_sub_dofmap(const std::vector<int>& component) const;
125 
133  std::pair<std::unique_ptr<DofMap>, std::vector<std::int32_t>> collapse(
134  MPI_Comm comm, const mesh::Topology& topology,
135  const std::function<std::vector<int>(
136  const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
137  = [](const graph::AdjacencyList<std::int32_t>& g)
138  { return graph::scotch::compute_gps(g, 2).first; }) const;
139 
143 
145  std::shared_ptr<const ElementDofLayout> element_dof_layout;
146 
148  std::shared_ptr<const common::IndexMap> index_map;
149 
151  int index_map_bs() const;
152 
153 private:
154  // Block size for the IndexMap
155  int _index_map_bs = -1;
156 
157  // Cell-local-to-dof map (dofs for cell dofmap[cell])
159 
160  // Block size for the dofmap
161  int _bs = -1;
162 };
163 } // namespace dolfinx::fem
Degree-of-freedom map.
Definition: DofMap.h:68
xtl::span< const std::int32_t > cell_dofs(int cell) const
Local-to-global mapping of dofs on a cell.
Definition: DofMap.h:113
std::shared_ptr< const ElementDofLayout > element_dof_layout
Layout of dofs on an element.
Definition: DofMap.h:145
int index_map_bs() const
Block size associated with the index_map.
Definition: DofMap.cpp:298
std::shared_ptr< const common::IndexMap > index_map
Index map that describes the parallel distribution of the dofmap.
Definition: DofMap.h:148
DofMap(std::shared_ptr< const ElementDofLayout > 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:85
DofMap & operator=(DofMap &&dofmap)=default
Move assignment.
const graph::AdjacencyList< std::int32_t > & list() const
Get dofmap data.
Definition: DofMap.cpp:293
virtual ~DofMap()=default
Destructor.
DofMap(DofMap &&dofmap)=default
Move constructor.
std::pair< std::unique_ptr< 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::scotch::compute_gps(g, 2).first;}) const
Create a "collapsed" dofmap (collapses a sub-dofmap)
Definition: DofMap.cpp:229
int bs() const noexcept
Return the block size for the dofmap.
Definition: DofMap.cpp:190
DofMap extract_sub_dofmap(const std::vector< int > &component) const
Extract subdofmap component.
Definition: DofMap.cpp:192
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:47
Miscellaneous classes, functions and types.
Finite element method functionality.
Definition: assemble_matrix_impl.h:23
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:148
std::pair< std::vector< int >, std::vector< int > > compute_gps(const AdjacencyList< std::int32_t > &graph, std::size_t num_passes=5)
Compute reordering (map[old] -> new) using Gibbs-Poole-Stockmeyer (GPS) re-ordering.
Definition: scotch.cpp:28
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:20