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 14615 : VectorBodyForce::validParams() 17 : { 18 14615 : InputParameters params = VectorKernel::validParams(); 19 14615 : 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 14615 : params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term"); 24 14615 : params.addParam<FunctionName>("function", 25 : "A function that defines a vectorValue method. This cannot be " 26 : "supplied with the component parameters."); 27 14615 : params.addParam<FunctionName>( 28 : "function_x", "1", "A function that describes the x-component of the body force"); 29 14615 : params.addParam<FunctionName>( 30 : "function_y", "0", "A function that describes the y-component of the body force"); 31 14615 : params.addParam<FunctionName>( 32 : "function_z", "0", "A function that describes the z-component of the body force"); 33 43845 : params.addParam<PostprocessorName>( 34 29230 : "postprocessor", 1, "A postprocessor whose value is multiplied by the body force"); 35 14615 : params.declareControllable("value"); 36 14615 : return params; 37 0 : } 38 : 39 178 : VectorBodyForce::VectorBodyForce(const InputParameters & parameters) 40 : : VectorKernel(parameters), 41 178 : _scale(getParam<Real>("value")), 42 178 : _function(isParamValid("function") ? &getFunction("function") : nullptr), 43 178 : _function_x(getFunction("function_x")), 44 178 : _function_y(getFunction("function_y")), 45 178 : _function_z(getFunction("function_z")), 46 356 : _postprocessor(getPostprocessorValue("postprocessor")) 47 : { 48 : 49 178 : if (_function && parameters.isParamSetByUser("function_x")) 50 4 : paramError("function_x", "The 'function' and 'function_x' parameters cannot both be set."); 51 174 : if (_function && parameters.isParamSetByUser("function_y")) 52 0 : paramError("function_y", "The 'function' and 'function_y' parameters cannot both be set."); 53 174 : if (_function && parameters.isParamSetByUser("function_z")) 54 0 : paramError("function_z", "The 'function' and 'function_z' parameters cannot both be set."); 55 174 : } 56 : 57 : Real 58 26466757 : VectorBodyForce::computeQpResidual() 59 : { 60 26466757 : Real factor = _scale * _postprocessor; 61 26466757 : if (_function) 62 0 : return _test[_i][_qp] * -factor * _function->vectorValue(_t, _q_point[_qp]); 63 : else 64 26466757 : return _test[_i][_qp] * -factor * 65 26466757 : RealVectorValue(_function_x.value(_t, _q_point[_qp]), 66 26466757 : _function_y.value(_t, _q_point[_qp]), 67 52933514 : _function_z.value(_t, _q_point[_qp])); 68 : }