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

[Core][MPI] Adding SpatialSearchResultContainer/SpatialSearchResultContainerVector and SearchWrapper (v.3.0) #11719

Open
wants to merge 588 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
588 commits
Select commit Hold shift + click to select a range
4de7430
Adding checks
loumalouomega Dec 5, 2023
998b350
Missing return
loumalouomega Dec 6, 2023
008e378
Refactor
loumalouomega Dec 6, 2023
7541337
Missing return
loumalouomega Dec 6, 2023
c49c462
Refactor
loumalouomega Dec 6, 2023
73ab997
Missing
loumalouomega Dec 6, 2023
c2ea227
Missing
loumalouomega Dec 6, 2023
e626b9b
Fix empty cases
loumalouomega Dec 7, 2023
75fe1e3
Fix empty cases
loumalouomega Dec 7, 2023
4c46d47
Refactor `SpatialSearchResultContainer`
loumalouomega Dec 7, 2023
3c79e77
Refactor `SpatialSearchResultContainerVector` (WIP)
loumalouomega Dec 7, 2023
edb1f82
Update `SpatialSearchResultContainer` tests
loumalouomega Dec 7, 2023
7def12a
Update `SpatialSearchResultContainerVector` tests
loumalouomega Dec 7, 2023
ad4f520
Refactor `SearchWrapper`
loumalouomega Dec 7, 2023
554bfb5
Expose new and missing methods
loumalouomega Dec 7, 2023
449deba
Update MPI test
loumalouomega Dec 7, 2023
48741b2
Refactor tests
loumalouomega Dec 7, 2023
b177ce1
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Dec 7, 2023
2bab9dc
Remove maps, pure vectors, suggested interface by @pooyan-dadvand
loumalouomega Dec 8, 2023
5bc04f0
Temporal cleaning
loumalouomega Dec 8, 2023
97a518d
Adding debug error
loumalouomega Dec 11, 2023
82cc503
Adding missing check required by @jcotela
loumalouomega Dec 13, 2023
f34aed9
Correction
loumalouomega Dec 13, 2023
84bd0fa
Fix MPI run
loumalouomega Dec 13, 2023
54381ff
Adding test to verify properly works
loumalouomega Dec 13, 2023
74af7ef
Prepare
loumalouomega Dec 14, 2023
0a51cf2
Some fixes
loumalouomega Dec 14, 2023
90f1eda
Some additional info added
loumalouomega Dec 14, 2023
d947bbc
Partial revert
loumalouomega Dec 14, 2023
9befaf5
Adding more info
loumalouomega Dec 15, 2023
ba413c0
Adding `IsLocalSearch` method
loumalouomega Dec 15, 2023
619e7cf
Merge branch 'master' into core/modify-spatial-search-result-containe…
loumalouomega Dec 15, 2023
a9fe0c3
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Dec 15, 2023
26a9268
Adding more info
loumalouomega Dec 15, 2023
5eb193a
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Dec 15, 2023
45ca399
Better check
loumalouomega Dec 15, 2023
5ca5bb6
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Dec 15, 2023
6b09f72
Extend checks
loumalouomega Dec 15, 2023
9c66116
Some function refactor, more check
loumalouomega Dec 15, 2023
cf4ac60
Correct the test suite
loumalouomega Dec 15, 2023
670977b
More generic
loumalouomega Dec 15, 2023
b4921c2
More generic
loumalouomega Dec 15, 2023
367b576
Update
loumalouomega Dec 15, 2023
82a5056
Update
loumalouomega Dec 15, 2023
ce24937
Missing
loumalouomega Dec 15, 2023
314ee43
Missing
loumalouomega Dec 15, 2023
ba8f15e
Refactor assign
loumalouomega Dec 15, 2023
69aa2ce
Fix clang compilation
loumalouomega Dec 17, 2023
aafd999
Unrequired definition
loumalouomega Dec 18, 2023
4aacb1d
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Dec 20, 2023
3ea9845
Update kratos/utilities/search_utilities.h
loumalouomega Dec 20, 2023
51ddc4b
Update kratos/utilities/search_utilities.h
loumalouomega Dec 20, 2023
c7d506a
Merge branch 'master' into core/modify-spatial-search-result-containe…
loumalouomega Dec 20, 2023
e7bcb20
Update kratos/utilities/search_utilities.h
loumalouomega Dec 20, 2023
8d00cc3
Update kratos/utilities/search_utilities.h
loumalouomega Dec 20, 2023
6969d21
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Dec 20, 2023
845c2c7
Update
loumalouomega Dec 20, 2023
6aea813
Recommendation
loumalouomega Dec 20, 2023
f638046
Suggestion by @roigcarlo
loumalouomega Dec 20, 2023
2629c5b
Recommendation
loumalouomega Dec 20, 2023
8ff08ef
Suggestion by @roigcarlo
loumalouomega Dec 20, 2023
59f6c5b
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Dec 21, 2023
026e80b
Merge branch 'master' into core/modify-spatial-search-result-containe…
loumalouomega Dec 21, 2023
4d80957
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Dec 21, 2023
7515759
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jan 18, 2024
c2456a6
Merge branch 'master' into core/modify-spatial-search-result-containe…
loumalouomega Jan 18, 2024
82eb6ef
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Jan 18, 2024
e2221dc
Minor
loumalouomega Jan 18, 2024
a9d7f2e
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jan 22, 2024
d7561ac
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Jan 22, 2024
b975e68
Some modification in SearchUtilities to accommodate the requirements …
loumalouomega Jan 22, 2024
48f1674
Adding Barrier method, as well as separate global and local index
loumalouomega Jan 22, 2024
a71dc42
Update consistently SearchWrapper
loumalouomega Jan 22, 2024
dc795fc
Simplification
loumalouomega Jan 22, 2024
e8f730d
Minor test update
loumalouomega Jan 23, 2024
b49017f
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jan 25, 2024
6e6f9ae
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Jan 25, 2024
6cc9d45
Improve check
loumalouomega Jan 25, 2024
cde548f
Merge pull request #11857 from KratosMultiphysics/core/modify-spatial…
loumalouomega Jan 29, 2024
84fccc3
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jan 29, 2024
44ffe00
Minor
loumalouomega Jan 29, 2024
c5bdfb2
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jan 30, 2024
c3ed537
Consistent Rank
loumalouomega Jan 30, 2024
c5bf9fc
Fix
loumalouomega Jan 30, 2024
e353b61
Adding timers
loumalouomega Jan 30, 2024
c757642
Search ranks is a redundant information
loumalouomega Jan 31, 2024
10d55d8
Missing check (reduces sending/receiving info)
loumalouomega Jan 31, 2024
d8b76cf
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 1, 2024
bc22e90
[Core] Missing & in `Get` method in `SpatialSearchResult`
loumalouomega Feb 1, 2024
72c87bc
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 2, 2024
b3fa630
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 5, 2024
cf4113e
[Core] Correcting corner case in `GeometricalObjectBins` + typo ("ava…
loumalouomega Feb 5, 2024
e11e0ff
Minor clean up
loumalouomega Feb 5, 2024
73829d9
Revert
loumalouomega Feb 5, 2024
ba4f67c
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 5, 2024
3e103dd
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 6, 2024
4c3678f
Fix potential node conflict
loumalouomega Feb 6, 2024
3a54ce5
Update search utilities
loumalouomega Feb 6, 2024
f8a029d
Update the SpatialSearchResultContainer adding SpatialSearchCommunica…
loumalouomega Feb 6, 2024
8ff6850
Update the SpatialSearchResultContainerVector adding SpatialSearchCom…
loumalouomega Feb 6, 2024
d4e5cdc
Update the SearchWrapper consistently
loumalouomega Feb 6, 2024
a3ec6bb
Update python exposition
loumalouomega Feb 6, 2024
af04564
Serial compilation fix
loumalouomega Feb 7, 2024
4e5df90
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 7, 2024
a2d2794
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 7, 2024
9ecf8b3
Adding `GetSpatialSearchCommunication`
loumalouomega Feb 7, 2024
a63a0fc
Update tests
loumalouomega Feb 7, 2024
8f4dd45
Adding error
loumalouomega Feb 9, 2024
9838922
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 9, 2024
6b36995
Adding error
loumalouomega Feb 9, 2024
119cce7
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 9, 2024
9109f27
Minor fix
loumalouomega Feb 10, 2024
d60f1bf
Minor fix
loumalouomega Feb 10, 2024
5987400
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 10, 2024
96c767e
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 13, 2024
88b1dfa
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 13, 2024
6f62ac6
Adding `RemoveResultsFromRanksList`
loumalouomega Feb 16, 2024
3203640
Update `KeepOnlyGivenLambdaResult` with ranks
loumalouomega Feb 16, 2024
667de5b
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 16, 2024
2eee44a
Adding `RemoveResultsFromRanksList`
loumalouomega Feb 16, 2024
96c7a54
Update `KeepOnlyGivenLambdaResult` with ranks
loumalouomega Feb 16, 2024
777bb8f
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 16, 2024
6feebe0
Extra :
loumalouomega Feb 16, 2024
014d1bb
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 16, 2024
aae224f
Fix Windows communicator issue
loumalouomega Feb 16, 2024
70021c2
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 16, 2024
6d4ee58
Improve logic
loumalouomega Feb 16, 2024
63a6abd
Improve logic
loumalouomega Feb 16, 2024
8b97858
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 16, 2024
8d8a89c
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 16, 2024
990d9ed
Update `PreparePointsSearch` with Rank info
loumalouomega Feb 19, 2024
aba08bc
Add rank in `PreparePointsSearch` call
loumalouomega Feb 19, 2024
a55e460
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 19, 2024
2944fdd
Update `PreparePointsSearch` with Rank info
loumalouomega Feb 19, 2024
2d84ce2
Add rank in `PreparePointsSearch` call
loumalouomega Feb 19, 2024
bfd38ec
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 19, 2024
e03cc1d
work in progress
AFranci Dec 21, 2023
886f748
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 19, 2024
ecf62c6
work in progress
AFranci Dec 21, 2023
10c310e
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 19, 2024
3b2dcc0
Minor checks done when filling
loumalouomega Feb 20, 2024
2c244a1
Add additional checks
loumalouomega Feb 20, 2024
f4901cd
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 20, 2024
7047001
Add additional checks
loumalouomega Feb 20, 2024
8563e29
Minor checks done when filling
loumalouomega Feb 20, 2024
6b0bb35
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 20, 2024
f72a9e5
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 20, 2024
99dcd01
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 20, 2024
1e5c34a
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Feb 20, 2024
68115ee
Merge pull request #12024 from KratosMultiphysics/core/mpi/spatial-se…
loumalouomega Feb 20, 2024
5916649
Update test_edge_based_data_structure.cpp
rubenzorrilla Feb 20, 2024
a675438
Adding linear to quadratic tets modeler
jcotela Feb 5, 2024
b6116a8
Adding doc
loumalouomega Feb 6, 2024
635e042
Expose GeometryData to Python
jcotela Feb 8, 2024
5a44734
Use GeometryType to filter incorrect input
jcotela Feb 8, 2024
43a91c7
Class rename
jcotela Feb 15, 2024
17ad216
Adding python registry to MeshingApplication
jcotela Feb 15, 2024
653d99e
Install python registry file
jcotela Feb 15, 2024
32d942a
Fixing registry
jcotela Feb 16, 2024
810112c
Add tests
jcotela Feb 16, 2024
3be58a6
Removing factory method
jcotela Feb 16, 2024
02baedc
Revert unwanted change in output level
jcotela Feb 16, 2024
7d99473
Minor updates
jcotela Feb 16, 2024
2147ee5
Using any
jcotela Feb 19, 2024
48faca5
Require root model part
jcotela Feb 19, 2024
4b12221
Cleaning up
jcotela Feb 19, 2024
cc5ff62
Avoid element copy
jcotela Feb 19, 2024
09eecac
Add condition check
jcotela Feb 19, 2024
d76c637
Fix wrong check
jcotela Feb 19, 2024
686dd8d
Remove duplicate check
jcotela Feb 19, 2024
e82f5cc
Update applications/MeshingApplication/custom_utilities/linear_to_qua…
jcotela Feb 19, 2024
7ed5b2b
Update applications/MeshingApplication/custom_utilities/linear_to_qua…
jcotela Feb 19, 2024
10ee600
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 21, 2024
b947bee
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 22, 2024
ff954d3
Unify serial and distributed
loumalouomega Feb 22, 2024
573e408
Some remaining changes
loumalouomega Feb 22, 2024
16653f4
Inconsistent
loumalouomega Feb 22, 2024
5e19156
Clean up and unify code
loumalouomega Feb 22, 2024
02b3e94
Unnecesary serial fix
loumalouomega Feb 22, 2024
927c820
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 26, 2024
29d2fc5
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Feb 27, 2024
3687bba
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Mar 12, 2024
02ea856
1st cut-fem
AFranci Mar 14, 2023
2dc15e5
Set 10 to default `bucket_size`
loumalouomega Mar 12, 2024
428f04d
Clarify global BB
loumalouomega Mar 12, 2024
f4fffa7
Wrong description
loumalouomega Mar 12, 2024
9ab0417
Using vectorial version
loumalouomega Mar 12, 2024
82ef541
Clarify doc
loumalouomega Mar 12, 2024
9c002b0
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Mar 14, 2024
b3b86b0
Check already done in `Apply`
loumalouomega Mar 14, 2024
6d70719
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Mar 14, 2024
adc1476
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Mar 19, 2024
124be55
Minor
loumalouomega Mar 20, 2024
318abab
Some missing stuff
loumalouomega Mar 20, 2024
d4c9d02
Minor correction
loumalouomega Mar 20, 2024
f401e2b
Add new methods and variables to the SpatialSearchResultContainerVect…
loumalouomega Mar 20, 2024
eb6e33b
Add missing methods and variables to the SpatialSearchResultContainer…
loumalouomega Mar 20, 2024
a9f19ce
Add new test cases to SpatialSearchResultContainerVector class
loumalouomega Mar 20, 2024
d53aee0
Add new MPI test cases to SpatialSearchResultContainerVector class
loumalouomega Mar 20, 2024
bb452b7
Fix compilation unsigned issue
loumalouomega Mar 20, 2024
dd7cffc
Compilation fix
loumalouomega Mar 21, 2024
6a23f7d
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega May 21, 2024
bcad3fc
Add GetGlobalIndex and SetGlobalIndex methods to SpatialSearchResultC…
loumalouomega May 30, 2024
ffe1312
Adding more extended and complex search test
loumalouomega May 30, 2024
e9b668d
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jun 3, 2024
0fad27f
[Core] Fix BB check
loumalouomega Jun 3, 2024
655214a
Extend test (WIP)
loumalouomega Jun 3, 2024
b3818a3
Fix index
loumalouomega Jun 3, 2024
c8bbe65
Activate test MPI
loumalouomega Jun 3, 2024
4cb4066
Add tests for PointIsInsideBoundingBox functions
loumalouomega Jun 4, 2024
058087a
Refactor search_wrapper.h to use zero instead of -1 for non-distribut…
loumalouomega Jun 4, 2024
b0338f2
[Core] Refactor search_utilities.h to handle negative tolerance value…
loumalouomega Jun 5, 2024
f5f8944
Refactor search_wrapper.h to use consistent bounding box threshold value
loumalouomega Jun 5, 2024
e65c432
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jun 5, 2024
f324df5
Refactor search_wrapper.h to use consistent bounding box threshold value
loumalouomega Jun 6, 2024
59aea26
Refactor search_wrapper.h to use consistent bounding box threshold value
loumalouomega Jun 6, 2024
23eb0b3
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jun 6, 2024
87fdd9b
Merge branch 'master' into doc/document-search-mpi
loumalouomega Jun 6, 2024
a11aa71
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jun 10, 2024
ce164ac
Merge branch 'master' into doc/document-search-mpi
loumalouomega Jun 10, 2024
0bef7e1
Remove whitespace
loumalouomega Jun 14, 2024
afdba02
Document tree
loumalouomega Jun 14, 2024
267685a
Document spatial search result
loumalouomega Jun 14, 2024
48111fd
Document octree
loumalouomega Jun 14, 2024
b936bae
Document kd_tree
loumalouomega Jun 14, 2024
ff31cf0
Document bins static
loumalouomega Jun 14, 2024
bd47b60
Document bins dynamic
loumalouomega Jun 14, 2024
a9ceb62
Document GeometricalObjectsBins
loumalouomega Jun 14, 2024
ef3af98
Point to wiki
loumalouomega Jun 14, 2024
5926add
Remove images
loumalouomega Jun 14, 2024
e1094e9
Merge branch 'doc/initial-search-doc' into doc/document-search-mpi
loumalouomega Jun 20, 2024
77f1df7
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jun 20, 2024
403d792
Merge branch 'master' into doc/document-search-mpi
loumalouomega Jun 20, 2024
89aa204
Delete duplicated doc
loumalouomega Jun 20, 2024
37d9391
[Core] Adding documentation for MPI classes
loumalouomega Jun 25, 2024
e393e73
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jun 25, 2024
3c29117
Merge branch 'core/mpi/spatial-search-container-new-proposal-v3' into…
loumalouomega Jun 25, 2024
f78191c
Merge pull request #12480 from KratosMultiphysics/doc/document-search…
loumalouomega Jun 25, 2024
1cd8c19
Minor doc update
loumalouomega Jun 26, 2024
8fc59ae
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jul 17, 2024
b8badaf
Update the includes
loumalouomega Jul 17, 2024
854466e
Deactivate hetereogeneous tests
loumalouomega Jul 17, 2024
7b1d86e
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Jul 17, 2024
f5984de
Cleanup subdatacommunicators in SearchWrapper destructor
loumalouomega Jul 18, 2024
d45c5f2
Redundant
loumalouomega Jul 18, 2024
7a52876
Reactivate hetereogeneous tests
loumalouomega Jul 18, 2024
4ad9e07
Simplify code with data communicator implementation
loumalouomega Aug 1, 2024
9443276
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Oct 8, 2024
e6a1223
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Oct 17, 2024
74320c8
Merge branch 'master' into core/mpi/spatial-search-container-new-prop…
loumalouomega Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,357 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Vicente Mataix Ferrandiz
//
//

// System includes

// External includes

// Project includes
#include "testing/testing.h"
#include "geometries/line_2d_2.h"
#include "spatial_containers/spatial_search_result.h"
#include "spatial_containers/spatial_search_result_container.h"

namespace Kratos::Testing
{

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerAddResult, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1);
SpatialSearchResult<GeometricalObject> result(&object);
result.SetDistance(0.5);

// Add the result to the container
container.AddResult(result);

// Check that the result was added correctly
auto& r_local_pointers = container.GetLocalResults();
KRATOS_EXPECT_EQ(r_local_pointers.size(), 1);
KRATOS_EXPECT_EQ(r_local_pointers.size(), container.NumberOfLocalResults());

// Check distances
KRATOS_EXPECT_EQ(container[0].GetDistance(), 0.5);

// Check global pointers
auto& r_global_pointers = container.GetGlobalResults();
KRATOS_EXPECT_EQ(r_global_pointers.size(), 0); // It should be empty as we have not synchronized
KRATOS_EXPECT_EQ(r_global_pointers.size(), container.NumberOfGlobalResults()); // It should be empty as we have not synchronized
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerClear, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1);
SpatialSearchResult<GeometricalObject> result(&object);
result.SetDistance(0.5);

// Add the result to the container
container.AddResult(result);

// Clear
container.Clear();

// Check that the result was added correctly
auto& r_local_pointers = container.GetLocalResults();
KRATOS_EXPECT_EQ(r_local_pointers.size(), 0);
KRATOS_EXPECT_EQ(r_local_pointers.size(), container.NumberOfLocalResults());
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerSynchronizeAll, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1);
SpatialSearchResult<GeometricalObject> result(&object);

// Add the result to the container
container.AddResult(result);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Check that the result was added correctly
auto& r_local_pointers = container.GetLocalResults();
KRATOS_EXPECT_EQ(r_local_pointers.size(), 1);
KRATOS_EXPECT_EQ(r_local_pointers.size(), container.NumberOfLocalResults());

// Check global pointers
auto& r_global_pointers = container.GetGlobalResults();
KRATOS_EXPECT_EQ(static_cast<int>(r_global_pointers.size()), r_data_comm.Size());
KRATOS_EXPECT_EQ(r_global_pointers.size(), container.NumberOfGlobalResults());
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerGetResultShapeFunctions, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Generate a geometry
auto p_node1 = Kratos::make_intrusive<Node>(1, 0.0, 0.0, 0.0);
auto p_node2 = Kratos::make_intrusive<Node>(2, 1.0, 0.0, 0.0);
Geometry<Node>::Pointer p_geom = Kratos::make_shared<Line2D2<Node>>(p_node1, p_node2);

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1, p_geom);
SpatialSearchResult<GeometricalObject> result(&object);

// Add the result to the container
container.AddResult(result);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Compute shape functions
Point point = Point(0.5, 0.0, 0.0);
auto shape_functions = container.GetResultShapeFunctions(point);

// Check shape functions
KRATOS_EXPECT_EQ(static_cast<int>(shape_functions.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_NEAR(shape_functions[i_rank][0], 0.5, 1.0e-12);
KRATOS_EXPECT_NEAR(shape_functions[i_rank][1], 0.5, 1.0e-12);
}

// Check is inside
auto is_inside_true = container.GetResultIsInside(point, 1.0e-5);
KRATOS_EXPECT_EQ(static_cast<int>(is_inside_true.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_TRUE(is_inside_true[i_rank]);
}

Point point_outside = Point(1.0e6, 1.0e6, 1.0e6);
auto is_inside_false = container.GetResultIsInside(point_outside, 1.0e-5);
KRATOS_EXPECT_EQ(static_cast<int>(is_inside_true.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_FALSE(is_inside_false[i_rank]);
}
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerGetResultIsLocal, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1);
SpatialSearchResult<GeometricalObject> result(&object, r_data_comm.Rank());

// Add the result to the container
container.AddResult(result);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Compute is local
auto is_local = container.GetResultIsLocal();

// Check is local
KRATOS_EXPECT_EQ(static_cast<int>(is_local.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
if (i_rank == r_data_comm.Rank()) {
KRATOS_EXPECT_TRUE(static_cast<int>(is_local[i_rank]));
} else {
KRATOS_EXPECT_FALSE(static_cast<int>(is_local[i_rank]));
}
}

// Compute ranks
auto ranks = container.GetResultRank();

// Check ranks
KRATOS_EXPECT_EQ(static_cast<int>(ranks.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_EQ(ranks[i_rank], i_rank);
}
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerGetResultIsActive, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1);
SpatialSearchResult<GeometricalObject> result(&object);

// Add the result to the container
container.AddResult(result);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Compute is active
auto is_active = container.GetResultIsActive();

// Check is active
KRATOS_EXPECT_EQ(static_cast<int>(is_active.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_TRUE(static_cast<int>(is_active[i_rank]));
}

// Deactivate the object
object.Set(ACTIVE, false);

// Compute is active
is_active = container.GetResultIsActive();

// Check is active
KRATOS_EXPECT_EQ(static_cast<int>(is_active.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_FALSE(static_cast<int>(is_active[i_rank]));
}
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerGetResultIndices, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1);
SpatialSearchResult<GeometricalObject> result(&object);

// Add the result to the container
container.AddResult(result);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Compute indices
auto indices = container.GetResultIndices();

// Check indices
KRATOS_EXPECT_EQ(static_cast<int>(indices.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_EQ(static_cast<int>(indices[i_rank]), i_rank + 1);
}
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerGetResultCoordinates, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Generate a geometry
auto p_node1 = Kratos::make_intrusive<Node>(1, 0.0, 0.0, 0.0);
auto p_node2 = Kratos::make_intrusive<Node>(2, 1.0, 0.0, 0.0);
Geometry<Node>::Pointer p_geom = Kratos::make_shared<Line2D2<Node>>(p_node1, p_node2);

// Create a test result
GeometricalObject object = GeometricalObject(r_data_comm.Rank() + 1, p_geom);
SpatialSearchResult<GeometricalObject> result(&object);

// Add the result to the container
container.AddResult(result);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Compute shape functions
auto coordinates = container.GetResultCoordinates();

// Check shape functions
KRATOS_EXPECT_EQ(static_cast<int>(coordinates.size()), r_data_comm.Size());
for (int i_rank = 0; i_rank < r_data_comm.Size(); ++i_rank) {
KRATOS_EXPECT_EQ(coordinates[i_rank].size(), 2);
KRATOS_EXPECT_VECTOR_NEAR(coordinates[i_rank][0], p_node1->Coordinates(), 1.0e-12);
KRATOS_EXPECT_VECTOR_NEAR(coordinates[i_rank][1], p_node2->Coordinates(), 1.0e-12);
}
}

KRATOS_DISTRIBUTED_TEST_CASE_IN_SUITE(MPISpatialSearchResultContainerRemoveResultsFromIndexesList, KratosMPICoreFastSuite)
{
// The data communicator
const DataCommunicator& r_data_comm = Testing::GetDefaultDataCommunicator();
const int rank = r_data_comm.Rank();
const int world_size = r_data_comm.Size();

// Create a test object
SpatialSearchResultContainer<GeometricalObject> container;

// Create a test result
GeometricalObject object_1 = GeometricalObject(3 * rank + 1);
SpatialSearchResult<GeometricalObject> result_1(&object_1);
container.AddResult(result_1);
GeometricalObject object_2 = GeometricalObject(3 * rank + 2);
SpatialSearchResult<GeometricalObject> result_2(&object_2);
container.AddResult(result_2);
GeometricalObject object_3 = GeometricalObject(3 * rank + 3);
SpatialSearchResult<GeometricalObject> result_3(&object_3);
container.AddResult(result_3);

// Check that the result was added correctly
KRATOS_EXPECT_EQ(container.NumberOfLocalResults(), 3);

// Synchronize the container between partitions
container.SynchronizeAll(r_data_comm);

// Check global pointers
KRATOS_EXPECT_EQ(container.NumberOfGlobalResults(), static_cast<std::size_t>(3 * world_size));

// Remove indexes
std::vector<std::size_t> index_to_remove;
index_to_remove.reserve(2 * world_size);
for (int i_rank = 0; i_rank < world_size; ++i_rank) {
index_to_remove.push_back(3 * i_rank + 2);
index_to_remove.push_back(3 * i_rank + 3);
}
container.RemoveResultsFromIndexesList(index_to_remove);

// Check that the result was removed correctly
KRATOS_EXPECT_EQ(container.NumberOfLocalResults(), 1);
KRATOS_EXPECT_EQ(container.NumberOfGlobalResults(), static_cast<std::size_t>(world_size));

// Compute indices
auto indices = container.GetResultIndices();

// Check indices
KRATOS_EXPECT_EQ(indices.size(), static_cast<std::size_t>(world_size));
for (int i_rank = 0; i_rank < world_size; ++i_rank) {
KRATOS_EXPECT_EQ(indices[i_rank], static_cast<std::size_t>(3 * i_rank + 1));
}
}

} // namespace Kratos::Testing
Loading
Loading