LCOV - code coverage report
Current view: top level - src/bcs - PresetDisplacement.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 25 26 96.2 %
Date: 2024-02-27 11:53:14 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://www.mooseframework.org
       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("TensorMechanicsApp", PresetDisplacement);
      14             : 
      15             : InputParameters
      16          66 : PresetDisplacement::validParams()
      17             : {
      18          66 :   InputParameters params = DirichletBCBase::validParams();
      19          66 :   params.addClassDescription(
      20             :       "Prescribe the displacement on a given boundary in a given direction.");
      21             : 
      22         132 :   params.addParam<Real>("scale_factor", 1, "Scale factor if function is given.");
      23         132 :   params.addParam<FunctionName>("function", "1", "Function describing the displacement.");
      24         132 :   params.addRequiredCoupledVar("velocity", "The velocity variable.");
      25         132 :   params.addRequiredCoupledVar("acceleration", "The acceleration variable.");
      26         132 :   params.addRequiredParam<Real>("beta", "beta parameter for Newmark time integration.");
      27             : 
      28             :   // Forcefully preset the BC
      29          66 :   params.set<bool>("preset") = true;
      30          66 :   params.suppressParameter<bool>("preset");
      31             : 
      32          66 :   return params;
      33           0 : }
      34             : 
      35          33 : PresetDisplacement::PresetDisplacement(const InputParameters & parameters)
      36             :   : DirichletBCBase(parameters),
      37          33 :     _u_old(valueOld()),
      38          33 :     _scale_factor(parameters.get<Real>("scale_factor")),
      39          33 :     _function(getFunction("function")),
      40          33 :     _vel_old(coupledValueOld("velocity")),
      41          33 :     _accel_old(coupledValueOld("acceleration")),
      42          99 :     _beta(getParam<Real>("beta"))
      43             : {
      44          33 : }
      45             : 
      46             : Real
      47        8552 : PresetDisplacement::computeQpValue()
      48             : {
      49        8552 :   Real vel = _function.timeDerivative(_t);
      50        8552 :   Real vel_old = _function.timeDerivative(_t - _dt);
      51        8552 :   Real accel = (vel - vel_old) / _dt;
      52             : 
      53        8552 :   return _u_old[_qp] + _dt * _vel_old[_qp] +
      54        8552 :          ((0.5 - _beta) * _accel_old[_qp] + _beta * accel) * _dt * _dt;
      55             : }

Generated by: LCOV version 1.14