-
Notifications
You must be signed in to change notification settings - Fork 248
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
base: master
Are you sure you want to change the base?
[Core][MPI] Adding SpatialSearchResultContainer
/SpatialSearchResultContainerVector
and SearchWrapper
(v.3.0)
#11719
Conversation
kratos/includes/data_communicator.h
Outdated
|
||
#ifndef KRATOS_BASE_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_LOC_INTERFACE_FOR_TYPE | ||
#define KRATOS_BASE_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_LOC_INTERFACE_FOR_TYPE(...) \ | ||
virtual std::pair<__VA_ARGS__, int> MinLocAll(const __VA_ARGS__& rLocalValue) const { return std::pair<__VA_ARGS__, int>(rLocalValue, 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.
just to be sure:
the data_communicator changes being reviewed in a different PR, am i correct?
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.
const auto& r_local_min = r_local_bb.GetMinPoint(); | ||
|
||
// Getting max values | ||
r_max[0] = mrDataCommunicator.MaxAll(r_local_max[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.
unimportant question (just ignore if you feel) but, isn't there a vector version of this? i mean one that considers the vector of components instead of each component separately
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 don't know, if I can simplify the code that would be welcomed
if (mrDataCommunicator.IsDistributed()) { | ||
DistributedSearchInRadius(rPoint, Radius, rResults, SyncronizeResults); | ||
} else { // Call serial version | ||
SerialSearchInRadius(rPoint, Radius, rResults, SyncronizeResults); |
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.
why do you pass the "SyncronizeResults" flag to the serial version? in that case it can only be in sync
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.
Let me check if I can simplify code, originally this was supposed to be a derived class and when refactored the code maybe I copy pasted to much
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 have the impression that this is really not ready for prime time.
@loumalouomega can we have a call to speak about this ?
After all PR are merged, this is ready for final review |
@pooyan-dadvand @RiccardoRossi I removed the shared_ptr |
@RiccardoRossi you mentioned a random pooyan instead of @pooyan-dadvand |
const int rank = GetRank(); | ||
|
||
// If we are using GeometricalObjectBins we can use the optimized search | ||
if constexpr (IsGeometricalObjectBins) { |
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.
Wouldn't be easier for this to just have a specialized version? They don't share any code
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, they share part of the code, I am not using that constexpr all the time
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 see
auto rank = getRank()
if constexpr(x) {
do_something()
} else {
do_another_thing()
}
What is being shared?
Edit: I mean specialization for <> generic and <GeometricalBins> only.
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.
But in that case I would need to put the constexpr ina different place...
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 it would be cleaner if you specialize the method for GeomtricalObjectBin
:
template<SpatialSearchCommunication TSpatialSearchCommunication>
void SearchWrapper<GeomtricalObjectBin, TSpatialSearchCommunication>::LocalSearchInRadius(
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.
Aside for the fact that I still find the search_wrapper odd, I see no other problem.
@RiccardoRossi for me this is ok to merge...
… doc/document-search-mpi
…-mpi [Doc] Document search mpi
@pooyan-dadvand we need to revisit this |
@pooyan-dadvand We must check this eventually |
Just reminder |
📝 Description
#11416 + addressed comments
This PR introduces a new class named
SpatialSearchResultContainer
,SpatialSearchResultContainerVector
as well asSearchWrapper
. The two first classes provides storage and operations related to spatial search results. In additionSearchWrapper
class implements an interface for serial/MPI search for different search objects, in current PR addingGeometricalObjectBins
and the available trees.The
SpatialSearchResultContainer
class stores:PointerVectorSet
)The class includes functions such as,
SynchronizeAll
,HasResult
,GetResultIndices
,AddResult
... The interesting part is that integrates a global pointer communicator, so it is possible to calculate anything passing a functor. The most common operations required are already implemented:GetResultShapeFunctions
,GetResultIndices
andGetResultCoordinates
,The
SynchronizeAll
method synchronizes the container between partitions. TheAddResult
method adds a result to the local pointers. There is apush_back
which does the same.The
SpatialSearchResultContainerVector
class stores a std::vector ofSpatialSearchResultContainer
pointers. In theSearchWrapper
class the index of the vector corresponds with the node id when using nodes and just a counter when simply searching.Considering general data communicator instead of sub data communicator
TODO: Using coloring utilities instead of manual coloring
🆕 Changelog
spatial_search_result_container.cpp
,spatial_search_result_container.h
mspatial_search_result_container_vector.cpp
andspatial_search_result_container_vector.h
files have been added, representing the implementation and header for theSpatialSearchResultContainer
andSpatialSearchResultContainerVector
classes.SpatialSearchResultContainer
andSpatialSearchResultContainerVector
SpatialSearchResultContainer
andSpatialSearchResultContainerVector
SearchWrapper
class, currently just implementedGeometricalObjectBins
.SearchWrapper
.MinLocAll
andMaxLocAll
toDataCommunicator
#11712PointObject
in different file #11725GetBoundingBox
inTree
class. Plus adding documentation #11730ObjectType
andPointType
inGeometricalObjectsBins
#11731ObjectType
forPointObject
#11735GetObjectType
and defineObjectType
inTree
#11737GetObjectType
intree.h
#11739ObjectType
inDynamicBins
#11741SearchInRadius
inGeometricalObjectBins
#11754SetRank
method toGlobalPointer
+ documentation #11762GetDataCommunicator
toGlobalPointerCommunicator
#11794SynchronizePointsWithBoundingBox
method #11877Get
method inSpatialSearchResult
#12002SpatialSearchResultContainer
addingSpatialSearchCommunicator
enumSpatialSearchResultContainerVector
addingSpatialSearchCommunicator
enumSearchWrapper
consistently