LCOV - code coverage report
Current view: top level - src/kernels - INSADEnergySource.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 24 28 85.7 %
Date: 2025-08-14 10:14:56 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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         164 : INSADEnergySource::validParams()
      18             : {
      19         164 :   InputParameters params = ADKernelValue::validParams();
      20         164 :   params.addClassDescription("Computes an arbitrary volumetric heat source (or sink).");
      21         328 :   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         328 :   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         164 :   return params;
      30           0 : }
      31             : 
      32          88 : INSADEnergySource::INSADEnergySource(const InputParameters & parameters)
      33             :   : ADKernelValue(parameters),
      34          88 :     _temperature_source_strong_residual(
      35          88 :         getADMaterialProperty<Real>("temperature_source_strong_residual"))
      36             : {
      37          88 :   bool has_coupled = isCoupled("source_variable");
      38          88 :   bool has_function = isParamValid("source_function");
      39          88 :   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          88 :   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         176 :   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          88 :       _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
      53         176 :   for (const auto block_id : blockIDs())
      54             :   {
      55          88 :     obj_tracker.set("has_heat_source", true, block_id);
      56          88 :     if (has_coupled)
      57          88 :       obj_tracker.set("heat_source_var", getVar("source_variable", 0)->name(), block_id);
      58          44 :     else if (has_function)
      59         132 :       obj_tracker.set("heat_source_function", getParam<FunctionName>("source_function"), block_id);
      60             :   }
      61          88 : }
      62             : 
      63             : ADReal
      64      331776 : INSADEnergySource::precomputeQpResidual()
      65             : {
      66      331776 :   return _temperature_source_strong_residual[_qp];
      67             : }

Generated by: LCOV version 1.14