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
15using 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
44void
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
57AdvectionHDGAssemblyHelper::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
66void
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
77void
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
88void
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
102void
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}
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:110
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)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
auto index_range(const T &sizable)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
Argument for requesting functor evaluation at quadrature point locations on an element side.