Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Develop

- Fixed checkpoint JSON parameter parsing and their documentation. The
`output_checkpoints` parameter no longer has a default value.
- Added `vector_list_t` and `name` to `vector_t`.
- Rework hash table iterators, significantly faster (O(tsize) => O(entries)
- Remove redundant directory in `site-packages` when installing pyneko
Expand All @@ -14,10 +16,10 @@
- Support for user-defined scalar schemes are now added.
- Added source term for direct forcing from a field defined in the registry.
- Add description of the `fld` file format to the documentation.
- Added possibility to assign names to boundary conditions in the case file. The
- Added possibility to assign names to boundary conditions in the case file. The
`bc_list_t` now supports item retrieval by name or zone_index.
- Runtime statistics fields are now retrievable from the registry, for both
fluid_stats and user_stats. The naming convention of the fields in the
- Runtime statistics fields are now retrievable from the registry, for both
fluid_stats and user_stats. The naming convention of the fields in the
registry is `name_of_simcomp + "/mean_" + name_of_field`.
- Updated field types with a wrapper and ensure lifetime management of field
data in field lists and arrays.
Expand Down
33 changes: 31 additions & 2 deletions doc/pages/user-guide/case-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,46 @@ but also defines several parameters that pertain to the simulation as a whole.
| `output_layout` | Data layout for `adios2` files. (Choose `2` or `3` for ADIOS2 supported compressors BigWhoop or ZFP.) | Positive integer `1`, `2`, `3` | `1` |
| `load_balancing` | Whether to apply load balancing. | `true` or `false` | `false` |
| `output_partitions` | Whether to write a `partitions.vtk` file with domain partitioning. | `true` or `false` | `false` |
| `output_checkpoints` | Whether to output checkpoints, i.e. restart files. | `true` or `false` | `false` |
| `output_checkpoints` | Whether to output checkpoints, i.e. restart files. | `true` or `false` | - |
| `checkpoint_control` | Defines the interpretation of `checkpoint_value` to define the frequency of writing checkpoint files. | `nsamples`, `simulationtime`, `tsteps`, `never` | - |
| `checkpoint_value` | The frequency of sampling in terms of `checkpoint_control`. | Positive real or integer | - |
| `checkpoint_filename` | The filename of written checkpoint. | Strings such as `my_name` | `fluid` |
| `checkpoint_format` | The file format of checkpoints | `chkp` or `hdf5` | `chkp` |
| `restart_file` | checkpoint to use for a restart from previous data | Strings ending with `.chkp` | - |
| `restart_mesh_file` | If the restart file is on a different mesh, specify the .nmsh file used to generate it here | Strings ending with `.nmsh` | - |
| `mesh2mesh_tolerance` | Tolerance for the restart when restarting from another mesh | Positive reals | 1e-6 |
| `job_timelimit` | The maximum wall clock duration of the simulation. | String formatted as HH:MM:SS | No limit |
| `job_timelimit` | The maximum wall clock duration of the simulation. | String formatted as HH:MM:SS | No limit |
| `output_at_end` | Whether to always write all enabled output at the end of the run. | `true` or `false` | `true` |

Some additional practical comments are provided regarding the output triggered
by `job_timelimit` and `output_at_end` keywords.

If `output_at_end` is set to `true`, an additional write is performed after the
execution of the simulation time-loop is finished. This triggers most outputs,
like the fluid solvers, the checkpoint, etc. Note that if your case settings are
such that a particular output is written at the last time step regardless of
`output_at_end` (e.g. `end_time: 5`, `checkpoint_value: 5`,
`checkpoint_control: simulationtime` ) you will get two outputs with the same
values: one from your ordinary write and one triggered by `output_at_end`.

@note This has a rather detrimental effect on outputs from various
statistics-related [simulation components](@ref simcomps). Since the collected
statistics are reset on write, the data written by `output_at_end` will be just
zeroes.

The purpose of `job_timelimit` is to gracefully stop the simulation in a typical
supercomputer environment, where your runtime is limited. When Neko detects that
the time of the run exceeds the `job_timelimit`, it exits the time-loop. At this
point, if one sets `output_at_end` to `true`, this will trigger a write as per
usual. However, if `output_at_end` is `false`, Neko will still write a special
checkpoint file, with the filename called `joblimit#####.chkp`. This is done so
that the user is at least provided a restart file, and none of the computer time
spent on the simulation is wasted. Generally, however, it is recommended to
have `output_at_end` set to `true` in tandem with `job_timelimit`, so that what
exactly gets written is controlled by the case file settings.



### Constants
The `constants` array allows the user to define parameters that are global to
the case file, and can be referred to when setting the values of other
Expand Down
1 change: 1 addition & 0 deletions examples/rayleigh_benard/rayleigh.case
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"mesh_file": "box.nmsh",
"output_at_end": true,
"output_boundary": true,
"output_checkpoints": false,
"time": {
"end_time": 100.0,
"timestep": 0.01
Expand Down
32 changes: 21 additions & 11 deletions src/case.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! Copyright (c) 2020-2025, The Neko Authors
! Copyright (c) 2020-2026, The Neko Authors
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -512,19 +512,19 @@ subroutine case_init_common(this)
always_write_mesh = logical_val)
end if

call json_get_or_default(this%params, 'case.fluid.output_control',&
string_val, 'org')
call json_get(this%params, 'case.fluid.output_control', string_val)

if (trim(string_val) .eq. 'org') then
! yes, it should be real_val below for type compatibility
call json_get(this%params, 'case.nsamples', integer_val)
call json_get_or_lookup(this%params, 'case.nsamples', integer_val)
real_val = real(integer_val, kind=rp)
call this%output_controller%add(this%f_out, real_val, 'nsamples')
else if (trim(string_val) .eq. 'never') then
call this%output_controller%add(this%f_out, 0.0_rp, 'never')
else if (trim(string_val) .eq. 'tsteps' .or. &
trim(string_val) .eq. 'nsamples') then
call json_get(this%params, 'case.fluid.output_value', integer_val)
call json_get_or_lookup(this%params, 'case.fluid.output_value', &
integer_val)
real_val = real(integer_val, kind=rp)
call this%output_controller%add(this%f_out, real_val, string_val)
else if (trim(string_val) .eq. 'simulationtime') then
Expand All @@ -538,19 +538,29 @@ subroutine case_init_common(this)
!
! Save checkpoints (if nothing specified, default to saving at end of sim)
!
call json_get_or_default(this%params, 'case.output_checkpoints',&
logical_val, .true.)
call json_get(this%params, 'case.output_checkpoints',&
logical_val)
if (logical_val) then
call json_get_or_default(this%params, 'case.checkpoint_filename', &
name, "fluid")
call json_get_or_default(this%params, 'case.checkpoint_format', &
string_val, "chkp")
call this%chkp_out%init(this%chkp, name = name,&
path = this%output_directory, fmt = trim(string_val))
call json_get_or_default(this%params, 'case.checkpoint_control', &
string_val, "simulationtime")
call json_get_or_lookup_or_default(this%params, &
'case.checkpoint_value', real_val, 1e10_rp)
call json_get(this%params, 'case.checkpoint_control', &
string_val)
if (trim(string_val) .eq. 'tsteps' .or. &
trim(string_val) .eq. 'nsamples') then
call json_get_or_lookup(this%params, 'case.checkpoint_value', &
integer_val)
real_val = real(integer_val, kind=rp)
else if (trim(string_val) .eq. 'simulationtime') then
call json_get_or_lookup(this%params, 'case.checkpoint_value', &
real_val)
else if (trim(string_val) .eq. 'never') then
real_val = 0.0_rp
end if

call this%output_controller%add(this%chkp_out, real_val, string_val, &
NEKO_EPS)
end if
Expand Down
1 change: 1 addition & 0 deletions tests/reframe/src/rayleigh.case.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"mesh_file": "box.nmsh",
"output_at_end": true,
"output_boundary": true,
"output_checkpoints": false,
"time": {
"end_time": 100,
"timestep": 0.01
Expand Down