-
Notifications
You must be signed in to change notification settings - Fork 247
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
base: master
Are you sure you want to change the base?
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.
📝 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 are empty or return zero values:
18. CalculateMassMatrix
19. CalculateDampingMatrix
20. GetValuesVector
21. GetFirstDerivativesVector
22. GetSecondDerivativesVector
23. InitializeNonLinearIteration
24. FinalizeNonLinearIteration