LCOV - code coverage report
Current view: top level - src/bcs - DirectionalFluxBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 25 27 92.6 %
Date: 2025-09-04 07:53:51 Functions: 4 4 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 "DirectionalFluxBC.h"
      11             : #include "SelfShadowSideUserObject.h"
      12             : 
      13             : registerMooseObject("HeatTransferApp", DirectionalFluxBC);
      14             : 
      15             : InputParameters
      16         780 : DirectionalFluxBC::validParams()
      17             : {
      18         780 :   InputParameters params = FunctionNeumannBC::validParams();
      19         780 :   params.addClassDescription(
      20             :       "Applies a directional flux multiplied by the surface normal vector. "
      21             :       "Can utilize the self shadowing calculation from a SelfShadowSideUserObject.");
      22        1560 :   params.addRequiredParam<RealVectorValue>("illumination_flux",
      23             :                                            "Radiation direction and magnitude vector");
      24        1560 :   params.addParam<UserObjectName>(
      25             :       "self_shadow_uo",
      26             :       "SelfShadowSideUserObject that calculates the illumination state of a side set");
      27        1560 :   params.set<FunctionName>("function") = "1";
      28         780 :   return params;
      29           0 : }
      30             : 
      31         420 : DirectionalFluxBC::DirectionalFluxBC(const InputParameters & parameters)
      32             :   : FunctionNeumannBC(parameters),
      33         420 :     _direction(getParam<RealVectorValue>("illumination_flux")),
      34         420 :     _self_shadow(isParamValid("self_shadow_uo")
      35         784 :                      ? &getUserObject<SelfShadowSideUserObject>("self_shadow_uo")
      36         420 :                      : nullptr)
      37             : {
      38        1512 :   if (_self_shadow && _self_shadow->useDisplacedMesh() != getParam<bool>("use_displaced_mesh"))
      39           0 :     paramWarning("use_displaced_mesh",
      40             :                  "The SelfShadowSideUserObject should operate on the same mesh (displaced or "
      41             :                  "undisplaced) as this BC.");
      42         420 : }
      43             : 
      44             : void
      45     2537364 : DirectionalFluxBC::precalculateResidual()
      46             : {
      47     2537364 :   if (_self_shadow)
      48             :   {
      49     2448012 :     const SelfShadowSideUserObject::SideIDType id(_current_elem->id(), _current_side);
      50     2448012 :     _illumination = _self_shadow->illumination(id);
      51             :   }
      52             :   else
      53             :     // all bits set
      54       89352 :     _illumination = ~0u;
      55     2537364 : }
      56             : 
      57             : Real
      58   201746412 : DirectionalFluxBC::computeQpResidual()
      59             : {
      60   201746412 :   auto projected_flux = -_direction * _normals[_qp];
      61   201746412 :   if (projected_flux > 0)
      62             :   {
      63             :     // tests if the bit at position _qp is set
      64   200513196 :     if (_illumination & (1 << _qp))
      65   150332538 :       return FunctionNeumannBC::computeQpResidual() * projected_flux;
      66             :   }
      67             :   return 0.0;
      68             : }

Generated by: LCOV version 1.14