14 #ifdef SPH_USE_CHAISCRIPT
16 #include <chaiscript/chaiscript.hpp>
33 Vec3(
const Vec3& other) {
46 Vec3& operator=(
const Vec3& other) {
54 return { x + other.x, y + other.y, z + other.z };
57 return { x - other.x, y - other.y, z - other.z };
60 return { x * f, y * f, z * f };
63 return { x / f, y / f, z / f };
65 Vec3& operator+=(
const Vec3& other) {
66 *
this = *
this + other;
76 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
79 return Vec3{ v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x };
84 INLINE Vec3
min(
const Vec3& v1,
const Vec3& v2) {
87 INLINE Vec3
max(
const Vec3& v1,
const Vec3& v2) {
90 INLINE Vec3 normalized(
const Vec3& v) {
102 Box3(
const Vec3& lower,
const Vec3& upper)
106 Box3(
const Box3& other) {
110 Box3& operator=(
const Box3& other) {
117 return upper - lower;
120 void extend(
const Vec3& pos) {
121 lower =
min(lower, pos);
122 upper =
max(upper, pos);
136 std::vector<Vec3> positions, velocities, accelerations;
137 std::vector<Float> masses, energies, densities, radii;
140 Particles() =
default;
142 Particles(
const Size particleCnt);
146 void bindToStorage(
Storage& input);
150 Size getParticleCnt()
const;
152 void resize(
const Size particleCnt);
154 std::vector<Float>& getMasses();
156 std::vector<Float>& getEnergies();
158 std::vector<Float>& getDensities();
160 std::vector<Float>& getRadii();
162 std::vector<Vec3>& getPositions();
164 std::vector<Vec3>& getVelocities();
166 std::vector<Vec3>& getAccelerations();
170 Float getTotalMass()
const;
174 Vec3 getTotalMomentum()
const;
176 Vec3 getTotalAngularMomentum()
const;
180 void merge(Particles& other);
184 void registerBindings(chaiscript::ChaiScript& chai);
Various function for interpretation of the results of a simulation.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Lut< TValue, TScalar > operator/(const Lut< TValue, TScalar > &lut1, const Lut< TValue, TScalar > &lut2)
constexpr INLINE T max(const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
INLINE T sqrt(const T f)
Return a squared root of a value.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Holder of quantity values and their temporal derivatives.
Interface for executing tasks (potentially) asynchronously.
Box getBoundingBox(const Storage &storage, const Float radius)
Convenience function to get the bounding box of all particles.
Container for storing particle quantities and materials.
INLINE BasicVector< float > cross(const BasicVector< float > &v1, const BasicVector< float > &v2)
Cross product between two vectors.
BasicVector< Float > Vector
INLINE float dot(const BasicVector< float > &v1, const BasicVector< float > &v2)
Make sure the vector is trivially constructible and destructible, needed for fast initialization of a...
Container storing all quantities used within the simulations.
Creating code components based on values from settings.
Difference< TValue1, TValue2 > operator-(const TValue1 &v1, const TValue2 &v2)
MultiplyByScalar< TValue > operator*(const TValue &v, const Float f)
Sum< TValue1, TValue2 > operator+(const TValue1 &v1, const TValue2 &v2)
Vector getAngularFrequency(ArrayView< const Float > m, ArrayView< const Vector > r, ArrayView< const Vector > v, const Vector &r0, const Vector &v0, ArrayView< const Size > idxs=nullptr)
Computes the immediate vector of angular frequency of a rigid body.
Vector getCenterOfMass(ArrayView< const Float > m, ArrayView< const Vector > r, ArrayView< const Size > idxs=nullptr)
Computes the center of mass.