Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
vec3_array.hpp
Go to the documentation of this file.
1#pragma once
2
20
21#include <vector>
22
24#include "orrery/core/types.hpp"
26
27namespace orrery::core {
28
34class Vec3Array {
35public:
36 Vec3Array() = default;
37
39 explicit Vec3Array(Index count);
40
41 [[nodiscard]] Index size() const noexcept { return x_.size(); }
42
43 [[nodiscard]] bool empty() const noexcept { return x_.empty(); }
44
50 void resize(Index count);
51
52 [[nodiscard]] Vec3Span<Real> view() noexcept { return {x_, y_, z_}; }
53
54 [[nodiscard]] Vec3Span<const Real> view() const noexcept { return {x_, y_, z_}; }
55
56private:
57 using ComponentArray = std::vector<Real, AlignedAllocator<Real>>;
58
59 ComponentArray x_;
60 ComponentArray y_;
61 ComponentArray z_;
62};
63
64} // namespace orrery::core
An allocator that starts every allocation on a cache line.
Vec3Array(Index count)
Create count vectors, every component zero.
void resize(Index count)
Change the length, zero-filling anything new.
A view of three component arrays of equal length.
Definition vec3_span.hpp:33
The scalar and index types that every layer of the project agrees on.
std::size_t Index
The type of a particle index and of any count of particles.
Definition types.hpp:45
Three parallel component arrays, viewed as one sequence of 3-vectors.