|
Orrery
A GPU-accelerated N-body gravitational simulator
|
Storage for a set of point masses in structure-of-arrays layout. More...
#include <orrery/core/particle_data.hpp>
Public Member Functions | |
| ParticleData (Index count) | |
| Create count particles with every component zero. | |
| Index | size () const noexcept |
| bool | empty () const noexcept |
| Index | capacity () const noexcept |
| The number of particles the arrays can hold without reallocating. | |
| void | reserve (Index count) |
| Make room for count particles without changing how many there are. | |
| void | resize (Index count) |
| Change the number of particles, zero-filling any that are new. | |
| void | clear () noexcept |
| Remove every particle, keeping the storage for reuse. | |
| Index | add (Vec3 position, Vec3 velocity, Real mass) |
| Append one particle with zero acceleration and return its index. | |
| Vec3Span< Real > | positions () noexcept |
| Vec3Span< const Real > | positions () const noexcept |
| Vec3Span< Real > | velocities () noexcept |
| Vec3Span< const Real > | velocities () const noexcept |
| Vec3Span< Real > | accelerations () noexcept |
| Vec3Span< const Real > | accelerations () const noexcept |
| std::span< Real > | masses () noexcept |
| std::span< const Real > | masses () const noexcept |
Storage for a set of point masses in structure-of-arrays layout.
The class invariant is that all ten component arrays hold exactly size() elements. Every operation that can change a length goes through one private helper that applies it to all ten, so an array cannot be forgotten, and an eleventh added later is caught at the one place that lists them rather than at each of the four operations that resize them.
|
explicit |
Create count particles with every component zero.
Zero rather than uninitialised, and deliberately so: a particle of zero mass at the origin with no velocity exerts no force and feels the forces it is given, so a container that has been sized but not yet filled by an initial-condition generator perturbs nothing. Reading uninitialised storage would instead make a partially filled container produce results that vary between runs.
|
inlinenodiscardnoexcept |
The number of particles the arrays can hold without reallocating.
Reported from one array because the ten are grown together and always agree, for the same reason their lengths do.
Append one particle with zero acceleration and return its index.
For setup code and tests. Initial-condition generators that know their particle count size the container once and write through the views instead, which is both faster and how the solvers see the data.