-
Notifications
You must be signed in to change notification settings - Fork 247
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
[GeoMechanicsApplication] extract SetConstitutiveParameters function #12382
Conversation
…or small_strain_U_Pw_diff_order_element and U_Pw_small_strain_element
…for the rest of elements
@markelov208 This looks like a very useful PR. However, it will give quite some merge conflicts with my current attempt to extract the constitutive matrix. Could we wait with merging this one until that has gone back (since you are also waiting for that one for the stiffness matrix)? |
Sure, we can wait. |
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.
Yet another PR that cleans up our code. What I like most about this PR is that the new interface is explicit about which parameters will be set, rather than giving it a data structure without knowing which members will be used. As before, I only have a few minor suggestions.
strain_vector(0) = 1.0; | ||
strain_vector(1) = 2.0; | ||
strain_vector(2) = 3.0; |
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.
As for the other PR I have reviewed today, I would suggest to use the concise notation for assigning values to a vector (after including boost/numeric/ublas/assignment.hpp
):
strain_vector(0) = 1.0; | |
strain_vector(1) = 2.0; | |
strain_vector(2) = 3.0; | |
strain_vector <<= 1.0, 2.0, 3.0; |
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.
Thank you. fixed
N(0) = 0.1; | ||
N(1) = 0.2; | ||
N(2) = 0.5; |
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.
And a similar change here:
N(0) = 0.1; | |
N(1) = 0.2; | |
N(2) = 0.5; | |
N <<= 0.1, 0.2, 0.5; |
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.
fixed
@@ -24,6 +25,14 @@ class ConstitutiveLawUtilities | |||
public: | |||
static int GetStateVariableIndex(const Variable<double>& rThisVariable); | |||
|
|||
static void SetSixMechanicsConstitutiveParameters(ConstitutiveLaw::Parameters& rConstitutiveParameters, |
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.
Perhaps a name like SetConstitutiveParameters
will also do?
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.
Restored the old title. Agreed that the new title is not more informative.
# Conflicts: # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp
# Conflicts: # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.cpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_interface_element.hpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.cpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.cpp # applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp # applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.cpp
@rfaasse , it looks that these changes are not needed any more due to your recent PR. Correct? |
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.
Thanks a lot for extracting this function, again removing duplication!
It clashed a bit with the previous PR (sorry for the merge conflicts), but that also means that quite a few of the function calls are not necessary anymore after that commit. When looking at this PR, we only need to retain the places where previously this->SetConstitutiveParameters(Variables, ConstitutiveParameters);
was called (right now we see that there are quite some lines added with respect to master).
Also we can use your new function in the CalculateAnyOfMaterialResponse
function to make it shorter (both for diff order and non-diff order).
Please let me know if this is unclear (which I can imagine, because very specifically related to what I just merged).
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.
Clear unit test! To reflect the name of the file it tests, we could also rename it to test_constitutive_law_utilities.cpp
@@ -26,4 +26,19 @@ int ConstitutiveLawUtilities::GetStateVariableIndex(const Variable<double>& rThi | |||
return index - 1; | |||
} | |||
|
|||
void ConstitutiveLawUtilities::SetConstitutiveParameters(ConstitutiveLaw::Parameters& rConstitutiveParameters, |
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.
Very nice addition. I think it could also be used in the CalculateAnyOfMaterialResponse
functions in the diff order and non-diff order elements!
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.
Thank you for pointing. Added there.
ConstitutiveLawUtilities::SetConstitutiveParameters( | ||
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix, | ||
Variables.Nu, Variables.DNu_DX, Variables.F, Variables.detF); |
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.
This function call is no longer necessary, since the constitutive matrices are already calculated (they are only retrieved here from the vector).
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.
removed
@@ -1353,6 +1363,9 @@ void SmallStrainUPwDiffOrderElement::CalculateMaterialStiffnessMatrix(MatrixType | |||
Variables.F = deformation_gradients[GPoint]; | |||
Variables.StrainVector = strain_vectors[GPoint]; | |||
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint]; | |||
ConstitutiveLawUtilities::SetConstitutiveParameters( |
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.
This function call is no longer necessary, since the constitutive matrices are already calculated (they are only retrieved here from the vector).
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.
removed
@@ -152,6 +153,9 @@ void UPwSmallStrainFICElement<TDim, TNumNodes>::InitializeNonLinearIteration(con | |||
Variables.B = b_matrices[GPoint]; | |||
Variables.F = deformation_gradients[GPoint]; | |||
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint]; | |||
ConstitutiveLawUtilities::SetConstitutiveParameters( |
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.
This function call is no longer necessary, since the constitutive matrices are already calculated (they are only retrieved here from the vector). I think there will be only a few places left now after the changes of the PR for the lists of constitutive matrices. Basically everywhere we retrieve the Constitutive Matrix from a list (i.e. Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
) we don't need this call anymore. I think it will be there in ~3 places for diff order and ~3 places for non-diff order.
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.
Thank you. Removed in many places. But not all calls. ;)
@@ -169,8 +170,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::InitializeSolutionStep(const Proces | |||
Variables.detF = determinants_of_deformation_gradients[GPoint]; | |||
Variables.StrainVector = strain_vectors[GPoint]; | |||
|
|||
// Set Gauss points variables to constitutive law parameters | |||
this->SetConstitutiveParameters(Variables, ConstitutiveParameters); | |||
ConstitutiveLawUtilities::SetConstitutiveParameters( |
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.
This call we need to retain, because the constitutive matrix was not calculated before the loop
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.
Thanks.
@@ -268,6 +270,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::InitializeNonLinearIteration(const | |||
this->CalculateAnyOfMaterialResponse(deformation_gradients, ConstitutiveParameters, | |||
Variables.NContainer, Variables.DN_DXContainer, | |||
strain_vectors, mStressVector, constitutive_matrices); | |||
ConstitutiveLawUtilities::SetConstitutiveParameters( |
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.
This we can also remove, because we already called CalculateAnyOfMaterialResponse
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.
removed
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.
I have no further comments. I believe this is ready to go. Thanks for the hard work Gennady!
📝 Description