Skip to content

Commit

Permalink
Merge pull request #27224 from loganharbour/27178_subapp_transient
Browse files Browse the repository at this point in the history
Replace no_backup_and_restore with no_restore
  • Loading branch information
loganharbour authored Apr 18, 2024
2 parents 1bdcd97 + fda167d commit 0814fb3
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
4 changes: 3 additions & 1 deletion framework/include/multiapps/FullSolveMultiApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class FullSolveMultiApp : public MultiApp
// executioner postExecute has been called and we do not need to call it again
}

virtual void backup() override;
virtual void restore(bool force = true) override;

protected:
Expand All @@ -49,6 +48,9 @@ class FullSolveMultiApp : public MultiApp
*/
virtual void showStatusMessage(unsigned int i) const;

/// Whether or not to skip restoring
const bool _no_restore;

private:
/// Switch to tell executioner to keep going despite app solve not converging
const bool _ignore_diverge;
Expand Down
31 changes: 14 additions & 17 deletions framework/src/multiapps/FullSolveMultiApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ FullSolveMultiApp::validParams()
params.addParam<bool>(
"no_backup_and_restore",
false,
"True to turn off backup/restore for this multiapp. This is useful when doing steady-state "
"True to turn off restore for this multiapp. This is useful when doing steady-state "
"Picard iterations where we want to use the solution of previous Picard iteration as the "
"initial guess of the current Picard iteration");
"initial guess of the current Picard iteration.");
params.deprecateParam("no_backup_and_restore", "no_restore", "01/01/2025");
params.addParam<bool>(
"keep_full_output_history",
false,
Expand All @@ -40,26 +41,22 @@ FullSolveMultiApp::validParams()
}

FullSolveMultiApp::FullSolveMultiApp(const InputParameters & parameters)
: MultiApp(parameters), _ignore_diverge(getParam<bool>("ignore_solve_not_converge"))
: MultiApp(parameters),
_no_restore(getParam<bool>("no_restore")),
_ignore_diverge(getParam<bool>("ignore_solve_not_converge"))
{
// You could end up with some dirty hidden behavior if you do this. We could remove this check,
// but I don't think that it's sane to do so.
if (_no_restore && (_app.isRecovering() || _app.isRestarting()))
paramError("no_restore",
"The parent app is restarting or recovering, restoration cannot be disabled");
}

void
FullSolveMultiApp::backup()
FullSolveMultiApp::restore(bool force)
{
if (getParam<bool>("no_backup_and_restore"))
return;
else
MultiApp::backup();
}

void
FullSolveMultiApp::restore(bool /*force*/)
{
if (getParam<bool>("no_backup_and_restore"))
return;
else
MultiApp::restore();
if (!_no_restore)
MultiApp::restore(force);
}

void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ ParameterStudyAction::act()
params.set<bool>("keep_solution_during_restore") = true;
// batch-no-restore
else if (_multiapp_mode == 4)
params.set<bool>("no_backup_and_restore") = true;
params.set<bool>("no_restore") = true;
}

// Set the minimum number of procs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
csvdiff = distributions_csv_study_results_0001.csv
requirement = 'The system shall be able to setup a Monte Carlo parameter study with uniform, normal, Weibull, lognormal, and truncated normal distributions.'
[]

[distribution_errors]
requirement = 'The system shall throw an error when doing a simple parameter study if distribution parameters are '
[missing]
Expand Down Expand Up @@ -196,7 +196,7 @@
detail = 'error if there are unused statistics parameters;'
[]
[]

[outputs]
requirement = 'The system shall be able to output the results of a simple parameter study with '
[none]
Expand Down Expand Up @@ -275,7 +275,7 @@
input = monte_carlo.i
cli_args = 'ParameterStudy/show_study_objects=true ParameterStudy/multiapp_mode=batch-no-restore --color off'
csvdiff = 'monte_carlo_csv_study_results_0001.csv'
expect_out = 'mode : batch-restore\n\s*no_backup_and_restore : 1'
expect_out = 'mode : batch-restore\n\s*no_restore : 1'
detail = 'batches one sub-app per processor without restoring;'
[]
[]
Expand All @@ -288,47 +288,47 @@
cli_args = 'ParameterStudy/show_study_objects=true --color off'
csvdiff = distributions_csv_study_results_0001.csv
expect_out = 'mode : batch-reset'
detail = 'parameters are parsed;'
detail = 'parameters are parsed;'
[]
[not_controllable]
type = CSVDiff
input = monte_carlo_not_controllable.i
cli_args = 'Outputs/file_base=monte_carlo_csv ParameterStudy/sampler_column_names=\'BCs_left_value BCs_right_value\' ParameterStudy/show_study_objects=true --color off'
csvdiff = 'monte_carlo_csv_study_results_0001.csv'
expect_out = 'mode : batch-reset'
detail = 'parameters are not controllable;'
detail = 'parameters are not controllable;'
[]
[transient]
type = CSVDiff
input = monte_carlo_transient.i
cli_args = 'ParameterStudy/show_study_objects=true --color off'
csvdiff = 'monte_carlo_transient_csv_study_results_0001.csv'
expect_out = 'mode : batch-restore'
detail = 'parameters are controllable in a transient problem;'
detail = 'parameters are controllable in a transient problem;'
[]
[pseudo_transient]
type = CSVDiff
input = monte_carlo_pseudo_transient.i
cli_args = 'ParameterStudy/show_study_objects=true --color off'
csvdiff = 'monte_carlo_pseudo_transient_csv_study_results_0001.csv'
expect_out = 'keep_solution_during_restore : 1\n.*\n\s*mode : batch-restore'
detail = 'parameters are controllable in a pseudo-transient problem;'
detail = 'parameters are controllable in a pseudo-transient problem;'
[]
[steady]
type = CSVDiff
input = monte_carlo.i
cli_args = 'ParameterStudy/show_study_objects=true --color off'
csvdiff = 'monte_carlo_csv_study_results_0001.csv'
expect_out = 'mode : batch-restore\n\s*no_backup_and_restore : 1'
expect_out = 'mode : batch-restore\n\s*no_restore : 1'
detail = 'parameters are controllable in a steady-state problem;'
[]
[eigen]
type = CSVDiff
input = monte_carlo_eigen.i
cli_args = 'ParameterStudy/show_study_objects=true --color off'
csvdiff = 'monte_carlo_eigen_csv_study_results_0001.csv'
expect_out = 'mode : batch-restore\n\s*no_backup_and_restore : 1'
expect_out = 'mode : batch-restore\n\s*no_restore : 1'
detail = 'parameters are controllable in a eigenvalue problem;'
[]
[]
[]
[]
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
type = SamplerFullSolveMultiApp
input_files = model.i
mode = batch-restore
no_backup_and_restore = true
no_restore = true
[]
[]

Expand Down
2 changes: 1 addition & 1 deletion test/tests/multiapps/picard/picard_custom_postprocessor.i
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
[sub]
type = FullSolveMultiApp
input_files = steady_picard_sub.i
no_backup_and_restore = true
no_restore = true
[]
[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
[sub]
type = FullSolveMultiApp
input_files = pseudo_transient_picard_sub.i
no_backup_and_restore = true
no_restore = true
[]
[]

Expand Down
2 changes: 1 addition & 1 deletion test/tests/multiapps/picard/steady_custom_picard_parent.i
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
[sub]
type = FullSolveMultiApp
input_files = steady_picard_sub.i
no_backup_and_restore = true
no_restore = true
[]
[]

Expand Down
2 changes: 1 addition & 1 deletion test/tests/multiapps/picard/steady_picard_parent.i
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
[sub]
type = FullSolveMultiApp
input_files = steady_picard_sub.i
no_backup_and_restore = true
no_restore = true
[]
[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@
input_files = sub_level1.i
execute_on = 'timestep_end'

# We have to make backups of the full tree in order to do a proper restore for the Picard iteration.
no_backup_and_restore = false
# We need to disable restoration within the multiapp so that the previous
# picard iterate is used as the starting solution within each iteration
no_restore = false
[]
[]

Expand Down

0 comments on commit 0814fb3

Please sign in to comment.