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 "PresetDisplacement.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("SolidMechanicsApp", PresetDisplacement); 14 : 15 : InputParameters 16 88 : PresetDisplacement::validParams() 17 : { 18 88 : InputParameters params = DirichletBCBase::validParams(); 19 88 : params.addClassDescription( 20 : "Prescribe the displacement on a given boundary in a given direction."); 21 : 22 176 : params.addParam<Real>("scale_factor", 1, "Scale factor if function is given."); 23 176 : params.addParam<FunctionName>("function", "1", "Function describing the displacement."); 24 176 : params.addRequiredCoupledVar("velocity", "The velocity variable."); 25 176 : params.addRequiredCoupledVar("acceleration", "The acceleration variable."); 26 176 : params.addRequiredParam<Real>("beta", "beta parameter for Newmark time integration."); 27 : 28 : // Forcefully preset the BC 29 88 : params.set<bool>("preset") = true; 30 88 : params.suppressParameter<bool>("preset"); 31 : 32 88 : return params; 33 0 : } 34 : 35 44 : PresetDisplacement::PresetDisplacement(const InputParameters & parameters) 36 : : DirichletBCBase(parameters), 37 44 : _u_old(valueOld()), 38 44 : _scale_factor(parameters.get<Real>("scale_factor")), 39 44 : _function(getFunction("function")), 40 44 : _vel_old(coupledValueOld("velocity")), 41 44 : _accel_old(coupledValueOld("acceleration")), 42 132 : _beta(getParam<Real>("beta")) 43 : { 44 44 : } 45 : 46 : Real 47 10044 : PresetDisplacement::computeQpValue() 48 : { 49 10044 : Real vel = _function.timeDerivative(_t); 50 10044 : Real vel_old = _function.timeDerivative(_t - _dt); 51 10044 : Real accel = (vel - vel_old) / _dt; 52 : 53 10044 : return _u_old[_qp] + _dt * _vel_old[_qp] + 54 10044 : ((0.5 - _beta) * _accel_old[_qp] + _beta * accel) * _dt * _dt; 55 : }