10#include "CoordinateElement.h"
12#include "FiniteElement.h"
13#include "FunctionSpace.h"
15#include <basix/finite-element.h>
17#include <dolfinx/common/IndexMap.h>
18#include <dolfinx/graph/AdjacencyList.h>
19#include <dolfinx/mesh/Geometry.h>
20#include <dolfinx/mesh/Mesh.h>
21#include <dolfinx/mesh/Topology.h>
22#include <dolfinx/mesh/cell_types.h>
57template <std::
floating_po
int T>
60 const std::function<std::vector<int>(
67 throw std::invalid_argument(
68 "Cell shape of new coordinate element must match input mesh.");
71 const int gdim =
mesh->geometry().dim();
77 basix::element::family::P,
79 new_cmap.
variant(), basix::element::dpc_variant::unset,
81 auto element = std::make_shared<const FiniteElement<T>>(
82 b_element,
static_cast<std::size_t
>(gdim),
83 std::vector<std::size_t>{
static_cast<std::size_t
>(gdim)});
88 std::vector<T> x_new = V.tabulate_dof_coordinates(
false);
91 std::shared_ptr<const DofMap> dm = V.dofmap();
93 std::shared_ptr<const common::IndexMap> new_imap = dm->index_map;
96 auto map_view = dm->map();
97 std::vector<std::int32_t> dofmap_flat(
98 map_view.data_handle(), map_view.data_handle() + map_view.size());
102 const std::int32_t num_nodes
103 = new_imap->size_local() + new_imap->num_ghosts();
104 std::vector<std::int32_t> local(num_nodes);
105 std::iota(local.begin(), local.end(), 0);
106 std::vector<std::int64_t> igi(num_nodes);
107 new_imap->local_to_global(local, igi);
110 new_imap, std::vector<std::vector<std::int32_t>>{std::move(dofmap_flat)},
111 std::vector<CoordinateElement<T>>{new_cmap}, std::move(x_new), gdim,
Degree-of-freedom map representations and tools.
Definition CoordinateElement.h:27
Definition CoordinateElement.h:39
basix::element::lagrange_variant variant() const
Variant of the element.
Definition CoordinateElement.cpp:230
mesh::CellType cell_shape() const
Cell shape.
Definition CoordinateElement.cpp:46
bool is_discontinuous() const
Check if the element is the discontinuous version of the coordinate element.
Definition CoordinateElement.cpp:244
int degree() const
The polynomial degree of the element.
Definition CoordinateElement.cpp:216
This class represents a finite element function space defined by a mesh, a finite element,...
Definition FunctionSpace.h:35
This class provides a static adjacency list data structure.
Definition AdjacencyList.h:41
Geometry stores the geometry imposed on a mesh.
Definition Geometry.h:39
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:25
Factories for finite element dofmaps and function spaces.
Finite element method functionality.
Definition assemble_expression_impl.h:22
FunctionSpace< T > create_functionspace(std::shared_ptr< mesh::Mesh< T > > mesh, std::shared_ptr< const fem::FiniteElement< T > > e, std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> reorder_fn=nullptr)
NEW Create a function space from a fem::FiniteElement.
Definition functionspace_factory.h:105
mesh::Mesh< T > interpolate_geometry(std::shared_ptr< mesh::Mesh< T > > mesh, const CoordinateElement< T > &new_cmap, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn=nullptr)
Take an existing mesh and create a new mesh with its geometry interpolated into a new coordinate elem...
Definition interpolate_geometry.h:58
Geometry data structures and algorithms.
Definition BoundingBoxTree.h:24
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32
basix::cell::type cell_type_to_basix_type(CellType celltype)
Convert a cell type to a Basix cell type.
Definition cell_types.cpp:171