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

Generated by: LCOV version 1.14