Skip to content
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

Merged
merged 11 commits into from
May 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// Application includes
#include "custom_elements/U_Pw_small_strain_FIC_element.hpp"
#include "custom_utilities/constitutive_law_utilities.hpp"
#include "custom_utilities/math_utilities.h"

namespace Kratos
Expand Down Expand Up @@ -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(
Copy link
Contributor

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.

Copy link
Contributor Author

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. ;)

ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

this->SaveGPConstitutiveTensor(ConstitutiveTensorContainer, Variables.ConstitutiveMatrix, GPoint);

Expand Down Expand Up @@ -207,6 +211,9 @@ void UPwSmallStrainFICElement<TDim, TNumNodes>::FinalizeNonLinearIteration(const
Variables.B = b_matrices[GPoint];
Variables.F = deformation_gradients[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Compute DtStress
noalias(Variables.StrainVector) = prod(Variables.B, Variables.VelocityVector);
Expand Down Expand Up @@ -464,6 +471,9 @@ void UPwSmallStrainFICElement<TDim, TNumNodes>::CalculateAll(MatrixType& rLeftHa
Variables.F = deformation_gradients[GPoint];
Variables.StrainVector = strain_vectors[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

GeoElementUtilities::CalculateNuMatrix<TDim, TNumNodes>(Variables.Nu, Variables.NContainer, GPoint);
GeoElementUtilities::InterpolateVariableWithComponents<TDim, TNumNodes>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// Application includes
#include "custom_elements/U_Pw_small_strain_element.hpp"
#include "custom_utilities/constitutive_law_utilities.hpp"
#include "custom_utilities/equation_of_motion_utilities.h"
#include "custom_utilities/math_utilities.h"
#include "custom_utilities/transport_equation_utilities.hpp"
Expand Down Expand Up @@ -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(
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Initialize constitutive law
noalias(Variables.StressVector) = mStressVector[GPoint];
Expand Down Expand Up @@ -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(
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

KRATOS_CATCH("")
}
Expand Down Expand Up @@ -321,8 +326,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::FinalizeSolutionStep(const ProcessI
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(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Compute constitutive tensor and/or stresses
noalias(Variables.StressVector) = mStressVector[GPoint];
Expand Down Expand Up @@ -586,6 +592,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(const
this->CalculateAnyOfMaterialResponse(deformation_gradients, ConstitutiveParameters,
Variables.NContainer, Variables.DN_DXContainer,
strain_vectors, mStressVector, constitutive_matrices);
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

std::transform(constitutive_matrices.begin(), constitutive_matrices.end(), rOutput.begin(),
[variable_index](const Matrix& constitutive_matrix) {
Expand Down Expand Up @@ -708,6 +717,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(const
Variables.F = deformation_gradients[GPoint];
Variables.StrainVector = strain_vectors[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

Variables.BiotCoefficient = CalculateBiotCoefficient(Variables, hasBiotCoefficient);

Expand Down Expand Up @@ -875,6 +887,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateMaterialStiffnessMatrix(Ma
Variables.F = deformation_gradients[GPoint];
Variables.StrainVector = strain_vectors[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Compute weighting coefficient for integration
Variables.IntegrationCoefficient =
Expand Down Expand Up @@ -995,6 +1010,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateAll(MatrixType& rLe
Variables.F = deformation_gradients[GPoint];
Variables.StrainVector = strain_vectors[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Compute Nu and BodyAcceleration
GeoElementUtilities::CalculateNuMatrix<TDim, TNumNodes>(Variables.Nu, Variables.NContainer, GPoint);
Expand Down Expand Up @@ -1660,22 +1678,6 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateKinematics(ElementVariable
KRATOS_CATCH("")
}

template <unsigned int TDim, unsigned int TNumNodes>
void UPwSmallStrainElement<TDim, TNumNodes>::SetConstitutiveParameters(ElementVariables& rVariables,
ConstitutiveLaw::Parameters& rConstitutiveParameters)
{
KRATOS_TRY

rConstitutiveParameters.SetStrainVector(rVariables.StrainVector);
rConstitutiveParameters.SetConstitutiveMatrix(rVariables.ConstitutiveMatrix);
rConstitutiveParameters.SetShapeFunctionsValues(rVariables.Np);
rConstitutiveParameters.SetShapeFunctionsDerivatives(rVariables.GradNpT);
rConstitutiveParameters.SetDeformationGradientF(rVariables.F);
rConstitutiveParameters.SetDeterminantF(rVariables.detF);

KRATOS_CATCH("")
}

template <unsigned int TDim, unsigned int TNumNodes>
void UPwSmallStrainElement<TDim, TNumNodes>::CalculateRetentionResponse(ElementVariables& rVariables,
RetentionLaw::Parameters& rRetentionParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainElement : public UPwBa

virtual void InitializeElementVariables(ElementVariables& rVariables, const ProcessInfo& CurrentProcessInfo);

void SetConstitutiveParameters(ElementVariables& rVariables, ConstitutiveLaw::Parameters& rConstitutiveParameters);

virtual void CalculateKinematics(ElementVariables& rVariables, unsigned int PointNumber);

void InitializeBiotCoefficients(ElementVariables& rVariables, bool hasBiotCoefficient = false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// Application includes
#include "custom_elements/U_Pw_small_strain_interface_element.hpp"
#include "custom_utilities/constitutive_law_utilities.hpp"
#include "custom_utilities/transport_equation_utilities.hpp"
#include <custom_utilities/stress_strain_utilities.h>

Expand Down Expand Up @@ -659,7 +660,9 @@ void UPwSmallStrainInterfaceElement<TDim, TNumNodes>::CalculateOnIntegrationPoin
ConstitutiveParameters.Set(ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN);
ConstitutiveParameters.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR);

this->SetConstitutiveParameters(Variables, ConstitutiveParameters);
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Auxiliary variables
const double& MinimumJointWidth = rProp[MINIMUM_JOINT_WIDTH];
Expand Down Expand Up @@ -1000,8 +1003,9 @@ void UPwSmallStrainInterfaceElement<TDim, TNumNodes>::CalculateOnLobattoIntegrat

Vector TotalStressVector(mStressVector[0].size());

// set Gauss points variables to constitutive law parameters
this->SetConstitutiveParameters(Variables, ConstitutiveParameters);
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Auxiliary variables
const double& MinimumJointWidth = rProp[MINIMUM_JOINT_WIDTH];
Expand Down Expand Up @@ -1251,7 +1255,10 @@ void UPwSmallStrainInterfaceElement<TDim, TNumNodes>::CalculateMaterialStiffness
// Element variables
InterfaceElementVariables Variables;
this->InitializeElementVariables(Variables, Geom, Prop, CurrentProcessInfo);
this->SetConstitutiveParameters(Variables, ConstitutiveParameters);

ConstitutiveLawUtilities::SetConstitutiveParameters(ConstitutiveParameters, Variables.StrainVector,
Variables.ConstitutiveMatrix, Variables.Np,
Variables.GradNpT, Variables.F, Variables.detF);

// Auxiliary variables
const double& MinimumJointWidth = Prop[MINIMUM_JOINT_WIDTH];
Expand Down Expand Up @@ -1325,7 +1332,10 @@ void UPwSmallStrainInterfaceElement<TDim, TNumNodes>::CalculateAll(MatrixType& r
// Element variables
InterfaceElementVariables Variables;
this->InitializeElementVariables(Variables, Geom, Prop, CurrentProcessInfo);
this->SetConstitutiveParameters(Variables, ConstitutiveParameters);

ConstitutiveLawUtilities::SetConstitutiveParameters(ConstitutiveParameters, Variables.StrainVector,
Variables.ConstitutiveMatrix, Variables.Np,
Variables.GradNpT, Variables.F, Variables.detF);

// Auxiliary variables
const double& MinimumJointWidth = Prop[MINIMUM_JOINT_WIDTH];
Expand Down Expand Up @@ -1448,22 +1458,6 @@ void UPwSmallStrainInterfaceElement<TDim, TNumNodes>::InitializeElementVariables
KRATOS_CATCH("")
}

template <unsigned int TDim, unsigned int TNumNodes>
void UPwSmallStrainInterfaceElement<TDim, TNumNodes>::SetConstitutiveParameters(
InterfaceElementVariables& rVariables, ConstitutiveLaw::Parameters& rConstitutiveParameters)
{
KRATOS_TRY

rConstitutiveParameters.SetStrainVector(rVariables.StrainVector);
rConstitutiveParameters.SetConstitutiveMatrix(rVariables.ConstitutiveMatrix);
rConstitutiveParameters.SetShapeFunctionsValues(rVariables.Np);
rConstitutiveParameters.SetShapeFunctionsDerivatives(rVariables.GradNpT);
rConstitutiveParameters.SetDeformationGradientF(rVariables.F);
rConstitutiveParameters.SetDeterminantF(rVariables.detF);

KRATOS_CATCH("")
}

template <>
void UPwSmallStrainInterfaceElement<2, 4>::CalculateRotationMatrix(BoundedMatrix<double, 2, 2>& rRotationMatrix,
const GeometryType& Geom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainInterfaceElement

void CalculateSoilGamma(InterfaceElementVariables& rVariables);

void SetConstitutiveParameters(InterfaceElementVariables& rVariables,
ConstitutiveLaw::Parameters& rConstitutiveParameters);

Vector SetFullStressVector(const Vector& rStressVector);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// Application includes
#include "custom_elements/U_Pw_small_strain_link_interface_element.hpp"
#include "custom_utilities/constitutive_law_utilities.hpp"

namespace Kratos
{
Expand Down Expand Up @@ -321,7 +322,10 @@ void UPwSmallStrainLinkInterfaceElement<TDim, TNumNodes>::CalculateAll(MatrixTyp
// Element variables
InterfaceElementVariables Variables;
this->InitializeElementVariables(Variables, Geom, Prop, CurrentProcessInfo);
this->SetConstitutiveParameters(Variables, ConstitutiveParameters);

ConstitutiveLawUtilities::SetConstitutiveParameters(ConstitutiveParameters, Variables.StrainVector,
Variables.ConstitutiveMatrix, Variables.Np,
Variables.GradNpT, Variables.F, Variables.detF);

// Auxiliary variables
const double& MinimumJointWidth = Prop[MINIMUM_JOINT_WIDTH];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// Project includes
#include "custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp"
#include "custom_utilities/constitutive_law_utilities.hpp"
#include "custom_utilities/math_utilities.h"
#include "utilities/math_utils.h"

Expand Down Expand Up @@ -95,6 +96,9 @@ void UPwUpdatedLagrangianFICElement<TDim, TNumNodes>::CalculateAll(MatrixType& r
Variables.F = deformation_gradients[GPoint];
Variables.StrainVector = strain_vectors[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Compute Np, Nu and BodyAcceleration
GeoElementUtilities::CalculateNuMatrix<TDim, TNumNodes>(Variables.Nu, Variables.NContainer, GPoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// Project includes
#include "custom_elements/U_Pw_updated_lagrangian_element.hpp"
#include "custom_utilities/constitutive_law_utilities.hpp"
#include "custom_utilities/math_utilities.h"
#include "utilities/math_utils.h"

Expand Down Expand Up @@ -89,6 +90,9 @@ void UPwUpdatedLagrangianElement<TDim, TNumNodes>::CalculateAll(MatrixType& rLef
Variables.F = deformation_gradients[GPoint];
Variables.StrainVector = strain_vectors[GPoint];
Variables.ConstitutiveMatrix = constitutive_matrices[GPoint];
ConstitutiveLawUtilities::SetConstitutiveParameters(
ConstitutiveParameters, Variables.StrainVector, Variables.ConstitutiveMatrix,
Variables.Np, Variables.GradNpT, Variables.F, Variables.detF);

// Compute Np, Nu and BodyAcceleration
GeoElementUtilities::CalculateNuMatrix<TDim, TNumNodes>(Variables.Nu, Variables.NContainer, GPoint);
Expand Down
Loading
Loading