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

Generated by: LCOV version 1.14