Loading...
Searching...
No Matches
dolfinx::refinement Namespace Reference

Mesh refinement algorithms. More...

## Namespaces

namespace | plaza
| Plaza mesh refinement.

## Classes

struct | IdentityPartitionerPlaceholder
| Placeholder for the creation of an identity partitioner in refine. More...

## Enumerations

enum class | Option : std::uint8_t { none = 0b00 , parent_facet = 0b01 , parent_cell = 0b10 , parent_cell_and_facet = 0b11 }
| Options for data to compute during mesh refinement. More...

## Functions

constexpr Option | operator| (Option a, Option b)
| Combine two refinement options into one, both flags will be set for the resulting option.
constexpr bool | option_parent_facet (Option a)
| Check if parent_facet flag is set.
constexpr bool | option_parent_cell (Option a)
| Check if parent_cell flag is set.
template<std::floating_point T>
mesh::CellPartitionFunction | create_identity_partitioner (const mesh::Mesh< T > &parent_mesh, std::span< std::int32_t > parent_cell)
| Create a cell partitioner which maintains the partition of a coarse mesh.
template<std::floating_point T>
std::tuple< mesh::Mesh< T >, std::optional< std::vector< std::int32_t > >, std::optional< std::vector< std::int8_t > > > | refine (const mesh::Mesh< T > &mesh, std::optional< std::span< const std::int32_t > > edges, std::variant< IdentityPartitionerPlaceholder, mesh::CellPartitionFunction > partitioner=IdentityPartitionerPlaceholder(), Option option=Option::parent_cell)
| Refine a mesh with markers.
template<typename T>
mesh::Mesh< T > | uniform_refine (const mesh::Mesh< T > &mesh, const mesh::CellPartitionFunction &partitioner=mesh::create_cell_partitioner(mesh::GhostMode::none))
| Uniform refinement of a 2D or 3D mesh, containing any supported cell types. Hexahedral, tetrahedral and prism cells are subdivided into 8, each being similar to the original cell. Pyramid cells are subdivided into 5 similar pyramids, plus 4 tetrahedra. Triangle and quadrilateral cells are subdivided into 4 similar subcells.
void | update_logical_edgefunction (MPI_Comm comm, const std::vector< std::vector< std::int32_t > > &marked_for_update, std::span< std::int8_t > marked_edges, const common::IndexMap &map)
| Communicate edge markers between processes that share edges.
template<std::floating_point T>
std::tuple< graph::AdjacencyList< std::int64_t >, std::vector< T >, std::array< std::size_t, 2 > > | create_new_vertices (MPI_Comm comm, const graph::AdjacencyList< int > &shared_edges, const mesh::Mesh< T > &mesh, std::span< const std::int8_t > marked_edges)
| Add new vertex for each marked edge, and create new_vertex_coordinates and global_edge->new_vertex map.
std::vector< std::int64_t > | adjust_indices (const common::IndexMap &map, std::int32_t n)
| Given an index map, add "n" extra indices at the end of local range.
std::array< std::vector< std::int32_t >, 2 > | transfer_facet_meshtag (const mesh::MeshTags< std::int32_t > &tags0, const mesh::Topology &topology1, std::span< const std::int32_t > cell, std::span< const std::int8_t > facet)
| Transfer facet MeshTags from coarse mesh to refined mesh.
std::array< std::vector< std::int32_t >, 2 > | transfer_cell_meshtag (const mesh::MeshTags< std::int32_t > &tags0, const mesh::Topology &topology1, std::span< const std::int32_t > parent_cell)
| Transfer cell MeshTags from coarse mesh to refined mesh.

## Detailed Description

Mesh refinement algorithms.

Methods for refining meshes uniformly, or with markers, using edge bisection.

## Enumeration Type Documentation

## Option

enum class Option : std::uint8_t

strong

Options for data to compute during mesh refinement.

Enumerator
none | No extra data
parent_facet | Compute 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 | Compute list with the parent cell index for each new cell

## Function Documentation

## adjust_indices()

std::vector< std::int64_t > adjust_indices | ( | const common::IndexMap & | map,
|  | std::int32_t | n )

Given an index map, add "n" extra indices at the end of local range.

Todo
  Improve docstring.

Note
  The returned global indices (local and ghosts) are adjust for the addition of new local indices.

Parameters

  [in] | map | Index map.
  [in] | n | Number of new local indices.

Returns
  New global indices for both owned and ghosted indices in input index map.

## create_identity_partitioner()

template<std::floating_point T>

mesh::CellPartitionFunction create_identity_partitioner | ( | const mesh::Mesh< T > & | parent_mesh,
|  | std::span< std::int32_t > | parent_cell )

Create a cell partitioner which maintains the partition of a coarse mesh.

Template Parameters

  T | floating point type of mesh geometry.

Parameters

  parent_mesh | mesh indicating the partition scheme to use, i.e. the coarse mesh.
  parent_cell | list of cell indices mapping cells of the new refined mesh into the coarse mesh, usually output of refinement::refine.

Returns
  The created cell partition function.

## create_new_vertices()

template<std::floating_point T>

std::tuple< graph::AdjacencyList< std::int64_t >, std::vector< T >, std::array< std::size_t, 2 > > create_new_vertices | ( | MPI_Comm | comm,
|  | const graph::AdjacencyList< int > & | shared_edges,
|  | const mesh::Mesh< T > & | mesh,
|  | std::span< const 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

  [in] | comm | MPI Communicator for neighborhood
  [in] | shared_edges | For each local edge on a process map to ghost processes
  [in] | mesh | Existing mesh
  [in] | marked_edges | A marker for all edges on the process (local + ghosts) indicating if an edge should be refined

Returns
  (0) map from local edge index to new vertex global index, (1) the coordinates of the new vertices (row-major storage) and (2) the shape of the new coordinates.

## refine()

template<std::floating_point T>

std::tuple< mesh::Mesh< T >, std::optional< std::vector< std::int32_t > >, std::optional< std::vector< std::int8_t > > > refine | ( | const mesh::Mesh< T > & | mesh,
|  | std::optional< std::span< const std::int32_t > > | edges,
|  | std::variant< IdentityPartitionerPlaceholder, mesh::CellPartitionFunction > | partitioner = IdentityPartitionerPlaceholder(),
|  | Option | option = Option::parent_cell )

Refine a mesh with markers.

The refined mesh can be optionally re-partitioned across processes. Passing nullptr for partitioner, refined cells will be on the same process as the parent cell.

Parent-child relationships can be optionally computed. Parent-child relationships can be used to create MeshTags on the refined mesh from MeshTags on the parent mesh.

Warning
  Using the default partitioner for a refined mesh, the refined mesh will not include ghosts cells (cells connected by facet to an owned cell) even if the parent mesh is ghosted.

Parameters

  [in] | mesh | Input mesh to be refined.
  [in] | edges | Indices of the edges that should be split in the refinement. If not provided (std::nullopt), uniform refinement is performed.
  [in] | partitioner | (Optional) partitioner to be used to distribute the refined mesh. If not provided (std::nullopt) the partition of the coarse mesh will be maintained. If not callable, refined cells will be on the same process as the parent cell.
  [in] | option | Control the computation of parent facets, parent cells.

Returns
  New mesh, and optional parent cell indices and parent facet indices.

## transfer_cell_meshtag()

std::array< std::vector< std::int32_t >, 2 > transfer_cell_meshtag | ( | const mesh::MeshTags< std::int32_t > & | tags0,
|  | const mesh::Topology & | topology1,
|  | std::span< const std::int32_t > | parent_cell )

Transfer cell MeshTags from coarse mesh to refined mesh.

Warning
  The refined mesh must not have been redistributed during refinement.
  Mesh/topology GhostMode must be mesh::GhostMode::none.

Parameters

  [in] | tags0 | Tags on the parent mesh.
  [in] | topology1 | Refined mesh topology.
  [in] | parent_cell | Parent cell of each cell in refined mesh.

Returns
  (0) entities and (1) values on the refined topology.

## transfer_facet_meshtag()

std::array< std::vector< std::int32_t >, 2 > transfer_facet_meshtag | ( | const mesh::MeshTags< std::int32_t > & | tags0,
|  | const mesh::Topology & | topology1,
|  | std::span< const std::int32_t > | cell,
|  | std::span< const std::int8_t > | facet )

Transfer facet MeshTags from coarse mesh to refined mesh.

Warning
  The refined mesh must not have been redistributed during refinement.
  Mesh/topology GhostMode must be mesh::GhostMode::none.

Parameters

  [in] | tags0 | Tags on the parent mesh.
  [in] | topology1 | Refined mesh topology.
  [in] | cell | Parent cell of each cell in refined mesh
  [in] | facet | Local facets of parent in each cell in refined mesh.

Returns
  (0) entities and (1) values on the refined topology.

## uniform_refine()

template<typename T>

mesh::Mesh< T > uniform_refine | ( | const mesh::Mesh< T > & | mesh,
|  | const mesh::CellPartitionFunction & | partitioner = mesh::create_cell_partitioner(mesh::GhostMode::none) )

Uniform refinement of a 2D or 3D mesh, containing any supported cell types. Hexahedral, tetrahedral and prism cells are subdivided into 8, each being similar to the original cell. Pyramid cells are subdivided into 5 similar pyramids, plus 4 tetrahedra. Triangle and quadrilateral cells are subdivided into 4 similar subcells.

Template Parameters

  T | Scalar type of the mesh geometry

Parameters

  mesh | Input mesh
  partitioner | Function to partition new mesh across processes.

Returns
  Uniformly refined mesh

## update_logical_edgefunction()

void update_logical_edgefunction | ( | MPI_Comm | comm,
|  | const std::vector< std::vector< std::int32_t > > & | marked_for_update,
|  | std::span< std::int8_t > | marked_edges,
|  | const common::IndexMap & | map )

Communicate edge markers between processes that share edges.

Parameters

  [in] | comm | MPI Communicator for neighborhood
  [in] | marked_for_update | Lists of edges to be updated on each neighbor. marked_for_update[r] is the list of edge indices that are marked by the caller and are shared with local MPI rank r.
  [in,out] | marked_edges | Marker for each edge on the calling process
  [in] | map | Index map for the mesh edges