LCOV - code coverage report
Current view: top level - src/linearfvkernels - LinearFVTimeDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 28 96.4 %
Date: 2025-07-17 01:28:37 Functions: 5 5 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 "LinearFVTimeDerivative.h"
      11             : 
      12             : registerMooseObject("MooseApp", LinearFVTimeDerivative);
      13             : 
      14             : InputParameters
      15       14313 : LinearFVTimeDerivative::validParams()
      16             : {
      17       14313 :   InputParameters params = LinearFVElementalKernel::validParams();
      18       14313 :   params.addClassDescription("Represents the matrix and right hand side contributions of a "
      19             :                              "time derivative term in a partial differential equation.");
      20       42939 :   params.addParam<MooseFunctorName>(
      21       28626 :       "factor", 1.0, "A multiplier on the variable within the time derivative.");
      22       14313 :   return params;
      23           0 : }
      24             : 
      25          24 : LinearFVTimeDerivative::LinearFVTimeDerivative(const InputParameters & params)
      26             :   : LinearFVElementalKernel(params),
      27          24 :     _factor(getFunctor<Real>("factor")),
      28          24 :     _time_integrator(_sys.getTimeIntegrator(_var_num)),
      29          24 :     _factor_history(_time_integrator.numStatesRequired(), 0.0),
      30          48 :     _state_args(_time_integrator.numStatesRequired(), determineState())
      31             : {
      32             :   // In case we need older states
      33          48 :   for (const auto i : index_range(_state_args))
      34          24 :     _state_args[i] = Moose::StateArg(i, Moose::SolutionIterationType::Time);
      35          24 : }
      36             : 
      37             : Real
      38       10400 : LinearFVTimeDerivative::computeMatrixContribution()
      39             : {
      40       10400 :   const auto elem_arg = makeElemArg(_current_elem_info->elem());
      41       10400 :   return _time_integrator.timeDerivativeMatrixContribution(_factor(elem_arg, _state_args[0])) *
      42       10400 :          _current_elem_volume;
      43             : }
      44             : 
      45             : Real
      46       10400 : LinearFVTimeDerivative::computeRightHandSideContribution()
      47             : {
      48       10400 :   return _time_integrator.timeDerivativeRHSContribution(_dof_id, _factor_history) *
      49       10400 :          _current_elem_volume;
      50             : }
      51             : 
      52             : void
      53       10400 : LinearFVTimeDerivative::setCurrentElemInfo(const ElemInfo * elem_info)
      54             : {
      55       10400 :   LinearFVElementalKernel::setCurrentElemInfo(elem_info);
      56             : 
      57       10400 :   const auto elem_arg = makeElemArg(_current_elem_info->elem());
      58       20800 :   for (const auto i : index_range(_factor_history))
      59       10400 :     _factor_history[i] = _factor(elem_arg, _state_args[i]);
      60       10400 : }

Generated by: LCOV version 1.14