DOLFIN-X
DOLFIN-X C++ interface
utils.h
1 // Copyright (C) 2012-2020 Chris Richardson
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/Dense>
10 #include <cstdint>
11 #include <dolfinx/common/MPI.h>
12 #include <map>
13 #include <set>
14 #include <vector>
15 
16 namespace dolfinx
17 {
18 
19 namespace mesh
20 {
21 class Mesh;
22 }
23 
24 namespace common
25 {
26 class IndexMap;
27 }
28 
29 namespace refinement
30 {
31 
38 std::pair<MPI_Comm, std::map<std::int32_t, std::set<int>>>
39 compute_edge_sharing(const mesh::Mesh& mesh);
40 
48  const MPI_Comm& neighbor_comm,
49  const std::vector<std::vector<std::int32_t>>& marked_for_update,
50  std::vector<bool>& marked_edges, const common::IndexMap& map_e);
51 
60 std::pair<std::map<std::int32_t, std::int64_t>,
61  Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
63  const MPI_Comm& neighbor_comm,
64  const std::map<std::int32_t, std::set<std::int32_t>>& shared_edges,
65  const mesh::Mesh& mesh, const std::vector<bool>& marked_edges);
66 
76 mesh::Mesh
77 partition(const mesh::Mesh& old_mesh,
78  const std::vector<std::int64_t>& cell_topology, int num_ghost_cells,
79  const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic,
80  Eigen::RowMajor>& new_vertex_coordinates,
81  bool redistribute);
82 
88 mesh::Mesh build_local(
89  const mesh::Mesh& old_mesh, const std::vector<std::int64_t>& cell_topology,
90  const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&
91  new_vertex_coordinates);
92 
101 std::vector<std::int64_t>
102 adjust_indices(const std::shared_ptr<const common::IndexMap>& index_map,
103  std::int32_t n);
104 
105 } // namespace refinement
106 } // namespace dolfinx
mesh::Mesh partition(const mesh::Mesh &old_mesh, const std::vector< std::int64_t > &cell_topology, int num_ghost_cells, const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > &new_vertex_coordinates, bool redistribute)
Use vertex and topology data to partition new mesh across processes.
Definition: utils.cpp:370
std::vector< std::int64_t > adjust_indices(const std::shared_ptr< const common::IndexMap > &index_map, std::int32_t n)
Adjust indices to account for extra n values on each process This is a utility to help add new topolo...
Definition: utils.cpp:319
mesh::Mesh build_local(const mesh::Mesh &old_mesh, const std::vector< std::int64_t > &cell_topology, const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > &new_vertex_coordinates)
Build local mesh from internal data when not running in parallel.
Definition: utils.cpp:348
std::pair< MPI_Comm, std::map< std::int32_t, std::set< int > > > compute_edge_sharing(const mesh::Mesh &mesh)
Compute the sharing of edges between processes. The resulting MPI_Comm is over the neighborhood of sh...
Definition: utils.cpp:152
std::pair< std::map< std::int32_t, std::int64_t >, Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > create_new_vertices(const MPI_Comm &neighbor_comm, const std::map< std::int32_t, std::set< std::int32_t >> &shared_edges, const mesh::Mesh &mesh, const std::vector< bool > &marked_edges)
Add new vertex for each marked edge, and create new_vertex_coordinates and global_edge->new_vertex ma...
Definition: utils.cpp:225
void update_logical_edgefunction(const MPI_Comm &neighbor_comm, const std::vector< std::vector< std::int32_t >> &marked_for_update, std::vector< bool > &marked_edges, const common::IndexMap &map_e)
Transfer marked edges between processes.
Definition: utils.cpp:195