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 "FVBodyForce.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("MooseApp", FVBodyForce); 14 : 15 : InputParameters 16 19124 : FVBodyForce::validParams() 17 : { 18 19124 : InputParameters params = FVElementalKernel::validParams(); 19 19124 : params.addClassDescription( 20 : "Demonstrates the multiple ways that scalar values can be introduced " 21 : "into finite volume kernels, e.g. (controllable) constants, functions, and " 22 : "postprocessors."); 23 19124 : params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term"); 24 19124 : params.addParam<FunctionName>("function", "1", "A function that describes the body force"); 25 57372 : params.addParam<PostprocessorName>( 26 38248 : "postprocessor", 1, "A postprocessor whose value is multiplied by the body force"); 27 19124 : params.declareControllable("value"); 28 19124 : return params; 29 0 : } 30 : 31 2456 : FVBodyForce::FVBodyForce(const InputParameters & parameters) 32 : : FVElementalKernel(parameters), 33 2456 : _scale(getParam<Real>("value")), 34 2456 : _function(getFunction("function")), 35 4912 : _postprocessor(getPostprocessorValue("postprocessor")) 36 : { 37 2456 : } 38 : 39 : ADReal 40 12116955 : FVBodyForce::computeQpResidual() 41 : { 42 : // FVKernels are not evaluated at quadrature points like our finite element kernels. 43 : // computeQpResidual is currrently only called once per element. With that in mind we'll just read 44 : // our function at the element centroid 45 12116955 : Real factor = _scale * _postprocessor * _function.value(_t, _current_elem->vertex_average()); 46 24233910 : return -factor; 47 : }