Skip to content

Commit

Permalink
Refactor assign
Browse files Browse the repository at this point in the history
  • Loading branch information
loumalouomega committed Dec 15, 2023
1 parent ce24937 commit ba8f15e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
10 changes: 10 additions & 0 deletions kratos/spatial_containers/search_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@ void SearchWrapper<TSearchObject>::PrepareResultsInProperRanks(

// Initialize results
rResults.InitializeResults(data_communicators);

// Set some values
const auto& r_search_ranks = rSearchInfo.SearchRanks;
const auto& r_indexes = rSearchInfo.Indexes;
auto& r_results_vector = rResults.GetContainer();
IndexPartition<IndexType>(r_results_vector.size()).for_each([&r_results_vector, & r_search_ranks, &r_indexes](const IndexType Index) {
auto& r_point_result = *(r_results_vector[Index]);
r_point_result.SetRankSearch(r_search_ranks[Index]);
r_point_result.SetIndex(r_indexes[Index]);
});
}

/***********************************************************************************/
Expand Down
24 changes: 4 additions & 20 deletions kratos/spatial_containers/search_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper

// Prepare MPI search
DistributedSearchInformation search_info;
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, Radius, mrDataCommunicator);
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, Radius, mrDataCommunicator, true);

// Initialize results
PrepareResultsInProperRanks(rResults, search_info, ConsiderGlobalDataCommunicator);
Expand All @@ -633,10 +633,6 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper
rTLS.point[2] = search_info.PointCoordinates[i_point * 3 + 2];
auto& r_point_result = rResults[i_point];

// Set some values
r_point_result.SetRankSearch(rank);
r_point_result.SetIndex(i_point);

// Search
std::vector<ResultType> results;
LocalSearchInRadius(rTLS.point, Radius, results, allocation_size);
Expand Down Expand Up @@ -688,7 +684,7 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper

// Prepare MPI search
DistributedSearchInformation search_info;
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, Radius, mrDataCommunicator);
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, Radius, mrDataCommunicator, true);

// Initialize results
PrepareResultsInProperRanks(rResults, search_info, ConsiderGlobalDataCommunicator);
Expand All @@ -704,10 +700,6 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper
rTLS.point[2] = search_info.PointCoordinates[i_point * 3 + 2];
auto& r_point_result = rResults[i_point];

// Set some values
r_point_result.SetRankSearch(rank);
r_point_result.SetIndex(i_point);

// Result of search
ResultType local_result;
LocalSearchNearestInRadius(rTLS.point, Radius, local_result, allocation_size);
Expand Down Expand Up @@ -759,7 +751,7 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper

// Prepare MPI search
DistributedSearchInformation search_info;
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, max_radius, mrDataCommunicator);
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, max_radius, mrDataCommunicator, true);

// Initialize results
PrepareResultsInProperRanks(rResults, search_info, ConsiderGlobalDataCommunicator);
Expand All @@ -775,10 +767,6 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper
rTLS.point[2] = search_info.PointCoordinates[i_point * 3 + 2];
auto& r_point_result = rResults[i_point];

// Set some values
r_point_result.SetRankSearch(rank);
r_point_result.SetIndex(i_point);

// Result of search
ResultType local_result;
LocalSearchNearest(rTLS.point, local_result);
Expand Down Expand Up @@ -827,7 +815,7 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper

// Prepare MPI search
DistributedSearchInformation search_info;
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, 0.0, mrDataCommunicator);
SearchUtilities::SynchronousPointSynchronizationWithBoundingBox(itPointBegin, itPointEnd, search_info, r_local_bb, 0.0, mrDataCommunicator, true);

// Initialize results
PrepareResultsInProperRanks(rResults, search_info, ConsiderGlobalDataCommunicator);
Expand All @@ -843,10 +831,6 @@ class KRATOS_API(KRATOS_CORE) SearchWrapper
rTLS.point[2] = search_info.PointCoordinates[i_point * 3 + 2];
auto& r_point_result = rResults[i_point];

// Set some values
r_point_result.SetRankSearch(rank);
r_point_result.SetIndex(i_point);

// Result of search
ResultType local_result;
LocalSearchIsInside(rTLS.point, local_result);
Expand Down

0 comments on commit ba8f15e

Please sign in to comment.