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 <Eigen/Core>
10 #include <dolfinx/common/MPI.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 Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor>
48 cell_normals(const Mesh& mesh, int dim,
49  const tcb::span<const std::int32_t>& entities);
50 
52 Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor>
53 midpoints(const mesh::Mesh& mesh, int dim,
54  const tcb::span<const std::int32_t>& entities);
55 
66 std::vector<std::int32_t> locate_entities(
67  const mesh::Mesh& mesh, int dim,
68  const std::function<Eigen::Array<bool, Eigen::Dynamic, 1>(
69  const Eigen::Ref<const Eigen::Array<double, 3, Eigen::Dynamic,
70  Eigen::RowMajor>>&)>& marker);
71 
92 std::vector<std::int32_t> locate_entities_boundary(
93  const mesh::Mesh& mesh, int dim,
94  const std::function<Eigen::Array<bool, Eigen::Dynamic, 1>(
95  const Eigen::Ref<const Eigen::Array<double, 3, Eigen::Dynamic,
96  Eigen::RowMajor>>&)>& marker);
97 
109 Eigen::Array<std::int32_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
110 entities_to_geometry(const mesh::Mesh& mesh, int dim,
111  const tcb::span<const std::int32_t>& entity_list,
112  bool orient);
113 
119 std::vector<std::int32_t> exterior_facet_indices(const Mesh& mesh);
120 
136 graph::AdjacencyList<std::int32_t>
137 partition_cells_graph(MPI_Comm comm, int n, const mesh::CellType cell_type,
138  const graph::AdjacencyList<std::int64_t>& cells,
139  mesh::GhostMode ghost_mode);
140 
143 graph::AdjacencyList<std::int32_t>
144 partition_cells_graph(MPI_Comm comm, int n, const mesh::CellType cell_type,
145  const graph::AdjacencyList<std::int64_t>& cells,
146  mesh::GhostMode ghost_mode,
147  const graph::partition_fn& partfn);
148 
149 } // namespace mesh
150 } // 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:485
Eigen::Array< std::int32_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > 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:378
Eigen::Array< double, Eigen::Dynamic, 3, Eigen::RowMajor > 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:171
Eigen::Array< double, Eigen::Dynamic, 3, Eigen::RowMajor > 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:94
std::vector< std::int32_t > locate_entities_boundary(const mesh::Mesh &mesh, int dim, const std::function< Eigen::Array< bool, Eigen::Dynamic, 1 >(const Eigen::Ref< const Eigen::Array< double, 3, Eigen::Dynamic, Eigen::RowMajor >> &)> &marker)
Compute indicies of all mesh entities that are attached to an owned boundary facet and evaluate to tr...
Definition: utils.cpp:265
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:21
std::vector< std::int32_t > locate_entities(const mesh::Mesh &mesh, int dim, const std::function< Eigen::Array< bool, Eigen::Dynamic, 1 >(const Eigen::Ref< const Eigen::Array< double, 3, Eigen::Dynamic, Eigen::RowMajor >> &)> &marker)
Compute indicies of all mesh entities that evaluate to true for the provided geometric marking functi...
Definition: utils.cpp:198
GhostMode
Enum for different partitioning ghost modes.
Definition: Mesh.h:48
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:450
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