-
Notifications
You must be signed in to change notification settings - Fork 279
[GeoMechanicsApplication] Added CheckDomainSize #13305
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1377c1f
added check utility for DomainSize
markelov208 85e5653
corrected error message
markelov208 701c2d0
removed accidentally added space
markelov208 bf08c2b
used nullopt to remove a code smell
markelov208 40f866e
used value_or
markelov208 f62b194
split check_utilities.hpp into header and body
markelov208 7d3ac1f
Merge branch 'master' into geo/13303-domain-checks
markelov208 c4aabf8
added unit test
markelov208 b8ba329
removed pragma from cpp file
markelov208 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
applications/GeoMechanicsApplication/custom_utilities/check_utilities.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Gennady Markelov | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| // Project includes | ||
| #include "check_utilities.h" | ||
| #include "includes/exception.h" | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| void CheckUtilities::CheckDomainSize(double DomainSize, std::size_t Id, const std::optional<std::string>& PrintName) | ||
| { | ||
| constexpr auto min_domain_size = 1.0e-15; | ||
| KRATOS_ERROR_IF(DomainSize < min_domain_size) | ||
| << PrintName.value_or("DomainSize") << " (" << DomainSize << ") is smaller than " | ||
| << min_domain_size << " for element " << Id << std::endl; | ||
| } | ||
|
|
||
| } /* namespace Kratos.*/ | ||
31 changes: 31 additions & 0 deletions
31
applications/GeoMechanicsApplication/custom_utilities/check_utilities.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Gennady Markelov | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| // Project includes | ||
| #include "includes/define.h" | ||
|
|
||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| class KRATOS_API(GEO_MECHANICS_APPLICATION) CheckUtilities | ||
| { | ||
| public: | ||
| static void CheckDomainSize(double DomainSize, | ||
| std::size_t Id, | ||
| const std::optional<std::string>& PrintName = std::nullopt); | ||
| }; /* Class CheckUtilities*/ | ||
| } /* namespace Kratos.*/ |
49 changes: 49 additions & 0 deletions
49
...ications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_check_utilities.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Gennady Markelov | ||
| // | ||
|
|
||
| #include "custom_utilities/check_utilities.h" | ||
| #include "includes/checks.h" | ||
| #include "tests/cpp_tests/geo_mechanics_fast_suite.h" | ||
|
|
||
| using namespace Kratos; | ||
|
|
||
| namespace Kratos::Testing | ||
| { | ||
|
|
||
| KRATOS_TEST_CASE_IN_SUITE(CheckUtilities_CheckDomainSize, KratosGeoMechanicsFastSuiteWithoutKernel) | ||
| { | ||
| // Arrange | ||
| constexpr std::size_t id = 1; | ||
| PointerVector<Node> nodes; | ||
| nodes.push_back(make_intrusive<Node>(0, 0.0, 0.0, 0.0)); | ||
| nodes.push_back(make_intrusive<Node>(1, 0.0, 0.0, 0.0)); | ||
| const auto line_with_coincident_nodes = Line2D2<Node>(nodes); | ||
| nodes.push_back(make_intrusive<Node>(2, 0.0, 0.0, 0.0)); | ||
| const auto triangle_with_coincident_nodes = Triangle2D3<Node>(nodes); | ||
| nodes.push_back(make_intrusive<Node>(2, 0.0, 0.0, 0.0)); | ||
| const auto tetra_with_coincident_nodes = Tetrahedra3D4<Node>(nodes); | ||
|
|
||
| // Act and Assert | ||
| KRATOS_EXPECT_EXCEPTION_IS_THROWN( | ||
| CheckUtilities::CheckDomainSize(line_with_coincident_nodes.DomainSize(), id, "Length"), | ||
| "Length (0) is smaller than 1e-15 for element 1") | ||
|
|
||
| KRATOS_EXPECT_EXCEPTION_IS_THROWN( | ||
| CheckUtilities::CheckDomainSize(triangle_with_coincident_nodes.DomainSize(), id), | ||
| "DomainSize (0) is smaller than 1e-15 for element 1") | ||
|
|
||
| KRATOS_EXPECT_EXCEPTION_IS_THROWN( | ||
| CheckUtilities::CheckDomainSize(tetra_with_coincident_nodes.DomainSize(), id), | ||
| "DomainSize (0) is smaller than 1e-15 for element 1") | ||
| } | ||
|
|
||
| } // namespace Kratos::Testing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
No inclusion guard needed in an implementation file (
.cpp).