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 "ArrayBodyForce.h" 11 : 12 : #include "Function.h" 13 : 14 : registerMooseObject("MooseApp", ArrayBodyForce); 15 : 16 : InputParameters 17 14381 : ArrayBodyForce::validParams() 18 : { 19 14381 : InputParameters params = ArrayKernel::validParams(); 20 14381 : params.addRequiredParam<std::vector<FunctionName>>("function", "The body force functions."); 21 14381 : params.addClassDescription("Applies body forces specified with functions to an array variable."); 22 14381 : return params; 23 0 : } 24 : 25 56 : ArrayBodyForce::ArrayBodyForce(const InputParameters & parameters) : ArrayKernel(parameters) 26 : { 27 56 : auto & funcs = getParam<std::vector<FunctionName>>("function"); 28 56 : if (_var.count() != funcs.size()) 29 0 : paramError("function", 30 : "Number of functions must agree with the number of array variable components"); 31 182 : for (auto & func : funcs) 32 126 : _func.push_back(&getFunctionByName(func)); 33 56 : } 34 : 35 : void 36 5736600 : ArrayBodyForce::computeQpResidual(RealEigenVector & residual) 37 : { 38 28247856 : for (unsigned int p = 0; p < _count; ++p) 39 22511256 : residual(p) = -_test[_i][_qp] * _func[p]->value(_t, _q_point[_qp]); 40 5736600 : }