https://mooseframework.inl.gov
AdvectionIPHDGAssemblyHelper.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 "MooseTypes.h"
12 #include "MooseObject.h"
14 
15 using namespace libMesh;
16 
19 {
20  auto params = IPHDGAssemblyHelper::validParams();
21  params.addRequiredParam<MaterialPropertyName>("velocity", "Velocity vector");
22  params.addParam<Real>(
23  "coeff", 1, "A constant coefficient. This could be something like a density");
24  params.addParam<bool>("self_advection",
25  true,
26  "Whether this kernel should advect its variables, e.g. its "
27  "variable/side_variable pair. If false, we will advect "
28  "unity (possibly multiplied by the 'coeff' parameter");
29  return params;
30 }
31 
33  const MooseObject * const moose_obj,
35  const TransientInterface * const ti,
36  SystemBase & sys,
37  const Assembly & assembly,
38  const THREAD_ID tid,
39  const std::set<SubdomainID> & block_ids,
40  const std::set<BoundaryID> & boundary_ids)
41  : IPHDGAssemblyHelper(moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
42  _velocity(getADMaterialProperty<RealVectorValue>("velocity")),
43  _face_velocity(getFaceADMaterialProperty<RealVectorValue>("velocity")),
44  _coeff(moose_obj->getParam<Real>("coeff")),
45  _self_advection(moose_obj->getParam<bool>("self_advection"))
46 {
47 }
48 
49 void
51 {
52  for (const auto qp : make_range(_ip_qrule->n_points()))
53  {
54  ADReal adv_quant = _coeff;
55  if (_self_advection)
56  adv_quant *= _u_sol[qp];
57  const auto qp_term = _ip_JxW[qp] * _velocity[qp] * adv_quant;
58  for (const auto i : index_range(_scalar_re))
59  _scalar_re(i) -= _grad_scalar_phi[i][qp] * qp_term;
60  }
61 }
62 
63 void
65 {
66  for (const auto qp : make_range(_ip_qrule_face->n_points()))
67  {
68  const auto vdotn = _face_velocity[qp] * _ip_normals[qp];
69  ADReal adv_quant = _coeff;
70  if (_self_advection)
71  adv_quant *= (MetaPhysicL::raw_value(vdotn) >= 0 ? _u_sol[qp] : _lm_u_sol[qp]);
72  const auto qp_term = _ip_JxW_face[qp] * vdotn * adv_quant;
73  for (const auto i : index_range(_scalar_re))
74  _scalar_re(i) += _scalar_phi_face[i][qp] * qp_term;
75  }
76 }
77 
78 void
80 {
81  for (const auto qp : make_range(_ip_qrule_face->n_points()))
82  {
83  const auto vdotn = _face_velocity[qp] * _ip_normals[qp];
84  ADReal adv_quant = _coeff;
85  if (_self_advection)
86  adv_quant *= (MetaPhysicL::raw_value(vdotn) >= 0 ? _u_sol[qp] : _lm_u_sol[qp]);
87  const auto qp_term = _ip_JxW_face[qp] * vdotn * adv_quant;
88  for (const auto i : index_range(_lm_re))
89  _lm_re(i) -= _lm_phi_face[i][qp] * qp_term;
90  }
91 }
92 
93 void
95 {
96  for (const auto qp : make_range(_ip_qrule_face->n_points()))
97  {
98  const auto vdotn = _face_velocity[qp] * _ip_normals[qp];
99  mooseAssert(_self_advection, "This shouldn't be called if we are not self-advecting");
100  const auto dirichlet_value = dirichlet_functor(
103  _ti.determineState());
104  const auto adv_quant = dirichlet_value * _coeff;
105  const auto qp_term = _ip_JxW_face[qp] * vdotn * adv_quant;
106  for (const auto i : index_range(_scalar_re))
107  _scalar_re(i) += _scalar_phi_face[i][qp] * qp_term;
108  }
109 }
110 
111 void
113 {
114  for (const auto qp : make_range(_ip_qrule_face->n_points()))
115  {
116 #ifndef NDEBUG
117  const auto vdotn = _face_velocity[qp] * _ip_normals[qp];
118  mooseAssert(MetaPhysicL::raw_value(vdotn) >= 0, "The velocity must create outflow conditions");
119  mooseAssert(_self_advection, "This shouldn't be called if we are not self-advecting");
120 #endif
121  const auto qp_term = _ip_JxW_face[qp] * _coeff * (_lm_u_sol[qp] - _u_sol[qp]);
122  for (const auto i : index_range(_lm_re))
123  // Force the LM solution to be equivalent to the internal solution
124  _lm_re(i) += _lm_phi_face[i][qp] * qp_term;
125  }
126 }
virtual void scalarDirichlet(const Moose::Functor< Real > &dirichlet_value) override
Weakly imposes a Dirichlet condition for the scalar field in the scalar field equation.
DenseVector< ADReal > _scalar_re
Keeps track of stuff related to assembling.
Definition: Assembly.h:101
const bool _self_advection
Whether this kernel should advect itself, e.g.
DenseVector< ADReal > _lm_re
const unsigned int & _ip_current_side
The current element side.
const MooseArray< std::vector< RealVectorValue > > & _grad_scalar_phi
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
const MooseArray< std::vector< Real > > & _lm_phi_face
void lmOutflow()
prescribes an outflow condition
virtual void lmFace() override
Computes a local residual vector for the weak form: -<Dq*n, > + < * (u - {u}) * n * n...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
Definition: SystemBase.h:84
const QBase *const & _ip_qrule_face
The face qrule.
const TransientInterface & _ti
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:46
const Elem *const & _ip_current_elem
The current element.
const MooseArray< Real > & _ip_JxW
The element JxW.
Base class that declares all the methods for assembling a hybridized interior penalty discontinuous G...
Interface for objects that needs transient capabilities.
virtual void scalarVolume() override
Computes a local residual vector for the weak form: (Dq, grad(w)) - (f, w) where D is the diffusivity...
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
const MooseArray< Point > & _ip_normals
The normal vector on the face.
const QBase *const & _ip_qrule
The element qrule.
const ADMaterialProperty< RealVectorValue > & _velocity
The velocity in the element interior.
AdvectionIPHDGAssemblyHelper(const MooseObject *const moose_obj, MooseVariableDependencyInterface *const mvdi, const TransientInterface *const ti, SystemBase &sys, const Assembly &assembly, const THREAD_ID tid, const std::set< SubdomainID > &block_ids, const std::set< BoundaryID > &boundary_ids)
const MooseArray< Point > & _ip_q_point_face
The physical quadrature point locations on the face.
unsigned int n_points() const
const ADMaterialProperty< RealVectorValue > & _face_velocity
The velocity on the element faces.
const MooseArray< ADReal > & _lm_u_sol
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void scalarFace() override
Computes a local residual vector for the weak form: -<Dq*n, w> + < * (u - {u}) * n * n...
const MooseArray< ADReal > & _u_sol
const MooseArray< Real > & _ip_JxW_face
The face JxW.
const MooseArray< std::vector< Real > > & _scalar_phi_face
IntRange< T > make_range(T beg, T end)
static InputParameters validParams()
auto index_range(const T &sizable)
Argument for requesting functor evaluation at quadrature point locations on an element side...
const Real _coeff
The quantity we are advecting, e.g.
unsigned int THREAD_ID
Definition: MooseTypes.h:209