1
// Copyright (C) 2007 Anders Logg and Garth N. Wells.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2007-03-01
5
// Last changed: 2007-04-03
12
#include <dolfin/Mesh.h>
13
#include <dolfin/UFCCell.h>
14
#include <dolfin/UFCMesh.h>
15
#include <dolfin/constants.h>
16
#include <dolfin/MeshFunction.h>
24
/// This class handles the mapping of degrees of freedom.
25
/// It wraps a ufc::dof_map on a specific mesh and provides
26
/// optional precomputation and reordering of dofs.
32
/// Create dof map on mesh
33
DofMap(ufc::dof_map& dof_map, Mesh& mesh);
35
/// Create dof map on mesh (parallel)
36
DofMap(ufc::dof_map& dof_map, Mesh& mesh, MeshFunction<uint>& partitions);
38
/// Create dof map on mesh
39
DofMap(const std::string signature, Mesh& mesh);
41
/// Create dof map on mesh (parallel)
42
DofMap(const std::string signature, Mesh& mesh,
43
MeshFunction<uint>& partitions);
48
/// Return a string identifying the dof map
49
const char* signature() const
52
return ufc_dof_map->signature();
55
error("DofMap has been re-ordered. Cannot return signature string.");
56
return ufc_dof_map->signature();
60
/// Return the dimension of the global finite element function space
61
unsigned int global_dimension() const
62
{ return ufc_dof_map->global_dimension(); }
64
/// Return the dimension of the local finite element function space
65
unsigned int local_dimension() const
66
{ return ufc_dof_map->local_dimension(); }
68
/// Return the dimension of the local finite element function space
69
unsigned int macro_local_dimension() const
70
{ return ufc_dof_map->local_dimension(); }
72
/// Return number of facet dofs
73
unsigned int num_facet_dofs() const
74
{ return ufc_dof_map->num_facet_dofs(); }
76
/// Tabulate the local-to-global mapping of dofs on a cell
77
void tabulate_dofs(uint* dofs, Cell& cell)
81
for (uint i = 0; i < local_dimension(); i++)
82
dofs[i] = dof_map[cell.index()][i];
86
ufc_cell.update(cell);
87
ufc_dof_map->tabulate_dofs(dofs, ufc_mesh, ufc_cell);
91
/// Tabulate local-local facet dofs
92
void tabulate_facet_dofs(uint* dofs, uint local_facet) const
93
{ ufc_dof_map->tabulate_facet_dofs(dofs, local_facet); }
95
// FIXME: Can this function eventually be removed?
96
/// Tabulate the local-to-global mapping of dofs on a ufc cell
97
void tabulate_dofs(uint* dofs, const ufc::cell& cell) const
98
{ ufc_dof_map->tabulate_dofs(dofs, ufc_mesh, cell); }
100
void tabulate_coordinates(real** coordinates, const ufc::cell& ufc_cell) const
101
{ ufc_dof_map->tabulate_coordinates(coordinates, ufc_cell); }
103
/// Extract sub dof map
104
DofMap* extractDofMap(const Array<uint>& sub_system, uint& offset) const;
106
/// Return mesh associated with map
108
{ return dolfin_mesh; }
110
/// Build parallel dof map
111
void build(UFC& ufc);
113
/// Return renumbering (used for testing)
114
std::map<uint, uint> getMap() const;
118
/// Initialise DofMap
121
/// Extract sub DofMap
122
ufc::dof_map* extractDofMap(const ufc::dof_map& dof_map, uint& offset, const Array<uint>& sub_system) const;
128
ufc::dof_map* ufc_dof_map;
131
ufc::dof_map* ufc_dof_map_local;
144
// Number of cells in the mesh
148
MeshFunction<uint>* partitions;
150
// Provide easy access to map for testing
151
std::map<uint, uint> map;