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

Generated by: LCOV version 1.14