LCOV - code coverage report
Current view: top level - src/hdgkernels - DiffusionIPHDGAssemblyHelper.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 52 53 98.1 %
Date: 2026-08-03 21:12:22 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "DiffusionIPHDGAssemblyHelper.h"
      11             : #include "MooseFunctor.h"
      12             : #include "MooseTypes.h"
      13             : #include "MooseVariableDependencyInterface.h"
      14             : #include "MooseVariableScalar.h"
      15             : #include "SystemBase.h"
      16             : #include "MooseMesh.h"
      17             : #include "MooseObject.h"
      18             : #include "MaterialPropertyInterface.h"
      19             : #include "MooseVariableFE.h"
      20             : #include "TransientInterface.h"
      21             : 
      22             : using namespace libMesh;
      23             : 
      24             : InputParameters
      25       10391 : DiffusionIPHDGAssemblyHelper::validParams()
      26             : {
      27       10391 :   auto params = ElementAndTraceScalarHDGAssemblyHelper::validParams();
      28       41564 :   params.addRequiredParam<MaterialPropertyName>("diffusivity", "The diffusivity");
      29       31173 :   params.addRequiredParam<Real>("alpha",
      30             :                                 "The stabilization coefficient required for discontinuous Galerkin "
      31             :                                 "schemes.");
      32       10391 :   return params;
      33           0 : }
      34             : 
      35         562 : DiffusionIPHDGAssemblyHelper::DiffusionIPHDGAssemblyHelper(
      36             :     const MooseObject * const moose_obj,
      37             :     MooseVariableDependencyInterface * const mvdi,
      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         562 :     const std::set<BoundaryID> & boundary_ids)
      44             :   : ElementAndTraceScalarHDGAssemblyHelper(
      45             :         moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
      46        1124 :     _grad_u_sol(_u_var.adGradSln()),
      47         562 :     _grad_scalar_phi_face(_u_var.gradPhiFace()),
      48        1124 :     _diff(this->getADMaterialProperty<Real>("diffusivity")),
      49        1124 :     _face_diff(this->getFaceADMaterialProperty<Real>("diffusivity")),
      50        1686 :     _alpha(moose_obj->getParam<Real>("alpha"))
      51             : {
      52         562 : }
      53             : 
      54             : void
      55      100501 : DiffusionIPHDGAssemblyHelper::scalarVolume()
      56             : {
      57      525005 :   for (const auto qp : make_range(_qrule->n_points()))
      58     1796296 :     for (const auto i : index_range(_scalar_re))
      59     1371792 :       _scalar_re(i) += _JxW[qp] * (_grad_scalar_phi[i][qp] * _diff[qp] * _grad_u_sol[qp]);
      60      100501 : }
      61             : 
      62             : void
      63      363318 : DiffusionIPHDGAssemblyHelper::scalarFace()
      64             : {
      65      363318 :   const auto h_elem = _current_elem->hmax();
      66             : 
      67     1547016 :   for (const auto i : index_range(_scalar_re))
      68     3602394 :     for (const auto qp : make_range(_qrule_face->n_points()))
      69             :     {
      70     4837392 :       _scalar_re(i) -= _JxW_face[qp] * _face_diff[qp] * _scalar_phi_face[i][qp] *
      71     7256088 :                        (_grad_u_sol[qp] * _normals[qp]);
      72     7256088 :       _scalar_re(i) -= _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] *
      73     9674784 :                        (_lm_u_sol[qp] - _u_sol[qp]) * _scalar_phi_face[i][qp];
      74     7256088 :       _scalar_re(i) += _JxW_face[qp] * (_lm_u_sol[qp] - _u_sol[qp]) * _face_diff[qp] *
      75     9674784 :                        _grad_scalar_phi_face[i][qp] * _normals[qp];
      76             :     }
      77      363318 : }
      78             : 
      79             : void
      80      363318 : DiffusionIPHDGAssemblyHelper::lmFace()
      81             : {
      82      363318 :   const auto h_elem = _current_elem->hmax();
      83             : 
      84     2442048 :   for (const auto i : index_range(_lm_re))
      85     6372990 :     for (const auto qp : make_range(_qrule_face->n_points()))
      86             :     {
      87     4294260 :       _lm_re(i) +=
      88     8588520 :           _JxW_face[qp] * _face_diff[qp] * _grad_u_sol[qp] * _normals[qp] * _lm_phi_face[i][qp];
      89     8588520 :       _lm_re(i) += _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] * (_lm_u_sol[qp] - _u_sol[qp]) *
      90     8588520 :                    _lm_phi_face[i][qp];
      91             :     }
      92      363318 : }
      93             : 
      94             : void
      95       19236 : DiffusionIPHDGAssemblyHelper::scalarDirichlet(const Moose::Functor<Real> & dirichlet_value)
      96             : {
      97       19236 :   const auto h_elem = _current_elem->hmax();
      98             : 
      99       58608 :   for (const auto qp : make_range(_qrule_face->n_points()))
     100             :   {
     101      118116 :     const auto scalar_value = dirichlet_value(
     102       39372 :         Moose::ElemSideQpArg{_current_elem, _current_side, qp, _qrule_face, _q_point_face[qp]},
     103       39372 :         _ti.determineState());
     104             : 
     105      166560 :     for (const auto i : index_range(_u_dof_indices))
     106             :     {
     107      254376 :       _scalar_re(i) -= _JxW_face[qp] * _face_diff[qp] * _scalar_phi_face[i][qp] *
     108      381564 :                        (_grad_u_sol[qp] * _normals[qp]);
     109      381564 :       _scalar_re(i) -= _JxW_face[qp] * _alpha / h_elem * _face_diff[qp] *
     110      508752 :                        (scalar_value - _u_sol[qp]) * _scalar_phi_face[i][qp];
     111      381564 :       _scalar_re(i) += _JxW_face[qp] * (scalar_value - _u_sol[qp]) * _face_diff[qp] *
     112      508752 :                        _grad_scalar_phi_face[i][qp] * _normals[qp];
     113             :     }
     114             :   }
     115       19236 : }

Generated by: LCOV version 1.14