Skip to content

Commit fd532b9

Browse files
added read_point_data
1 parent 35eb3bc commit fd532b9

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/io4dolfinx/backends/exodus/backend.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,22 @@ def read_point_data(
530530
Returns:
531531
Data local to process (contiguous, no mpi comm) and local start range
532532
"""
533-
raise NotImplementedError("The Exodus backend cannot read point data.")
533+
infile = netCDF4.Dataset(filename)
534+
timestep = 0 # FIXME - need to find the correct timestep based on time argument
535+
if name not in infile.variables:
536+
raise ValueError(
537+
f"Point data with name {name} not found in file. Available variables: {list(infile.variables.keys())}"
538+
)
539+
dataset = infile.variables[name][:][timestep].data
540+
if len(dataset.shape) == 1:
541+
num_components = 1
542+
dataset = dataset.reshape(-1, num_components)
543+
else:
544+
num_components = dataset.shape[1]
545+
546+
local_start_range = 0
547+
548+
return dataset, int(local_start_range)
534549

535550

536551
def read_cell_data(
@@ -575,3 +590,11 @@ def write_data(
575590
backend_args: The backend arguments
576591
"""
577592
raise NotImplementedError("Exodus has not implemented this yet")
593+
594+
595+
def getNames(model, key):
596+
# name of the element variables
597+
name_var = []
598+
for vname in np.ma.getdata(model.variables[key][:]).astype("U8"):
599+
name_var.append("".join(vname))
600+
return name_var

0 commit comments

Comments
 (0)