LCOV - code coverage report
Current view: top level - src/materials - DensityScaling.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 23 25 92.0 %
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             : //* This file is part of the MOOSE framework
       3             : //* https://www.mooseframework.org
       4             : //*
       5             : //* All rights reserved, see COPYRIGHT for full restrictions
       6             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       7             : //*
       8             : //* Licensed under LGPL 2.1, please see LICENSE for details
       9             : //* https://www.gnu.org/licenses/lgpl-2.1.html
      10             : 
      11             : #include "DensityScaling.h"
      12             : #include "libmesh/utility.h"
      13             : 
      14             : registerMooseObject("TensorMechanicsApp", DensityScaling);
      15             : 
      16             : InputParameters
      17          12 : DensityScaling::validParams()
      18             : {
      19          12 :   InputParameters params = Material::validParams();
      20          24 :   params.addRequiredParam<MaterialPropertyName>(
      21             :       "density",
      22             :       "Name of Material Property or a constant real number defining the density of the material.");
      23          24 :   params.addRequiredParam<Real>("desired_time_step", "Time step to achieve.");
      24          24 :   params.addParam<Real>(
      25             :       "factor",
      26          24 :       1.0,
      27             :       "Factor to multiply to the critical time step. This factor is typically less than one to be "
      28             :       "on the conservative side due to two types of approximation: Time step lagging and the "
      29             :       "approximation of the critical time step formula.");
      30          12 :   return params;
      31           0 : }
      32             : 
      33           9 : DensityScaling::DensityScaling(const InputParameters & parameters)
      34             :   : Material(parameters),
      35           9 :     _desired_time_step(getParam<Real>("desired_time_step")),
      36           9 :     _density_scaling(declareProperty<Real>("density_scaling")),
      37          18 :     _material_density(getMaterialPropertyByName<Real>("density")),
      38          18 :     _effective_stiffness(getMaterialPropertyByName<Real>("effective_stiffness")),
      39          27 :     _factor(getParam<Real>("factor"))
      40             : {
      41             :   mooseInfo("Since it can change key simulation results, usage of selective density (mass) scaling "
      42             :             "is only recommended for advanced users.");
      43           9 : }
      44             : 
      45             : void
      46         320 : DensityScaling::computeQpProperties()
      47             : {
      48         320 :   const Real critical = _factor * _current_elem->hmin() * std::sqrt(_material_density[_qp]) /
      49         320 :                         (_effective_stiffness[0]);
      50             : 
      51         320 :   if (critical < _desired_time_step)
      52             :   {
      53         320 :     const Real desired_density = std::pow(_effective_stiffness[_qp] * _desired_time_step, 2) /
      54         320 :                                  std::pow(_factor * _current_elem->hmin(), 2);
      55             : 
      56             :     const Real density_to_add =
      57         320 :         desired_density > _material_density[_qp] ? desired_density - _material_density[_qp] : 0.0;
      58             : 
      59         320 :     _density_scaling[_qp] = density_to_add;
      60             :   }
      61             :   else
      62           0 :     _density_scaling[_qp] = 0.0;
      63         320 : }

Generated by: LCOV version 1.14