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 "INSADEnergySource.h" 11 : #include "INSADObjectTracker.h" 12 : #include "FEProblemBase.h" 13 : 14 : registerMooseObject("NavierStokesApp", INSADEnergySource); 15 : 16 : InputParameters 17 76 : INSADEnergySource::validParams() 18 : { 19 76 : InputParameters params = ADKernelValue::validParams(); 20 76 : params.addClassDescription("Computes an arbitrary volumetric heat source (or sink)."); 21 152 : params.addCoupledVar( 22 : "source_variable", 23 : "Variable describing the volumetric heat source. Note that if this variable evaluates to a " 24 : "negative number, then this object will be an energy sink"); 25 152 : params.addParam<FunctionName>( 26 : "source_function", 27 : "Function describing the volumetric heat source. Note that if this function evaluates to a " 28 : "negative number, then this object will be an energy sink"); 29 76 : return params; 30 0 : } 31 : 32 40 : INSADEnergySource::INSADEnergySource(const InputParameters & parameters) 33 : : ADKernelValue(parameters), 34 40 : _temperature_source_strong_residual( 35 40 : getADMaterialProperty<Real>("temperature_source_strong_residual")) 36 : { 37 40 : bool has_coupled = isCoupled("source_variable"); 38 40 : bool has_function = isParamValid("source_function"); 39 40 : if (!has_coupled && !has_function) 40 0 : mooseError("Either the 'source_variable' or 'source_function' param must be set for the " 41 : "'INSADMomentumCoupledForce' object"); 42 40 : else if (has_coupled && has_function) 43 0 : mooseError("Both the 'source_variable' or 'source_function' param are set for the " 44 : "'INSADMomentumCoupledForce' object. Please use one or the other."); 45 : 46 80 : if (has_coupled && coupledComponents("source_variable") != 1) 47 0 : paramError("source_variable", "Only expect one variable for the 'source_variable' parameter"); 48 : 49 : // Bypass the UserObjectInterface method because it requires a UserObjectName param which we 50 : // don't need 51 : auto & obj_tracker = const_cast<INSADObjectTracker &>( 52 40 : _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker")); 53 80 : for (const auto block_id : blockIDs()) 54 : { 55 40 : obj_tracker.set("has_heat_source", true, block_id); 56 40 : if (has_coupled) 57 40 : obj_tracker.set("heat_source_var", getVar("source_variable", 0)->name(), block_id); 58 20 : else if (has_function) 59 60 : obj_tracker.set("heat_source_function", getParam<FunctionName>("source_function"), block_id); 60 : } 61 40 : } 62 : 63 : ADReal 64 221184 : INSADEnergySource::precomputeQpResidual() 65 : { 66 221184 : return _temperature_source_strong_residual[_qp]; 67 : }