-
Notifications
You must be signed in to change notification settings - Fork 248
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
Conversation
There was a problem hiding this 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" |
There was a problem hiding this comment.
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)
for (auto p_dof : degrees_of_freedom) { | ||
KRATOS_EXPECT_EQ(p_dof->GetVariable(), WATER_PRESSURE); | ||
} |
There was a problem hiding this comment.
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):
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;}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for (const auto& retention_law : r_retention_law_vector) { | ||
KRATOS_EXPECT_NE(dynamic_cast<SaturatedLaw*>(retention_law.get()), nullptr); | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for (auto& node : p_element->GetGeometry()) { | ||
KRATOS_EXPECT_EQ(node.FastGetSolutionStepValue(HYDRAULIC_DISCHARGE), 0.0); | ||
} |
There was a problem hiding this comment.
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 👍 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go in my opinion, I have one discussion point left (about calling some now empty functions and not asserting anything for the coverage), but I don't think it is blocking
// Act empty functions to increase the coverage | ||
element.InitializeNonLinearIteration(dummy_process_info); | ||
element.FinalizeNonLinearIteration(dummy_process_info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should add these lines, since nothing is asserted (of course right now there's nothing to be asserted). However, if we ever add any functionality to these functions, it seems like they're covered (because of this test), but actually they're only called.
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for formatting these (where I forgot to)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this is good to go!
📝 Description
A brief description of the PR.
Unit tests have been created for the following TransientPwElement functions
Two unit tests (2D and 3D elements) call CalculateLocalSystem that calls
An extra unit test is created for functions that return zero values:
18. CalculateMassMatrix
19. CalculateDampingMatrix
20. GetValuesVector
21. GetFirstDerivativesVector
22. GetSecondDerivativesVector
The following function have an empty body:
23. InitializeNonLinearIteration
24. FinalizeNonLinearIteration