-
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 list for constitutive matrices and stress vectors #12380
[GeoMechanicsApplication] Extract list for constitutive matrices and stress vectors #12380
Conversation
…nts inside the function instead of input and use it everywhere the constitutive matrix is being used
…train element and used it in the class (not derived classes yet)
@@ -1943,6 +1887,37 @@ Vector UPwSmallStrainElement<TDim, TNumNodes>::GetPressureSolutionVector() | |||
return result; | |||
} | |||
|
|||
template <unsigned int TDim, unsigned int TNumNodes> | |||
void UPwSmallStrainElement<TDim, TNumNodes>::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.
I know that we have two identical functions now for small strain and for diff order, but I still think in total we remove more duplication than we added and the duplication is a lot more localized now.
GeoElementUtilities::CalculateNuMatrix<TDim, TNumNodes>(Variables.Nu, Variables.NContainer, GPoint); | ||
GeoElementUtilities::InterpolateVariableWithComponents<TDim, TNumNodes>( |
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.
We checked that these functions don't change anything that the constitutive law uses (i.e. only Nu, while the constitutive law uses Np). Since we changed the order here, I'd like to double check with you: do you think this is correct @WPK4FEM?
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.
When there is a difference between Nu and Np ( e.g. for reason of different interpolation orders of u and Pw ) the constitutive law ( relation between strain and stress ) should be using Nu. For same order interpolation Nu and Np will be equal, still the correct one should be used.
…ist-for-constitutive-matrices-and-stress-vectors
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain); | ||
std::vector<Matrix> constitutive_matrices; | ||
this->CalculateAnyOfMaterialResponse(deformation_gradients, ConstitutiveParameters, |
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.
At very first sight this function name is not very descriptive for me. I have to learn what it does reading the function itself.
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 agree, I was struggling with the name. Would CalculateAnyOfStressesStrainsOrConstitutiveMatrices
be better?
GeoElementUtilities::CalculateNuMatrix<TDim, TNumNodes>(Variables.Nu, Variables.NContainer, GPoint); | ||
GeoElementUtilities::InterpolateVariableWithComponents<TDim, TNumNodes>( |
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.
When there is a difference between Nu and Np ( e.g. for reason of different interpolation orders of u and Pw ) the constitutive law ( relation between strain and stress ) should be using Nu. For same order interpolation Nu and Np will be equal, still the correct one should be used.
rConstitutiveParameters.SetStrainVector(rStrainVectors[GPoint]); | ||
rConstitutiveParameters.SetShapeFunctionsDerivatives(rDNu_DXContainer[GPoint]); | ||
rConstitutiveParameters.SetShapeFunctionsValues(row(rNuContainer, GPoint)); | ||
rConstitutiveParameters.SetDeterminantF(determinants_of_deformation_gradients[GPoint]); |
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.
A more logical order would be SetDeformationGradientF ( as F is the DeformationGradient, this is a repeat ) followed by SetDeterminantF ( which then would have had the expected name SetDeterminantDeformationGradientF ).
When F is given DetF could be computed.
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.
Changed the order
/// | ||
/// \brief This function calculates the constitutive matrices, stresses and strains depending on the | ||
/// constitutive parameters. Note that depending on the settings in the rConstitutiveParameters | ||
/// the function could calculate the stress, the constitutive matrix, the strains, or a combination. |
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.
Looking at 1896 of the corresponding cpp file, the strain is given. The implementation of CalculateMaterialResponseCauchy may decide to recompute ( for reasons of a different strain measure ) also the constitutive tensor and stress have their own steering through rConsitutiveParameters.GetOptions()
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.
The strain is only given because we always use the line ConstitutiveParameters.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN);
on the ConstitutiveLaw::Parameters we pass to this function. If we don't the strain could actually be calculated by the constitutive law. Therefore, rStrainVectors is a non-const&, because at this point the function is generic and at this point I'd like this to work with any ConstitutiveLaw::Parameters and any constitutive law
{ | ||
std::vector<Matrix> result; | ||
const SizeType VoigtSize = | ||
(GetGeometry().WorkingSpaceDimension() == 3 ? VOIGT_SIZE_3D : VOIGT_SIZE_2D_PLANE_STRAIN); |
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.
Are the ( ) necessary to encapsulate the ternary operator?
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.
No, removed!
@@ -1932,6 +1876,37 @@ Vector UPwSmallStrainElement<TDim, TNumNodes>::GetPressureSolutionVector() | |||
return result; | |||
} | |||
|
|||
template <unsigned int TDim, unsigned int TNumNodes> | |||
void UPwSmallStrainElement<TDim, TNumNodes>::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.
For the naming of this function, it computes the indicated things for all i.p.
In other cases we indicated that with a trailing s. That can be done here too: CalculateMaterialResponses
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.
Agreed, either this, or we rename to something like CalculateAnyOfStressesStrainsOrConstitutiveMatrices
(see other comment)
…assume any of the stress, strain or matrices vector could be empty or filled and initialized variable_index to fix pipeline build
…ist-for-constitutive-matrices-and-stress-vectors
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 very much for this great effort to compute the constitutive matrices in advance. That was definitely not an easy task, since the code was strongly coupled. As far as I can see you have done an excellent job. I only have a few minor comments and questions. None of them are blocking in my opinion.
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
Show resolved
Hide resolved
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.
Richard, a very useful step to improve the structure and to make functions more uniform. However, for my understand of the code it will be useful to split CalculateAnyOfMaterialResponse into three functions. What is your opinion? It can be next PR.
@markelov208 I fully agree with this observation and would have preferred 3 functions as well (I would really like to decouple this). However, we are bound by the Constitutive Law interface which does all three at the same time in the |
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 looks good to go for me.
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.
Looks consistent and is a step towards understandable code in the elements
📝 Description
This PR extracts lists for constitutive matrices and stress vectors. In doing so we add two identical functions to diff order and to the non-diff order element, but we reduce a lot of other duplicated code. If anyone has ideas how to extract something generic here, please let me know. I think it would mean we need to pass on the constitutive laws and maybe make a vector of constitutive parameters and pass that on to make a separate utility function, but that's open for discussion.