Skip to content

Commit

Permalink
Add support for BCs on auxVariables for LinearFV. (idaholab#29531)
Browse files Browse the repository at this point in the history
  • Loading branch information
grmnptr committed Dec 13, 2024
1 parent f6923d8 commit bd0ad90
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
17 changes: 12 additions & 5 deletions framework/src/problems/FEProblemBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -4087,17 +4087,20 @@ FEProblemBase::addObjectParamsHelper(InputParameters & parameters,
const std::string & object_name,
const std::string & var_param_name)
{
const auto solver_sys_num =
const auto sys_num =
parameters.isParamValid(var_param_name) &&
determineSolverSystem(parameters.varName(var_param_name, object_name)).first
? determineSolverSystem(parameters.varName(var_param_name, object_name)).second
&getSystem(parameters.varName(var_param_name, object_name))
? getSystem(parameters.varName(var_param_name, object_name)).number()
: (unsigned int)0;

if (_displaced_problem && parameters.have_parameter<bool>("use_displaced_mesh") &&
parameters.get<bool>("use_displaced_mesh"))
{
parameters.set<SubProblem *>("_subproblem") = _displaced_problem.get();
parameters.set<SystemBase *>("_sys") = &_displaced_problem->solverSys(solver_sys_num);
if (sys_num == _aux->number())
parameters.set<SystemBase *>("_sys") = _aux.get();
else
parameters.set<SystemBase *>("_sys") = &_displaced_problem->solverSys(sys_num);
}
else
{
Expand All @@ -4109,7 +4112,11 @@ FEProblemBase::addObjectParamsHelper(InputParameters & parameters,
parameters.set<bool>("use_displaced_mesh") = false;

parameters.set<SubProblem *>("_subproblem") = this;
parameters.set<SystemBase *>("_sys") = _solver_systems[solver_sys_num].get();

if (sys_num == _aux->number())
parameters.set<SystemBase *>("_sys") = _aux.get();
else
parameters.set<SystemBase *>("_sys") = _solver_systems[sys_num].get();
}
}

Expand Down
1 change: 1 addition & 0 deletions framework/src/variables/MooseLinearVariableFV.C
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ MooseLinearVariableFV<OutputType>::evaluate(const FaceArg & face, const StateArg
mooseAssert(fi, "The face information must be non-null");

const auto face_type = fi->faceType(std::make_pair(this->_var_num, this->_sys_num));

if (face_type == FaceInfo::VarFaceNeighbors::BOTH)
return Moose::FV::interpolate(*this, face, state);
else if (auto * bc_pointer = this->getBoundaryCondition(*fi->boundaryIDs().begin()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ LinearFVEnthalpyFunctorMaterial::LinearFVEnthalpyFunctorMaterial(const InputPara
{
addFunctorProperty<Real>("h_from_p_T",
[this](const auto & r, const auto & t) -> Real
{ return _fluid->h_from_p_T(raw_value(_pressure(r, t)), raw_value(_T_fluid(r, t))); });
{
return _fluid->h_from_p_T(raw_value(_pressure(r, t)), raw_value(_T_fluid(r, t))); });
addFunctorProperty<Real>("T_from_p_h",
[this](const auto & r, const auto & t) -> Real
{ return _fluid->T_from_p_h(raw_value(_pressure(r, t)), raw_value(_h(r, t))); });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
H = 0.05 #halfwidth of the channel, 10 cm of channel height
L = 30
H = 0.015 #halfwidth of the channel, 10 cm of channel height
L = 3
bulk_u = 0.01
p_ref = 101325.0
#inlet_temp = 860.
Expand All @@ -15,20 +15,11 @@ advected_interp_method = 'upwind'
xmax = ${L}
ymin = -${H}
ymax = ${H}
nx = 200
ny = 80
#bias_y = 0.95
nx = 100
ny = 30
[]
[]

[GlobalParams]
rhie_chow_user_object = 'rc'
advected_interp_method = ${advected_interp_method}
#velocity_interp_method = 'rc'
u = vel_x
v = vel_y
[]

[Problem]
linear_sys_names = 'u_system v_system pressure_system energy_system'
previous_nl_solution_required = true
Expand Down Expand Up @@ -64,7 +55,7 @@ advected_interp_method = 'upwind'
[h]
type = MooseLinearVariableFVReal
solver_sys = energy_system
initial_condition = ${fparse 860.*2416.} # 1900 is an approx of cp(T)
initial_condition = 44000 # 1900 is an approx of cp(T)
[]
[]

Expand All @@ -83,7 +74,7 @@ advected_interp_method = 'upwind'
[]
[T]
type = MooseLinearVariableFVReal
initial_condition = 860.
initial_condition = 777.
[]
[]

Expand All @@ -95,6 +86,10 @@ advected_interp_method = 'upwind'
mu = 'mu'
momentum_component = 'x'
use_nonorthogonal_correction = false
advected_interp_method = ${advected_interp_method}
rhie_chow_user_object = 'rc'
u = vel_x
v = vel_y
[]
[u_pressure]
type = LinearFVMomentumPressure
Expand All @@ -109,6 +104,10 @@ advected_interp_method = 'upwind'
mu = 'mu'
momentum_component = 'y'
use_nonorthogonal_correction = false
advected_interp_method = ${advected_interp_method}
rhie_chow_user_object = 'rc'
u = vel_x
v = vel_y
[]
[v_pressure]
type = LinearFVMomentumPressure
Expand Down Expand Up @@ -138,6 +137,8 @@ advected_interp_method = 'upwind'
[temp_advection]
type = LinearFVEnergyAdvection
variable = h
advected_interp_method = ${advected_interp_method}
rhie_chow_user_object = 'rc'
[]
[]

Expand Down Expand Up @@ -232,7 +233,8 @@ advected_interp_method = 'upwind'

[FluidProperties]
[salt]
type = FlibeFluidProperties
# type = FlibeFluidProperties
type = LeadFluidProperties
[]
[]

Expand All @@ -250,7 +252,7 @@ advected_interp_method = 'upwind'
type = ADParsedFunctorMaterial
property_name = 'alpha'
functor_names = 'k cp'
expression = '100*k/cp'
expression = 'k/cp'
[]
[enthalpy_material]
type = LinearFVEnthalpyFunctorMaterial
Expand Down Expand Up @@ -308,8 +310,8 @@ advected_interp_method = 'upwind'
energy_system = 'energy_system'
momentum_equation_relaxation = 0.7
pressure_variable_relaxation = 0.3
energy_equation_relaxation = 0.7
num_iterations = 1000
energy_equation_relaxation = 0.9
num_iterations = 200
pressure_absolute_tolerance = 1e-8
momentum_absolute_tolerance = 1e-8
energy_absolute_tolerance = 1e-8
Expand Down

0 comments on commit bd0ad90

Please sign in to comment.