https://mooseframework.inl.gov
DiffusionIPHDGAssemblyHelper.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 "MooseTypes.h"
14 #include "MooseVariableScalar.h"
15 #include "SystemBase.h"
16 #include "MooseMesh.h"
17 #include "MooseObject.h"
19 #include "MooseVariableFE.h"
20 #include "TransientInterface.h"
21 
22 using namespace libMesh;
23 
26 {
28  params.addRequiredParam<MaterialPropertyName>("diffusivity", "The diffusivity");
29  params.addRequiredParam<Real>("alpha",
30  "The stabilization coefficient required for discontinuous Galerkin "
31  "schemes.");
32  return params;
33 }
34 
36  const MooseObject * const moose_obj,
38  const TransientInterface * const ti,
39  SystemBase & sys,
40  const Assembly & assembly,
41  const THREAD_ID tid,
42  const std::set<SubdomainID> & block_ids,
43  const std::set<BoundaryID> & boundary_ids)
45  moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
46  _grad_u_sol(_u_var.adGradSln()),
47  _grad_scalar_phi_face(_u_var.gradPhiFace()),
48  _diff(this->getADMaterialProperty<Real>("diffusivity")),
49  _face_diff(this->getFaceADMaterialProperty<Real>("diffusivity")),
50  _alpha(moose_obj->getParam<Real>("alpha"))
51 {
52 }
53 
54 void
56 {
57  for (const auto qp : make_range(_qrule->n_points()))
58  for (const auto i : index_range(_scalar_re))
59  _scalar_re(i) += _JxW[qp] * (_grad_scalar_phi[i][qp] * _diff[qp] * _grad_u_sol[qp]);
60 }
61 
62 void
64 {
65  const auto h_elem = _current_elem->hmax();
66 
67  for (const auto i : index_range(_scalar_re))
68  for (const auto qp : make_range(_qrule_face->n_points()))
69  {
70  _scalar_re(i) -= _JxW_face[qp] * _face_diff[qp] * _scalar_phi_face[i][qp] *
71  (_grad_u_sol[qp] * _normals[qp]);
72  _scalar_re(i) -= _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] *
73  (_lm_u_sol[qp] - _u_sol[qp]) * _scalar_phi_face[i][qp];
74  _scalar_re(i) += _JxW_face[qp] * (_lm_u_sol[qp] - _u_sol[qp]) * _face_diff[qp] *
75  _grad_scalar_phi_face[i][qp] * _normals[qp];
76  }
77 }
78 
79 void
81 {
82  const auto h_elem = _current_elem->hmax();
83 
84  for (const auto i : index_range(_lm_re))
85  for (const auto qp : make_range(_qrule_face->n_points()))
86  {
87  _lm_re(i) +=
88  _JxW_face[qp] * _face_diff[qp] * _grad_u_sol[qp] * _normals[qp] * _lm_phi_face[i][qp];
89  _lm_re(i) += _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] * (_lm_u_sol[qp] - _u_sol[qp]) *
90  _lm_phi_face[i][qp];
91  }
92 }
93 
94 void
96 {
97  const auto h_elem = _current_elem->hmax();
98 
99  for (const auto qp : make_range(_qrule_face->n_points()))
100  {
101  const auto scalar_value = dirichlet_value(
103  _ti.determineState());
104 
105  for (const auto i : index_range(_u_dof_indices))
106  {
107  _scalar_re(i) -= _JxW_face[qp] * _face_diff[qp] * _scalar_phi_face[i][qp] *
108  (_grad_u_sol[qp] * _normals[qp]);
109  _scalar_re(i) -= _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] *
110  (scalar_value - _u_sol[qp]) * _scalar_phi_face[i][qp];
111  _scalar_re(i) += _JxW_face[qp] * (scalar_value - _u_sol[qp]) * _face_diff[qp] *
112  _grad_scalar_phi_face[i][qp] * _normals[qp];
113  }
114  }
115 }
const ADMaterialProperty< Real > & _diff
The diffusivity in the element volume.
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
const Real _alpha
Our stabilization coefficient.
virtual void scalarVolume() override
Computes a local residual vector for the weak form: (Dq, grad(w)) - (f, w) where D is the diffusivity...
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.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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...
virtual Real hmax() const
Base class for a system (of equations)
Definition: SystemBase.h:85
Interface for objects that needs transient capabilities.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
unsigned int n_points() const
const ADMaterialProperty< Real > & _face_diff
The diffusivity on the element faces.
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
virtual void lmFace() override
Computes a local residual vector for the weak form: -<Dq*n, > + < * (u - {u}) * n * n...
DenseVector< ADReal > _scalar_re
Residual for the element-interior scalar equation.
IntRange< T > make_range(T beg, T end)
const MooseArray< std::vector< RealVectorValue > > & _grad_scalar_phi_face
Element-interior scalar test-function gradients evaluated on a face.
DiffusionIPHDGAssemblyHelper(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)
virtual void scalarFace() override
Computes a local residual vector for the weak form: -<Dq*n, w> + < * (u - {u}) * n * n...
virtual void scalarDirichlet(const Moose::Functor< Real > &dirichlet_value) override
Weakly imposes a Dirichlet condition for the scalar field in the scalar field equation.
const TransientInterface & _ti
Transient state used to evaluate boundary functors.
const MooseArray< ADRealVectorValue > & _grad_u_sol
Element-interior scalar gradients at quadrature points.
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 std::vector< dof_id_type > & _u_dof_indices
Degree-of-freedom indices for the element-interior scalar.
const MooseArray< Real > & _JxW
Element quadrature weights including the transformed Jacobian.
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.