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
24{
26 params.addRequiredParam<MaterialPropertyName>("diffusivity", "The diffusivity");
27 params.addRequiredParam<Real>("alpha",
28 "The stabilization coefficient required for discontinuous Galerkin "
29 "schemes.");
30 return params;
31}
32
34 const MooseObject * const moose_obj,
36 const TransientInterface * const ti,
37 SystemBase & sys,
38 const Assembly & assembly,
39 const THREAD_ID tid,
40 const std::set<SubdomainID> & block_ids,
41 const std::set<BoundaryID> & boundary_ids)
43 moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
44 _grad_u_sol(_u_var.adGradSln()),
45 _grad_scalar_phi_face(_u_var.gradPhiFace()),
46 _diff(this->getADMaterialProperty<Real>("diffusivity")),
47 _face_diff(this->getFaceADMaterialProperty<Real>("diffusivity")),
48 _alpha(moose_obj->getParam<Real>("alpha"))
49{
50}
51
52void
54{
55 for (const auto qp : make_range(_qrule->n_points()))
56 for (const auto i : index_range(_scalar_re))
57 _scalar_re(i) += _JxW[qp] * (_grad_scalar_phi[i][qp] * _diff[qp] * _grad_u_sol[qp]);
58}
59
60void
62{
63 const auto h_elem = _current_elem->hmax();
64
65 for (const auto i : index_range(_scalar_re))
66 for (const auto qp : make_range(_qrule_face->n_points()))
67 {
68 _scalar_re(i) -= _JxW_face[qp] * _face_diff[qp] * _scalar_phi_face[i][qp] *
69 (_grad_u_sol[qp] * _normals[qp]);
70 _scalar_re(i) -= _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] *
71 (_lm_u_sol[qp] - _u_sol[qp]) * _scalar_phi_face[i][qp];
72 _scalar_re(i) += _JxW_face[qp] * (_lm_u_sol[qp] - _u_sol[qp]) * _face_diff[qp] *
74 }
75}
76
77void
79{
80 const auto h_elem = _current_elem->hmax();
81
82 for (const auto i : index_range(_lm_re))
83 for (const auto qp : make_range(_qrule_face->n_points()))
84 {
85 _lm_re(i) +=
86 _JxW_face[qp] * _face_diff[qp] * _grad_u_sol[qp] * _normals[qp] * _lm_phi_face[i][qp];
87 _lm_re(i) += _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] * (_lm_u_sol[qp] - _u_sol[qp]) *
88 _lm_phi_face[i][qp];
89 }
90}
91
92void
94{
95 const auto h_elem = _current_elem->hmax();
96
97 for (const auto qp : make_range(_qrule_face->n_points()))
98 {
99 const auto scalar_value = dirichlet_value(
102
103 for (const auto i : index_range(_u_dof_indices))
104 {
105 _scalar_re(i) -= _JxW_face[qp] * _face_diff[qp] * _scalar_phi_face[i][qp] *
106 (_grad_u_sol[qp] * _normals[qp]);
107 _scalar_re(i) -= _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] *
108 (scalar_value - _u_sol[qp]) * _scalar_phi_face[i][qp];
109 _scalar_re(i) += _JxW_face[qp] * (scalar_value - _u_sol[qp]) * _face_diff[qp] *
110 _grad_scalar_phi_face[i][qp] * _normals[qp];
111 }
112 }
113}
unsigned int THREAD_ID
Definition MooseTypes.h:237
Keeps track of stuff related to assembling.
Definition Assembly.h:101
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.
unsigned int n_points() const
Argument for requesting functor evaluation at quadrature point locations on an element side.