Refinement (dolfinx::refinement
)
-
namespace dolfinx::refinement
Mesh refinement algorithms.
Methods for refining meshes uniformly, or with markers, using edge bisection.
Functions
-
mesh::Mesh refine(const mesh::Mesh &mesh, bool redistribute = true)
Create a uniformly refined mesh.
- Parameters
mesh – [in] The mesh from which to build a refined Mesh
redistribute – [in] Optional argument to redistribute the refined mesh if mesh is a distributed mesh.
- Returns
A refined mesh
-
mesh::Mesh refine(const mesh::Mesh &mesh, const xtl::span<const std::int32_t> &edges, bool redistribute = true)
Create a locally refined mesh.
- Parameters
mesh – [in] The mesh from which to build a refined Mesh
edges – [in] Indices of the edges that should be split by this refinement. mesh::compute_incident_entities can be used to compute the edges that are incident to other entities, e.g. incident to cells.
redistribute – [in] Optional argument to redistribute the refined mesh if mesh is a distributed mesh.
- Returns
A locally refined mesh
-
std::pair<MPI_Comm, std::map<std::int32_t, std::vector<int>>> compute_edge_sharing(const mesh::Mesh &mesh)
Compute the sharing of edges between processes.
The resulting MPI_Comm is over the neighborhood of shared edges, allowing direct communication between peers. The resulting map is from local edge index to the set of neighbors (within the comm) that share that edge.
- Parameters
mesh – [in] Mesh
- Returns
pair of comm and map
-
void update_logical_edgefunction(MPI_Comm neighbor_comm, const std::vector<std::vector<std::int32_t>> &marked_for_update, std::vector<std::int8_t> &marked_edges, const common::IndexMap &map_e)
Transfer marked edges between processes.
- Parameters
neighbor_comm – [in] MPI Communicator for neighborhood
marked_for_update – [in] Lists of edges to be updates on each neighbor
marked_edges – [inout] Marked edges to be updated
map_e – [in] IndexMap for edges
-
std::pair<std::map<std::int32_t, std::int64_t>, xt::xtensor<double, 2>> create_new_vertices(MPI_Comm neighbor_comm, const std::map<std::int32_t, std::vector<std::int32_t>> &shared_edges, const mesh::Mesh &mesh, const std::vector<std::int8_t> &marked_edges)
Add new vertex for each marked edge, and create new_vertex_coordinates and global_edge->new_vertex map. Communicate new vertices with MPI to all affected processes.
- Parameters
neighbor_comm – [in] MPI Communicator for neighborhood
shared_edges – [in]
mesh – [in] Existing mesh
marked_edges – [in]
- Returns
edge_to_new_vertex map and geometry array
-
mesh::Mesh partition(const mesh::Mesh &old_mesh, const graph::AdjacencyList<std::int64_t> &cell_topology, const xt::xtensor<double, 2> &new_vertex_coordinates, bool redistribute, mesh::GhostMode ghost_mode)
Use vertex and topology data to partition new mesh across processes.
- Parameters
old_mesh – [in]
cell_topology – [in] Topology of cells, (vertex indices)
new_vertex_coordinates – [in]
redistribute – [in] Call graph partitioner if true
ghost_mode – [in] None or shared_facet
- Returns
New mesh
-
std::vector<std::int64_t> adjust_indices(const common::IndexMap &index_map, std::int32_t n)
brief description indices to account for extra n values on each process.
This is a utility to help add new topological vertices on each process into the space of the index map.
- Parameters
index_map – [in] Index map for the current mesh vertices
n – [in] Number of new entries to be accommodated on this process
- Returns
Global indices as if “n” extra values are appended on each process
-
mesh::MeshTags<std::int32_t> transfer_facet_meshtag(const mesh::MeshTags<std::int32_t> &parent_meshtag, const mesh::Mesh &refined_mesh, const std::vector<std::int32_t> &parent_cell, const std::vector<std::int8_t> &parent_facet)
Transfer facet MeshTags from coarse mesh to refined mesh.
Note
The refined mesh must not have been redistributed during refinement
Note
GhostMode must be GhostMode.none
- Parameters
parent_meshtag – [in] Facet MeshTags on parent mesh
refined_mesh – [in] Refined mesh based on parent mesh
parent_cell – [in] Parent cell of each cell in refined mesh
parent_facet – [in] Local facets of parent in each cell in refined mesh
- Returns
MeshTags on refined mesh, values copied over from coarse mesh
-
mesh::MeshTags<std::int32_t> transfer_cell_meshtag(const mesh::MeshTags<std::int32_t> &parent_meshtag, const mesh::Mesh &refined_mesh, const std::vector<std::int32_t> &parent_cell)
Transfer cell MeshTags from coarse mesh to refined mesh.
Note
The refined mesh must not have been redistributed during refinement
Note
GhostMode must be GhostMode.none
- Parameters
parent_meshtag – [in] Cell MeshTags on parent mesh
refined_mesh – [in] Refined mesh based on parent mesh
parent_cell – [in] Parent cell of each cell in refined mesh
- Returns
MeshTags on refined mesh, values copied over from coarse mesh
-
namespace plaza
Function in this namespace implement the refinement method described in Plaza and Carey “Local refinement of simplicial grids based on
the skeleton” (Applied Numerical Mathematics 32 (2000) 195-218).
Enums
-
enum class RefinementOptions : int
Selection of options when refining a Mesh.
parent_cell
will output a list containing the local parent cell index for each new cell,parent_facet
will output a list of the cell-local facet indices in the parent cell of each facet in each new cell (or -1 if no match).parent_cell_and_facet
will output both datasets.Values:
-
enumerator none
-
enumerator parent_cell
-
enumerator parent_facet
-
enumerator parent_cell_and_facet
-
enumerator none
Functions
-
std::tuple<mesh::Mesh, std::vector<std::int32_t>, std::vector<std::int8_t>> refine(const mesh::Mesh &mesh, bool redistribute, RefinementOptions options)
Uniform refine, optionally redistributing and optionally calculating the parent-child relationships, selected by
RefinementOptions
.- Parameters
mesh – [in] Input mesh to be refined
redistribute – [in] Flag to call the mesh partitioner to redistribute after refinement
options – [in] RefinementOptions enum to choose the computation of parent facets, parent cells. If an option is unselected, an empty list is returned.
- Returns
New Mesh and optional parent cell index, parent facet indices
-
std::tuple<mesh::Mesh, std::vector<std::int32_t>, std::vector<std::int8_t>> refine(const mesh::Mesh &mesh, const xtl::span<const std::int32_t> &edges, bool redistribute, RefinementOptions options)
Refine with markers, optionally redistributing, and optionally calculating the parent-child relationships, selected by
RefinementOptions
.- Parameters
mesh – [in] Input mesh to be refined
edges – [in] Indices of the edges that should be split by this refinement
redistribute – [in] Flag to call the Mesh Partitioner to redistribute after refinement
options – [in] RefinementOptions enum to choose the computation of parent facets, parent cells. If an option is unselected, an empty list is returned.
- Returns
New Mesh and optional parent cell index, parent facet indices
-
std::tuple<graph::AdjacencyList<std::int64_t>, xt::xtensor<double, 2>, std::vector<std::int32_t>, std::vector<std::int8_t>> compute_refinement_data(const mesh::Mesh &mesh, RefinementOptions options)
Refine mesh returning new mesh data.
- Parameters
mesh – [in] Input mesh to be refined
options – [in] RefinementOptions enum to choose the computation of parent facets, parent cells. If an option is unselected, an empty list is returned.
- Returns
New mesh data: cell topology, vertex coordinates, and optional parent cell index, and parent facet indices.
-
std::tuple<graph::AdjacencyList<std::int64_t>, xt::xtensor<double, 2>, std::vector<std::int32_t>, std::vector<std::int8_t>> compute_refinement_data(const mesh::Mesh &mesh, const xtl::span<const std::int32_t> &edges, RefinementOptions options)
Refine with markers returning new mesh data.
- Parameters
mesh – [in] Input mesh to be refined
edges – [in] Indices of the edges that should be split by this refinement
options – [in] RefinementOptions enum to choose the computation of parent facets, parent cells. If an option is unselected, an empty list is returned.
- Returns
New mesh data: cell topology, vertex coordinates and parent cell index, and stored parent facet indices (if requested).
-
enum class RefinementOptions : int
-
mesh::Mesh refine(const mesh::Mesh &mesh, bool redistribute = true)