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