LCOV - code coverage report
Current view: top level - src/bcs - PresetVelocity.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 19 20 95.0 %
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 "PresetVelocity.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", PresetVelocity);
      14             : 
      15             : InputParameters
      16          56 : PresetVelocity::validParams()
      17             : {
      18          56 :   InputParameters params = DirichletBCBase::validParams();
      19          56 :   params.addClassDescription(
      20             :       "Sets the boundary displacements through time from an imposed velocity");
      21             : 
      22         112 :   params.addParam<Real>(
      23         112 :       "velocity", 1, "Value of the velocity.  Used as scale factor if function is given.");
      24         112 :   params.addParam<FunctionName>("function", "1", "Function describing the velocity.");
      25             : 
      26             :   // Forcefully preset the BC
      27          56 :   params.set<bool>("preset") = true;
      28          56 :   params.suppressParameter<bool>("preset");
      29             : 
      30          56 :   return params;
      31           0 : }
      32             : 
      33          28 : PresetVelocity::PresetVelocity(const InputParameters & parameters)
      34             :   : DirichletBCBase(parameters),
      35          28 :     _u_old(valueOld()),
      36          28 :     _velocity(parameters.get<Real>("velocity")),
      37          56 :     _function(getFunction("function"))
      38             : {
      39          28 : }
      40             : 
      41             : Real
      42       36200 : PresetVelocity::computeQpValue()
      43             : {
      44       36200 :   Real v2 = _function.value(_t, *_current_node);
      45       36200 :   Real v1 = _function.value(_t - _dt, *_current_node);
      46       36200 :   Real vel = _velocity * 0.5 * (v1 + v2);
      47             : 
      48       36200 :   return _u_old[_qp] + _dt * vel;
      49             : }

Generated by: LCOV version 1.14