9#include "dolfinx/graph/AdjacencyList.h"
10#include "dolfinx/mesh/Mesh.h"
11#include "dolfinx/mesh/Topology.h"
12#include "dolfinx/mesh/cell_types.h"
19#include <spdlog/spdlog.h>
54template <std::
floating_po
int T>
55std::tuple<mesh::Mesh<T>, std::optional<std::vector<std::int32_t>>,
56 std::optional<std::vector<std::int8_t>>>
58 std::optional<std::span<const std::int32_t>> edges,
63 auto topology = mesh.topology();
66 throw std::runtime_error(
"Refinement only defined for simplices");
69 = (topology->cell_type() == mesh::CellType::interval)
70 ? interval::compute_refinement_data(mesh, edges, option)
74 mesh.comm(), mesh.comm(), cell_adj.array(), mesh.geometry().cmap(),
75 mesh.comm(), new_vertex_coords, xshape, partitioner);
78 const int D = topology->dim();
79 const std::int64_t n0 = topology->index_map(D)->size_global();
80 const std::int64_t n1 = mesh1.
topology()->index_map(D)->size_global();
82 "Number of cells increased from {} to {} ({}% increase).", n0, n1,
83 100.0 * (
static_cast<double>(n1) /
static_cast<double>(n0) - 1.0));
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:23
std::shared_ptr< Topology > topology()
Get mesh topology.
Definition Mesh.h:64
Functions supporting mesh operations.
Mesh< typename std::remove_reference_t< typename U::value_type > > create_mesh(MPI_Comm comm, MPI_Comm commt, std::span< const std::int64_t > cells, const fem::CoordinateElement< typename std::remove_reference_t< typename U::value_type > > &element, MPI_Comm commg, const U &x, std::array< std::size_t, 2 > xshape, const CellPartitionFunction &partitioner)
Create a distributed mesh from mesh data using a provided graph partitioning function for determining...
Definition utils.h:783
bool is_simplex(CellType type)
Definition cell_types.cpp:145
std::function< graph::AdjacencyList< std::int32_t >( MPI_Comm comm, int nparts, const std::vector< CellType > &cell_types, const std::vector< std::span< const std::int64_t > > &cells)> CellPartitionFunction
Signature for the cell partitioning function. The function should compute the destination rank for ce...
Definition utils.h:185
CellPartitionFunction create_cell_partitioner(mesh::GhostMode ghost_mode=mesh::GhostMode::none, const graph::partition_fn &partfn=&graph::partition_graph)
Definition utils.cpp:85
std::tuple< graph::AdjacencyList< std::int64_t >, std::vector< T >, std::array< std::size_t, 2 >, std::optional< std::vector< std::int32_t > >, std::optional< std::vector< std::int8_t > > > compute_refinement_data(const mesh::Mesh< T > &mesh, std::optional< std::span< const std::int32_t > > edges, Option option)
Definition plaza.h:463
Mesh refinement algorithms.
Definition dolfinx_refinement.h:8
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, const mesh::CellPartitionFunction &partitioner=mesh::create_cell_partitioner(mesh::GhostMode::none), Option option=Option::none)
Refine a mesh with markers.
Definition refine.h:57
Option
Options for data to compute during mesh refinement.
Definition option.h:16