https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSFVPhaseChangeSource.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11#include "NS.h"
12
14
17{
18 auto params = FVElementalKernel::validParams();
19 params.addClassDescription("Computes the energy source due to solidification/melting.");
20 params.addRequiredParam<MooseFunctorName>("liquid_fraction", "Liquid Fraction Functor.");
21 params.addRequiredParam<MooseFunctorName>("L", "Latent heat.");
22 params.addRequiredParam<MooseFunctorName>(NS::density, "The mixture density.");
23 params.addRequiredParam<MooseFunctorName>("T_solidus", "The solidus temperature.");
24 params.addRequiredParam<MooseFunctorName>("T_liquidus", "The liquidus temperature.");
25 return params;
26}
27
29 : FVElementalKernel(parameters),
30 _liquid_fraction(getFunctor<ADReal>("liquid_fraction")),
31 _L(getFunctor<ADReal>("L")),
32 _rho(getFunctor<ADReal>(NS::density)),
33 _T_solidus(getFunctor<ADReal>("T_solidus")),
34 _T_liquidus(getFunctor<ADReal>("T_liquidus"))
35{
36}
37
40{
41 using namespace MetaPhysicL;
42
43 const auto elem_arg = makeElemArg(_current_elem);
44 const auto state = determineState();
45
46 const auto T_sol = _T_solidus(elem_arg, state);
47 const auto T_liq = _T_liquidus(elem_arg, state);
48 const auto T = _var(elem_arg, state);
49
50 // This is necessary to have a bounded derivative
51 // Otherwise the nonlinear solve won't converge!
52 const auto fl = (T - T_sol) / (T_liq - T_sol);
53
54 // The (6.0) comes from the integral of x*(1-x) between 0 and 1.
55 const auto source_index = std::max(6.0 * fl * (1 - fl), (ADReal)0);
56 const auto pre_factor = (_L(elem_arg, state) * _rho(elem_arg, state)) / (T_liq - T_sol);
57
58 return source_index * pre_factor * _var.dot(elem_arg, state);
59}
DualNumber< Real, DNDerivativeType, true > ADReal
const double T
registerMooseObject("NavierStokesApp", NSFVPhaseChangeSource)
static InputParameters validParams()
MooseVariableFV< Real > & _var
const Elem *const & _current_elem
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
DotType dot(const ElemArg &elem, const StateArg &state) const
Heat source coming from the melting/solidification of materials.
static InputParameters validParams()
const Moose::Functor< ADReal > & _T_liquidus
Liquidus Temperature.
const Moose::Functor< ADReal > & _rho
Density.
ADReal computeQpResidual() override
const Moose::Functor< ADReal > & _L
Latent heat.
NSFVPhaseChangeSource(const InputParameters &params)
const Moose::Functor< ADReal > & _T_solidus
Solidus Temperature.
Moose::StateArg determineState() const
static const std::string density
Definition NS.h:34