Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d0/d47/mesh_2utils_8h_source.html
DOLFINx  0.4.1
DOLFINx 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/graph/AdjacencyList.h>
10 #include <dolfinx/graph/partition.h>
11 #include <functional>
12 #include <mpi.h>
13 #include <xtl/xspan.hpp>
14 
15 namespace dolfinx::fem
16 {
17 class ElementDofLayout;
18 }
19 
20 namespace dolfinx::mesh
21 {
22 enum class CellType;
23 class Mesh;
24 
26 enum class GhostMode : int
27 {
28  none,
29  shared_facet,
30  shared_vertex
31 };
32 
49  = std::function<dolfinx::graph::AdjacencyList<std::int32_t>(
50  MPI_Comm comm, int nparts, int tdim,
52  dolfinx::mesh::GhostMode ghost_mode)>;
53 
64 extract_topology(const CellType& cell_type, const fem::ElementDofLayout& layout,
66 
68 std::vector<double> h(const Mesh& mesh,
69  const xtl::span<const std::int32_t>& entities, int dim);
70 
72 xt::xtensor<double, 2>
73 cell_normals(const Mesh& mesh, int dim,
74  const xtl::span<const std::int32_t>& entities);
75 
77 xt::xtensor<double, 2>
78 compute_midpoints(const Mesh& mesh, int dim,
79  const xtl::span<const std::int32_t>& entities);
80 
91 std::vector<std::int32_t> locate_entities(
92  const Mesh& mesh, int dim,
93  const std::function<xt::xtensor<bool, 1>(const xt::xtensor<double, 2>&)>&
94  marker);
95 
116 std::vector<std::int32_t> locate_entities_boundary(
117  const Mesh& mesh, int dim,
118  const std::function<xt::xtensor<bool, 1>(const xt::xtensor<double, 2>&)>&
119  marker);
120 
132 xt::xtensor<std::int32_t, 2>
133 entities_to_geometry(const Mesh& mesh, int dim,
134  const xtl::span<const std::int32_t>& entity_list,
135  bool orient);
136 
142 std::vector<std::int32_t> exterior_facet_indices(const Mesh& mesh);
143 
150 
158 std::vector<std::int32_t>
159 compute_incident_entities(const Mesh& mesh,
160  const xtl::span<const std::int32_t>& entities, int d0,
161  int d1);
162 
163 } // namespace dolfinx::mesh
The class represents the degree-of-freedom (dofs) for an element. Dofs are associated with a mesh ent...
Definition: ElementDofLayout.h:31
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:46
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition: Mesh.h:33
Finite element method functionality.
Definition: assemble_matrix_impl.h:24
std::function< graph::AdjacencyList< std::int32_t >(MPI_Comm, int, const AdjacencyList< std::int64_t > &, bool)> partition_fn
Signature of functions for computing the parallel partitioning of a distributed graph.
Definition: partition.h:34
AdjacencyList< std::int32_t > partition_graph(MPI_Comm comm, int nparts, const AdjacencyList< std::int64_t > &local_graph, bool ghosting)
Partition graph across processes using the default graph partitioner.
Definition: partition.cpp:22
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30
xt::xtensor< std::int32_t, 2 > entities_to_geometry(const Mesh &mesh, int dim, const xtl::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:403
CellPartitionFunction create_cell_partitioner(const graph::partition_fn &partfn=&graph::partition_graph)
Create a function that computes destination rank for mesh cells in this rank by applying the default ...
Definition: utils.cpp:520
std::vector< std::int32_t > locate_entities(const Mesh &mesh, int dim, const std::function< xt::xtensor< bool, 1 >(const xt::xtensor< double, 2 > &)> &marker)
Compute indices of all mesh entities that evaluate to true for the provided geometric marking functio...
Definition: utils.cpp:224
GhostMode
Enum for different partitioning ghost modes.
Definition: utils.h:27
std::vector< std::int32_t > locate_entities_boundary(const Mesh &mesh, int dim, const std::function< xt::xtensor< bool, 1 >(const xt::xtensor< double, 2 > &)> &marker)
Compute indices of all mesh entities that are attached to an owned boundary facet and evaluate to tru...
Definition: utils.cpp:292
std::vector< std::int32_t > compute_incident_entities(const Mesh &mesh, const xtl::span< const std::int32_t > &entities, int d0, int d1)
Compute incident indices.
Definition: utils.cpp:543
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:32
xt::xtensor< double, 2 > compute_midpoints(const Mesh &mesh, int dim, const xtl::span< const std::int32_t > &entities)
Compute the midpoints for mesh entities of a given dimension.
Definition: utils.cpp:198
xt::xtensor< double, 2 > cell_normals(const Mesh &mesh, int dim, const xtl::span< const std::int32_t > &entities)
Compute normal to given cell (viewed as embedded in 3D)
Definition: utils.cpp:109
CellType
Cell type identifier.
Definition: cell_types.h:22
std::function< dolfinx::graph::AdjacencyList< std::int32_t >(MPI_Comm comm, int nparts, int tdim, const dolfinx::graph::AdjacencyList< std::int64_t > &cells, dolfinx::mesh::GhostMode ghost_mode)> CellPartitionFunction
Signature for the cell partitioning function. The function should compute the destination rank for ce...
Definition: utils.h:52
std::vector< double > h(const Mesh &mesh, const xtl::span< const std::int32_t > &entities, int dim)
Compute greatest distance between any two vertices.
Definition: utils.cpp:59
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:482