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] Create exit criterion for c phi process #12980

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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 @@ -28,6 +28,8 @@ void ApplyCPhiReductionProcess::ExecuteInitializeSolutionStep()
mReductionFactor = mPreviousReductionFactor - mReductionIncrement;
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;
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 @@ -185,6 +185,14 @@ KRATOS_TEST_CASE_IN_SUITE(CheckFailureEmptyModelPartApplyCPhiReductionProcess, K
"ApplyCPhiReductionProces has no elements in modelpart dummy")
}

KRATOS_TEST_CASE_IN_SUITE(CheckReturnsZeroForValidModelPartApplyCPhiReductionProcess, KratosGeoMechanicsFastSuite)
{
Model model;
auto& r_model_part = PrepareCPhiTestModelPart(model);
ApplyCPhiReductionProcess process{r_model_part, {}};
KRATOS_CHECK_EQUAL(process.Check(), 0);
}

KRATOS_TEST_CASE_IN_SUITE(CheckFailureNegativeReductionFactorApplyCPhiReductionProcess, KratosGeoMechanicsFastSuite)
{
Model model;
Expand All @@ -200,4 +208,23 @@ KRATOS_TEST_CASE_IN_SUITE(CheckFailureNegativeReductionFactorApplyCPhiReductionP
"Reduction factor should not drop below 0.01, calculation stopped.");
}

KRATOS_TEST_CASE_IN_SUITE(CheckFailureTooSmallReductionIncrementApplyCPhiReductionProcess, KratosGeoMechanicsFastSuite)
{
Model model;
auto& r_model_part = PrepareCPhiTestModelPart(model);
// Number of cycles should be larger than one to trigger the step halving of the
// reduction increment
r_model_part.GetProcessInfo().GetValue(NUMBER_OF_CYCLES) = 10;
ApplyCPhiReductionProcess process{r_model_part, {}};
for (size_t i = 0; i < 6; ++i) {
process.ExecuteInitializeSolutionStep();
}

// After halving the initial reduction increment (0.1) for the seventh time, it becomes
// 0,00078125, so it should throw an exception
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking (use the dot as decimal separator):

Suggested change
// 0,00078125, so it should throw an exception
// 0.00078125, so it should throw an exception

KRATOS_EXPECT_EXCEPTION_IS_THROWN(
process.ExecuteInitializeSolutionStep(),
"Reduction increment should not drop below 0.001, calculation stopped. Final safety factor = 1");
Copy link
Contributor

Choose a reason for hiding this comment

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

I was a bit surprised to see a final safety factor of 1.0. I'm not sure whether I would have expected that particular value. Can you perhaps help me to see why 1.0 must be the correct value in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. the error message use mPreviousReductionFactor which is only updated in ExecuteFinalizeSolutionStep.
process.ExecuteFinalizeSolutionStep is not invoked in the test, hence the factor of safety remained 1.

}

} // namespace Kratos::Testing
Loading