Skip to content

Add control to fld output from a field list#2300

Open
timofeymukha wants to merge 13 commits intoExtremeFLOW:developfrom
timofeymukha:feature/fld_skip_control
Open

Add control to fld output from a field list#2300
timofeymukha wants to merge 13 commits intoExtremeFLOW:developfrom
timofeymukha:feature/fld_skip_control

Conversation

@timofeymukha
Copy link
Copy Markdown
Collaborator

This adds components to the fld_file_t, which can be set to skip certain fields in the output when writing a passed field_list_t or field_t.
For example, setting skip_pressure to true, will make the solver skip writing into the p field. I stress that this is about the fields in the sense of "parts of the fld file", not in any physical sense; we simply adjust the mapping between the item number in the field_list_t to the locations in the fld file.

The mechanism is not used anywhere now, but it will allow us to adjust things if we decide to. It also provides this additional freedom to be used in the user file.

I isolated the logic into a subroutine,so that I can reuse it for field_t by creating a dummpy list with 1 field.

@timofeymukha timofeymukha added the enhancement New feature or request label Feb 4, 2026
@timofeymukha
Copy link
Copy Markdown
Collaborator Author

Also adds a test!

Comment thread src/io/fld_file.f90
Comment thread src/io/fld_file.f90
@adperezm
Copy link
Copy Markdown
Collaborator

Was this discussed in the development meeting?

@timfelle
Copy link
Copy Markdown
Collaborator

Was this discussed in the development meeting?

Yes, @timofeymukha will investigate a bit if we can make the default just a list of scalars.

@adperezm adperezm mentioned this pull request Feb 11, 2026
@vbaconnet
Copy link
Copy Markdown
Collaborator

vbaconnet commented Mar 4, 2026

How are we doing with this? Would it be possible to add a skip_scalars and skip_mesh as attributes to fld_file_data_t as well? That way we would have a way to read only fld metadata by skipping everything. I am thinking of using this for the fld "pseudo-restart" of #2355

@timfelle
Copy link
Copy Markdown
Collaborator

timfelle commented Mar 4, 2026

How are we doing with this? Would it be possible to add a skip_scalars and skip_mesh as attributes to fld_file_data_t as well? That way we would have a way to read only fld metadata by skipping everything. I am thinking of using this for the fld "pseudo-restart" of #2355

Would that not be setting the fld file as an IC rather than a "restart"

@vbaconnet
Copy link
Copy Markdown
Collaborator

vbaconnet commented Mar 4, 2026

Would that not be setting the fld file as an IC rather than a "restart"

Yes basically, but we need to take care of properly setting the controllers and simcomps to start from the time stamp of the fld file, as done in for the chkp files in simulation.f90:

    ! Restart the output controller
    call C%output_controller%set_counter(C%time)

    ! Restart the simulation components
    call neko_simcomps%restart(C%time)

And because the restart section and the initial condition sections are very separated in case.f90 and simulation.f90, instead of having them communicate in strange ways i though why not just load the IC as usual in case.f90, and in simulation check for the presence of a flag in the JSON that says we want to set the fld time stamp as the simulation initialization time (note, different from start_time). Then you would just read the metadata of said fld file in simulation.f90 as you would do for a chkp.

@timfelle
Copy link
Copy Markdown
Collaborator

timfelle commented Mar 4, 2026

Yes basically, but we need to take care of properly setting the controllers and simcomps to start from the time stamp of the fld file, as done in for the chkp files in simulation.f90:

    ! Restart the output controller
    call C%output_controller%set_counter(C%time)

    ! Restart the simulation components
    call neko_simcomps%restart(C%time)

And because the restart section and the initial condition sections are very separated in case.f90 and simulation.f90, instead of having them communicate in strange ways i though why not just load the IC as usual in case.f90, and in simulation check for the presence of a flag in the JSON that says we want to set the fld time stamp as the simulation initialization time (note, different from start_time). Then you would just read the metadata of said fld file in simulation.f90 as you would do for a chkp.

I guess I do not understand why you want to transform the fld format into another way to restart when we already have HDF5 and CHKP restart files. Especially if it would not be accurate anyway, then I would not disguise the fact that it is indeed not a restart, but just starting the simulation with previous state as an initial condition.

@timofeymukha
Copy link
Copy Markdown
Collaborator Author

@vbaconnet I've been waiting for Adalberto's fld_file changes to get in (they are now) to return to this. Haven't touched it yet!

@adperezm
Copy link
Copy Markdown
Collaborator

adperezm commented Mar 4, 2026

@vbaconnet I've been waiting for Adalberto's fld_file changes to get in (they are now) to return to this. Haven't touched it yet!

My bad. I will sort things out on that one today. It is not in, as far as I see :D

@timofeymukha
Copy link
Copy Markdown
Collaborator Author

@vbaconnet I've been waiting for Adalberto's fld_file changes to get in (they are now) to return to this. Haven't touched it yet!

My bad. I will sort things out on that one today. It is not in, as far as I see :D

Oh right, I thought it was merged :-)!

@timofeymukha
Copy link
Copy Markdown
Collaborator Author

@vbaconnet @adperezm I changed the default to skip everything, and added overrides to all _output types besides the basic fld_file_output. So, fluid and all stats, basically. I think it works as expected. But maybe I missed something?

Copy link
Copy Markdown
Collaborator

@vbaconnet vbaconnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Did you test the fluid_stats? Even though it doesn't look like your tests you added cover the other output types, I believe there is no reason it shouldn't work. But in my experience, especially since this IO stuff fails at runtime most of the time, I would give it a try on the cylinder example or whatever (if you haven't already :)). I guess if those work it would be safe to assume the other types of stats would work (?).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable mapping/omission of standard NEKTON fld “slots” (P/U/T) when writing field_list_t/field_t, by introducing skip flags on fld_file_t and centralizing the list→slot mapping logic.

Changes:

  • Extend fld_file_t with skip_pressure/skip_velocity/skip_temperature and refactor field-list mapping into fld_file_select_from_field_list.
  • Update several output writers to explicitly set skip flags before writing.
  • Add an integration test suite (Fortran user module + pytest) to validate generated rdcode for selected skip-flag combinations.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/io/fld_file.f90 Adds skip flags and refactors mapping logic for field_list_t/field_t writes.
src/io/fluid_output.f90 Forces skip flags off before writing fluid outputs.
src/io/fluid_stats_output.f90 Imports fld_file_t and forces skip flags off after init_base.
src/io/fluid_sgs_stats_output.f90 Same as above for SGS fluid stats output.
src/io/scalar_stats_output.f90 Same as above for scalar stats output.
src/io/scalar_sgs_stats_output.f90 Same as above for SGS scalar stats output.
src/io/mean_field_output.f90 Same as above for mean-field output.
tests/integration/tests/test_fld_file/test_fld_file.py New pytest integration tests that read fld headers and assert expected rdcode.
tests/integration/tests/test_fld_file/test_fld_file.f90 New user module to drive fld writing with skip flags.
tests/integration/tests/test_fld_file/test_fld_file.json Base case config used by the new integration tests.
tests/integration/tests/test_fld_file/clean.sh Cleanup helper for generated outputs/artifacts.
tests/integration/tests/test_fld_file/.gitignore Ignores generated per-case JSON files.
src/.depends Updates build deps to include io/fld_file.lo where fld_file_t is referenced.

Comment thread src/io/fld_file.f90
Comment thread src/io/fld_file.f90
Comment thread src/io/fld_file.f90
Comment thread src/io/fld_file.f90
Comment thread tests/integration/tests/test_fld_file/test_fld_file.py
Comment on lines +1 to +6
from os.path import join
from testlib import get_neko, run_neko, configure_nprocs, get_makeneko
import subprocess
import numpy as np
import json
import os
@vbaconnet
Copy link
Copy Markdown
Collaborator

Reviving this before it gets forgotten :) We talked about it last week during the dev meeting but I forgot what you said. Where you going to work more on this?

@timofeymukha
Copy link
Copy Markdown
Collaborator Author

Reviving this before it gets forgotten :) We talked about it last week during the dev meeting but I forgot what you said. Where you going to work more on this?

Sorry, yes, I was going to do as you said, run some cylinder and check that it works. But I am constantly diverted to other stuff :))).

@vbaconnet
Copy link
Copy Markdown
Collaborator

No problem. I'm interested in this as well so if you want some backup please ping and I can try to test as well.

@timofeymukha
Copy link
Copy Markdown
Collaborator Author

No problem. I'm interested in this as well so if you want some backup please ping and I can try to test as well.

Would be much appreciated if you have the time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants