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 "ComputeEigenstrainBase.h" 11 : 12 : #include "RankTwoTensor.h" 13 : 14 : template <bool is_ad> 15 : InputParameters 16 6212 : ComputeEigenstrainBaseTempl<is_ad>::validParams() 17 : { 18 6212 : InputParameters params = Material::validParams(); 19 12424 : params.addParam<std::string>("base_name", 20 : "Optional parameter that allows the user to define " 21 : "multiple mechanics material systems on the same " 22 : "block, i.e. for multiple phases"); 23 12424 : params.addRequiredParam<std::string>("eigenstrain_name", 24 : "Material property name for the eigenstrain tensor computed " 25 : "by this model. IMPORTANT: The name of this property must " 26 : "also be provided to the strain calculator."); 27 6212 : return params; 28 0 : } 29 : 30 : template <bool is_ad> 31 4660 : ComputeEigenstrainBaseTempl<is_ad>::ComputeEigenstrainBaseTempl(const InputParameters & parameters) 32 : : Material(parameters), 33 4660 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 34 9320 : _eigenstrain_name(_base_name + getParam<std::string>("eigenstrain_name")), 35 4660 : _eigenstrain(declareGenericProperty<RankTwoTensor, is_ad>(_eigenstrain_name)), 36 13980 : _step_zero(declareRestartableData<bool>("step_zero", true)) 37 : { 38 4660 : } 39 : 40 : template <bool is_ad> 41 : void 42 204640 : ComputeEigenstrainBaseTempl<is_ad>::initQpStatefulProperties() 43 : { 44 : // This property can be promoted to be stateful by other models that use it, 45 : // so it needs to be initalized. 46 204640 : _eigenstrain[_qp].zero(); 47 204640 : } 48 : 49 : template <bool is_ad> 50 : void 51 11513614 : ComputeEigenstrainBaseTempl<is_ad>::computeQpProperties() 52 : { 53 11513614 : if (_t_step >= 1) 54 11512014 : _step_zero = false; 55 : 56 : // Skip the eigenstrain calculation in step zero because no solution is computed during 57 : // the zeroth step, hence computing the eigenstrain in the zeroth step would result in 58 : // an incorrect calculation of mechanical_strain, which is stateful. 59 11513614 : if (!_step_zero) 60 11512014 : computeQpEigenstrain(); 61 11513594 : } 62 : 63 : template <bool is_ad> 64 : GenericReal<is_ad> 65 2592 : ComputeEigenstrainBaseTempl<is_ad>::computeVolumetricStrainComponent( 66 : const GenericReal<is_ad> & volumetric_strain) const 67 : { 68 : // The engineering strain in a given direction is: 69 : // epsilon_eng = cbrt(volumetric_strain + 1.0) - 1.0 70 : // 71 : // We need to provide this as a logarithmic strain to be consistent with the strain measure 72 : // used for finite strain: 73 : // epsilon_log = log(1.0 + epsilon_eng) 74 : // 75 : // This can be simplified down to a more direct form: 76 : // epsilon_log = log(cbrt(volumetric_strain + 1.0)) 77 : // or: 78 : // epsilon_log = (1/3) log(volumetric_strain + 1.0) 79 : 80 4928 : return std::log(volumetric_strain + 1.0) / 3.0; 81 : } 82 : 83 : template class ComputeEigenstrainBaseTempl<false>; 84 : template class ComputeEigenstrainBaseTempl<true>;