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

Generated by: LCOV version 1.14