Coverage for  / dolfinx-env / lib / python3.12 / site-packages / io4dolfinx / structures.py: 100%

62 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-26 18:16 +0000

1# Copyright (C) 2024 Jørgen Schartum Dokken 

2# 

3# This file is part of io4dolfinx 

4# 

5# SPDX-License-Identifier: MIT 

6 

7from __future__ import annotations 

8 

9from dataclasses import dataclass 

10 

11import numpy as np 

12import numpy.typing as npt 

13from dolfinx.graph import AdjacencyList 

14 

15"""Internal library classes for storing mesh and function data""" 

16__all__ = ["MeshData", "FunctionData", "ReadMeshData", "MeshTagsData"] 

17 

18 

19@dataclass 

20class MeshData: 

21 """ 

22 Container for distributed mesh data that will be stored to disk 

23 """ 

24 

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 

29 

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 

34 

35 cell_type: str #: The cell type 

36 degree: int #: Degree of underlying Lagrange element 

37 lagrange_variant: int #: Lagrange-variant of DOFs 

38 

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 

48 

49 

50@dataclass 

51class FunctionData: 

52 """ 

53 Container for distributed function data that will be written to file 

54 """ 

55 

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 

67 

68 

69@dataclass 

70class ReadMeshData: 

71 """Container containing data that will be read into DOLFINx""" 

72 

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 

82 

83@dataclass 

84class MeshTagsData: 

85 name: str #: Name of tag 

86 values: npt.NDArray # Array of values 

87 indices: npt.NDArray[np.int64] # Global indices of the entities 

88 dim: int # Topological dimension of the entities 

89 

90 # Optional entries (used for writing to disk) 

91 num_entities_global: int | None = None #: Global number of entities that will be written out 

92 num_dofs_per_entity: int | None = None #: Number of dofs per entity 

93 #: Starting index in output array `(0<=local_start<num_entities_global)`` 

94 local_start: int | None = None 

95 

96 # Optional info to help visualization 

97 cell_type: str | None = None #: The cell type 

98 

99 

100@dataclass 

101class ArrayData: 

102 name: str # Name of point data 

103 values: npt.NDArray # Array of values (num_entities, num_components) 

104 global_shape: tuple[int, int] # Global shape of data 

105 local_range: tuple[int, int] # Start and stop of local array in global array 

106 type: str # Type of array-data