Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 "ComputeInstantaneousThermalExpansionFunctionEigenstrain.h" 11 : #include "Function.h" 12 : #include "CastDualNumber.h" 13 : #include "RankTwoTensor.h" 14 : 15 : registerMooseObject("TensorMechanicsApp", ComputeInstantaneousThermalExpansionFunctionEigenstrain); 16 : registerMooseObject("TensorMechanicsApp", 17 : ADComputeInstantaneousThermalExpansionFunctionEigenstrain); 18 : 19 : template <bool is_ad> 20 : InputParameters 21 192 : ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl<is_ad>::validParams() 22 : { 23 192 : InputParameters params = ComputeThermalExpansionEigenstrainBaseTempl<is_ad>::validParams(); 24 192 : params.addClassDescription("Computes eigenstrain due to thermal expansion using a function that " 25 : "describes the instantaneous thermal expansion as a function of " 26 : "temperature"); 27 384 : params.addRequiredParam<FunctionName>("thermal_expansion_function", 28 : "Function describing the instantaneous thermal expansion " 29 : "coefficient as a function of temperature"); 30 192 : params.suppressParameter<bool>("use_old_temperature"); 31 192 : return params; 32 0 : } 33 : 34 : template <bool is_ad> 35 144 : ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl<is_ad>:: 36 : ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl(const InputParameters & parameters) 37 : : ComputeThermalExpansionEigenstrainBaseTempl<is_ad>(parameters), 38 144 : _thermal_expansion_function(this->getFunction("thermal_expansion_function")), 39 144 : _thermal_strain(this->template declareGenericProperty<Real, is_ad>( 40 144 : this->_base_name + "InstantaneousThermalExpansionFunction_thermal_strain")), 41 288 : _thermal_strain_old(this->template getMaterialPropertyOld<Real>( 42 : this->_base_name + "InstantaneousThermalExpansionFunction_thermal_strain")), 43 432 : _step_one(this->template declareRestartableData<bool>("step_one", true)) 44 : { 45 144 : if (this->_use_old_temperature) 46 0 : this->paramError("use_old_temperature", 47 : "The old temperature value cannot be used in this incremental update model."); 48 144 : } 49 : 50 : template <bool is_ad> 51 : void 52 11424 : ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl<is_ad>::initQpStatefulProperties() 53 : { 54 11424 : _thermal_strain[_qp] = 0; 55 11424 : } 56 : 57 : template <bool is_ad> 58 : ValueAndDerivative<is_ad> 59 1164096 : ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl<is_ad>::computeThermalStrain() 60 : { 61 1164096 : if (this->_t_step > 1) 62 11664 : _step_one = false; 63 : 64 : const auto & old_temp = 65 1164096 : (_step_one ? this->_stress_free_temperature[_qp] : this->_temperature_old[_qp]); 66 1164096 : const auto delta_T = this->_temperature[_qp] - old_temp; 67 : 68 1164096 : const auto alpha_current_temp = _thermal_expansion_function.value(this->_temperature[_qp]); 69 1164096 : const auto alpha_old_temp = _thermal_expansion_function.value(old_temp); 70 : 71 1164096 : const auto thermal_strain = 72 3264928 : _thermal_strain_old[_qp] + delta_T * 0.5 * (alpha_current_temp + alpha_old_temp); 73 : 74 : // Store thermal strain for use in the next timestep (casts ValueAndDerivative<is_ad> 75 : // to GenericReal<is_ad>). 76 1164096 : _thermal_strain[_qp] = dual_number_cast<GenericReal<is_ad>>(thermal_strain); 77 : 78 1164096 : return thermal_strain; 79 : } 80 : 81 : template class ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl<false>; 82 : template class ComputeInstantaneousThermalExpansionFunctionEigenstrainTempl<true>;