https://mooseframework.inl.gov
AdvectionHDGAssemblyHelper.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 "MooseFunctor.h"
12 #include "MooseObject.h"
13 #include "TransientInterface.h"
14 
15 using namespace libMesh;
16 
19 {
21  params.addRequiredParam<MaterialPropertyName>(
22  "velocity", "The cell-interior velocity material property used in the volume advection term");
23  params.addRequiredParam<Real>(
24  "coeff", "Constant coefficient multiplying the advected scalar, such as density");
25  return params;
26 }
27 
29  const MooseObject * const moose_obj,
31  const TransientInterface * const ti,
32  SystemBase & sys,
33  const Assembly & assembly,
34  const THREAD_ID tid,
35  const std::set<SubdomainID> & block_ids,
36  const std::set<BoundaryID> & boundary_ids)
38  moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
39  _velocity(getADMaterialProperty<RealVectorValue>("velocity")),
40  _coeff(moose_obj->getParam<Real>("coeff"))
41 {
42 }
43 
44 void
46 {
47  for (const auto qp : make_range(_qrule->n_points()))
48  {
49  const auto advected_quantity = _coeff * _u_sol[qp];
50  const auto qp_term = _JxW[qp] * _velocity[qp] * advected_quantity;
51  for (const auto i : index_range(_scalar_re))
52  _scalar_re(i) -= _grad_scalar_phi[i][qp] * qp_term;
53  }
54 }
55 
56 ADReal
57 AdvectionHDGAssemblyHelper::computeFlux(const unsigned int qp, const ADReal & face_value) const
58 {
59  const auto vdotn = faceVelocity(qp) * _normals[qp];
60  const auto face_phi = _coeff * face_value;
61  const auto internal_phi = _coeff * _u_sol[qp];
62  // If velocity points out of the element, use the interior value; otherwise use the face value.
63  return 0.5 * vdotn * (internal_phi + face_phi) + 0.5 * abs(vdotn) * (internal_phi - face_phi);
64 }
65 
66 void
68 {
69  for (const auto qp : make_range(_qrule_face->n_points()))
70  {
71  const auto qp_term = _JxW_face[qp] * computeFlux(qp, _lm_u_sol[qp]);
72  for (const auto i : index_range(_scalar_re))
73  _scalar_re(i) += _scalar_phi_face[i][qp] * qp_term;
74  }
75 }
76 
77 void
79 {
80  for (const auto qp : make_range(_qrule_face->n_points()))
81  {
82  const auto qp_term = _JxW_face[qp] * computeFlux(qp, _lm_u_sol[qp]);
83  for (const auto i : index_range(_lm_re))
84  _lm_re(i) -= _lm_phi_face[i][qp] * qp_term;
85  }
86 }
87 
88 void
90 {
91  for (const auto qp : make_range(_qrule_face->n_points()))
92  {
93  const auto dirichlet_value = dirichlet_functor(
96  const auto qp_term = _JxW_face[qp] * computeFlux(qp, dirichlet_value);
97  for (const auto i : index_range(_scalar_re))
98  _scalar_re(i) += _scalar_phi_face[i][qp] * qp_term;
99  }
100 }
101 
102 void
104 {
105  for (const auto qp : make_range(_qrule_face->n_points()))
106  {
107 #ifndef NDEBUG
108  const auto vdotn = faceVelocity(qp) * _normals[qp];
109  mooseAssert(MetaPhysicL::raw_value(vdotn) >= 0, "The velocity must create outflow conditions");
110 #endif
111  const auto qp_term = _JxW_face[qp] * _coeff * (_lm_u_sol[qp] - _u_sol[qp]);
112  for (const auto i : index_range(_lm_re))
113  // Force the facet solution to be equivalent to the interior solution.
114  _lm_re(i) += _lm_phi_face[i][qp] * qp_term;
115  }
116 }
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:50
const MooseArray< Point > & _normals
Outward unit normals on the current face.
const MooseArray< std::vector< Real > > & _lm_phi_face
Facet trace test functions evaluated on a face.
Keeps track of stuff related to assembling.
Definition: Assembly.h:109
AdvectionHDGAssemblyHelper(const MooseObject *moose_obj, MooseVariableDependencyInterface *mvdi, const TransientInterface *ti, SystemBase &sys, const Assembly &assembly, THREAD_ID tid, const std::set< SubdomainID > &block_ids, const std::set< BoundaryID > &boundary_ids)
virtual void scalarFace() override
Assembles the element-interior equation&#39;s face contribution.
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...
const MooseArray< Real > & _JxW_face
Face quadrature weights including the transformed Jacobian.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:100
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void scalarVolume() override
Assembles the element-interior equation&#39;s volume contribution.
const ADMaterialProperty< RealVectorValue > & _velocity
Cell-interior velocity used in the volume advection term.
const MooseArray< ADReal > & _lm_u_sol
Facet trace values at face quadrature points.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
Definition: SystemBase.h:85
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:42
Interface for objects that needs transient capabilities.
virtual ADRealVectorValue faceVelocity(unsigned int qp) const =0
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
void lmOutflow()
Prescribes an outflow condition for the facet scalar.
const Real _coeff
Constant coefficient multiplying the advected scalar, such as density.
unsigned int n_points() const
ADReal computeFlux(unsigned int qp, const ADReal &face_value) const
Computes the upwind face flux.
const MooseArray< Point > & _q_point_face
Physical face quadrature points.
Method-neutral assembly data and operations for an element-and-trace scalar hybridized DG discretizat...
const MooseArray< ADReal > & _u_sol
Element-interior scalar values at quadrature points.
const libMesh::QBase *const & _qrule
Element quadrature rule.
const unsigned int & _current_side
Current element-side index.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
DenseVector< ADReal > _scalar_re
Residual for the element-interior scalar equation.
virtual void lmFace() override
Assembles the facet equation&#39;s interior-face contribution.
IntRange< T > make_range(T beg, T end)
const TransientInterface & _ti
Transient state used to evaluate boundary functors.
const libMesh::QBase *const & _qrule_face
Face quadrature rule.
const MooseArray< std::vector< Real > > & _scalar_phi_face
Element-interior scalar test functions evaluated on a face.
auto index_range(const T &sizable)
Argument for requesting functor evaluation at quadrature point locations on an element side...
const MooseArray< Real > & _JxW
Element quadrature weights including the transformed Jacobian.
virtual void scalarDirichlet(const Moose::Functor< Real > &dirichlet_value) override
Assembles the element-interior equation on a Dirichlet boundary.
const MooseArray< std::vector< RealVectorValue > > & _grad_scalar_phi
Gradients of the element-interior scalar test functions.
unsigned int THREAD_ID
Definition: MooseTypes.h:237
DenseVector< ADReal > _lm_re
Residual for the facet trace equation.