LCOV - code coverage report
Current view: top level - src/kernels - Gravity.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 17 18 94.4 %
Date: 2025-07-25 05:00:39 Functions: 6 6 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 "Gravity.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", Gravity);
      14             : registerMooseObject("SolidMechanicsApp", ADGravity);
      15             : 
      16             : template <bool is_ad>
      17             : InputParameters
      18         168 : GravityTempl<is_ad>::validParams()
      19             : {
      20             :   InputParameters params = GenericKernel<is_ad>::validParams();
      21         168 :   params.addClassDescription("Apply gravity. Value is in units of acceleration.");
      22         336 :   params.addParam<bool>("use_displaced_mesh", true, "Displaced mesh defaults to true");
      23         336 :   params.addRequiredParam<Real>(
      24             :       "value", "Value multiplied against the residual, e.g. gravitational acceleration");
      25         336 :   params.addParam<FunctionName>(
      26             :       "function", "1", "A function that describes the gravitational force");
      27         336 :   params.addParam<Real>("alpha", 0.0, "alpha parameter required for HHT time integration scheme");
      28         336 :   params.addParam<MaterialPropertyName>("density", "density", "The density");
      29         168 :   return params;
      30           0 : }
      31             : 
      32             : template <bool is_ad>
      33          84 : GravityTempl<is_ad>::GravityTempl(const InputParameters & parameters)
      34             :   : GenericKernel<is_ad>(parameters),
      35          84 :     _density(this->template getGenericMaterialProperty<Real, is_ad>("density")),
      36         168 :     _value(this->template getParam<Real>("value")),
      37          84 :     _function(this->getFunction("function")),
      38         252 :     _alpha(this->template getParam<Real>("alpha"))
      39             : {
      40          84 : }
      41             : 
      42             : template <bool is_ad>
      43             : GenericReal<is_ad>
      44     6040960 : GravityTempl<is_ad>::computeQpResidual()
      45             : {
      46     6040960 :   Real factor = _value * _function.value(_t + _alpha * _dt, _q_point[_qp]);
      47     6040960 :   return _density[_qp] * _test[_i][_qp] * -factor;
      48             : }
      49             : 
      50             : template class GravityTempl<false>;
      51             : template class GravityTempl<true>;

Generated by: LCOV version 1.14