Skip to content

Commit

Permalink
Adding subapp only restart feature
Browse files Browse the repository at this point in the history
  • Loading branch information
permcody authored and SudiptaBiswas committed Mar 29, 2016
1 parent b84dda6 commit 9947394
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 26 deletions.
1 change: 1 addition & 0 deletions framework/include/base/FEProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ class FEProblem :
bool _use_legacy_uo_initialization;

bool _error_on_jacobian_nonzero_reallocation;
bool _force_restart;
bool _fail_next_linear_convergence_check;

/// Whether or not the system is currently computing the Jacobian matrix
Expand Down
2 changes: 1 addition & 1 deletion framework/include/restart/RestartableDataIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class RestartableDataIO
FEProblem & _fe_problem;

/// A vector of file handles, one per thread
std::vector<std::ifstream *> _in_file_handles;
std::vector<MooseSharedPointer<std::ifstream> > _in_file_handles;
};

#endif /* RESTARTABLEDATAIO_H */
9 changes: 7 additions & 2 deletions framework/src/base/FEProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ InputParameters validParams<FEProblem>()
params.addParam<bool>("solve", true, "Whether or not to actually solve the Nonlinear system. This is handy in the case that all you want to do is execute AuxKernels, Transfers, etc. without actually solving anything");
params.addParam<bool>("use_nonlinear", true, "Determines whether to use a Nonlinear vs a Eigenvalue system (Automatically determined based on executioner)");
params.addParam<bool>("error_on_jacobian_nonzero_reallocation", false, "This causes PETSc to error if it had to reallocate memory in the Jacobian matrix due to not having enough nonzeros");
params.addParam<bool>("force_restart", false, "EXPERIMENTAL: If true, a sub_app may use a restart file instead of using of using the master backup file");

return params;
}
Expand Down Expand Up @@ -153,6 +154,7 @@ FEProblem::FEProblem(const InputParameters & parameters) :
_use_legacy_uo_aux_computation(_app.legacyUoAuxComputationDefault()),
_use_legacy_uo_initialization(_app.legacyUoInitializationDefault()),
_error_on_jacobian_nonzero_reallocation(getParam<bool>("error_on_jacobian_nonzero_reallocation")),
_force_restart(getParam<bool>("force_restart")),
_fail_next_linear_convergence_check(false),
_currently_computing_jacobian(false)
{
Expand Down Expand Up @@ -314,10 +316,10 @@ void FEProblem::initialSetup()
// Flush all output to _console that occur during construction and initialization of objects
_app.getOutputWarehouse().mooseConsole();

if (_app.isRecovering() && _app.isUltimateMaster())
if (_app.isRecovering() && (_app.isUltimateMaster() || _force_restart))
_resurrector->setRestartFile(_app.getRecoverFileBase());

if ((_app.isRestarting() || _app.isRecovering()) && _app.isUltimateMaster())
if ((_app.isRestarting() || _app.isRecovering()) && (_app.isUltimateMaster() || _force_restart))
_resurrector->restartFromFile();
else
{
Expand Down Expand Up @@ -554,6 +556,9 @@ void FEProblem::initialSetup()
Moose::perf_log.push("execMultiApps()", "Setup");
//TODO: we did not check the convergence of the multiapps on initial
execMultiApps(EXEC_INITIAL);

// We'll backup the Multiapp here
backupMultiApps(EXEC_INITIAL);
Moose::perf_log.pop("execMultiApps()", "Setup");
}

Expand Down
9 changes: 2 additions & 7 deletions framework/src/restart/RestartableDataIO.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ RestartableDataIO::RestartableDataIO(FEProblem & fe_problem) :

RestartableDataIO::~RestartableDataIO()
{
unsigned int n_threads = libMesh::n_threads();

for (unsigned int tid=0; tid<n_threads; tid++)
delete _in_file_handles[tid];
}

void
Expand Down Expand Up @@ -236,8 +232,7 @@ RestartableDataIO::readRestartableDataHeader(std::string base_file_name)

const unsigned int file_version = 2;

mooseAssert(_in_file_handles[tid] == NULL, "Looks like you might be leaking in RestartableDataIO.C");
_in_file_handles[tid] = new std::ifstream(file_name.c_str(), std::ios::in | std::ios::binary);
_in_file_handles[tid] = MooseSharedPointer<std::ifstream>(new std::ifstream(file_name.c_str(), std::ios::in | std::ios::binary));

// header
char id[2];
Expand Down Expand Up @@ -281,7 +276,7 @@ RestartableDataIO::readRestartableData(const RestartableDatas & restartable_data
{
const std::map<std::string, RestartableDataValue *> & restartable_data = restartable_datas[tid];

if (!_in_file_handles[tid]->is_open())
if (!_in_file_handles[tid].get() || !_in_file_handles[tid]->is_open())
mooseError("In RestartableDataIO: Need to call readRestartableDataHeader() before calling readRestartableData()");

deserializeRestartableData(restartable_data, *_in_file_handles[tid], recoverable_data);
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion test/tests/restart/restart_subapp_not_master/tests
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
exodiff = 'two_step_solve_master.e'
cli_args = 'Outputs/file_base=two_step_solve_master
MultiApps/full_solve/input_files=two_step_solve_sub.i'
recover = false
[../]
# split into sub solve 0 <= t <= 2 && master 2 <= t <= 4
# this time restart the sub but _not_ the master
Expand All @@ -23,6 +24,5 @@
cli_args = 'Outputs/file_base=two_step_solve_master_restart
MultiApps/full_solve/input_files=two_step_solve_sub_restart.i'
prereq = two_step_solve_master
skip = 'Segfault #6297'
[../]
[]
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
type = FullSolveMultiApp
execute_on = initial
positions = '0 0 0'
##input_files = two_step_solve_sub.i
# input file will come from cli-args
[../]
[]

Expand All @@ -100,6 +100,6 @@
[]

[Outputs]
##file_base = two_step_solve_master
#file_base will come from cli-args
exodus = true
[]
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[Mesh]
file = two_step_solve_master_out_full_solve0_cp/0002_mesh.cpr
file = two_step_solve_master_cp/0002_mesh.cpr
[]

[Problem]
restart_file_base = two_step_solve_master_out_full_solve0_cp/0002
restart_file_base = two_step_solve_master_cp/LATEST
force_restart = true
[]

[Functions]
Expand All @@ -25,13 +26,7 @@
[../]
[]

[ICs]
[./u_var]
type = FunctionIC
variable = u
function = exact_fn
[../]
[]
# Initial Condition will come from the restart file

[Kernels]
[./td]
Expand Down Expand Up @@ -75,8 +70,5 @@
[]

[Outputs]
[./checkpoint]
type = Checkpoint
num_files = 3
[../]
exodus = true
[]

0 comments on commit 9947394

Please sign in to comment.