-
Notifications
You must be signed in to change notification settings - Fork 242
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] Making PointerVectorSet to be always ordered and unique #12077
[Core] Making PointerVectorSet to be always ordered and unique #12077
Conversation
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.
some questions
Sort(); | ||
std::unique(mData.begin(), mData.end(), EqualKeyTo()); | ||
std::sort(mData.begin(), mData.end()); | ||
auto last = std::unique(mData.begin(), mData.end(), EqualKeyTo()); |
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 not using unique?
@@ -543,75 +529,125 @@ class PointerVectorSet final | |||
*/ | |||
void push_back(TPointerType x) |
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 thought we wanted to remove this method
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 will be deprecated pointing to the insert
. In this PR, I will only replace push_back uses in the core only. In another PR, I will change the application uses of push_back
to keep the changes in this PR as small as possible.
// the position to insert is at the end. | ||
mData.push_back(value); | ||
return iterator(mData.end() - 1); | ||
} else if (EqualKeyTo(KeyOf(*value))(*itr_pos)) { |
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
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 explained before.
|
||
*i = pData; | ||
return i; | ||
} else if (EqualKeyTo(KeyOf(position_hint))(*ptr_begin())) { |
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
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 explained before.
@@ -96,6 +96,18 @@ class IndexedObject | |||
return rThisObject.Id(); | |||
} | |||
|
|||
template<class TObjectType> |
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.
templating this is a bit dangerous. don't we want it to work only for the same type?
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 was following the signature of the operator()
to be consistent. I was not sure why operator()
was templated. @pooyan-dadvand ?
@@ -599,12 +599,16 @@ class CalculateEmbeddedNodalVariableFromSkinProcess : public Process | |||
|
|||
// Populate the modelpart with all the nodes in NodesMap | |||
// Note that a temporary vector is created from the set to add all nodes at once | |||
PointerVectorSet<Node> tmp; | |||
PointerVectorSet< |
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 the defaults do not work 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.
Nodes constructor with key
is not available (it throws an error), if someone does not specify the second template argument to the PointerVectorSet
, then it uses SetIdentityFunction
, which will need to create a copy of the node by using the key
and node consturctor which throws an error. This is only problematic for Node
type 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.
This is the ctor being called in this case.
Lines 117 to 128 in 8fa8e65
explicit Node(IndexType NewId ) | |
: BaseType() | |
, Flags() | |
, mNodalData(NewId) | |
, mDofs() | |
, mData() | |
, mInitialPosition() | |
, mNodeLock() | |
{ | |
KRATOS_ERROR << "Calling the default constructor for the node ... illegal operation!!" << std::endl; | |
CreateSolutionStepData(); | |
} |
I am closing this because, this PR will be seperated into few different PRs. Keeping the branch to get these changes propery to new PRs. |
π Description
β CI IS FAILING BECAUSE, I WANT TO CONFIRM THE PROPOSED CHANGES ARE OK FIRST BEFORE PROCEEDING, AFTERWARDS I WILL FIX THE PROBLEMS β
Finally got time to work on the issue #11363. This PR intends to make
PointerVectorSet
to be always sorted and unique. Following changes are made:find
do not sort. It assumes the container is sorted and returns the found items.count
method is removed [count should be always one for the uniquePointerVectorSet
].push_back
will be deprecated, and will useinsert
Sort
andUnique
will be deprecated, and will useConform
PointerVectorSet::GetContainer
can kill the sorted orderedness of thePointerVectorSet
from outside.PointerVectorSet
always ordered and unique:SetId
method ofNode
,Condition
,Element
or anyIndexedObject
allows mutating the ids of the entities in thePointerVectorSet
, hence making it unordered and not unique. Therefore, we still need to have eitherSort
andUnique
methods, or I would like to introduceConform
method which does both, and deprecateSort
andUnique
.SetId
is heavily used, hence we cannot disallow it.SetId
, then they should callConform
afterwards, otherwise, results may be affected.find
will fail, if thePointerVectorSet
is not sorted and unique.π§ͺ This is ready for review. CI may be failing because, We first need to agree on the suggested changes in this PR before proceeding further. @KratosMultiphysics/technical-committee
π Changelog
PointerVectorSet::find
immutable and mutable versions does not sort any more.PointerVectorSet::count
method