LCOV - code coverage report
Current view: top level - src/kernels - MaterialVectorBodyForce.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 22 24 91.7 %
Date: 2025-09-04 07:57:23 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 "MaterialVectorBodyForce.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", MaterialVectorBodyForce);
      14             : 
      15             : InputParameters
      16          70 : MaterialVectorBodyForce::validParams()
      17             : {
      18          70 :   InputParameters params = Kernel::validParams();
      19          70 :   params.addClassDescription("Apply a body force vector to the coupled displacement component.");
      20         140 :   params.addParam<FunctionName>(
      21             :       "function", "1", "Function to scale the coupled body force vector property");
      22         140 :   params.addParam<Real>(
      23         140 :       "hht_alpha", 0.0, "alpha parameter required for HHT time integration scheme");
      24         140 :   params.addRequiredParam<MaterialPropertyName>("body_force", "Force per unit volume vector");
      25         140 :   params.addCoupledVar("displacements", "The displacements");
      26          70 :   return params;
      27           0 : }
      28             : 
      29          35 : MaterialVectorBodyForce::MaterialVectorBodyForce(const InputParameters & parameters)
      30             :   : Kernel(parameters),
      31          35 :     _component(libMesh::invalid_uint),
      32          35 :     _body_force(getMaterialProperty<RealVectorValue>("body_force")),
      33          35 :     _function(getFunction("function")),
      34         105 :     _alpha(getParam<Real>("hht_alpha"))
      35             : {
      36         252 :   for (unsigned int i = 0; i < coupledComponents("displacements"); ++i)
      37         182 :     if (_var.number() == getVar("displacements", i)->number())
      38          35 :       _component = i;
      39             : 
      40          35 :   if (_component == libMesh::invalid_uint)
      41           0 :     this->paramError("variable",
      42             :                      "The kernel variable needs to be one of the 'displacements' variables");
      43          35 : }
      44             : 
      45             : Real
      46      746240 : MaterialVectorBodyForce::computeQpResidual()
      47             : {
      48      746240 :   Real factor = _function.value(_t + _alpha * _dt, _q_point[_qp]);
      49      746240 :   return -_body_force[_qp](_component) * _test[_i][_qp] * factor;
      50             : }

Generated by: LCOV version 1.14