DOLFIN-X
DOLFIN-X C++ interface
utils.h
1 // Copyright (C) 2019-2020 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 <dolfinx/common/MPI.h>
10 #include <dolfinx/common/array2d.h>
11 #include <dolfinx/common/span.hpp>
12 #include <dolfinx/graph/AdjacencyList.h>
13 #include <dolfinx/graph/partition.h>
14 #include <functional>
15 
16 namespace dolfinx
17 {
18 namespace fem
19 {
20 class ElementDofLayout;
21 }
22 
23 namespace mesh
24 {
25 enum class CellType;
26 enum class GhostMode : int;
27 class Mesh;
28 
38 graph::AdjacencyList<std::int64_t>
39 extract_topology(const CellType& cell_type, const fem::ElementDofLayout& layout,
40  const graph::AdjacencyList<std::int64_t>& cells);
41 
43 std::vector<double> h(const Mesh& mesh,
44  const tcb::span<const std::int32_t>& entities, int dim);
45 
47 array2d<double> cell_normals(const Mesh& mesh, int dim,
48  const tcb::span<const std::int32_t>& entities);
49 
51 array2d<double> midpoints(const mesh::Mesh& mesh, int dim,
52  const tcb::span<const std::int32_t>& entities);
53 
64 std::vector<std::int32_t> locate_entities(
65  const mesh::Mesh& mesh, int dim,
66  const std::function<std::vector<bool>(const array2d<double>&)>& marker);
67 
88 std::vector<std::int32_t> locate_entities_boundary(
89  const mesh::Mesh& mesh, int dim,
90  const std::function<std::vector<bool>(const array2d<double>&)>& marker);
91 
103 array2d<std::int32_t>
104 entities_to_geometry(const mesh::Mesh& mesh, int dim,
105  const tcb::span<const std::int32_t>& entity_list,
106  bool orient);
107 
113 std::vector<std::int32_t> exterior_facet_indices(const Mesh& mesh);
114 
130 graph::AdjacencyList<std::int32_t>
131 partition_cells_graph(MPI_Comm comm, int n, const mesh::CellType cell_type,
132  const graph::AdjacencyList<std::int64_t>& cells,
133  mesh::GhostMode ghost_mode);
134 
137 graph::AdjacencyList<std::int32_t>
138 partition_cells_graph(MPI_Comm comm, int n, const mesh::CellType cell_type,
139  const graph::AdjacencyList<std::int64_t>& cells,
140  mesh::GhostMode ghost_mode,
141  const graph::partition_fn& partfn);
142 
143 } // namespace mesh
144 } // namespace dolfinx
graph::AdjacencyList< std::int32_t > partition_cells_graph(MPI_Comm comm, int n, const mesh::CellType cell_type, const graph::AdjacencyList< std::int64_t > &cells, mesh::GhostMode ghost_mode)
Compute destination rank for mesh cells in this rank by applying the default graph partitioner to the...
Definition: utils.cpp:495
std::vector< std::int32_t > locate_entities(const mesh::Mesh &mesh, int dim, const std::function< std::vector< bool >(const array2d< double > &)> &marker)
Compute indicies of all mesh entities that evaluate to true for the provided geometric marking functi...
Definition: utils.cpp:206
std::vector< std::int32_t > locate_entities_boundary(const mesh::Mesh &mesh, int dim, const std::function< std::vector< bool >(const array2d< double > &)> &marker)
Compute indicies of all mesh entities that are attached to an owned boundary facet and evaluate to tr...
Definition: utils.cpp:270
graph::AdjacencyList< std::int64_t > extract_topology(const CellType &cell_type, const fem::ElementDofLayout &layout, const graph::AdjacencyList< std::int64_t > &cells)
Extract topology from cell data, i.e. extract cell vertices.
Definition: utils.cpp:27
CellType
Cell type identifier.
Definition: cell_types.h:22
array2d< double > cell_normals(const Mesh &mesh, int dim, const tcb::span< const std::int32_t > &entities)
Compute normal to given cell (viewed as embedded in 3D)
Definition: utils.cpp:93
GhostMode
Enum for different partitioning ghost modes.
Definition: Mesh.h:48
array2d< std::int32_t > entities_to_geometry(const mesh::Mesh &mesh, int dim, const tcb::span< const std::int32_t > &entity_list, bool orient)
Compute the indices the geometry data for the vertices of the given mesh entities.
Definition: utils.cpp:384
std::vector< std::int32_t > exterior_facet_indices(const Mesh &mesh)
Compute the indices (local) of all exterior facets. An exterior facet (co-dimension 1) is one that is...
Definition: utils.cpp:460
std::vector< double > h(const Mesh &mesh, const tcb::span< const std::int32_t > &entities, int dim)
Compute greatest distance between any two vertices.
Definition: utils.cpp:54
array2d< double > midpoints(const mesh::Mesh &mesh, int dim, const tcb::span< const std::int32_t > &entities)
Compute midpoints or mesh entities of a given dimension.
Definition: utils.cpp:175