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