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 "CriticalTimeStep.h" 11 : 12 : registerMooseObject("SolidMechanicsApp", CriticalTimeStep); 13 : 14 : InputParameters 15 46 : CriticalTimeStep::validParams() 16 : { 17 46 : InputParameters params = ElementPostprocessor::validParams(); 18 46 : params.addClassDescription( 19 : "Computes and reports the critical time step for the explicit solver."); 20 92 : params.addParam<MaterialPropertyName>( 21 : "density", "density", "Name of Material Property defining the density of the material."); 22 92 : params.addParam<MaterialPropertyName>( 23 : "density_scaling", "Name of material property to add mass scaling in explicit simulations."); 24 92 : params.addParam<Real>("factor", 1.0, "Factor to mulitply to the critical time step."); 25 46 : return params; 26 0 : } 27 : 28 23 : CriticalTimeStep::CriticalTimeStep(const InputParameters & parameters) 29 : : ElementPostprocessor(parameters), 30 : GuaranteeConsumer(this), 31 23 : _material_density(getMaterialProperty<Real>("density")), 32 46 : _density_scaling(parameters.isParamSetByUser("density_scaling") 33 31 : ? &getMaterialPropertyByName<Real>("density_scaling") 34 : : nullptr), 35 23 : _sqrt_effective_stiffness(getMaterialPropertyByName<Real>("effective_stiffness")), 36 46 : _factor(getParam<Real>("factor")), 37 46 : _critical_time(parameters.isParamValid("critical_time")) 38 : { 39 23 : } 40 : 41 : void 42 23 : CriticalTimeStep::initialSetup() 43 : { 44 46 : if (!hasGuaranteedMaterialProperty("effective_stiffness", Guarantee::ISOTROPIC)) 45 1 : paramError("CriticalTimeStep can only be used with elasticity tensor materials " 46 : "that guarantee isotropic tensors."); 47 22 : } 48 : 49 : void 50 34 : CriticalTimeStep::initialize() 51 : { 52 34 : _critical_time = std::numeric_limits<Real>::max(); 53 34 : } 54 : 55 : void 56 6280 : CriticalTimeStep::execute() 57 : { 58 6280 : const Real dens = _material_density[0]; 59 6280 : const Real dens_scaling = _density_scaling ? (*_density_scaling)[0] : 0.0; 60 : 61 : // In the above line, density is inferred only at the first quadrature point 62 : // of each element. Since critical time step is computed across all elements and 63 : // a minimum is then taken, this is okay. 64 18840 : _critical_time = std::min(_factor * _current_elem->hmin() * std::sqrt(dens + dens_scaling) / 65 6280 : (_sqrt_effective_stiffness[0]), 66 6280 : _critical_time); 67 6280 : } 68 : 69 : void 70 34 : CriticalTimeStep::finalize() 71 : { 72 34 : gatherMin(_critical_time); 73 34 : } 74 : 75 : Real 76 34 : CriticalTimeStep::getValue() const 77 : { 78 34 : return _critical_time; 79 : } 80 : 81 : void 82 0 : CriticalTimeStep::threadJoin(const UserObject & y) 83 : { 84 : const auto & pps = static_cast<const CriticalTimeStep &>(y); 85 0 : _critical_time = std::min(pps._critical_time, _critical_time); 86 0 : }