LCOV - code coverage report
Current view: top level - src/bcs - DashpotBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 0 32 0.0 %
Date: 2025-07-25 05:00:39 Functions: 0 5 0.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 "DashpotBC.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", DashpotBC);
      13             : 
      14             : InputParameters
      15           0 : DashpotBC::validParams()
      16             : {
      17           0 :   InputParameters params = IntegratedBC::validParams();
      18           0 :   params.addClassDescription(
      19             :       "Model a dashpot boundary condition where the traction is proportional "
      20             :       "to the normal velocity.");
      21           0 :   params.addRequiredParam<unsigned int>(
      22             :       "component", "The displacement component corresponding the variable this BC acts on.");
      23           0 :   params.addRequiredCoupledVar("disp_x", "Displacement in the x direction");
      24           0 :   params.addCoupledVar("disp_y", "Displacement in the y direction");
      25           0 :   params.addCoupledVar("disp_z", "Displacement in the z direction");
      26             : 
      27           0 :   params.addParam<Real>("coefficient", 1.0, "The viscosity coefficient");
      28             : 
      29           0 :   return params;
      30           0 : }
      31             : 
      32           0 : DashpotBC::DashpotBC(const InputParameters & parameters)
      33             :   : IntegratedBC(parameters),
      34           0 :     _component(getParam<unsigned int>("component")),
      35           0 :     _coefficient(getParam<Real>("coefficient")),
      36           0 :     _disp_x_var(coupled("disp_x")),
      37           0 :     _disp_y_var(isCoupled("disp_y") ? coupled("disp_y") : 0),
      38           0 :     _disp_z_var(isCoupled("disp_z") ? coupled("disp_z") : 0),
      39             : 
      40           0 :     _disp_x_dot(coupledDot("disp_x")),
      41           0 :     _disp_y_dot(isCoupled("disp_y") ? coupledDot("disp_y") : _zero),
      42           0 :     _disp_z_dot(isCoupled("disp_z") ? coupledDot("disp_z") : _zero)
      43             : {
      44           0 : }
      45             : 
      46             : Real
      47           0 : DashpotBC::computeQpResidual()
      48             : {
      49           0 :   RealVectorValue velocity(_disp_x_dot[_qp], _disp_y_dot[_qp], _disp_z_dot[_qp]);
      50             : 
      51           0 :   return _test[_i][_qp] * _coefficient * _normals[_qp] * velocity;
      52             : }
      53             : 
      54             : Real
      55           0 : DashpotBC::computeQpJacobian()
      56             : {
      57             :   RealVectorValue velocity;
      58           0 :   velocity(_component) = _phi[_j][_qp] / _dt;
      59             : 
      60           0 :   return _test[_i][_qp] * _coefficient * _normals[_qp] * velocity;
      61             : }
      62             : 
      63             : Real
      64           0 : DashpotBC::computeQpOffDiagJacobian(unsigned int jvar)
      65             : {
      66             :   RealVectorValue velocity;
      67             :   unsigned int component = 0;
      68             : 
      69           0 :   if (jvar == _disp_x_var)
      70             :     component = 0;
      71           0 :   else if (jvar == _disp_y_var)
      72             :     component = 1;
      73           0 :   else if (jvar == _disp_z_var)
      74             :     component = 2;
      75             : 
      76           0 :   velocity(component) = _phi[_j][_qp] / _dt;
      77             : 
      78           0 :   return -_test[_i][_qp] * _normals[_qp] * velocity;
      79             : }

Generated by: LCOV version 1.14