-
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] Geo/11626 initialize solving strategies settlement #11665
[GeoMechanicsApplication] Geo/11626 initialize solving strategies settlement #11665
Conversation
…nd made sure the run_cpp_unit_tests.py runs both by default and has the option to only run the slowest
…6_InitializeSolvingStrategies_Settlement
…ategy_factory.cpp
applications/GeoMechanicsApplication/tests/run_cpp_unit_tests.py
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_workflows/dgeosettlement.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_builder_and_solver_factory.cpp
Show resolved
Hide resolved
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.
This looks good to me. Nice to have factories that we can extend as we see fit. I just had several minor comments, nothing major.
applications/GeoMechanicsApplication/custom_utilities/builder_and_solver_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/scheme_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_scheme_factory.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_convergence_criteria_factory.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/run_cpp_unit_tests.py
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/run_cpp_unit_tests.py
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/builder_and_solver_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/scheme_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/scheme_factory.hpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/scheme_factory.hpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_builder_and_solver_factory.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_builder_and_solver_factory.cpp
Outdated
Show resolved
Hide resolved
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 the great work Richard! I still found several minor things that you may want to address.
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/solving_strategy_factory.hpp
Outdated
Show resolved
Hide resolved
const auto factory = BuilderAndSolverFactory<SparseSpaceType, LocalSpaceType, LinearSolverType>(); | ||
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{}, solver), | ||
"the block_builder parameter is not defined, aborting BuilderAndSolverCreation") |
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.
Since Create
is a static member function, you'd better write it like this (just as for the two above test cases):
const auto factory = BuilderAndSolverFactory<SparseSpaceType, LocalSpaceType, LinearSolverType>(); | |
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{}, solver), | |
"the block_builder parameter is not defined, aborting BuilderAndSolverCreation") | |
KRATOS_EXPECT_EXCEPTION_IS_THROWN(BuilderAndSolverFactory<SparseSpaceType, LocalSpaceType, LinearSolverType>::Create(Parameters{}, solver), | |
"the block_builder parameter is not defined, aborting BuilderAndSolverCreation") |
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.
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.
Yes, you're right. However, you may overcome the above problem by wrapping the first argument of the macro in a pair of parenthesis, i.e.:
const auto factory = BuilderAndSolverFactory<SparseSpaceType, LocalSpaceType, LinearSolverType>(); | |
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{}, solver), | |
"the block_builder parameter is not defined, aborting BuilderAndSolverCreation") | |
KRATOS_EXPECT_EXCEPTION_IS_THROWN((BuilderAndSolverFactory<SparseSpaceType, LocalSpaceType, LinearSolverType>::Create(Parameters{}, solver)), | |
"the block_builder parameter is not defined, aborting BuilderAndSolverCreation") |
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.
This works indeed, and what also does is creating an alias (which is better for readability anyway), since in this case the problem of the macro seems to be related to having the template arguments there.
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | ||
"scheme_type is not defined, aborting") |
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.
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | |
"scheme_type is not defined, aborting") | |
KRATOS_EXPECT_EXCEPTION_IS_THROWN(SchemeFactory<SparseSpaceType, LocalSpaceType>::Create(Parameters{parameters}), | |
"scheme_type is not defined, aborting") |
(And then variable factory
is no longer needed.)
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.
Same answer as before, the macro doesn't seem to accept it
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 using your suggestion
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | ||
"solution_type is not defined, aborting") |
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.
Same thing here...
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.
Same answer as before, the macro doesn't seem to accept it
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 using your suggestion
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | ||
"Specified solution_type/scheme_type is not supported, aborting") |
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.
... and here
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.
Same answer as before, the macro doesn't seem to accept it
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 using your suggestion
KRATOS_TEST_CASE_IN_SUITE(Create_ReturnsSolvingStrategy_ForNewtonRhapsonStrategy, KratosGeoMechanicsFastSuite) | ||
{ | ||
Model model; | ||
const int buffer_size = 3; |
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.
As Wijtze Pieter suggested, let's change this value to 2
:-)
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
parameters, dummy_model_part); | ||
|
||
KRATOS_EXPECT_NE(created_strategy, nullptr); | ||
created_strategy->Check(); |
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.
Was this function call added intentionally? If yes, then I would have expected some kind of checking. Perhaps its return value. Or whether it throws (or not). The way it is written now confuses me a bit.
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.
Agreed, I implicitly check if it throws by just having it there. I added the check for the return value.
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.
Got the static calls in, feel free to re-review
const auto factory = BuilderAndSolverFactory<SparseSpaceType, LocalSpaceType, LinearSolverType>(); | ||
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{}, solver), | ||
"the block_builder parameter is not defined, aborting BuilderAndSolverCreation") |
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.
This works indeed, and what also does is creating an alias (which is better for readability anyway), since in this case the problem of the macro seems to be related to having the template arguments there.
const ConvergenceCriteriaFactory<SparseSpaceType, LocalSpaceType> factory; | ||
|
||
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{"{}"}), "No convergence_criterion is defined, aborting.") |
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 using your suggestion
const ConvergenceCriteriaFactory<SparseSpaceType, LocalSpaceType> factory; | ||
|
||
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{R"({"convergence_criterion" : "something_unknown" })"}), |
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 using your suggestion
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | ||
"scheme_type is not defined, aborting") |
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 using your suggestion
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | ||
"solution_type is not defined, aborting") |
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 using your suggestion
KRATOS_EXPECT_EXCEPTION_IS_THROWN(factory.Create(Parameters{parameters}), | ||
"Specified solution_type/scheme_type is not supported, aborting") |
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 using your suggestion
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.
This looks good and clear to me. Please merge.
📝 Description
This PR aims to create the factory for the solving strategy and the necessary subcomponents (Scheme, BuilderAndSolver, ConvergenceCriteria and LinearSolver) and test them using unit tests.
🆕 Changelog