Skip to content

Commit

Permalink
New error when two different ICs are specified
Browse files Browse the repository at this point in the history
-Error thrown if an initial_condition parameter is provided along with an initial_from_file_var parameter for the same variable.

closes idaholab#20944
  • Loading branch information
DanielYankura committed Jan 14, 2025
1 parent 2df0918 commit e6be134
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions framework/src/actions/AddVariableAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ AddVariableAction::validParams()
"Specifies a scaling factor to apply to this variable");
params.addParam<std::vector<Real>>("initial_condition",
"Specifies a constant initial condition for this variable");
params.addParam<std::string>("initial_from_file_var", "Initial from file");
return params;
}

Expand Down Expand Up @@ -132,6 +133,12 @@ AddVariableAction::init()
"`scaling` parameter set, and they are different values. I don't know how you "
"achieved this, but you need to rectify it.");

if (_pars.isParamSetByUser("initial_condition") &&
_pars.isParamSetByUser("initial_from_file_var"))
mooseError("Two initial conditions have been provided for the variable ",
name(),
". One from the user and one from the restart input file.");

_moose_object_pars.applySpecificParameters(_pars, {"order", "family", "scaling"});

// Determine the MooseVariable type
Expand Down
50 changes: 50 additions & 0 deletions test/tests/restart/scalar-var/part3.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[Mesh]
[fmg]
type = FileMeshGenerator
file = part1_out.e
use_for_exodus_restart = true
[]
[]

[Variables]
[v]
family = MONOMIAL
order = CONSTANT
fv = true
initial_from_file_var = v
initial_condition = 0
[]
[lambda]
family = SCALAR
order = FIRST
initial_from_file_var = lambda
[]
[]

[FVKernels]
[advection]
type = FVElementalAdvection
variable = v
velocity = '1 0 0'
[]
[lambda]
type = FVScalarLagrangeMultiplier
variable = v
lambda = lambda
phi0 = 1
[]
[]

[Executioner]
type = Steady
petsc_options_iname = '-snes_max_it'
petsc_options_value = '0'
nl_abs_tol = 1e-10
[]

[Outputs]
[out]
type = Exodus
execute_on = 'final'
[]
[]
6 changes: 6 additions & 0 deletions test/tests/restart/scalar-var/tests
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
exodiff = part2_out.e
detail = 'run restart input'
[]
[part3]
prereq = 'restarting/part1'
type = 'RunException'
input = part3.i
expect_err = 'Two initial conditions have been provided for the variable v. One from the user and one from the restart input file.'
[]
[]
[]

0 comments on commit e6be134

Please sign in to comment.