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 48 : PresetVelocity::validParams() 17 : { 18 48 : InputParameters params = DirichletBCBase::validParams(); 19 48 : params.addClassDescription( 20 : "Sets the boundary displacements through time from an imposed velocity"); 21 : 22 96 : params.addParam<Real>( 23 96 : "velocity", 1, "Value of the velocity. Used as scale factor if function is given."); 24 96 : params.addParam<FunctionName>("function", "1", "Function describing the velocity."); 25 : 26 : // Forcefully preset the BC 27 48 : params.set<bool>("preset") = true; 28 48 : params.suppressParameter<bool>("preset"); 29 : 30 48 : return params; 31 0 : } 32 : 33 24 : PresetVelocity::PresetVelocity(const InputParameters & parameters) 34 : : DirichletBCBase(parameters), 35 24 : _u_old(valueOld()), 36 24 : _velocity(parameters.get<Real>("velocity")), 37 48 : _function(getFunction("function")) 38 : { 39 24 : } 40 : 41 : Real 42 28928 : PresetVelocity::computeQpValue() 43 : { 44 28928 : Real v2 = _function.value(_t, *_current_node); 45 28928 : Real v1 = _function.value(_t - _dt, *_current_node); 46 28928 : Real vel = _velocity * 0.5 * (v1 + v2); 47 : 48 28928 : return _u_old[_qp] + _dt * vel; 49 : }