/usr/include/dolfin/fem/DofMapBuilder.h is in libdolfin-dev 2017.2.0.post0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | // Copyright (C) 2008-2015 Anders Logg, Ola Skavhaug and Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Niclas Jansson 2009.
// Modified by Garth Wells 2009-2012
// Modified by Mikael Mortensen 2012.
// Modified by Martin Alnaes, 2015
#ifndef __DOF_MAP_BUILDER_H
#define __DOF_MAP_BUILDER_H
#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include <utility>
#include <vector>
namespace ufc
{
class dofmap;
}
namespace dolfin
{
class DofMap;
class Mesh;
class IndexMap;
class SubDomain;
class UFC;
class Cell;
/// Builds a DofMap on a Mesh
class DofMapBuilder
{
public:
/// Build dofmap. The constrained domain may be a null pointer, in
/// which case it is ignored.
///
/// @param[out] dofmap
/// @param[in] dolfin_mesh
/// @param[in] constrained_domain
static void build(DofMap& dofmap, const Mesh& dolfin_mesh,
std::shared_ptr<const SubDomain> constrained_domain);
/// Build sub-dofmap. This is a view into the parent dofmap.
///
/// @param[out] sub_dofmap
/// @param[in] parent_dofmap
/// @param[in] component
/// @param[in] mesh
static void build_sub_map_view(DofMap& sub_dofmap,
const DofMap& parent_dofmap,
const std::vector<std::size_t>& component,
const Mesh& mesh);
private:
// Build modified global entity indices that account for periodic
// bcs
static std::size_t build_constrained_vertex_indices(
const Mesh& mesh,
const std::map<unsigned int, std::pair<unsigned int,
unsigned int>>& slave_to_master_vertices,
std::vector<std::int64_t>& modified_vertex_indices_global);
// Build simple local UFC-based dofmap data structure (does not
// account for master/slave constraints)
static void
build_local_ufc_dofmap(std::vector<std::vector<dolfin::la_index>>& dofmap,
const ufc::dofmap& ufc_dofmap,
const Mesh& mesh);
// Compute which process 'owns' each node (point at which dofs live)
// - node_ownership = -1 -> dof shared but not 'owned' by this
// process
// - node_ownership = 0 -> dof owned by this process and shared
// with other processes
// - node_ownership = 1 -> dof owned by this process and not
// shared
//
// Also computes map from shared node to sharing processes and a
// set of process that share dofs on this process.
// Returns: number of locally owned nodes
static int compute_node_ownership(
std::vector<short int>& node_ownership,
std::unordered_map<int, std::vector<int>>& shared_node_to_processes,
std::set<int>& neighbours,
const std::vector<std::vector<la_index>>& node_dofmap,
const std::vector<int>& boundary_nodes,
const std::set<std::size_t>& global_nodes,
const std::vector<std::size_t>& node_local_to_global,
const Mesh& mesh,
const std::size_t global_dim);
// Build dofmap based on re-ordered nodes
static void
build_dofmap(std::vector<std::vector<la_index>>& dofmap,
const std::vector<std::vector<la_index>>& node_dofmap,
const std::vector<int>& old_to_new_node_local,
const std::size_t block_size);
// Compute set of global dofs (e.g. Reals associated with global
// Lagrange multipliers) based on UFC numbering. Global dofs are
// not associated with any mesh entity. The returned indices are
// local to the process.
static std::set<std::size_t>
compute_global_dofs(std::shared_ptr<const ufc::dofmap> ufc_dofmap,
const std::vector<std::size_t>& num_mesh_entities_local);
// Iterate recursively over all sub-dof maps to find global
// degrees of freedom
static void
compute_global_dofs(std::set<std::size_t>& global_dofs,
std::size_t& offset_local,
std::shared_ptr<const ufc::dofmap> ufc_dofmap,
const std::vector<std::size_t>& num_mesh_entities_local);
// Recursively extract UFC sub-dofmap and compute offset
static std::shared_ptr<ufc::dofmap> extract_ufc_sub_dofmap(
const ufc::dofmap& ufc_dofmap,
std::size_t& offset,
const std::vector<std::size_t>& component,
const std::vector<std::size_t>& num_global_mesh_entities);
// Compute block size, e.g. in 3D elasticity block_size = 3
static std::size_t compute_blocksize(const ufc::dofmap& ufc_dofmap);
static void compute_constrained_mesh_indices(
std::vector<std::vector<std::int64_t>>& global_entity_indices,
std::vector<std::size_t>& num_mesh_entities_global,
const std::vector<bool>& needs_mesh_entities,
const Mesh& mesh,
const SubDomain& constrained_domain);
static std::shared_ptr<const ufc::dofmap>
build_ufc_node_graph(
std::vector<std::vector<la_index>>& node_dofmap,
std::vector<std::size_t>& node_local_to_global,
std::vector<std::size_t>& num_mesh_entities_global,
std::shared_ptr<const ufc::dofmap> ufc_dofmap,
const Mesh& mesh,
std::shared_ptr<const SubDomain> constrained_domain,
const std::size_t block_size);
static std::shared_ptr<const ufc::dofmap>
build_ufc_node_graph_constrained(
std::vector<std::vector<la_index>>& node_dofmap,
std::vector<std::size_t>& node_local_to_global,
std::vector<int>& node_ufc_local_to_local,
std::vector<std::size_t>& num_mesh_entities_global,
std::shared_ptr<const ufc::dofmap> ufc_dofmap,
const Mesh& mesh,
std::shared_ptr<const SubDomain> constrained_domain,
const std::size_t block_size);
// Mark shared nodes. Boundary nodes are assigned a random
// positive integer, interior nodes are marked as -1, interior
// nodes in ghost layer of other processes are marked -2, and
// ghost nodes are marked as -3
static void compute_shared_nodes(
std::vector<int>& boundary_nodes,
const std::vector<std::vector<la_index>>& node_dofmap,
const std::size_t num_nodes_local,
const ufc::dofmap& ufc_dofmap,
const Mesh& mesh);
static void compute_node_reordering(
IndexMap& index_map,
std::vector<int>& old_to_new_local,
const std::unordered_map<int, std::vector<int>>& node_to_sharing_processes,
const std::vector<std::size_t>& old_local_to_global,
const std::vector<std::vector<la_index>>& node_dofmap,
const std::vector<short int>& node_ownership,
const std::set<std::size_t>& global_nodes,
const MPI_Comm mpi_comm);
static void get_cell_entities_local(const Cell& cell,
std::vector<std::vector<std::size_t>>& entity_indices,
const std::vector<bool>& needs_mesh_entities);
static void get_cell_entities_global(const Cell& cell,
std::vector<std::vector<std::size_t>>& entity_indices,
const std::vector<bool>& needs_mesh_entities);
static void get_cell_entities_global_constrained(const Cell& cell,
std::vector<std::vector<std::size_t>>& entity_indices,
const std::vector<std::vector<std::int64_t>>& global_entity_indices,
const std::vector<bool>& needs_mesh_entities);
// Compute number of mesh entities for dimensions required by
// dofmap
static std::vector<std::size_t> compute_num_mesh_entities_local(
const Mesh& mesh, const std::vector<bool>& needs_mesh_entities);
};
}
#endif
|