Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.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 <memory>
13 #include <utility>
14 #include <vector>
15 #include <xtl/xspan.hpp>
16 
17 namespace dolfinx::common
18 {
19 class IndexMap;
20 }
21 
22 namespace dolfinx::mesh
23 {
24 class Topology;
25 }
26 
27 namespace dolfinx::fem
28 {
29 class ElementDofLayout;
30 
54 graph::AdjacencyList<std::int32_t>
55 transpose_dofmap(const graph::AdjacencyList<std::int32_t>& dofmap,
56  std::int32_t num_cells);
57 
64 
65 class DofMap
66 {
67 public:
80  template <typename U,
81  typename = std::enable_if_t<std::is_same<
82  graph::AdjacencyList<std::int32_t>, std::decay_t<U>>::value>>
83  DofMap(std::shared_ptr<const ElementDofLayout> element,
84  std::shared_ptr<const common::IndexMap> index_map, int index_map_bs,
85  U&& dofmap, int bs)
87  _index_map_bs(index_map_bs), _dofmap(std::forward<U>(dofmap)), _bs(bs)
88  {
89  // Do nothing
90  }
91 
92  // Copy constructor
93  DofMap(const DofMap& dofmap) = delete;
94 
96  DofMap(DofMap&& dofmap) = default;
97 
99  virtual ~DofMap() = default;
100 
101  // Copy assignment
102  DofMap& operator=(const DofMap& dofmap) = delete;
103 
105  DofMap& operator=(DofMap&& dofmap) = default;
106 
111  xtl::span<const std::int32_t> cell_dofs(int cell) const
112  {
113  return _dofmap.links(cell);
114  }
115 
117  int bs() const noexcept;
118 
122  DofMap extract_sub_dofmap(const std::vector<int>& component) const;
123 
129  std::pair<std::unique_ptr<DofMap>, std::vector<std::int32_t>>
130  collapse(MPI_Comm comm, const mesh::Topology& topology) const;
131 
134  const graph::AdjacencyList<std::int32_t>& list() const;
135 
137  std::shared_ptr<const ElementDofLayout> element_dof_layout;
138 
140  std::shared_ptr<const common::IndexMap> index_map;
141 
143  int index_map_bs() const;
144 
145 private:
146  // Block size for the IndexMap
147  int _index_map_bs = -1;
148 
149  // Cell-local-to-dof map (dofs for cell dofmap[cell])
150  graph::AdjacencyList<std::int32_t> _dofmap;
151 
152  // Block size for the dofmap
153  int _bs = -1;
154 };
155 } // namespace dolfinx::fem
dolfinx::mesh
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:22
dolfinx::fem::DofMap::extract_sub_dofmap
DofMap extract_sub_dofmap(const std::vector< int > &component) const
Extract subdofmap component.
Definition: DofMap.cpp:194
dolfinx::fem::DofMap::collapse
std::pair< std::unique_ptr< DofMap >, std::vector< std::int32_t > > collapse(MPI_Comm comm, const mesh::Topology &topology) const
Create a "collapsed" dofmap (collapses a sub-dofmap)
Definition: DofMap.cpp:232
dolfinx::fem::DofMap::element_dof_layout
std::shared_ptr< const ElementDofLayout > element_dof_layout
Layout of dofs on an element.
Definition: DofMap.h:137
dolfinx::graph::AdjacencyList
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:46
dolfinx::fem::DofMap::list
const graph::AdjacencyList< std::int32_t > & list() const
Get dofmap data.
Definition: DofMap.cpp:293
dolfinx::fem::DofMap
Degree-of-freedom map.
Definition: DofMap.h:65
dolfinx::fem::transpose_dofmap
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:150
dolfinx::common
Miscellaneous classes, functions and types.
dolfinx::fem::DofMap::bs
int bs() const noexcept
Return the block size for the dofmap.
Definition: DofMap.cpp:192
dolfinx::fem::DofMap::~DofMap
virtual ~DofMap()=default
Destructor.
dolfinx::fem::ElementDofLayout
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:35
dolfinx::fem::DofMap::DofMap
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:83
dolfinx::fem::DofMap::index_map
std::shared_ptr< const common::IndexMap > index_map
Index map that describes the parallel distribution of the dofmap.
Definition: DofMap.h:140
dolfinx::fem
Finite element method functionality.
Definition: assemble_matrix_impl.h:22
dolfinx::fem::DofMap::index_map_bs
int index_map_bs() const
Block size associated with the index_map.
Definition: DofMap.cpp:298
dolfinx::fem::DofMap::cell_dofs
xtl::span< const std::int32_t > cell_dofs(int cell) const
Local-to-global mapping of dofs on a cell.
Definition: DofMap.h:111