Coverage for /dolfinx-env/lib/python3.14/site-packages/io4dolfinx/structures.py: 100%
62 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-23 13:30 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-23 13:30 +0000
1"""Internal library classes for storing mesh and function data"""
2# Copyright (C) 2024 Jørgen Schartum Dokken
3#
4# This file is part of io4dolfinx
5#
6# SPDX-License-Identifier: MIT
8from __future__ import annotations
10from dataclasses import dataclass
12import numpy as np
13import numpy.typing as npt
14from dolfinx.graph import AdjacencyList
16__all__ = ["MeshData", "FunctionData", "ReadMeshData", "MeshTagsData"]
19@dataclass
20class MeshData:
21 """
22 Container for distributed mesh data that will be stored to disk
23 """
25 #: Two-dimensional array of node coordinates
26 local_geometry: npt.NDArray[np.float32] | npt.NDArray[np.float64]
27 local_geometry_pos: tuple[int, int] #: Insert range on current process for geometry nodes
28 num_nodes_global: int #: Number of nodes in global geometry array
30 local_topology: npt.NDArray[np.int64] #: Two-dimensional connectivity array for mesh topology
31 #: Insert range on current process for topology
32 local_topology_pos: tuple[int, int]
33 num_cells_global: int #: NUmber of cells in global topology
35 cell_type: str #: The cell type
36 degree: int #: Degree of underlying Lagrange element
37 lagrange_variant: int #: Lagrange-variant of DOFs
39 # Partitioning_information
40 store_partition: bool #: Indicator if one should store mesh partitioning
41 partition_processes: int | None = None #: Number of processes in partition
42 ownership_array: npt.NDArray[np.int32] | None = None #: Ownership array for cells
43 ownership_offset: npt.NDArray[np.int32] | None = None #: Ownership offset for cells
44 partition_range: tuple[int, int] | None = (
45 None #: Local insert position for partitioning information
46 )
47 partition_global: int | None = None #: Global size of partitioning array
50@dataclass
51class FunctionData:
52 """
53 Container for distributed function data that will be written to file
54 """
56 cell_permutations: npt.NDArray[np.uint32] #: Cell permutations for dofmap
57 local_cell_range: tuple[int, int] #: Range of cells on current process
58 num_cells_global: int #: Number of cells in global topology
59 dofmap_array: npt.NDArray[np.int64] #: Local function dofmap (using global indices)
60 dofmap_offsets: npt.NDArray[np.int64] #: Global dofmap offsets
61 dofmap_range: tuple[int, int] #: Range of dofmap on current process
62 global_dofs_in_dofmap: int #: Number of entries in global dofmap
63 values: npt.NDArray[np.floating] #: Local function values
64 dof_range: tuple[int, int] #: Range of local function values
65 num_dofs_global: int #: Number of global function values
66 name: str #: Name of function
69@dataclass
70class ReadMeshData:
71 """Container containing data that will be read into DOLFINx"""
73 #: Two-dimensional array containing global cell->node connectivity
74 cells: npt.NDArray[np.int64]
75 cell_type: str #: The cell type of the mesh
76 x: npt.NDArray[np.floating] #: The mesh coordinates
77 lvar: int #: The Lagrange variant
78 degree: int #: The degree of the underlying Lagrange element
79 #: Partitioning information per cell on the process
80 partition_graph: AdjacencyList | None = None
81 #: Geometry uses the degree 2 serendipity element with nodes at vertices and edge
82 #: midpoints (8-node quadrilateral, 20-node hexahedron) instead of Lagrange
83 serendipity: bool = False
86@dataclass
87class MeshTagsData:
88 name: str #: Name of tag
89 values: npt.NDArray # Array of values
90 indices: npt.NDArray[np.int64] # Global indices of the entities
91 dim: int # Topological dimension of the entities
93 # Optional entries (used for writing to disk)
94 num_entities_global: int | None = None #: Global number of entities that will be written out
95 num_dofs_per_entity: int | None = None #: Number of dofs per entity
96 #: Starting index in output array `(0<=local_start<num_entities_global)``
97 local_start: int | None = None
99 # Optional info to help visualization
100 cell_type: str | None = None #: The cell type
103@dataclass
104class ArrayData:
105 name: str # Name of point data
106 values: npt.NDArray # Array of values (num_entities, num_components)
107 global_shape: tuple[int, int] # Global shape of data
108 local_range: tuple[int, int] # Start and stop of local array in global array
109 type: str # Type of array-data