Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extending MooseVariableFV to face and qp for transient two-phase flow… #26774

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions framework/include/variables/MooseVariableFV.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ class MooseVariableFV : public MooseVariableField<OutputType>
GradientType evaluateGradient(const ElemArg & elem_arg, const StateArg &) const override final;
GradientType evaluateGradient(const FaceArg & face, const StateArg &) const override final;
DotType evaluateDot(const ElemArg & elem, const StateArg &) const override final;
DotType evaluateDot(const FaceArg & face, const StateArg &) const override final;
DotType evaluateDot(const ElemQpArg & elem_qp, const StateArg &) const override final;

/**
* Setup the boundary to Dirichlet BC map
Expand Down
41 changes: 41 additions & 0 deletions framework/src/variables/MooseVariableFV.C
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,47 @@ MooseVariableFV<Real>::evaluateDot(const ElemArg & elem_arg, const StateArg & st
return (*_sys.solutionUDot())(dof_index);
}

template <>
ADReal
MooseVariableFV<Real>::evaluateDot(const FaceArg & face, const StateArg & state) const
{
const FaceInfo * const fi = face.fi;
mooseAssert(fi, "The face information must be non-null");
if (isDirichletBoundaryFace(*fi, face.face_side, state))
return ADReal(0.0);
else if (isExtrapolatedBoundaryFace(*fi, face.face_side, state))
{
const auto elem_guaranteed_to_have_dofs =
std::get<0>(Moose::FV::determineElemOneAndTwo(*fi, *this));
const auto elem_arg = ElemArg({elem_guaranteed_to_have_dofs, face.correct_skewness});
return evaluateDot(elem_arg, state);
MengnanLi91 marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
mooseAssert(this->isInternalFace(*fi),
"We must be either Dirichlet, extrapolated, or internal");
const auto [elem_one, elem_two, elem_one_is_fi_elem] =
Moose::FV::determineElemOneAndTwo(*fi, *this);
const auto elem_dt_val = evaluateDot(ElemArg({elem_one, face.correct_skewness}), state);
const auto neigh_dt_val = evaluateDot(ElemArg({elem_two, face.correct_skewness}), state);
ADReal interp_dt_val;
Moose::FV::interpolate(/*InterpMethod*/ _face_interp_method,
/*result*/ interp_dt_val,
/*value1*/ elem_dt_val,
/*value2*/ neigh_dt_val,
/*FaceInfo*/ *fi,
/*one_is_elem*/ elem_one_is_fi_elem);
lindsayad marked this conversation as resolved.
Show resolved Hide resolved
return interp_dt_val;
}
}

template <>
ADReal
MooseVariableFV<Real>::evaluateDot(const ElemQpArg & elem_qp, const StateArg & state) const
{
return evaluateDot(ElemArg({elem_qp.elem, /*correct_skewness*/ false}), state);
}

template <typename OutputType>
void
MooseVariableFV<OutputType>::prepareAux()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
mu = 1.0
rho = 10.0
mu_d = 0.1
rho_d = 1.0
l = 2
U = 1
dp = 0.01
inlet_phase_2 = 0.1
advected_interp_method = 'average'
velocity_interp_method = 'rc'

[GlobalParams]
rhie_chow_user_object = 'rc'
density_interp_method = 'average'
mu_interp_method = 'average'
[]

[UserObjects]
[rc]
type = INSFVRhieChowInterpolator
u = vel_x
v = vel_y
pressure = pressure
[]
[]

[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
xmin = 0
xmax = '${fparse l * 5}'
ymin = '${fparse -l / 2}'
ymax = '${fparse l / 2}'
nx = 10
ny = 4
[]
uniform_refine = 0
[]

[Variables]
[vel_x]
type = INSFVVelocityVariable
initial_condition = 0
[]
[vel_y]
type = INSFVVelocityVariable
initial_condition = 0
[]
[pressure]
type = INSFVPressureVariable
[]
[phase_2]
type = INSFVScalarFieldVariable
[]
[]

[FVKernels]

[mass]
type = INSFVMassAdvection
variable = pressure
advected_interp_method = ${advected_interp_method}
velocity_interp_method = ${velocity_interp_method}
rho = 'rho_mixture'
[]

[u_time]
type = INSFVMomentumTimeDerivative
variable = vel_x
rho = 'rho_mixture'
momentum_component = 'x'
[]
[u_advection]
type = INSFVMomentumAdvection
variable = vel_x
advected_interp_method = ${advected_interp_method}
velocity_interp_method = ${velocity_interp_method}
rho = 'rho_mixture'
momentum_component = 'x'
[]
[u_drift]
type = WCNSFV2PMomentumDriftFlux
variable = vel_x
rho_d = ${rho_d}
fd = 'rho_mixture_var'
u_slip = 'vel_slip_x'
v_slip = 'vel_slip_y'
momentum_component = 'x'
[]
[u_viscosity]
type = INSFVMomentumDiffusion
variable = vel_x
mu = 'mu_mixture'
limit_interpolation = true
momentum_component = 'x'
[]
[u_pressure]
type = INSFVMomentumPressure
variable = vel_x
momentum_component = 'x'
pressure = pressure
[]

[v_time]
type = INSFVMomentumTimeDerivative
variable = vel_y
rho = 'rho_mixture'
momentum_component = 'y'
[]
[v_advection]
type = INSFVMomentumAdvection
variable = vel_y
advected_interp_method = ${advected_interp_method}
velocity_interp_method = ${velocity_interp_method}
rho = 'rho_mixture'
momentum_component = 'y'
[]
[v_drift]
type = WCNSFV2PMomentumDriftFlux
variable = vel_y
rho_d = ${rho_d}
fd = 'rho_mixture_var'
u_slip = 'vel_slip_x'
v_slip = 'vel_slip_y'
momentum_component = 'y'
[]
[v_viscosity]
type = INSFVMomentumDiffusion
variable = vel_y
mu = 'mu_mixture'
limit_interpolation = true
momentum_component = 'y'
[]
[v_pressure]
type = INSFVMomentumPressure
variable = vel_y
momentum_component = 'y'
pressure = pressure
[]

[phase_2_time]
type = FVFunctorTimeKernel
variable = phase_2
functor = phase_2
[]
[phase_2_advection]
type = INSFVScalarFieldAdvection
variable = phase_2
u_slip = 'vel_x'
v_slip = 'vel_y'
velocity_interp_method = ${velocity_interp_method}
advected_interp_method = 'upwind'
[]
[phase_2_src]
type = NSFVMixturePhaseInterface
variable = phase_2
phase_coupled = phase_1
alpha = 0.1
[]
[]

[FVBCs]
[inlet-u]
type = INSFVInletVelocityBC
boundary = 'left'
variable = vel_x
functor = '${U}'
[]
[inlet-v]
type = INSFVInletVelocityBC
boundary = 'left'
variable = vel_y
functor = '0'
[]
[walls-u]
type = INSFVNoSlipWallBC
boundary = 'top bottom'
variable = vel_x
function = 0
[]
[walls-v]
type = INSFVNoSlipWallBC
boundary = 'top bottom'
variable = vel_y
function = 0
[]
[outlet_p]
type = INSFVOutletPressureBC
boundary = 'right'
variable = pressure
function = '0'
[]
[inlet_phase_2]
type = FVDirichletBC
boundary = 'left'
variable = phase_2
value = ${inlet_phase_2}
[]
[]

[AuxVariables]
[drag_coefficient]
type = MooseVariableFVReal
[]
[rho_mixture_var]
type = MooseVariableFVReal
[]
[mu_mixture_var]
type = MooseVariableFVReal
[]
[]

[AuxKernels]
[populate_cd]
type = FunctorAux
variable = drag_coefficient
functor = 'Darcy_coefficient'
[]
[populate_rho_mixture_var]
type = FunctorAux
variable = rho_mixture_var
functor = 'rho_mixture'
[]
[populate_mu_mixture_var]
type = FunctorAux
variable = mu_mixture_var
functor = 'mu_mixture'
[]
[]

[FunctorMaterials]
[populate_u_slip]
type = WCNSFV2PSlipVelocityFunctorMaterial
slip_velocity_name = 'vel_slip_x'
momentum_component = 'x'
u = 'vel_x'
v = 'vel_y'
rho = ${rho}
mu = 'mu_mixture'
rho_d = ${rho_d}
particle_diameter = ${dp}
linear_coef_name = 'Darcy_coefficient'
[]
[populate_v_slip]
type = WCNSFV2PSlipVelocityFunctorMaterial
slip_velocity_name = 'vel_slip_y'
momentum_component = 'y'
u = 'vel_x'
v = 'vel_y'
rho = ${rho}
mu = 'mu_mixture'
rho_d = ${rho_d}
particle_diameter = ${dp}
linear_coef_name = 'Darcy_coefficient'
[]
[compute_phase_1]
type = ADParsedFunctorMaterial
property_name = phase_1
functor_names = 'phase_2'
expression = '1 - phase_2'
[]
[CD]
type = NSFVDispersePhaseDragFunctorMaterial
rho = 'rho_mixture'
mu = mu_mixture
u = 'vel_x'
v = 'vel_y'
particle_diameter = ${dp}
[]
[mixing_material]
type = NSFVMixtureFunctorMaterial
phase_2_names = '${rho} ${mu}'
phase_1_names = '${rho_d} ${mu_d}'
prop_names = 'rho_mixture mu_mixture'
phase_1_fraction = 'phase_2'
[]
[]

[Executioner]
type = Transient
solve_type = 'NEWTON'
nl_rel_tol = 1e-10
dt = 0.1
end_time = 1.0
[]

[Preconditioning]
[SMP]
type = SMP
full = true
petsc_options_iname = '-pc_type -pc_factor_shift_type'
petsc_options_value = 'lu NONZERO'
[]
[]

[Outputs]
exodus = false
[CSV]
type = CSV
execute_on = 'TIMESTEP_END'
[]
[]

[Postprocessors]
[Re]
type = ParsedPostprocessor
function = '${rho} * ${l} * ${U}'
pp_names = ''
[]
[rho_outlet]
type = SideAverageValue
boundary = 'right'
variable = 'rho_mixture_var'
[]
[]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
time,Re,rho_outlet
0.1,20,9.9117647172289
0.2,20,9.8252596090608
0.3,20,9.740450918661
0.4,20,9.6573057114606
0.5,20,9.5757918265099
0.6,20,9.4958776476968
0.7,20,9.4175315781681
0.8,20,9.3407211541948
0.9,20,9.2654118160675
1,20,9.1915654482304
Binary file not shown.
Loading