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 "LinearFVSource.h" 11 : #include "Assembly.h" 12 : #include "SubProblem.h" 13 : 14 : registerMooseObject("MooseApp", LinearFVSource); 15 : 16 : InputParameters 17 16483 : LinearFVSource::validParams() 18 : { 19 16483 : InputParameters params = LinearFVElementalKernel::validParams(); 20 16483 : params.addClassDescription( 21 : "Represents the matrix and right hand side contributions of a " 22 : "solution-independent source term in a partial differential equation."); 23 16483 : params.addParam<MooseFunctorName>("source_density", 1.0, "The source density."); 24 49449 : params.addParam<MooseFunctorName>( 25 32966 : "scaling_factor", 1.0, "Coefficient to multiply the body force term with."); 26 16483 : return params; 27 0 : } 28 : 29 1109 : LinearFVSource::LinearFVSource(const InputParameters & params) 30 : : LinearFVElementalKernel(params), 31 1109 : _source_density(getFunctor<Real>("source_density")), 32 2218 : _scale(getFunctor<Real>("scaling_factor")) 33 : { 34 1109 : } 35 : 36 : Real 37 1478808 : LinearFVSource::computeMatrixContribution() 38 : { 39 : // This doesn't contribute to the matrix as we assumed it was independent of 40 : // the solution 41 1478808 : return 0.0; 42 : } 43 : 44 : Real 45 1478808 : LinearFVSource::computeRightHandSideContribution() 46 : { 47 1478808 : const auto elem_arg = makeElemArg(_current_elem_info->elem()); 48 1478808 : const auto state_arg = determineState(); 49 : 50 : // The contribution to the right hand side is s_C*V_C 51 1478808 : return _scale(elem_arg, state_arg) * _source_density(elem_arg, state_arg) * _current_elem_volume; 52 : }