Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use idx kwarg in CheckpointFile when exporting #227

Merged
merged 27 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
747d4be
Export data to vtk or h5
ddundo Oct 14, 2024
658baf2
Add tests for exporting data
ddundo Oct 14, 2024
0c2ab2e
Allow export of initial conditions
ddundo Oct 14, 2024
02637be
Fix for exporting multiple ics
ddundo Oct 14, 2024
594d64b
Allow exporting mixed fns
ddundo Oct 14, 2024
5aa111d
Use export in demos
ddundo Oct 14, 2024
e7fbafb
Fix docstring
ddundo Oct 14, 2024
e3e8887
Separate export into private methods
ddundo Oct 14, 2024
d91f6a0
Don't export _old and _next by default
ddundo Oct 14, 2024
a123ee6
Fix minor bug from last commit
ddundo Oct 14, 2024
f7a3b11
Tidy up
ddundo Oct 14, 2024
ac2908e
#222: Fix cache error in tests
ddundo Oct 14, 2024
30b7c2b
#222: Fix TSFC cache clear
ddundo Oct 14, 2024
73e38f4
#222: Fix pyop2 cache clear
ddundo Oct 14, 2024
1a83733
#222: Fix pyop2 cache clear 2
ddundo Oct 14, 2024
bb92187
Merge branch 'main' into 117_export
ddundo Oct 31, 2024
d38b2dd
#117: Avoid list->set conversion
ddundo Oct 31, 2024
566a5a9
#117: Rename msh to mesh
ddundo Oct 31, 2024
d6d09c4
#117: Use [idx] in names of subfunctions in vtu
ddundo Oct 31, 2024
6f96c36
#117: VTU exports NaN for initial non-forward fields
ddundo Oct 31, 2024
85ef5fd
#117: Fix failing test
ddundo Oct 31, 2024
0b6964a
#117: Add unit tests
ddundo Oct 31, 2024
514af10
#117: Remove unnecessary method
ddundo Oct 31, 2024
eb82642
#117: Update docstring for export
ddundo Nov 1, 2024
8e91e7c
#117: Better docstring update for export
ddundo Nov 1, 2024
ff8d131
Merge branch 'main' into 117_export
ddundo Nov 1, 2024
19c2adb
#117: Use idx in checkpointing
ddundo Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions goalie/function_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,16 @@ def export(self, output_fpath, export_field_types=None, initial_condition=None):
If the output file format is '.h5', the data is exported as a single HDF5 file
using Firedrake's :class:`~.CheckpointFile`. If names of meshes in the mesh
sequence are not unique, they are renamed to ``"mesh_i"``, where ``i`` is the
subinterval index. Functions are saved with names of the form
``"field_label_i_j"``, where ``i`` is the subinterval index and ``j`` is the
export index. Initial conditions are named in the form ``"field_initial"``.
The exported data may then be loaded using, for example,
subinterval index. Functions are saved with names of the form ``"field_label"``.
Initial conditions are named in the form ``"field_initial"``. The exported data
may then be loaded using, for example,

.. code-block:: python

with CheckpointFile(output_fpath, "r") as afile:
first_mesh = afile.load_mesh("mesh_0")
initial_condition = afile.load_function(first_mesh, "u_initial")
first_export = afile.load_function(first_mesh, "u_forward_0_0")
first_export = afile.load_function(first_mesh, "u_forward", idx=0)

:arg output_fpath: the path to the output file
:type output_fpath: :class:`str`
Expand Down Expand Up @@ -274,12 +273,12 @@ def _export_h5(self, output_fpath, export_field_types, initial_condition=None):
mesh = self.function_spaces[tp.field_names[0]][i].mesh()
mesh.name = mesh_name
mesh.topology_dm.name = mesh_name
for j in range(tp.num_exports_per_subinterval[i] - 1):
for field in tp.field_names:
for field_type in export_field_types:
for field in tp.field_names:
for field_type in export_field_types:
name = f"{field}_{field_type}"
for j in range(tp.num_exports_per_subinterval[i] - 1):
f = self._data[field][field_type][i][j]
name = f"{field}_{field_type}_{i}_{j}"
outfile.save_function(f, name=name)
outfile.save_function(f, name=name, idx=j)


class ForwardSolutionData(FunctionData):
Expand Down
Loading