Skip to content

Commit

Permalink
Write full Nektar++ field file contents to HDF5 output
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-graham committed Mar 2, 2024
1 parent b3c18e6 commit 16d1650
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions NektarDriftwave/src/nektar_driftwave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,27 @@ function ParticleDA.write_model_metadata(file::HDF5.File, model::NektarDriftwave
end
end

function ParticleDA.write_state(
file::HDF5.File,
state::AbstractVector,
time_index::Int,
group_name::String,
model
)
time_stamp = ParticleDA.time_index_to_hdf5_key(time_index)
group, _ = ParticleDA.create_or_open_group(file, group_name)
conditions_file_paths = model.task_conditions_file_paths[1]
driftwave_field_file_path = get_field_file_path(conditions_file_paths.driftwave)
h5open(driftwave_field_file_path, "r+") do field_file
check_fields(field_file)
field_file["NEKTAR"]["DATA"][:] = state
if !haskey(group, time_stamp)
time_stamp_group = create_group(group, time_stamp)
copy_object(field_file["NEKTAR"], time_stamp_group, "NEKTAR")
else
@warn "Write failed, timestamp $time_stamp already exists in $group"
end
end
end

end

0 comments on commit 16d1650

Please sign in to comment.