Particle: accessor for all state data - #2228
Conversation
35f99e8 to
0243b82
Compare
|
The error you are seeing in #2224 is not due to an empty particle container. I looked at the following output from the log
|
|
No, I am seeing the error I am talking about here. It's just not the only error: |
ppraegla
left a comment
There was a problem hiding this comment.
I think it makes sense to distinguish between access to state vector and access to state vector for a specific particle.
You missed one call of get_ptr...(...,0) in SPHPeridynamic::compute_acceleration()
|
Note - this PR is draft because I'm still working on it. I am currently eating lunch |
c863ca7 to
705dfdd
Compare
705dfdd to
9c19d57
Compare
9c19d57 to
2f79f33
Compare
|
Ok, I think this is doing what I need now, but I'm waiting for the extra checks in CI to verify my local test suite runs for #2224. Then I'll swap this PR out of draft (though that PR will have more work in addition to the changes in this branch) |
|
Ok, looks like this now does what I want |
Description and Context
We use
*get_ptr_to_state*to do two different tasks - accessing the particle state for a single particle and accessing the particle state for all particles. This works fine until we try to access the state for an empty container and get an error when 4C is built with assertions (see #2224).This PR adds overloaded versions of
*get_ptr_to_state*that drops theindexargument. In these, if the container is empty, then anullptris returned. This should be perfectly fine, as in these cases the array should be accessed in a loop over the number of particles in the container, so thisnullptrshould never be dereferenced. This matches with conventions I've seen in other projects. The alternative would be to insert checks at every callsite for*get_ptr_to_state*that is accessing the state for all particles and prevent the call if the container is empty. That is a lot of places in #2224, so I think this solution is much better.Related Issues and Pull Requests
#2148 #2224
Disclosure of AI assistance
None