LCOV - code coverage report
Current view: top level - src/kernels - BodyForce.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 21 22 95.5 %
Date: 2025-07-17 01:28:37 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 "BodyForce.h"
      11             : 
      12             : // MOOSE
      13             : #include "Function.h"
      14             : #include "Assembly.h"
      15             : 
      16             : registerMooseObject("MooseApp", BodyForce);
      17             : registerMooseObject("MooseApp", ADBodyForce);
      18             : 
      19             : template <bool is_ad>
      20             : InputParameters
      21       89194 : BodyForceTempl<is_ad>::validParams()
      22             : {
      23       89194 :   InputParameters params = GenericKernel<is_ad>::validParams();
      24       89194 :   params.addClassDescription("Demonstrates the multiple ways that scalar values can be introduced "
      25             :                              "into kernels, e.g. (controllable) constants, functions, and "
      26             :                              "postprocessors. Implements the weak form $(\\psi_i, -f)$.");
      27       89194 :   params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
      28       89194 :   params.addParam<FunctionName>("function", "1", "A function that describes the body force");
      29      267582 :   params.addParam<PostprocessorName>(
      30      178388 :       "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
      31       89194 :   params.declareControllable("value");
      32       89194 :   return params;
      33           0 : }
      34             : 
      35             : template <bool is_ad>
      36        9260 : BodyForceTempl<is_ad>::BodyForceTempl(const InputParameters & parameters)
      37             :   : GenericKernel<is_ad>(parameters),
      38        9260 :     _scale(this->template getParam<Real>("value")),
      39        9260 :     _function(getFunction("function")),
      40        9260 :     _postprocessor(getPostprocessorValue("postprocessor")),
      41        9260 :     _generic_q_point(this->_use_displaced_mesh ? &this->_assembly.template genericQPoints<is_ad>()
      42        9260 :                                                : nullptr)
      43             : {
      44        9260 : }
      45             : 
      46             : template <bool is_ad>
      47             : GenericReal<is_ad>
      48  2449818458 : BodyForceTempl<is_ad>::computeQpResidual()
      49             : {
      50  2449818458 :   if (_generic_q_point)
      51     7757440 :     return -_test[_i][_qp] * _scale * _postprocessor *
      52    16000640 :            _function.value(_t, (*_generic_q_point)[_qp]);
      53             :   else
      54  2506113246 :     return -_test[_i][_qp] * _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
      55             : }
      56             : 
      57             : template class BodyForceTempl<false>;
      58             : template class BodyForceTempl<true>;

Generated by: LCOV version 1.14