LCOV - code coverage report
Current view: top level - src/auxkernels - KineticEnergyAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 20 22 90.9 %
Date: 2025-07-25 05:00:39 Functions: 3 6 50.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 "KineticEnergyAux.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", KineticEnergyAux);
      13             : registerMooseObject("SolidMechanicsApp", ADKineticEnergyAux);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17          12 : KineticEnergyAuxTempl<is_ad>::validParams()
      18             : {
      19          12 :   InputParameters params = AuxKernel::validParams();
      20          12 :   params.addClassDescription("Compute the kinetic energy of continuum-based finite elements");
      21          24 :   params.addRequiredCoupledVar("newmark_velocity_x",
      22             :                                "X component of the velocity from the Newmark integration scheme");
      23          24 :   params.addRequiredCoupledVar("newmark_velocity_y",
      24             :                                "Y component of the velocity from the Newmark integration scheme");
      25          24 :   params.addRequiredCoupledVar("newmark_velocity_z",
      26             :                                "Z component of the velocity from the Newmark integration scheme");
      27             : 
      28          24 :   params.addParam<MaterialPropertyName>("density",
      29             :                                         "density",
      30             :                                         "Name of material property or a constant real number "
      31             :                                         "defining the density of the continuum material.");
      32          24 :   params.addParam<std::string>("base_name", "Mechanical property base name");
      33          12 :   return params;
      34           0 : }
      35             : 
      36             : template <bool is_ad>
      37           6 : KineticEnergyAuxTempl<is_ad>::KineticEnergyAuxTempl(const InputParameters & parameters)
      38             :   : AuxKernel(parameters),
      39           6 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      40           6 :     _density(getGenericMaterialProperty<Real, is_ad>(_base_name + "density")),
      41           6 :     _vel_x(coupledValue("newmark_velocity_x")),
      42           6 :     _vel_y(coupledValue("newmark_velocity_y")),
      43          12 :     _vel_z(coupledValue("newmark_velocity_z"))
      44             : {
      45           6 : }
      46             : 
      47             : template <bool is_ad>
      48             : Real
      49     1047840 : KineticEnergyAuxTempl<is_ad>::computeValue()
      50             : {
      51           0 :   const Real kinetic_energy = MetaPhysicL::raw_value(
      52     1047840 :       0.5 * _density[_qp] *
      53     1047840 :       (_vel_x[_qp] * _vel_x[_qp] + _vel_y[_qp] * _vel_y[_qp] + _vel_z[_qp] * _vel_z[_qp]));
      54     1047840 :   return kinetic_energy;
      55             : }
      56             : 
      57             : template class KineticEnergyAuxTempl<false>;
      58             : template class KineticEnergyAuxTempl<true>;

Generated by: LCOV version 1.14