https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeThermalExpansionEigenstrainBase.C
Go to the documentation of this file.
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
11#include "RankTwoTensor.h"
12
13template <bool is_ad>
16{
18 params.addCoupledVar("temperature", "Coupled temperature");
19 params.addRequiredCoupledVar("stress_free_temperature",
20 "Reference temperature at which there is no "
21 "thermal expansion for thermal eigenstrain "
22 "calculation");
23 params.addParam<bool>("use_old_temperature",
24 false,
25 "Flag to optionally use the temperature value from the previous timestep.");
26 params.addParam<MaterialPropertyName>("mean_thermal_expansion_coefficient_name",
27 "Name of the mean coefficient of thermal expansion.");
28 return params;
29}
30
31template <bool is_ad>
33 const InputParameters & parameters)
35 _temperature(_temperature_buffer),
36 _use_old_temperature(this->template getParam<bool>("use_old_temperature")),
37 _temperature_old(this->_fe_problem.isTransient() ? this->coupledValueOld("temperature")
38 : this->_zero),
39 _deigenstrain_dT((is_ad || this->isCoupledConstant("temperature"))
40 ? nullptr
41 : &this->template declarePropertyDerivative<RankTwoTensor>(
42 _eigenstrain_name, this->coupledName("temperature"))),
43 _stress_free_temperature(this->coupledValue("stress_free_temperature")),
44 _temperature_prop(this->template coupledGenericValue<is_ad>("temperature")),
45 _mean_thermal_expansion_coefficient(
46 this->isParamValid("mean_thermal_expansion_coefficient_name")
47 ? &this->template declareProperty<Real>(this->template getParam<MaterialPropertyName>(
48 "mean_thermal_expansion_coefficient_name"))
49 : nullptr)
50{
51 if (_use_old_temperature && !this->_fe_problem.isTransient())
52 this->paramError(
53 "use_old_temperature",
54 "The old state of the temperature variable is only available in a transient simulation.");
55}
56
57template <bool is_ad>
58void
60{
61 // call parent class subdomain setup, which ultimately calls Material::subdomainSetup()
63
64 // make sure we have enouch space to hold the augmented temperature values
65 const auto nqp = this->_fe_problem.getMaxQps();
66 _temperature_buffer.resize(nqp);
67}
68
69template <bool is_ad>
70void
72{
73 // we need to convert the temperature variable to a ChainedReal in the is_ad == false case
74 for (_qp = 0; _qp < this->_qrule->n_points(); ++_qp)
75 if constexpr (is_ad)
76 _temperature_buffer[_qp] =
77 _use_old_temperature ? _temperature_old[_qp] : _temperature_prop[_qp];
78 else
79 {
80 if (_use_old_temperature)
81 _temperature_buffer[_qp] = {_temperature_old[_qp], 0};
82 else
83 _temperature_buffer[_qp] = {_temperature_prop[_qp], 1};
84 }
85
87}
88
89template <bool is_ad>
90void
92{
93 _eigenstrain[_qp].zero();
94 const auto thermal_strain = computeThermalStrain();
95
96 if constexpr (is_ad)
97 {
98 _eigenstrain[_qp].addIa(thermal_strain);
99 if (_mean_thermal_expansion_coefficient)
100 {
101 if (_temperature[_qp] == _stress_free_temperature[_qp])
102 (*_mean_thermal_expansion_coefficient)[_qp] = 0.0;
103 else
104 (*_mean_thermal_expansion_coefficient)[_qp] = MetaPhysicL::raw_value(
105 thermal_strain / (_temperature[_qp] - _stress_free_temperature[_qp]));
106 }
107 }
108 else
109 {
110 _eigenstrain[_qp].addIa(thermal_strain.value());
111 if (_mean_thermal_expansion_coefficient)
112 {
113 if (_temperature[_qp].value() == _stress_free_temperature[_qp])
114 (*_mean_thermal_expansion_coefficient)[_qp] = 0.0;
115 else
116 (*_mean_thermal_expansion_coefficient)[_qp] =
117 thermal_strain.value() / (_temperature[_qp].value() - _stress_free_temperature[_qp]);
118 }
119 if (_deigenstrain_dT)
120 {
121 (*_deigenstrain_dT)[_qp].zero();
122 if (!_use_old_temperature)
123 (*_deigenstrain_dT)[_qp].addIa(thermal_strain.derivatives());
124 }
125 }
126}
127
ComputeEigenstrainBase is the base class for eigenstrain tensors.
static InputParameters validParams()
ComputeThermalExpansionEigenstrainBase is a base class for all models that compute eigenstrains due t...
virtual void computeProperties() final
update _temperature_buffer
ComputeThermalExpansionEigenstrainBaseTempl(const InputParameters &parameters)
virtual void subdomainSetup() final
resize _temperature_buffer
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual void computeProperties() override
virtual void subdomainSetup() override
auto raw_value(const Eigen::Map< T > &in)