35 , idxs(
std::move(idxs)) {
37 kernel = Factory::getKernel<3>(settings);
41 for (
Size i : this->idxs) {
71 volume += m[i] / rho[i];
88 h_max =
max(h_max, r[i][
H]);
96 for (
auto& n : neighs) {
98 const Size j = idxs[n.index];
99 field += m[j] / rho[j] * kernel.
value(v - r[j], r[j][
H]);
101 return field > level;
130 for (
Size i : idxs) {
149 for (
Size i = 0; i < r_nbody.
size(); ++i) {
152 r_nbody[i][
H] =
cbrt(3._f * m_sph[i] / (4._f *
PI * rho_sph[i]));
188 for (
Size i : idxs) {
190 v_com += m_nbody[i] * v_nbody[i];
191 r_com += m_nbody[i] * r_nbody[i];
207 const Vector omega = getAngularFrequency(idxs, m_nbody, r_nbody, v_nbody, r_com, v_com);
208 for (
Size i = 0; i < r_lr.
size(); ++i) {
209 v_lr[i] = v_com +
cross(omega, r_lr[i]);
Various function for interpretation of the results of a simulation.
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Filling spatial domain with SPH particles.
Object defining computational domain.
const EmptyFlags EMPTY_FLAGS
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.
Storage convertSphToSpheres(const Storage &sph, const RunSettings &settings, const HandoffParams ¶ms)
Utility functions for handing-off the results of SPH simulations to N-body integrator.
Vector moveToCenterOfMassSystem(ArrayView< const Float > m, ArrayView< Vector > r)
Modifies particle positions so that their center of mass lies at the origin.
Generating initial conditions of SPH particles.
Integrals of motion and other integral quantities.
SPH-specific implementation of particle materials.
constexpr INLINE T max(const T &f1, const T &f2)
INLINE Float cbrt(const Float f)
Returns a cubed root of a value.
constexpr Float PI
Mathematical constants.
#define NAMESPACE_SPH_END
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
Holder of quantity values and their temporal derivatives.
@ SECOND
Quantity with 1st and 2nd derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
SequentialScheduler SEQUENTIAL
Global instance of the sequential scheduler.
Interface for executing tasks (potentially) asynchronously.
Box getBoundingBox(const Storage &storage, const Float radius)
Convenience function to get the bounding box of all particles.
INLINE BasicVector< float > cross(const BasicVector< float > &v1, const BasicVector< float > &v2)
Cross product between two vectors.
Generic dynamically allocated resizable storage.
INLINE Iterator< StorageType > end() noexcept
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
void remove(const TCounter idx)
Removes an element with given index from the array.
void fill(const T &t)
Sets all elements of the array to given value.
INLINE TCounter size() const noexcept
INLINE Iterator< StorageType > begin() noexcept
void pushAll(const TIter first, const TIter last)
Helper object defining three-dimensional interval (box).
void build(IScheduler &scheduler, ArrayView< const Vector > points)
Constructs the struct with an array of vectors.
virtual Size findAll(const Size index, const Float radius, Array< NeighbourRecord > &neighbours) const =0
Finds all neighbours within given radius from the point given by index.
Base class for computational domains.
INLINE Float value(const Vector &r, const Float h) const noexcept
INLINE Float radius() const noexcept
Wrapper of type value of which may or may not be present.
Domain represented by SPH particles.
virtual void project(ArrayView< Vector >, Optional< ArrayView< Size >>) const override
Projects vectors outside of the domain onto its boundary.
virtual void getSubset(ArrayView< const Vector >, Array< Size > &, const SubsetType) const override
Returns an array of indices, marking vectors with given property by their index.
virtual Vector getCenter() const override
Returns the center of the domain.
virtual Float getVolume() const override
Returns the total volume of the domain.
virtual void getDistanceToBoundary(ArrayView< const Vector >, Array< Float > &) const override
Returns distances of particles lying close to the boundary.
virtual bool contains(const Vector &v) const override
Checks if the given point lies inside the domain.
virtual Box getBoundingBox() const override
Returns the bounding box of the domain.
virtual Float getSurfaceArea() const override
Returns the surface area of the domain.
virtual void addGhosts(ArrayView< const Vector >, Array< Ghost > &, const Float, const Float) const override
Duplicates positions located close to the boundary, placing copies ("ghosts") symmetrically to the ot...
SphDomain(const Storage &storage, ArrayView< const Size > idxs, const RunSettings &settings)
Container storing all quantities used within the simulations.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Creating code components based on values from settings.
const EmptySettingsTag EMPTY_SETTINGS
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
Array< Size > findLargestComponent(const Storage &storage, const Float particleRadius, const Flags< ComponentFlag > flags)
Returns the indices of particles belonging to the largest remnant.
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.
Overload of std::swap for Sph::Array.
Float radiusMultiplier
Conversion factor between smoothing length and particle radius.
@ EQUAL_VOLUME
The created sphere has the same volume as the SPH particles (=mass/density)
@ SMOOTHING_LENGTH
The radius is proportional to the smoothing length of the particles.
Optional< LargestRemnant > largestRemnant
bool centerOfMassSystem
If true, the particles are moved to a system where the center of mass is at the origin.