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

Support for file IO. More...

## Namespaces

namespace | cells
| Functions for the re-ordering of input mesh topology to the DOLFINx ordering, and transpose orderings for file output.
namespace | xdmf_function
| Low-level methods for reading/writing XDMF files.
namespace | xdmf_mesh
| Low-level methods for reading XDMF files.

## Classes

class | VTKFile
| Output of meshes and functions in VTK/ParaView format. More...
class | XDMFFile
| Read and write mesh::Mesh, fem::Function and other objects in XDMF. More...

## Functions

template<typename T>

std::pair< std::vector< std::int32_t >, std::vector< T > >

distribute_entity_data (const mesh::Topology &topology, std::span< const std::int64_t > nodes_g, std::int64_t num_nodes_g, const fem::ElementDofLayout &cmap_dof_layout, md::mdspan< const std::int32_t, md::dextents< std::size_t, 2 > > xdofmap, int entity_dim, md::mdspan< const std::int64_t, md::dextents< std::size_t, 2 > > entities, std::span< const T > data)

| Get owned entities and associated data from input entities defined by global 'node' indices.
template<typename T>
std::tuple< std::vector< T >, std::array< std::size_t, 2 >, std::vector< std::int64_t >, std::vector< std::uint8_t >, std::vector< std::int64_t >, std::array< std::size_t, 2 > > | vtk_mesh_from_space (const fem::FunctionSpace< T > &V)
| Given a FunctionSpace, create a topology and geometry based on the dof coordinates.
std::pair< std::vector< std::int64_t >, std::array< std::size_t, 2 > > | extract_vtk_connectivity (md::mdspan< const std::int32_t, md::dextents< std::size_t, 2 > > dofmap_x, mesh::CellType cell_type)
| Extract the cell topology (connectivity) in VTK ordering for all cells the mesh. The 'topology' includes higher-order 'nodes'.

## Detailed Description

Support for file IO.

IO to files for checkpointing and visualisation.

## Function Documentation

## distribute_entity_data()

template<typename T>

std::pair< std::vector< std::int32_t >, std::vector< T > > distribute_entity_data | ( | const mesh::Topology & | topology,
|  | std::span< const std::int64_t > | nodes_g,
|  | std::int64_t | num_nodes_g,
|  | const fem::ElementDofLayout & | cmap_dof_layout,
|  | md::mdspan< const std::int32_t, md::dextents< std::size_t, 2 > > | xdofmap,
|  | int | entity_dim,
|  | md::mdspan< const std::int64_t, md::dextents< std::size_t, 2 > > | entities,
|  | std::span< const T > | data )

Get owned entities and associated data from input entities defined by global 'node' indices.

The input entities and data can be supplied on any rank and this function will manage the communication.

Parameters

  [in] | topology | A mesh topology.
  [in] | nodes_g | Global 'input' indices for the mesh, as returned by Geometry::input_global_indices.
  [in] | num_nodes_g | Global number of geometry nodes, as returned by Geometry::index_map()->size_global().
  [in] | cmap_dof_layout | Coordinate element dof layout, computed using Geometry::cmap().create_dof_layout().
  [in] | xdofmap | Dofmap for the mesh geometry (Geometry::dofmap).
  [in] | entity_dim | Topological dimension of entities to extract.

  [in]

  entities

  Mesh entities defined using global input indices ('nodes'), typically from an input mesh file, e.g. [gi0, gi1, gi2] for a triangle. Let [v0, v1, v2] be the vertex indices of some triangle (using local indexing). Each vertex has a 'node' (geometry dof) index, and each node has a persistent input global index, so the triangle [gi0, gi1, gi2] could be identified with [v0, v1, v2]. The data is flattened and the shape is (num_entities, nodes_per_entity).

  [in] | data | Data associated with each entity in entities.

Returns
  (entity-vertex connectivity of owned entities, associated data (values) with each entity).

Note
  This function involves parallel distribution and must be called collectively. Global input indices for entities which are not owned by current rank could be passed to this function. E.g., rank0 provides an entity with global input indices [gi0, gi1, gi2], but this identifies a triangle that is owned by rank1. It will be distributed and rank1 will receive the (local) cell-vertex connectivity for this triangle.

## extract_vtk_connectivity()

std::pair< std::vector< std::int64_t >, std::array< std::size_t, 2 > > extract_vtk_connectivity | ( | md::mdspan< const std::int32_t, md::dextents< std::size_t, 2 > > | dofmap_x,
|  | mesh::CellType | cell_type )

Extract the cell topology (connectivity) in VTK ordering for all cells the mesh. The 'topology' includes higher-order 'nodes'.

The index of a 'node' corresponds to the index of DOLFINx geometry 'nodes'.

Parameters

  [in] | dofmap_x | Geometry dofmap.
  [in] | cell_type | Cell type.

Returns
  Cell topology in VTK ordering and in term of the DOLFINx geometry 'nodes'.

Note
  The indices in the return array correspond to the point indices in the mesh geometry array.
  Even if the indices are local (int32), VTX requires int64 as local input.

## vtk_mesh_from_space()

template<typename T>

std::tuple< std::vector< T >, std::array< std::size_t, 2 >, std::vector< std::int64_t >, std::vector< std::uint8_t >, std::vector< std::int64_t >, std::array< std::size_t, 2 > > vtk_mesh_from_space | ( | const fem::FunctionSpace< T > & | V | ) |

Given a FunctionSpace, create a topology and geometry based on the dof coordinates.

Precondition
  V must be a (discontinuous) Lagrange space

Parameters

  [in] | V | The function space

Returns
  Mesh data
  1. node coordinates (shape={num_nodes, 3}), row-major storage
  2. node coordinates shape
  3. unique global ID for each node (a node that appears on more than one rank will have the same global ID)
  4. ghost index for each node (0=non-ghost, 1=ghost)
  5. cells (shape={num_cells, nodes_per_cell)}), row-major storage
  6. cell shape (shape={num_cells, nodes_per_cell)})