LCOV - code coverage report
Current view: top level - src/kernels - VectorBodyForce.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 32 35 91.4 %
Date: 2026-05-29 20:35:17 Functions: 3 3 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 "VectorBodyForce.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("MooseApp", VectorBodyForce);
      14             : 
      15             : InputParameters
      16        3549 : VectorBodyForce::validParams()
      17             : {
      18        3549 :   InputParameters params = VectorKernel::validParams();
      19        7098 :   params.addClassDescription(
      20             :       "Demonstrates the multiple ways that scalar values can be introduced "
      21             :       "into kernels, e.g. (controllable) constants, functions, and "
      22             :       "postprocessors. Implements the weak form $(\\vec{\\psi_i}, -\\vec{f})$.");
      23       14196 :   params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
      24       14196 :   params.addParam<FunctionName>("function",
      25             :                                 "A function that defines a vectorValue method. This cannot be "
      26             :                                 "supplied with the component parameters.");
      27       14196 :   params.addParam<FunctionName>(
      28             :       "function_x", "1", "A function that describes the x-component of the body force");
      29       14196 :   params.addParam<FunctionName>(
      30             :       "function_y", "0", "A function that describes the y-component of the body force");
      31       14196 :   params.addParam<FunctionName>(
      32             :       "function_z", "0", "A function that describes the z-component of the body force");
      33        7098 :   params.addParam<PostprocessorName>(
      34        7098 :       "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
      35       10647 :   params.declareControllable("value");
      36        3549 :   return params;
      37           0 : }
      38             : 
      39         251 : VectorBodyForce::VectorBodyForce(const InputParameters & parameters)
      40             :   : VectorKernel(parameters),
      41         251 :     _scale(getParam<Real>("value")),
      42         664 :     _function(isParamValid("function") ? &getFunction("function") : nullptr),
      43         502 :     _function_x(getFunction("function_x")),
      44         502 :     _function_y(getFunction("function_y")),
      45         502 :     _function_z(getFunction("function_z")),
      46         753 :     _postprocessor(getPostprocessorValue("postprocessor"))
      47             : {
      48             : 
      49         413 :   if (_function && parameters.isParamSetByUser("function_x"))
      50           6 :     paramError("function_x", "The 'function' and 'function_x' parameters cannot both be set.");
      51         404 :   if (_function && parameters.isParamSetByUser("function_y"))
      52           0 :     paramError("function_y", "The 'function' and 'function_y' parameters cannot both be set.");
      53         404 :   if (_function && parameters.isParamSetByUser("function_z"))
      54           0 :     paramError("function_z", "The 'function' and 'function_z' parameters cannot both be set.");
      55         248 : }
      56             : 
      57             : Real
      58    26454012 : VectorBodyForce::computeQpResidual()
      59             : {
      60    26454012 :   Real factor = _scale * _postprocessor;
      61    26454012 :   if (_function)
      62      285696 :     return _test[_i][_qp] * -factor * _function->vectorValue(_t, _q_point[_qp]);
      63             :   else
      64    26168316 :     return _test[_i][_qp] * -factor *
      65    26168316 :            RealVectorValue(_function_x.value(_t, _q_point[_qp]),
      66    26168316 :                            _function_y.value(_t, _q_point[_qp]),
      67    52336632 :                            _function_z.value(_t, _q_point[_qp]));
      68             : }

Generated by: LCOV version 1.14