LCOV - code coverage report
Current view: top level - src/bcs - SeismicForce.C (source / functions) Hit Total Coverage
Test: idaholab/mastodon: 55510a Lines: 47 50 94.0 %
Date: 2025-08-26 23:09:31 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*************************************************/
       2             : /*           DO NOT MODIFY THIS HEADER           */
       3             : /*                                               */
       4             : /*                     MASTODON                  */
       5             : /*                                               */
       6             : /*    (c) 2015 Battelle Energy Alliance, LLC     */
       7             : /*            ALL RIGHTS RESERVED                */
       8             : /*                                               */
       9             : /*   Prepared by Battelle Energy Alliance, LLC   */
      10             : /*     With the U. S. Department of Energy       */
      11             : /*                                               */
      12             : /*     See COPYRIGHT for full restrictions       */
      13             : /*************************************************/
      14             : #include "Function.h"
      15             : #include "MooseError.h"
      16             : #include "MooseMesh.h"
      17             : #include "SeismicForce.h"
      18             : 
      19             : registerMooseObject("MastodonApp", SeismicForce);
      20             : 
      21             : InputParameters
      22          25 : SeismicForce::validParams()
      23             : {
      24          25 :   InputParameters params = IntegratedBC::validParams();
      25          25 :   params.addClassDescription("Applies a seismic force on a given boundary in a "
      26             :                              "given direction proportional to input velocity.");
      27          50 :   params.addRequiredParam<unsigned int>("component",
      28             :                                         "The direction in which the force is applied.");
      29          50 :   params.addRequiredParam<unsigned int>("vel_component",
      30             :                                         "The direction in which the input velocity is applied.");
      31          50 :   params.addParam<Real>("factor", 1.0, "Scaling factor to be applied to the force.");
      32          50 :   params.addParam<FunctionName>("velocity_function",
      33             :                                 "The function that describes the input ground velocity.");
      34          50 :   params.addCoupledVar("velocity", "The variable that describes the input velocity.");
      35          50 :   params.addRequiredRangeCheckedParam<Real>(
      36             :       "density", "density>0.0", "Density of the underlying bedrock.");
      37          50 :   params.addRequiredRangeCheckedParam<Real>(
      38             :       "p_wave_speed", "p_wave_speed>0.0", "P-wave speed of the underlying bedrock.");
      39          50 :   params.addRequiredRangeCheckedParam<Real>(
      40             :       "shear_wave_speed", "shear_wave_speed>0.0", "shear wave speed of the underlying bedrock.");
      41          50 :   params.addParam<Real>(
      42          50 :       "alpha", 0.0, "The alpha parameter required for HHT time integration scheme.");
      43          25 :   params.set<bool>("use_displaced_mesh") = true;
      44          25 :   return params;
      45           0 : }
      46             : 
      47          21 : SeismicForce::SeismicForce(const InputParameters & parameters)
      48             :   : IntegratedBC(parameters),
      49          21 :     _component(getParam<unsigned int>("component")),
      50          42 :     _vel_component(getParam<unsigned int>("vel_component")),
      51          42 :     _factor(getParam<Real>("factor")),
      52          42 :     _alpha(getParam<Real>("alpha")),
      53          42 :     _density(getParam<Real>("density")),
      54          42 :     _p_wave_speed(getParam<Real>("p_wave_speed")),
      55          63 :     _shear_wave_speed(getParam<Real>("shear_wave_speed"))
      56             : {
      57          21 :   if (_component >= _mesh.dimension())
      58           2 :     mooseError("Invalid value for 'component' (",
      59           1 :                _component,
      60             :                ") given in \"",
      61             :                name(),
      62             :                "\" block, it must be a value from 0 to ",
      63           1 :                _mesh.dimension() - 1,
      64             :                ".");
      65             : 
      66          20 :   if (_vel_component >= _mesh.dimension())
      67           2 :     mooseError("Invalid value for 'vel_component' (",
      68           1 :                _vel_component,
      69             :                ") given in \"",
      70             :                name(),
      71             :                "\" block, it must be a value from 0 to ",
      72           1 :                _mesh.dimension() - 1,
      73             :                ".");
      74             : 
      75          40 :   if (!isParamValid("velocity_function") && !isParamValid("velocity"))
      76           1 :     mooseError("A function ('velocity_function') or variable ('velocity') "
      77             :                "describing the input velocity must be supplied in the \"",
      78             :                name(),
      79             :                "\" block.");
      80          18 : }
      81             : 
      82             : Real
      83     1410432 : SeismicForce::computeQpResidual()
      84             : {
      85     1410432 :   std::vector<Real> vel(3, 0.0);
      86     1410432 :   std::vector<Real> tangential_vel(3, 0.0);
      87             :   Real normal_vel(0.0);
      88             : 
      89     2820864 :   if (isParamValid("velocity_function"))
      90             :   {
      91     1410432 :     const Function * const velocity_function = &getFunction("velocity_function");
      92     1410432 :     vel[_vel_component] = velocity_function->value(_t + _alpha * _dt, _q_point[_qp]);
      93             :   }
      94             :   else
      95             :   {
      96           0 :     const VariableValue & velocity = coupledValue("velocity");
      97           0 :     vel[_vel_component] = velocity[_qp];
      98             :   }
      99             : 
     100     1410432 :   normal_vel = vel[_vel_component] * _normals[_qp](_vel_component);
     101             : 
     102     5641728 :   for (unsigned int i = 0; i < _mesh.dimension(); i++)
     103     4231296 :     tangential_vel[i] = vel[i] - normal_vel * _normals[_qp](i);
     104             : 
     105     1410432 :   return _factor * _test[_i][_qp] * _density *
     106     1410432 :          (_p_wave_speed * normal_vel * _normals[_qp](_component) +
     107     2820864 :           _shear_wave_speed * tangential_vel[_component]);
     108     1410432 : }

Generated by: LCOV version 1.14