Orrery
A GPU-accelerated N-body gravitational simulator
Toggle main menu visibility
Loading...
Searching...
No Matches
vec3_array.hpp
Go to the documentation of this file.
1
#pragma once
2
20
21
#include <vector>
22
23
#include "
orrery/core/aligned_allocator.hpp
"
24
#include "
orrery/core/types.hpp
"
25
#include "
orrery/core/vec3_span.hpp
"
26
27
namespace
orrery::core {
28
34
class
Vec3Array {
35
public
:
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
56
private
:
57
using
ComponentArray = std::vector<Real, AlignedAllocator<Real>>;
58
59
ComponentArray x_;
60
ComponentArray y_;
61
ComponentArray z_;
62
};
63
64
}
// namespace orrery::core
aligned_allocator.hpp
An allocator that starts every allocation on a cache line.
orrery::core::Vec3Array::Vec3Array
Vec3Array(Index count)
Create count vectors, every component zero.
orrery::core::Vec3Array::resize
void resize(Index count)
Change the length, zero-filling anything new.
orrery::core::Vec3Span
A view of three component arrays of equal length.
Definition
vec3_span.hpp:33
types.hpp
The scalar and index types that every layer of the project agrees on.
orrery::core::Index
std::size_t Index
The type of a particle index and of any count of particles.
Definition
types.hpp:45
vec3_span.hpp
Three parallel component arrays, viewed as one sequence of 3-vectors.
orrery
core
vec3_array.hpp
Generated by
1.17.0