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