Skip to content

Commit

Permalink
Merge pull request idaholab#8286 from permcody/bad_subcycle
Browse files Browse the repository at this point in the history
Stateful materials fixup with subcycling
  • Loading branch information
friedmud committed Jan 11, 2017
2 parents 049a023 + b57ecb2 commit 406b8fc
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 17 deletions.
10 changes: 4 additions & 6 deletions framework/src/multiapps/TransientMultiApp.C
Expand Up @@ -210,16 +210,13 @@ TransientMultiApp::solveStep(Real dt, Real target_time, bool auto_advance)
bool local_first = _first;

// Now do all of the solves we need
while (true)
while (!at_steady && ex->getTime() + app_time_offset + 2e-14 < target_time)
{
if (local_first != true)
ex->incrementStepOrReject();

local_first = false;

if (!(!at_steady && ex->getTime() + app_time_offset + 2e-14 < target_time))
break;

ex->preStep();
ex->computeDT();

Expand Down Expand Up @@ -314,7 +311,7 @@ TransientMultiApp::solveStep(Real dt, Real target_time, bool auto_advance)
{
_console << "Solving Normal Step!" << std::endl;

if (_first)
if (_first && !_app.isRecovering())
problem.advanceState();

if (auto_advance)
Expand Down Expand Up @@ -517,6 +514,7 @@ TransientMultiApp::setupApp(unsigned int i, Real /*time*/) // FIXME: Should we
}

ex->preExecute();
problem.advanceState();
if (!_app.isRecovering())
problem.advanceState();
_transient_executioners[i] = ex;
}
14 changes: 7 additions & 7 deletions framework/src/parser/CommandLine.C
Expand Up @@ -205,22 +205,22 @@ CommandLine::haveVariable(const std::string & name, bool allow_prefix_change)
_get_pot->set_prefix((_base_prefix + ":").c_str());
if (_get_pot->have_variable(name))
return true;
}

/**
* As a final attempt we'll see if the user has passed a global command line parameter
* in the form ":name=value". Similarly to the normal subapp prefix, this will also
* modify subsequent invocations to GetPot until resetPrefix() has been called.
*/
_get_pot->set_prefix(":");
if (_get_pot->have_variable(name))
return true;
else
_get_pot->set_prefix(":");
if (_get_pot->have_variable(name))
return true;

/**
* We failed to find the parameter with the subapp prefix (if applicable) or
* in the global section so we need to reset the prefix now back to nothing.
* in the global section so we need to reset the prefix back to the way it was.
*/
_get_pot->set_prefix("");
resetPrefix();
}
}

return false;
Expand Down
8 changes: 7 additions & 1 deletion framework/src/parser/Parser.C
Expand Up @@ -150,7 +150,13 @@ Parser::parse(const std::string &input_filename)

MooseUtils::checkFileReadable(input_filename, true);

_getpot_file.absorb(*_app.commandLine()->getPot());
/**
* Only allow the main application to "absorb" it's command line parameters into the input file object.
* This allows DBEs with substitutions on the CLI to work for the master application but not sub apps.
* If we did allow this, it would remove the ability to only set CLI overrides for the main app only.
*/
if (_app.name() == "main")
_getpot_file.absorb(*_app.commandLine()->getPot());

// GetPot object
_getpot_file.enable_request_recording();
Expand Down
2 changes: 1 addition & 1 deletion python/TestHarness/TestHarness.py
Expand Up @@ -345,7 +345,7 @@ def appendRecoverableTests(self, testers):
# Part 1:
part1_params = part1.parameters()
part1_params['test_name'] += '_part1'
part1_params['cli_args'].append('--half-transient :Outputs/checkpoint=true')
part1_params['cli_args'].append('--half-transient Outputs/checkpoint=true')
part1_params['skip_checks'] = True

# Part 2:
Expand Down
@@ -0,0 +1,13 @@
time,matl_integral,x
0,0,0
1,1,0
2,2,0
3,4,0
4,8,0
5,16,0
6,32,0
7,64,0
8,128,0
9,256,0
10,512,0

@@ -0,0 +1,33 @@
[Problem]
solve = false
[]

[Mesh] #dummy
type = GeneratedMesh
dim = 2
[]

[Executioner]
type = Transient
start_time = 0.0
dt = 1
end_time = 10.0
[]

[MultiApps]
[./sub]
type = TransientMultiApp
app_type = MooseTestApp
execute_on = timestep_end
input_files = material_sub_app_test_sub.i

# Test that stateful material properties
# are updated properly with subcycling
sub_cycling = true
[../]
[]

[Outputs]
csv = false
exodus = false
[]
@@ -0,0 +1,53 @@
[GlobalParams]
dim = 2
[]

[Problem]
solve = false
[]

[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[AuxVariables]
[./x]
family = SCALAR
order = FIRST
[../]
[]

[AuxScalarKernels]
[./const_x]
type = ConstantScalarAux
variable = x
value = 0
[../]
[]

[Materials]
[./stateful]
type = StatefulMaterial
[../]
[]

[Executioner]
type = Transient
[]

[Postprocessors]
[./matl_integral]
type = ElementIntegralMaterialProperty
mat_prop = diffusivity
execute_on = timestep_end
outputs = 'console csv'
[../]
[]

[Outputs]
csv = true
exodus = true
[]
7 changes: 7 additions & 0 deletions test/tests/multiapps/stateful_material_sub_cycling/tests
@@ -0,0 +1,7 @@
[Tests]
[./test_stateful_subcycle]
type = 'CSVDiff'
input = 'material_sub_app_test_master.i'
csvdiff = 'material_sub_app_test_master_out_sub0.csv'
[../]
[]
@@ -1,9 +1,9 @@
[Mesh]
file = two_step_solve_master_cp/0002_mesh.cpr
file = two_step_solve_master_out_full_solve0_cp/0002_mesh.cpr
[]

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

Expand Down

0 comments on commit 406b8fc

Please sign in to comment.