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] Calculate strains #12385

Merged
merged 8 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ void UPwSmallStrainFICElement<TDim, TNumNodes>::InitializeNonLinearIteration(con
const auto deformation_gradients = this->CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = this->CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

// Loop over integration points
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down Expand Up @@ -202,8 +202,8 @@ void UPwSmallStrainFICElement<TDim, TNumNodes>::FinalizeNonLinearIteration(const
const auto deformation_gradients = this->CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = this->CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

// Loop over integration points
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down Expand Up @@ -465,8 +465,8 @@ void UPwSmallStrainFICElement<TDim, TNumNodes>::CalculateAll(MatrixType& rLeftHa
const auto deformation_gradients = this->CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = this->CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

// Loop over integration points
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::InitializeSolutionStep(const Proces
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

// Loop over integration points
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down Expand Up @@ -269,8 +269,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::InitializeNonLinearIteration(const
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

// Loop over integration points
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down Expand Up @@ -328,8 +328,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::FinalizeSolutionStep(const ProcessI
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

Matrix StressContainer(NumGPoints, mStressVector[0].size());
// Loop over integration points
Expand Down Expand Up @@ -596,8 +596,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(const
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

for (unsigned int GPoint = 0; GPoint < mConstitutiveLawVector.size(); ++GPoint) {
const PropertiesType& rProp = this->GetProperties();
Expand Down Expand Up @@ -658,8 +658,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(

const auto b_matrices = CalculateBMatrices(Variables.DN_DXContainer, Variables.NContainer);
const auto deformation_gradients = CalculateDeformationGradients();
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

std::vector<double> permeability_update_factors;
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down Expand Up @@ -731,8 +731,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(const
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

// Loop over integration points
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
Expand Down Expand Up @@ -782,7 +782,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(const
Variables.B = this->CalculateBMatrix(Variables.GradNpTInitialConfiguration, Variables.Np);

// Compute infinitesimal strain
Variables.StrainVector = this->CalculateCauchyStrain(Variables.B, Variables.DisplacementVector);
Variables.StrainVector =
StressStrainUtilities::CalculateCauchyStrain(Variables.B, Variables.DisplacementVector);

if (rOutput[GPoint].size() != Variables.StrainVector.size())
rOutput[GPoint].resize(Variables.StrainVector.size(), false);
Expand All @@ -795,8 +796,9 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateOnIntegrationPoints(const

const auto b_matrices = CalculateBMatrices(Variables.DN_DXContainer, Variables.NContainer);
const auto deformation_gradients = CalculateDeformationGradients();
rOutput = CalculateStrains(deformation_gradients, b_matrices, Variables.DisplacementVector,
Variables.UseHenckyStrain);
rOutput = StressStrainUtilities::CalculateStrains(deformation_gradients, b_matrices,
Variables.DisplacementVector,
Variables.UseHenckyStrain, VoigtSize);
} else if (rProp.Has(rVariable)) {
// Map initial material property to Gauss points, as required for the output
rOutput.clear();
Expand Down Expand Up @@ -908,8 +910,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateMaterialStiffnessMatrix(Ma
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
// Compute Np, GradNpT, B and StrainVector
Expand Down Expand Up @@ -1037,8 +1039,8 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateAll(MatrixType& rLe
const auto deformation_gradients = CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain, VoigtSize);

for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) {
// Compute GradNpT, B and StrainVector
Expand Down Expand Up @@ -1559,38 +1561,6 @@ void UPwSmallStrainElement<TDim, TNumNodes>::CalculateAndAddFluidBodyFlow(Vector
KRATOS_CATCH("")
}

template <unsigned int TDim, unsigned int TNumNodes>
Vector UPwSmallStrainElement<TDim, TNumNodes>::CalculateStrain(const Matrix& rDeformationGradient,
const Matrix& rB,
const Vector& rDisplacements,
bool UseHenckyStrain) const
{
return UseHenckyStrain ? StressStrainUtilities::CalculateHenckyStrain(rDeformationGradient, VoigtSize)
: this->CalculateCauchyStrain(rB, rDisplacements);
}

template <unsigned int TDim, unsigned int TNumNodes>
std::vector<Vector> UPwSmallStrainElement<TDim, TNumNodes>::CalculateStrains(const std::vector<Matrix>& rDeformationGradients,
const std::vector<Matrix>& rBs,
const Vector& rDisplacements,
bool UseHenckyStrain) const
{
std::vector<Vector> result;
std::transform(
rDeformationGradients.begin(), rDeformationGradients.end(), rBs.begin(), std::back_inserter(result),
[this, &rDisplacements, UseHenckyStrain](const auto& rDeformationGradient, const auto& rB) {
return CalculateStrain(rDeformationGradient, rB, rDisplacements, UseHenckyStrain);
});

return result;
}

template <unsigned int TDim, unsigned int TNumNodes>
Vector UPwSmallStrainElement<TDim, TNumNodes>::CalculateCauchyStrain(const Matrix& rB, const Vector& rDisplacements) const
{
return prod(rB, rDisplacements);
}

template <unsigned int TDim, unsigned int TNumNodes>
Vector UPwSmallStrainElement<TDim, TNumNodes>::CalculateGreenLagrangeStrain(const Matrix& rDeformationGradient) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainElement : public UPwBa
double CalculateBulkModulus(const Matrix& ConstitutiveMatrix) const;
double CalculateBiotCoefficient(const ElementVariables& rVariables, bool hasBiotCoefficient) const;

virtual Vector CalculateGreenLagrangeStrain(const Matrix& rDeformationGradient) const;
virtual Vector CalculateCauchyStrain(const Matrix& rB, const Vector& rDisplacements) const;
virtual Vector CalculateStrain(const Matrix& rDeformationGradient,
const Matrix& rB,
const Vector& rDisplacements,
bool UseHenckyStrain) const;
std::vector<Vector> CalculateStrains(const std::vector<Matrix>& rDeformationGradients,
const std::vector<Matrix>& rBs,
const Vector& rDisplacements,
bool UseHenckyStrain) const;
virtual Vector CalculateGreenLagrangeStrain(const Matrix& rDeformationGradient) const;

Matrix CalculateDeformationGradient(unsigned int GPoint) const;
std::vector<Matrix> CalculateDeformationGradients() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ void UPwUpdatedLagrangianFICElement<TDim, TNumNodes>::CalculateAll(MatrixType& r
const auto deformation_gradients = this->CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = this->CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain,
this->VoigtSize);

// Computing in all integrations points
for (IndexType GPoint = 0; GPoint < IntegrationPoints.size(); ++GPoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ void UPwUpdatedLagrangianElement<TDim, TNumNodes>::CalculateAll(MatrixType& rLef
const auto deformation_gradients = this->CalculateDeformationGradients();
const auto determinants_of_deformation_gradients =
GeoMechanicsMathUtilities::CalculateDeterminants(deformation_gradients);
const auto strain_vectors = this->CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain);
const auto strain_vectors = StressStrainUtilities::CalculateStrains(
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain,
this->VoigtSize);

// Computing in all integrations points
for (IndexType GPoint = 0; GPoint < IntegrationPoints.size(); ++GPoint) {
Expand Down
Loading
Loading