-
Notifications
You must be signed in to change notification settings - Fork 239
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
Fix PropertyVector<T*> for multi-component case #1441
Fix PropertyVector<T*> for multi-component case #1441
Conversation
@@ -185,6 +197,20 @@ friend class Properties; | |||
return t; | |||
} | |||
|
|||
//! Returns the value for the given component stored in the given tuple. | |||
T const& getComponent(std::size_t tuple_index, | |||
std::size_t component) const |
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.
At least on github the indentation seems to be not correct. ✅
|
||
void initPropertyValue(std::size_t group_id, std::vector<T> const& values) | ||
{ | ||
T* p = new T[values.size()]; |
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.
Maybe a check values.size() == _n_components
could be inserted? ✅
@@ -155,13 +156,24 @@ friend class Properties; | |||
|
|||
void initPropertyValue(std::size_t group_id, T const& value) | |||
{ | |||
_values[group_id] = new T(value); | |||
T* p = new T[1]; |
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.
Maybe a check _n_components == 1
could be inserted? ✅
If tests are ok: 👍 |
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 am OK with this PR.
I am only wondering:
Is PropertyVector<T*>
used anywhere? If I remember correctly the material group parameter will not be based on this class.
So what is a use-case for the multi-component extension?
And what will be the fate of this class in the medium/long run? Especially since its current implementation cannot store abstract types (am I correct?), nor unique_ptrs.
OGS_FATAL("Single-component version of initPropertyValue() is called " | ||
"for a multi-components PropertyVector<T*>"); | ||
T* p = new T[1]; | ||
p[0] = value; |
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.
Note: This will not work if T
is an abstract class or T
is not copyable. However, it did not work either before.
@chleh As far as I know, |
OpenGeoSys development has been moved to GitLab. |
Currently
PropertyVector<T*>
works only with a single component.