Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* This file is part of the MOOSE framework 3 : //* https://mooseframework.inl.gov 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("SolidMechanicsApp", DensityScaling); 15 : 16 : InputParameters 17 24 : DensityScaling::validParams() 18 : { 19 24 : InputParameters params = Material::validParams(); 20 24 : params.addClassDescription("Automatically scale the material density to achieve the desired time " 21 : "step size to satisfy CFL conditions."); 22 48 : params.addRequiredParam<MaterialPropertyName>( 23 : "density", 24 : "Name of Material Property or a constant real number defining the density of the material."); 25 48 : params.addRequiredParam<Real>("desired_time_step", "Time step to achieve."); 26 48 : params.addParam<Real>( 27 : "factor", 28 48 : 1.0, 29 : "Factor to multiply to the critical time step. This factor is typically less than one to be " 30 : "on the conservative side due to two types of approximation: Time step lagging and the " 31 : "approximation of the critical time step formula."); 32 24 : return params; 33 0 : } 34 : 35 18 : DensityScaling::DensityScaling(const InputParameters & parameters) 36 : : Material(parameters), 37 18 : _desired_time_step(getParam<Real>("desired_time_step")), 38 18 : _density_scaling(declareProperty<Real>("density_scaling")), 39 36 : _material_density(getMaterialPropertyByName<Real>("density")), 40 36 : _effective_stiffness(getMaterialPropertyByName<Real>("effective_stiffness")), 41 54 : _factor(getParam<Real>("factor")) 42 : { 43 18 : mooseInfo("Since it can change key simulation results, usage of selective density (mass) scaling " 44 : "is only recommended for advanced users."); 45 18 : } 46 : 47 : void 48 640 : DensityScaling::computeQpProperties() 49 : { 50 640 : const Real critical = _factor * _current_elem->hmin() * std::sqrt(_material_density[_qp]) / 51 640 : (_effective_stiffness[0]); 52 : 53 640 : if (critical < _desired_time_step) 54 : { 55 640 : const Real desired_density = std::pow(_effective_stiffness[_qp] * _desired_time_step, 2) / 56 640 : std::pow(_factor * _current_elem->hmin(), 2); 57 : 58 : const Real density_to_add = 59 640 : desired_density > _material_density[_qp] ? desired_density - _material_density[_qp] : 0.0; 60 : 61 640 : _density_scaling[_qp] = density_to_add; 62 : } 63 : else 64 0 : _density_scaling[_qp] = 0.0; 65 640 : }