LCOV - code coverage report
Current view: top level - src/hdgkernels - IPHDGAssemblyHelper.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 58 59 98.3 %
Date: 2025-09-04 07:52:05 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 "IPHDGAssemblyHelper.h"
      11             : #include "MooseTypes.h"
      12             : #include "MooseVariableDependencyInterface.h"
      13             : #include "MooseVariableFE.h"
      14             : #include "MooseVariableScalar.h"
      15             : #include "SystemBase.h"
      16             : #include "MooseMesh.h"
      17             : #include "MooseObject.h"
      18             : #include "MaterialPropertyInterface.h"
      19             : #include "TransientInterface.h"
      20             : 
      21             : using namespace libMesh;
      22             : 
      23             : InputParameters
      24      102760 : IPHDGAssemblyHelper::validParams()
      25             : {
      26      102760 :   auto params = emptyInputParameters();
      27      308280 :   params.addRequiredParam<NonlinearVariableName>("face_variable", "The face variable");
      28      102760 :   return params;
      29           0 : }
      30             : 
      31        1460 : IPHDGAssemblyHelper::IPHDGAssemblyHelper(const MooseObject * const moose_obj,
      32             :                                          MooseVariableDependencyInterface * const mvdi,
      33             :                                          const TransientInterface * const ti,
      34             :                                          SystemBase & sys,
      35             :                                          const Assembly & assembly,
      36             :                                          const THREAD_ID tid,
      37             :                                          const std::set<SubdomainID> & block_ids,
      38        1460 :                                          const std::set<BoundaryID> & boundary_ids)
      39             :   : ThreeMaterialPropertyInterface(moose_obj, block_ids, boundary_ids),
      40        1460 :     _ti(*ti),
      41        1460 :     _u_var(sys.getFieldVariable<Real>(tid, moose_obj->getParam<NonlinearVariableName>("variable"))),
      42        2920 :     _u_face_var(sys.getFieldVariable<Real>(
      43        2920 :         tid, moose_obj->getParam<NonlinearVariableName>("face_variable"))),
      44        1460 :     _u_dof_indices(_u_var.dofIndices()),
      45        1460 :     _lm_u_dof_indices(_u_face_var.dofIndices()),
      46        1460 :     _u_sol(_u_var.adSln()),
      47        1460 :     _grad_u_sol(_u_var.adGradSln()),
      48        1460 :     _lm_u_sol(_u_face_var.adSln()),
      49        1460 :     _scalar_phi(_u_var.phi()),
      50        1460 :     _grad_scalar_phi(_u_var.gradPhi()),
      51        1460 :     _scalar_phi_face(_u_var.phiFace()),
      52        1460 :     _grad_scalar_phi_face(_u_var.gradPhiFace()),
      53        1460 :     _lm_phi_face(_u_face_var.phiFace()),
      54        1460 :     _elem_volume(assembly.elemVolume()),
      55        1460 :     _side_area(assembly.sideElemVolume()),
      56        1460 :     _ip_current_elem(assembly.elem()),
      57        1460 :     _ip_current_side(assembly.side()),
      58        1460 :     _ip_JxW(assembly.JxW()),
      59        1460 :     _ip_qrule(assembly.qRule()),
      60        1460 :     _ip_q_point(assembly.qPoints()),
      61        1460 :     _ip_JxW_face(assembly.JxWFace()),
      62        1460 :     _ip_qrule_face(assembly.qRuleFace()),
      63        1460 :     _ip_q_point_face(assembly.qPointsFace()),
      64        2920 :     _ip_normals(assembly.normals())
      65             : {
      66        1460 :   mvdi->addMooseVariableDependency(&const_cast<MooseVariableFE<Real> &>(_u_var));
      67        1460 :   mvdi->addMooseVariableDependency(&const_cast<MooseVariableFE<Real> &>(_u_face_var));
      68        1460 : }
      69             : 
      70             : std::array<ADResidualsPacket, 2>
      71     5116841 : IPHDGAssemblyHelper::taggingData() const
      72             : {
      73     5116841 :   return {ADResidualsPacket{_scalar_re, _u_dof_indices, _u_var.scalingFactor()},
      74     5116841 :           ADResidualsPacket{_lm_re, _lm_u_dof_indices, _u_face_var.scalingFactor()}};
      75             : }
      76             : 
      77             : std::set<std::string>
      78         589 : IPHDGAssemblyHelper::additionalROVariables()
      79             : {
      80        1767 :   return {_u_face_var.name()};
      81         589 : }
      82             : 
      83             : void
      84      106601 : IPHDGAssemblyHelper::lmDirichlet(const Moose::Functor<Real> & dirichlet_value)
      85             : {
      86      321000 :   for (const auto qp : make_range(_ip_qrule_face->n_points()))
      87             :   {
      88      643197 :     const auto scalar_value = dirichlet_value(
      89      214399 :         Moose::ElemSideQpArg{
      90      214399 :             _ip_current_elem, _ip_current_side, qp, _ip_qrule_face, _ip_q_point_face[qp]},
      91      214399 :         _ti.determineState());
      92             : 
      93     1802709 :     for (const auto i : index_range(_lm_re))
      94     1588310 :       _lm_re(i) += _ip_JxW_face[qp] * (_lm_u_sol[qp] - scalar_value) * _lm_phi_face[i][qp];
      95             :   }
      96      106601 : }
      97             : 
      98             : void
      99       12398 : IPHDGAssemblyHelper::lmPrescribedFlux(const Moose::Functor<Real> & flux_value)
     100             : {
     101       38454 :   for (const auto qp : make_range(_ip_qrule_face->n_points()))
     102             :   {
     103       78168 :     const auto flux = flux_value(
     104       26056 :         Moose::ElemSideQpArg{
     105       26056 :             _ip_current_elem, _ip_current_side, qp, _ip_qrule_face, _ip_q_point_face[qp]},
     106       26056 :         _ti.determineState());
     107             : 
     108      230976 :     for (const auto i : index_range(_lm_re))
     109      204920 :       _lm_re(i) += _ip_JxW_face[qp] * flux * _lm_phi_face[i][qp];
     110             :   }
     111       12398 : }

Generated by: LCOV version 1.14