https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
22using 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
54void
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
62void
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] *
76 }
77}
78
79void
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
94void
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(
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}
unsigned int THREAD_ID
Definition MooseTypes.h:237
Keeps track of stuff related to assembling.
Definition Assembly.h:110
const MooseArray< ADRealVectorValue > & _grad_u_sol
Element-interior scalar gradients at quadrature points.
virtual void scalarDirichlet(const Moose::Functor< Real > &dirichlet_value) override
Weakly imposes a Dirichlet condition for the scalar field in the scalar field equation.
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)
const MooseArray< std::vector< RealVectorValue > > & _grad_scalar_phi_face
Element-interior scalar test-function gradients evaluated on a face.
virtual void scalarVolume() override
Computes a local residual vector for the weak form: (Dq, grad(w)) - (f, w) where D is the diffusivity...
const Real _alpha
Our stabilization coefficient.
virtual void scalarFace() override
Computes a local residual vector for the weak form: -<Dq*n, w> + <\tau * (u - \hat{u}) * n * n,...
const ADMaterialProperty< Real > & _face_diff
The diffusivity on the element faces.
const ADMaterialProperty< Real > & _diff
The diffusivity in the element volume.
virtual void lmFace() override
Computes a local residual vector for the weak form: -<Dq*n, \mu> + <\tau * (u - \hat{u}) * n * n,...
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 std::vector< dof_id_type > & _u_dof_indices
Degree-of-freedom indices for the element-interior scalar.
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.
virtual Real hmax() const
unsigned int n_points() const
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.