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] Fix some minor issues #13005

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -444,16 +444,16 @@ std::vector<double> UPwBaseElement::CalculateIntegrationCoefficients(
}

void UPwBaseElement::CalculateDerivativesOnInitialConfiguration(
double& detJ, Matrix& J0, Matrix& InvJ0, Matrix& DNu_DX0, unsigned int GPoint) const
double& detJ, Matrix& J0, Matrix& InvJ0, Matrix& DNu_DX0, unsigned int IntegrationPointIndex) const
{
KRATOS_TRY

const GeometryType& rGeom = this->GetGeometry();
const GeometryType::IntegrationPointsArrayType& IntegrationPoints =
rGeom.IntegrationPoints(mThisIntegrationMethod);

GeometryUtils::JacobianOnInitialConfiguration(rGeom, IntegrationPoints[GPoint], J0);
const Matrix& DN_De = rGeom.ShapeFunctionsLocalGradients(mThisIntegrationMethod)[GPoint];
GeometryUtils::JacobianOnInitialConfiguration(rGeom, IntegrationPoints[IntegrationPointIndex], J0);
const Matrix& DN_De = rGeom.ShapeFunctionsLocalGradients(mThisIntegrationMethod)[IntegrationPointIndex];
MathUtils<double>::InvertMatrix(J0, InvJ0, detJ);
GeometryUtils::ShapeFunctionsGradients(DN_De, InvJ0, DNu_DX0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwBaseElement : public Element
const Vector& rDetJs) const;

void CalculateDerivativesOnInitialConfiguration(
double& detJ, Matrix& J0, Matrix& InvJ0, Matrix& DN_DX, unsigned int PointNumber) const;
double& detJ, Matrix& J0, Matrix& InvJ0, Matrix& DN_DX, unsigned int IntegrationPointIndex) const;

void CalculateJacobianOnCurrentConfiguration(double& detJ, Matrix& rJ, Matrix& rInvJ, unsigned int GPoint) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1595,19 +1595,21 @@ void UPwSmallStrainElement<TDim, TNumNodes>::InitializeProperties(ElementVariabl
}

template <unsigned int TDim, unsigned int TNumNodes>
void UPwSmallStrainElement<TDim, TNumNodes>::CalculateKinematics(ElementVariables& rVariables, unsigned int GPoint)
void UPwSmallStrainElement<TDim, TNumNodes>::CalculateKinematics(ElementVariables& rVariables,
unsigned int IntegrationPointIndex)
{
KRATOS_TRY

// Setting the vector of shape functions and the matrix of the shape functions global gradients
noalias(rVariables.Np) = row(rVariables.NContainer, GPoint);
noalias(rVariables.GradNpT) = rVariables.DN_DXContainer[GPoint];
noalias(rVariables.Np) = row(rVariables.NContainer, IntegrationPointIndex);
noalias(rVariables.GradNpT) = rVariables.DN_DXContainer[IntegrationPointIndex];

rVariables.detJ = rVariables.detJContainer[GPoint];
rVariables.detJ = rVariables.detJContainer[IntegrationPointIndex];

Matrix J0, InvJ0;
this->CalculateDerivativesOnInitialConfiguration(rVariables.detJInitialConfiguration, J0, InvJ0,
rVariables.GradNpTInitialConfiguration, GPoint);
rVariables.GradNpTInitialConfiguration,
IntegrationPointIndex);

KRATOS_CATCH("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainElement : public UPwBa

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

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

Matrix CalculateBMatrix(const Matrix& rDN_DX, const Vector& rN) const;
std::vector<Matrix> CalculateBMatrices(const GeometryType::ShapeFunctionsGradientsType& rDN_DXContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,16 +548,17 @@ void TransientPwElement<TDim, TNumNodes>::CalculateAndAddCompressibilityFlow(Vec
}

template <unsigned int TDim, unsigned int TNumNodes>
void TransientPwElement<TDim, TNumNodes>::CalculateKinematics(ElementVariables& rVariables, unsigned int PointNumber)
void TransientPwElement<TDim, TNumNodes>::CalculateKinematics(ElementVariables& rVariables,
unsigned int IntegrationPointIndex)

{
KRATOS_TRY

// Setting the vector of shape functions and the matrix of the shape functions global gradients
noalias(rVariables.Np) = row(rVariables.NContainer, PointNumber);
noalias(rVariables.GradNpT) = rVariables.DN_DXContainer[PointNumber];
noalias(rVariables.Np) = row(rVariables.NContainer, IntegrationPointIndex);
noalias(rVariables.GradNpT) = rVariables.DN_DXContainer[IntegrationPointIndex];

rVariables.detJ = rVariables.detJContainer[PointNumber];
rVariables.detJ = rVariables.detJContainer[IntegrationPointIndex];

KRATOS_CATCH("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientPwElement : public UPwSmall

void CalculateAndAddRHS(VectorType& rRightHandSideVector, ElementVariables& rVariables, unsigned int GPoint) override;

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

void CalculateAndAddCompressibilityMatrix(MatrixType& rLeftHandSideMatrix,
const ElementVariables& rVariables) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ void ApplyCPhiReductionProcess::ExecuteInitializeSolutionStep()
KRATOS_ERROR_IF(mReductionFactor <= 0.01)
<< "Reduction factor should not drop below 0.01, calculation stopped." << std::endl;
KRATOS_ERROR_IF(mReductionIncrement <= 0.001)
<< "Reduction increment should not drop below 0.001, calculation stopped. Final safety factor = " << 1.0 / mPreviousReductionFactor << std::endl;
<< "Reduction increment should not drop below 0.001, calculation stopped. Final safety "
"factor = "
<< 1.0 / mPreviousReductionFactor << std::endl;
KRATOS_INFO("ApplyCPhiReductionProces::ExecuteInitializeSolutionStep")
<< "Try a c-phi reduction factor " << mReductionFactor << " (safety factor "
<< 1. / mReductionFactor << ") Previous reduction = " << mPreviousReductionFactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ KRATOS_TEST_CASE_IN_SUITE(CheckFailureEmptyModelPartApplyCPhiReductionProcess, K

KRATOS_TEST_CASE_IN_SUITE(CheckReturnsZeroForValidModelPartApplyCPhiReductionProcess, KratosGeoMechanicsFastSuite)
{
Model model;
auto& r_model_part = PrepareCPhiTestModelPart(model);
Model model;
auto& r_model_part = PrepareCPhiTestModelPart(model);
ApplyCPhiReductionProcess process{r_model_part, {}};
KRATOS_CHECK_EQUAL(process.Check(), 0);
}
Expand Down Expand Up @@ -224,9 +224,9 @@ KRATOS_TEST_CASE_IN_SUITE(CheckFailureTooSmallReductionIncrementApplyCPhiReducti
// After halving the initial reduction increment (0.1) for the seventh time, it becomes
// 0.00078125, so it should throw an exception
// The final safety factor can be calculated as (1.0 / (1 - 0.1 * 0.5 - 0.1 * 0.5^2 ... + 0.1*0.5^6)) = 1.10919
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
process.ExecuteInitializeSolutionStep(),
"Reduction increment should not drop below 0.001, calculation stopped. Final safety factor = 1.10919");
KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.ExecuteInitializeSolutionStep(),
"Reduction increment should not drop below 0.001, "
"calculation stopped. Final safety factor = 1.10919");
}

} // namespace Kratos::Testing
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace Kratos;
class StubConstitutiveLaw : public ConstitutiveLaw
{
public:
SizeType GetStrainSize() const override { return 4; }
[[nodiscard]] SizeType GetStrainSize() const override { return 4; }
};

class StubElementForResetDisplacementTest : public Element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class NewmarkQuasistaticUPwSchemeTester

NewmarkQuasistaticUPwSchemeTester() { CreateValidModelPart(); }

NewmarkQuasistaticUPwScheme<SparseSpaceType, LocalSpaceType> CreateValidScheme() const
[[nodiscard]] static NewmarkQuasistaticUPwScheme<SparseSpaceType, LocalSpaceType> CreateValidScheme()
{
return NewmarkQuasistaticUPwScheme<SparseSpaceType, LocalSpaceType>(0.25, 0.5, 0.75);
return {0.25, 0.5, 0.75};
}

void CreateValidModelPart()
Expand Down
Loading