Skip to content

Added parameters to keep all statepoints in transient solves. #1313

Open
TheBEllis wants to merge 15 commits intoneams-th-coe:develfrom
TheBEllis:statepoint_timestamps
Open

Added parameters to keep all statepoints in transient solves. #1313
TheBEllis wants to merge 15 commits intoneams-th-coe:develfrom
TheBEllis:statepoint_timestamps

Conversation

@TheBEllis
Copy link
Copy Markdown
Contributor

Addresses issue #1312. Adds two parameters to OpenMCProblemBase, statepoint_directory and keep_transient_statepoint.

statepoint_directory allows the user to set the directory they want the statepoint file to be written to. In OpenMCProblemBase this sets openmc::settings::path_output.

keep_transient_statepoint creates a directory for each timestep's statepoint file to be saved to. If the user has already set statepoint_directory, this value is used as a base directory name, and a suffix is appended to indicate the timestep.

I've added a couple of tests in, just to check the statepoints get output to the expected directories.

@moosebuild
Copy link
Copy Markdown
Collaborator

moosebuild commented Apr 1, 2026

Job Documentation, step Sync to remote on 2e8bfa7 wanted to post the following:

View the site here

This comment will be updated on new commits.

@aprilnovak
Copy link
Copy Markdown
Collaborator

@TheBEllis can you rebase your branch off devel? It looks like there's a bunch of other commits coming along for the ride.

@TheBEllis TheBEllis force-pushed the statepoint_timestamps branch from f241885 to 4367813 Compare April 1, 2026 15:55
@TheBEllis
Copy link
Copy Markdown
Contributor Author

Whoops my bad, should be rebased now!

@aprilnovak aprilnovak requested a review from nuclearkevin April 1, 2026 18:25
Copy link
Copy Markdown
Member

@nuclearkevin nuclearkevin left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR @TheBEllis! I have one question regarding the design and I think another test should be added to catch an edge case, but otherwise I don't have any major complaints.

Comment thread include/base/OpenMCProblemBase.h
Comment thread include/base/OpenMCProblemBase.h
Comment thread include/base/OpenMCProblemBase.h Outdated
Comment thread src/base/OpenMCProblemBase.C Outdated
Comment thread src/base/OpenMCProblemBase.C Outdated
Comment thread src/base/OpenMCProblemBase.C Outdated
[Executioner]
type = Transient
num_steps = 2
batches = 50 # this number needs to match the value in settings.xml for the purpose of the test
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

batches belongs in the [Problem] block.

[Executioner]
type = Transient
num_steps = 2
batches = 50 # this number needs to match the value in settings.xml for the purpose of the test
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

batches belongs in the [Problem] block.

Comment thread include/base/OpenMCProblemBase.h
Comment thread src/base/OpenMCProblemBase.C Outdated
if (isParamSetByUser("statepoint_directory") && !_keep_transient_statepoint)
{
openmc::settings::path_output = formattedOutputPath(_statepoint_directory);
if (!std::filesystem::is_directory(openmc::settings::path_output))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we catching this if statement with a test? From what I can see, none of the tests try to create a statepoint directory with the same name as a file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added a RunException for this exact scenario, let me know if you think that's enough or whether I should be catching it in code:)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works for me!

@TheBEllis TheBEllis force-pushed the statepoint_timestamps branch from 4367813 to a9e228b Compare April 2, 2026 09:27
@TheBEllis TheBEllis force-pushed the statepoint_timestamps branch from 734b297 to 9c36899 Compare April 2, 2026 15:47
@nuclearkevin
Copy link
Copy Markdown
Member

nuclearkevin commented Apr 4, 2026

It appears as if the include statements are still outside of the #ifdef ENABLE_OPENMC guard, which is why the NekRS test is failing.

I don't know off the top of my head where the cascading OpenMC/DAGMC test failures are coming from. The test timeouts appear to be an issue on the CIVET side of things as they're common to all PRs.

…rio when user defined output path has the same name as existing file
@TheBEllis TheBEllis force-pushed the statepoint_timestamps branch from d78c475 to 1b8b26a Compare April 7, 2026 12:48
@moosebuild
Copy link
Copy Markdown
Collaborator

moosebuild commented Apr 7, 2026

Job Coverage, step Generate coverage on 2e8bfa7 wanted to post the following:

Coverage

Inconsistent report tags were found between the head and base reports.
This can happen when reports are missing from either the head or the base.

Inconsistent tags:
nekrs
Full coverage report

This comment will be updated on new commits.

Copy link
Copy Markdown
Member

@nuclearkevin nuclearkevin left a comment

Choose a reason for hiding this comment

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

A few more comments from me, but I think this is almost ready to go.

Terribly sorry for the inconvenience dealing with the regression suite being non-deterministic - we're trying to figure out what's going on but can't find any patterns.

Comment thread src/base/OpenMCProblemBase.C Outdated
Comment thread src/base/OpenMCProblemBase.C Outdated
Comment thread test/tests/neutronics/openmc_statepoint/tests Outdated
[check_statepoint_exists_in_directory_w_existing_filenmae]
type = RunException
input = openmc_custom_dir_filename.i
expect_err = 'filesystem error: cannot create directory: File exists'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this trace back to OpenMCCellAverageProblem through a mooseError()? if not, it will be difficult for the user to debug the error message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've moved the logic around a bit so that a mooseError() is thrown now. There are some slightly annoying lines in there, mostly related to removing trailing "/". The value passed to openmc::settings::path_output must contain a trailing "/", but when checking is a file with the same name exists using is_regular_file(), this has to be removed.

Copy link
Copy Markdown
Member

@nuclearkevin nuclearkevin left a comment

Choose a reason for hiding this comment

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

LGTM!

@moosebuild
Copy link
Copy Markdown
Collaborator

Job Test OpenMC on 2e8bfa7 : invalidated by @nuclearkevin

@nuclearkevin
Copy link
Copy Markdown
Member

I'll rerun the tests until they pass. The random RunException failures are unrelated.

@moosebuild
Copy link
Copy Markdown
Collaborator

Job Test DagMC on 2e8bfa7 : invalidated by @nuclearkevin

@moosebuild
Copy link
Copy Markdown
Collaborator

Job Coverage on 2e8bfa7 : invalidated by @nuclearkevin

1 similar comment
@moosebuild
Copy link
Copy Markdown
Collaborator

Job Coverage on 2e8bfa7 : invalidated by @nuclearkevin

const std::string & _statepoint_directory;

/// Parameter determines whether statepoints from all timesteps should be saved in separtate directories to avoid them being overwritten
const bool _keep_transient_statepoint;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const bool _keep_transient_statepoint;
const bool & _keep_transient_statepoint;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

capturing by reference is recommended by MOOSE convention when possible because it'll be compatible with controls and other systems

params.addParam<bool>("keep_transient_statepoint",
false,
"Whether or not statepoints from all timesteps should be kept, and written "
"to seperate directories.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"to seperate directories.");
"to separate directories.");

const std::string & _statepoint_directory;

/// Parameter determines whether statepoints from all timesteps should be saved in separtate directories to avoid them being overwritten
const bool _keep_transient_statepoint;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

capturing by reference is recommended by MOOSE convention when possible because it'll be compatible with controls and other systems

requirement = "A statepoint file must be written to the parameter defined directory when the batches parameter matches the batches "
"in settings.xml and they are both specified."
capabilities = 'openmc'
[]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please make sure each test has a issues and design parameter

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants