LCOV - code coverage report
Current view: top level - src/bcs - PresetVelocity.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 18 19 94.7 %
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 "PresetVelocity.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("TensorMechanicsApp", PresetVelocity);
      14             : 
      15             : InputParameters
      16          24 : PresetVelocity::validParams()
      17             : {
      18          24 :   InputParameters params = DirichletBCBase::validParams();
      19             : 
      20          48 :   params.addParam<Real>(
      21          48 :       "velocity", 1, "Value of the velocity.  Used as scale factor if function is given.");
      22          48 :   params.addParam<FunctionName>("function", "1", "Function describing the velocity.");
      23             : 
      24             :   // Forcefully preset the BC
      25          24 :   params.set<bool>("preset") = true;
      26          24 :   params.suppressParameter<bool>("preset");
      27             : 
      28          24 :   return params;
      29           0 : }
      30             : 
      31          12 : PresetVelocity::PresetVelocity(const InputParameters & parameters)
      32             :   : DirichletBCBase(parameters),
      33          12 :     _u_old(valueOld()),
      34          12 :     _velocity(parameters.get<Real>("velocity")),
      35          24 :     _function(getFunction("function"))
      36             : {
      37          12 : }
      38             : 
      39             : Real
      40       19296 : PresetVelocity::computeQpValue()
      41             : {
      42       19296 :   Real v2 = _function.value(_t, *_current_node);
      43       19296 :   Real v1 = _function.value(_t - _dt, *_current_node);
      44       19296 :   Real vel = _velocity * 0.5 * (v1 + v2);
      45             : 
      46       19296 :   return _u_old[_qp] + _dt * vel;
      47             : }

Generated by: LCOV version 1.14