-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thermally coupled Constitutive Laws #9053
Changes from 34 commits
a5b0b0b
4e8a4ef
ce31fdd
7a350b5
c2a4de9
3edea79
8d801f1
41ebb4e
adbe4e9
6e8f8b6
cadc48c
0c7690d
463faaf
3dd0717
eae02ea
ed081e9
05ec7be
8653189
778dee0
76e06e2
b71f9ac
b1568d8
c1c4ccd
7371461
6cf902b
283b655
3ea0f42
2110294
31bc1c4
2f0ba7c
ace3bf3
905e976
a4b47fc
18ef872
1e4c8ec
d778296
08100ea
5cbee8a
e24773e
f0450f4
29a84ab
5d2c25f
747ce40
4b79eeb
0cd5425
b4c2486
1bbec1b
561ff93
e69eafb
c17d339
4ff5819
0bfeabe
6d150eb
867739f
41c5a5a
82bff15
daf8aee
0beab1d
3028750
b5ca197
35897b0
df42254
90931ca
e571160
a2c1eb8
f4d113e
66c5d5e
f472dbd
f4a84f1
c812a74
19267e9
aae7b3a
2b28c16
4bf41b7
cf462a0
5728160
c70fdc2
7af8149
3f89009
cf4a941
47dfb06
5ad8caf
d53b386
04c65dc
d1b7d5b
6a4ab1e
ddd313c
5a22749
7eea18f
e7c36a0
23e97fb
dca539f
7bb9197
86c96c9
b7131b0
97502fa
b028669
2c11d15
2e9ae9e
0c4db4c
b524bf2
ce917af
4a8bdba
1320fbb
45dcfc0
2c99965
eec1c63
f663c92
cd23846
2597637
ebcc1c3
4514fad
9c7d388
b7471f0
6e49d77
bee5ea5
f3a1267
f5cc3ca
435bc63
4176b36
9dbb4dd
63ee514
56ac970
30743ee
6839064
5cd7892
0cfece5
5b80f4a
9b1cdf7
3e597df
33e62ea
fbb447c
15edd48
447e70c
b12c201
681a299
8672900
1ef5613
cf6dff0
8eb0498
6c73a37
1df441c
077db45
d297a21
c091323
a11482c
60be0dd
8715e8d
22e35f3
232f7ee
9484323
2ee1083
202a613
d4debc3
a844ca8
a9e23d2
546bd51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// KRATOS ___ _ _ _ _ _ __ _ | ||
// / __\___ _ __ ___| |_(_) |_ _ _| |_(_)_ _____ / / __ ___ _____ /_\ _ __ _ __ | ||
// / / / _ \| '_ \/ __| __| | __| | | | __| \ \ / / _ \/ / / _` \ \ /\ / / __| //_\\| '_ \| '_ | | ||
// / /__| (_) | | | \__ \ |_| | |_| |_| | |_| |\ V / __/ /__| (_| |\ V V /\__ \/ _ \ |_) | |_) | | ||
// \____/\___/|_| |_|___/\__|_|\__|\__,_|\__|_| \_/ \___\____/\__,_| \_/\_/ |___/\_/ \_/ .__/| .__/ | ||
// |_| |_| | ||
// | ||
// License: BSD License | ||
// license: structural_mechanics_application/license.txt | ||
// | ||
// Main authors: Alejandro Cornejo | ||
// | ||
|
||
// System includes | ||
#include <iostream> | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "custom_constitutive_thermal/thermal_elastic_isotropic_3d.h" | ||
|
||
#include "includes/checks.h" | ||
#include "structural_mechanics_application_variables.h" | ||
|
||
namespace Kratos | ||
{ | ||
|
||
/***********************************************************************************/ | ||
/***********************************************************************************/ | ||
|
||
void ThermalElasticIsotropic3D::CalculateMaterialResponsePK2(ConstitutiveLaw::Parameters& rValues) | ||
{ | ||
KRATOS_TRY | ||
const auto& r_process_info = rValues.GetProcessInfo(); | ||
if (r_process_info[STEP] == 1) // We storage the ref temperature as the initial one | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually do not like this way of taking the reference temperature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please correct me if I am wrong, this function is called for every element no ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely, as I said at the beginning this is a work in progress PR :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now solved |
||
mReferenceTemperature = AdvancedConstitutiveLawUtilities<6>::CalculateInGaussPoint(TEMPERATURE, rValues); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be done in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @philbucher There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I thought about doing that. It is a solution depending on your needs. In this case I adopted that the ref Temp was the one at the very beginning of the calculation (can be different FE wise). In this case, it is required that the Thermal solver at leas has computed the Temp field once, and this is after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reference Temp could be also a material property BTW There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be a property... I am thinking that you maybe can define the temp information as a pointer to a struct, and check if the pointer is null (so if it is not possible to initialize in the Initialize can be checked later)... I don't know, there are many options. Can be just simply be set with the "SetValue" method, and be set outside, from the reading processes or some other point of the solver. There are many options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @philbucher This will be the simplest option, but if we want a ref temp element-wise, we should add as many material properties as FE! :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah // in Initialize
if this->Has(REFERENCE_TEMPERATURE)
mReferenceTemperature = REFERENCE_TEMPERATURE;
else if properties.Has(REFERENCE_TEMPERATURE)
mReferenceTemperature = REFERENCE_TEMPERATURE;
else
mReferenceTemperature = TEMPERATURE; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly, this is what I'm going to implement. The last option is the problematic in this case because the TEMPERATURE is not computed yet (Initialize state). I'll try to circumvent this problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add a new flag ... (opening Pandora's box) TEMPERATURE_INITIALIZED for example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see my proposal is not welcome. We can just simply modify the reading material process, so this is set on that reading fase... In any case ould be troublesome |
||
|
||
Flags& r_constitutive_law_options = rValues.GetOptions(); | ||
ConstitutiveLaw::StrainVectorType& r_strain_vector = rValues.GetStrainVector(); | ||
|
||
const bool use_elem_provided_flag_backup = r_constitutive_law_options.Is(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN); | ||
|
||
if (r_constitutive_law_options.IsNot(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN)) { | ||
// Since we are in small strains, any strain measure works, e.g. CAUCHY_GREEN | ||
CalculateCauchyGreenStrain(rValues, r_strain_vector); | ||
} | ||
|
||
// We add the thermal contribution | ||
AdvancedConstitutiveLawUtilities<6>::SubstractThermalStrain(r_strain_vector, mReferenceTemperature, rValues); | ||
|
||
// We force to use the already computed strain in the base CL | ||
r_constitutive_law_options.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, true); | ||
|
||
BaseType::CalculateMaterialResponsePK2(rValues); | ||
|
||
// We reset the flag | ||
r_constitutive_law_options.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN, use_elem_provided_flag_backup); | ||
|
||
KRATOS_CATCH("") | ||
} | ||
|
||
/***********************************************************************************/ | ||
/***********************************************************************************/ | ||
|
||
int ThermalElasticIsotropic3D::Check( | ||
const Properties& rMaterialProperties, | ||
const GeometryType& rElementGeometry, | ||
const ProcessInfo& rCurrentProcessInfo | ||
) | ||
{ | ||
KRATOS_ERROR_IF_NOT(rElementGeometry[0].SolutionStepsDataHas(TEMPERATURE)) << "The TEMPERATURE variable is not available at the nodes." << std::endl; | ||
KRATOS_ERROR_IF_NOT(rMaterialProperties.Has(THERMAL_EXPANSION_COEFFICIENT)) << "The THERMAL_EXPANSION_COEFFICIENT is not set in the material properties." << std::endl; | ||
KRATOS_ERROR_IF(rMaterialProperties[THERMAL_EXPANSION_COEFFICIENT] < 0.0) << "The THERMAL_EXPANSION_COEFFICIENT is negative..." << std::endl; | ||
BaseType::Check(rMaterialProperties, rElementGeometry, rCurrentProcessInfo); | ||
return 0; | ||
} | ||
|
||
/***********************************************************************************/ | ||
/***********************************************************************************/ | ||
|
||
Vector& ThermalElasticIsotropic3D::CalculateValue( | ||
ConstitutiveLaw::Parameters& rParameterValues, | ||
const Variable<Vector>& rThisVariable, | ||
Vector& rValue | ||
) | ||
{ | ||
if (rThisVariable == STRAIN || | ||
rThisVariable == GREEN_LAGRANGE_STRAIN_VECTOR || | ||
rThisVariable == ALMANSI_STRAIN_VECTOR) { | ||
|
||
Flags& r_flags = rParameterValues.GetOptions(); | ||
|
||
// Previous flags saved | ||
const bool flag_const_tensor = r_flags.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); | ||
const bool flag_stress = r_flags.Is(ConstitutiveLaw::COMPUTE_STRESS); | ||
|
||
// Set flags to only compute the strain | ||
r_flags.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, false); | ||
r_flags.Set(ConstitutiveLaw::COMPUTE_STRESS, false); | ||
|
||
ThermalElasticIsotropic3D::CalculateMaterialResponsePK2(rParameterValues); | ||
if (rValue.size() != GetStrainSize()) { | ||
rValue.resize(GetStrainSize()); | ||
} | ||
noalias(rValue) = rParameterValues.GetStrainVector(); | ||
|
||
// Previous flags restored | ||
r_flags.Set( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, flag_const_tensor ); | ||
r_flags.Set( ConstitutiveLaw::COMPUTE_STRESS, flag_stress ); | ||
|
||
} else if (rThisVariable == STRESSES || | ||
rThisVariable == CAUCHY_STRESS_VECTOR || | ||
rThisVariable == KIRCHHOFF_STRESS_VECTOR || | ||
rThisVariable == PK2_STRESS_VECTOR) { | ||
|
||
Flags& r_flags = rParameterValues.GetOptions(); | ||
|
||
// Previous flags saved | ||
const bool flag_const_tensor = r_flags.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR); | ||
const bool flag_stress = r_flags.Is(ConstitutiveLaw::COMPUTE_STRESS); | ||
|
||
// Set flags to only compute the stress | ||
r_flags.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); | ||
r_flags.Set(ConstitutiveLaw::COMPUTE_STRESS, true); | ||
|
||
ThermalElasticIsotropic3D::CalculateMaterialResponsePK2(rParameterValues); | ||
if (rValue.size() != GetStrainSize()) { | ||
rValue.resize(GetStrainSize()); | ||
} | ||
noalias(rValue) = rParameterValues.GetStressVector(); | ||
|
||
// Previous flags restored | ||
r_flags.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, flag_const_tensor); | ||
r_flags.Set(ConstitutiveLaw::COMPUTE_STRESS, flag_stress); | ||
} else if (rThisVariable == INITIAL_STRAIN_VECTOR) { | ||
if (this->HasInitialState()) { | ||
if (rValue.size() != GetStrainSize()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take care of the mixing of tabs and spaces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. solved |
||
rValue.resize(GetStrainSize()); | ||
} | ||
noalias(rValue) = GetInitialState().GetInitialStrainVector(); | ||
} else { | ||
noalias(rValue) = ZeroVector(0); | ||
} | ||
} | ||
return (rValue); | ||
} | ||
|
||
/***********************************************************************************/ | ||
/***********************************************************************************/ | ||
|
||
} // Namespace Kratos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of consistency with the rest of applications, I'd suggest to put the new constitutive models together with their corresponding base classes within the
custom_constitutive
folder.