DOLFIN-X
DOLFIN-X 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 <Eigen/Dense>
10 #include <cstdlib>
11 #include <dolfinx/common/MPI.h>
12 #include <dolfinx/graph/AdjacencyList.h>
13 #include <memory>
14 #include <utility>
15 #include <vector>
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(graph::AdjacencyList<std::int32_t>& dofmap,
56  std::int32_t num_cells);
57 
64 
65 class DofMap
66 {
67 public:
71  DofMap(std::shared_ptr<const ElementDofLayout> element_dof_layout,
72  std::shared_ptr<const common::IndexMap> index_map,
74 
75  // Copy constructor
76  DofMap(const DofMap& dofmap) = delete;
77 
79  DofMap(DofMap&& dofmap) = default;
80 
82  virtual ~DofMap() = default;
83 
84  // Copy assignment
85  DofMap& operator=(const DofMap& dofmap) = delete;
86 
88  DofMap& operator=(DofMap&& dofmap) = default;
89 
94  Eigen::Array<std::int32_t, Eigen::Dynamic, 1>::ConstSegmentReturnType
95  cell_dofs(int cell) const
96  {
97  return _dofmap.links(cell);
98  }
99 
103  DofMap extract_sub_dofmap(const std::vector<int>& component) const;
104 
110  std::pair<std::unique_ptr<DofMap>, std::vector<std::int32_t>>
111  collapse(MPI_Comm comm, const mesh::Topology& topology) const;
112 
115  const graph::AdjacencyList<std::int32_t>& list() const { return _dofmap; }
116 
118  std::shared_ptr<const ElementDofLayout> element_dof_layout;
119 
121  std::shared_ptr<const common::IndexMap> index_map;
122 
123 private:
124  // Cell-local-to-dof map (dofs for cell dofmap[cell])
126 };
127 } // namespace dolfinx::fem
dolfinx::mesh
Mesh data structures.
Definition: DirichletBC.h:27
dolfinx::fem::DofMap::extract_sub_dofmap
DofMap extract_sub_dofmap(const std::vector< int > &component) const
Extract subdofmap component.
Definition: DofMap.cpp:213
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:243
dolfinx::fem::transpose_dofmap
graph::AdjacencyList< std::int32_t > transpose_dofmap(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:162
dolfinx::fem::DofMap::operator=
DofMap & operator=(DofMap &&dofmap)=default
Move assignment.
dolfinx::fem::DofMap::element_dof_layout
std::shared_ptr< const ElementDofLayout > element_dof_layout
Layout of dofs on an element.
Definition: DofMap.h:118
dolfinx::graph::AdjacencyList
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:28
dolfinx::fem::DofMap
Degree-of-freedom map.
Definition: DofMap.h:66
dolfinx::common
Miscellaneous classes, functions and types.
dolfinx::fem::DofMap::~DofMap
virtual ~DofMap()=default
Destructor.
dolfinx::fem::DofMap::list
const graph::AdjacencyList< std::int32_t > & list() const
Get dofmap data.
Definition: DofMap.h:115
dolfinx::fem::DofMap::cell_dofs
Eigen::Array< std::int32_t, Eigen::Dynamic, 1 >::ConstSegmentReturnType cell_dofs(int cell) const
Local-to-global mapping of dofs on a cell.
Definition: DofMap.h:95
dolfinx::fem::DofMap::DofMap
DofMap(std::shared_ptr< const ElementDofLayout > element_dof_layout, std::shared_ptr< const common::IndexMap > index_map, const graph::AdjacencyList< std::int32_t > &dofmap)
Create a DofMap from the layout of dofs on a reference element, an IndexMap defining the distribution...
Definition: DofMap.cpp:203
dolfinx::fem::DofMap::index_map
std::shared_ptr< const common::IndexMap > index_map
Index map that described the parallel distribution of the dofmap.
Definition: DofMap.h:121
dolfinx::fem
Finite element method functionality.
Definition: assemble_matrix_impl.h:23
dolfinx::mesh::Topology
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:58
dolfinx::fem::DofMap::DofMap
DofMap(DofMap &&dofmap)=default
Move constructor.