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] Unit tests for TransientPwElement #13012

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

markelov208
Copy link
Contributor

@markelov208 markelov208 commented Jan 16, 2025

📝 Description
A brief description of the PR.

Unit tests have been created for the following TransientPwElement functions

  1. Create
  2. Initialize
  3. Check
  4. InitializeSolutionStep
  5. InitializeNonLinearIteration
  6. FinalizeNonLinearIteration
  7. FinalizeSolutionStep
  8. three CalculateOnIntegrationPoints
    Two unit tests (2D and 3D elements) call CalculateLocalSystem that calls
  9. CalculateAll
  10. InitializeElementVariables
  11. CalculateAndAddLHS
  12. CalculateAndAddCompressibilityMatrix
  13. CalculateAndAddRHS
  14. CalculateAndAddPermeabilityFlow
  15. CalculateAndAddFluidBodyFlow
  16. CalculateAndAddCompressibilityFlow
  17. CalculateKinematics

An extra unit test is created for functions that are empty or return zero values:
18. CalculateMassMatrix
19. CalculateDampingMatrix
20. GetValuesVector
21. GetFirstDerivativesVector
22. GetSecondDerivativesVector
23. InitializeNonLinearIteration
24. FinalizeNonLinearIteration

@markelov208 markelov208 self-assigned this Jan 16, 2025
Copy link
Contributor

@rfaasse rfaasse left a comment

Choose a reason for hiding this comment

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

Thank you for the (tedious) work you put int adding unit tests and increasing our coverage! I just have some ideas for using algorithms, but this is very valuable!

@@ -19,7 +19,6 @@
#include "custom_elements/U_Pw_small_strain_element.hpp"
#include "custom_utilities/element_utilities.hpp"
#include "custom_utilities/stress_strain_utilities.h"
#include "geo_mechanics_application_variables.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch! Removing these when redundant will speed up compilation times (especially large headers like this one)

Comment on lines 190 to 192
for (auto p_dof : degrees_of_freedom) {
KRATOS_EXPECT_EQ(p_dof->GetVariable(), WATER_PRESSURE);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could use an algorithm here (might be syntax errors here, but something like this):

Suggested change
for (auto p_dof : degrees_of_freedom) {
KRATOS_EXPECT_EQ(p_dof->GetVariable(), WATER_PRESSURE);
}
KRATOS_EXPECT_TRUE(std::all_of(degrees_of_freedom.begin(), degrees_of_freedom.end(), [](auto pdof){return p_dof->GetVariable() == WATER_PRESSURE;});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 431 to 433
for (const auto& retention_law : r_retention_law_vector) {
KRATOS_EXPECT_NE(dynamic_cast<SaturatedLaw*>(retention_law.get()), nullptr);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to my other comment, we should be able to use std::none_of here (KRATOS_EXPECT_TRUE(std::none_of... etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 449 to 451
for (auto& node : p_element->GetGeometry()) {
KRATOS_EXPECT_EQ(node.FastGetSolutionStepValue(HYDRAULIC_DISCHARGE), 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.

We can use a std::all_of here (and also in some other places in the next tests 👍 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@markelov208 markelov208 requested a review from rfaasse January 17, 2025 12:58
Copy link
Contributor Author

@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 and Wijtze-Pieter, thank you very much for making the code better. I added on more unit test and remove a few lines from the code. Hope the coverage will be higher now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GeoMechanicsApplication] Assessment of making TransientPwElement inherent from Element
2 participants