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

Generated by: LCOV version 1.14