Skip to content

Conversation

@rfaasse
Copy link
Contributor

@rfaasse rfaasse commented Dec 3, 2025

📝 Description
Extends the extrapolator to be able to extrapolate lines and adds a regression unit test for it. Next to that, a minor addition is done to the ublas utilities to also be able to generate a matrix.

@rfaasse rfaasse self-assigned this Dec 3, 2025
@rfaasse rfaasse requested a review from a team as a code owner December 3, 2025 10:53
@rfaasse rfaasse added the GeoMechanics Issues related to the GeoMechanicsApplication label Dec 3, 2025
Comment on lines 41 to 42
expected_extrapolation_matrix <<= UblasUtilities::CreateMatrix({{ 0.923275, 0.444444,-0.367719},
{-0.367719, 0.444444, 0.923275}});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should still check these values

Copy link
Contributor

Choose a reason for hiding this comment

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

outdated, now an analytical result.

Comment on lines 34 to 35
// Used the integration method found in the 2d3 Timoshenko Beam element
constexpr auto integration_method = GeometryData::IntegrationMethod::GI_GAUSS_3;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this integration method is strange for a 2D2 (same for the 2D3 case), but for the moment I just took the same as the timoshenko beam (since that's what we'll use it for)

Copy link
Contributor

Choose a reason for hiding this comment

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

Outdated, now using GAUSS_2

Copy link
Contributor

@markelov208 markelov208 left a comment

Choose a reason for hiding this comment

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

Hi Richard, it looks the extension was very easy to do. ;)

Comment on lines +30 to +34
Matrix result(rInitializerList.size(), rInitializerList.begin()->size(), 0.0);
for (std::size_t i = 0; const auto& r_row : rInitializerList) {
std::ranges::copy(r_row, row(result, i).begin());
++i;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The function does not check the input for correctness. Is it on purpose? To have it fast, right?

namespace Kratos::Testing
{

KRATOS_TEST_CASE_IN_SUITE(NodalExtrapolator_GivesCorrectExtrapolationMatrix_For2D3NLine,
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no test when numbers of nodes and gauss points are equal. The output is expected. However, is it useful to have such a test to increase the code coverage? Or just in case?

Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

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

Hi Richard,
Thank you very much for extending the linear nodal extrapolator such that it can also handle line geometries. The changes are clear and nicely unit-tested. I only have a few minor suggestions, so I expect we can merge this soon.

return result;
}

Matrix UblasUtilities::CreateMatrix(const std::initializer_list<std::initializer_list<double>>& rInitializerList)
Copy link
Contributor

Choose a reason for hiding this comment

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

The code suggests that we receive a list of rows. Perhaps we can rename the function parameter such that this is clearer? For instance:

Suggested change
Matrix UblasUtilities::CreateMatrix(const std::initializer_list<std::initializer_list<double>>& rInitializerList)
Matrix UblasUtilities::CreateMatrix(const std::initializer_list<std::initializer_list<double>>& rRows)

{
if (rInitializerList.size() == 0) return {};

Matrix result(rInitializerList.size(), rInitializerList.begin()->size(), 0.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there are no checks on the sizes of the supplied rows, it may be safer to determine the maximum row length and use that as the number of columns of the matrix. What do you think? Or should we raise an error when the rows don't have one and the same size?

nodal_extrapolator.CalculateElementExtrapolationMatrix(geometry, integration_method);

// clang-format off
Matrix expected_extrapolation_matrix = UblasUtilities::CreateMatrix(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make this one const auto:

Suggested change
Matrix expected_extrapolation_matrix = UblasUtilities::CreateMatrix(
const auto expected_extrapolation_matrix = UblasUtilities::CreateMatrix(

{0.5, 0.5}});
// clang-format on

KRATOS_EXPECT_MATRIX_NEAR(extrapolation_matrix, expected_extrapolation_matrix, 1e-6)
Copy link
Contributor

Choose a reason for hiding this comment

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

When we #include "tests/cpp_tests/test_utilities.h", we can use the default absolute tolerance in the check:

Suggested change
KRATOS_EXPECT_MATRIX_NEAR(extrapolation_matrix, expected_extrapolation_matrix, 1e-6)
KRATOS_EXPECT_MATRIX_NEAR(extrapolation_matrix, expected_extrapolation_matrix, Defaults::absolute_tolerance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GeoMechanics Issues related to the GeoMechanicsApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GeoMechanicsApplication] Submerged excavation model with linear elastic materials: apply prestress to the interface elements

5 participants