21 const Size iterationCnt = 3) {
27 for (
Size i = 0; i < iterationCnt; ++i) {
34 if (omega !=
Vector(0._f)) {
49 : scheduler(scheduler)
51 kernel = Factory::getKernel<3>(settings);
71 if (neighsPerParticle.
empty()) {
76 finder->
build(scheduler, r);
77 const Float maxH = r[0][
H];
80 for (
Size i = 0; i < r.
size(); ++i) {
82 V0[i] = m[i] / rho[i];
89 const Size j = n.index;
90 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
91 if (i != j && n.distanceSqr <
sqr(kernel.
radius() * hbar)) {
92 neighsPerParticle[i].
push(j);
100 C[i] = C[i].inverse();
107 for (
Size i = 0; i < r.
size(); ++i) {
108 for (
Size j : neighsPerParticle[i]) {
109 SPH_ASSERT(std::find(neighsPerParticle[j].begin(), neighsPerParticle[j].end(), i) !=
110 neighsPerParticle[j].end());
124 Tensor F = Tensor::null();
125 for (Size j : neighsPerParticle[i]) {
126 const Vector w = C[i] * kernel.grad(r0[i], r0[j]);
127 F += V0[j] * outer(r[j] - r[i], w);
131 R[i] = extractRotation(convert<AffineMatrix>(F), R[i]);
141 for (
Size j : neighsPerParticle[i]) {
142 const Vector w_star = R[i] * (C[i] * kernel.
grad(r0[i], r0[j]));
143 F_star += V0[j] *
outer(r[j] - r[i] - R[i] * (r0[j] - r0[i]), w_star);
149 p[i] = -sigma.
trace() / 3._f;
155 for (Size j : neighsPerParticle[i]) {
156 const Vector w = kernel.grad(r0[i], r0[j]);
157 const Vector wi_star = R[i] * (C[i] * w);
158 const Vector wj_star = R[j] * (C[j] * w);
160 V0[i] * V0[j] * (-p[i] * wi_star - p[j] * wj_star + S[i] * wi_star + S[j] * wj_star);
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
Spatial derivatives to be computed by SPH discretization.
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.
Base class for all particle materials.
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
INLINE auto abs(const T &f)
constexpr Float RAD_TO_DEG
#define NAMESPACE_SPH_END
@ STRAIN_RATE_CORRECTION_TENSOR
Correction tensor used to improve conservation of total angular momentum.
@ DEVIATORIC_STRESS
Deviatoric stress tensor, always a traceless tensor.
@ PRESSURE
Pressure, affected by yielding and fragmentation model, always a scalar quantity.
@ 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.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
Interface for executing tasks (potentially) asynchronously.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
INLINE SymmetricTensor symmetricOuter(const Vector &v1, const Vector &v2)
SYMMETRIZED outer product of two vectors.
INLINE SymmetricTensor symmetrize(const Tensor &t)
Computes a symmetrized tensor 1/2*(t + t^T)
INLINE Tensor outer(const Vector &r1, const Vector &r2)
Outer product.
INLINE Tuple< TArgs &... > tieToTuple(TArgs &... args)
Creates a tuple of l-value references. Use IGNORE placeholder to omit one or more parameters.
INLINE Tuple< Vector, Float > getNormalizedWithLength(const Vector &v)
Returns normalized vector and length of the input vector as tuple.
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...
static AffineMatrix identity()
INLINE Vector column(const Size idx) const
INLINE Vector row(const Size idx) const
static AffineMatrix rotateAxis(const Vector &axis, const Float angle)
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
void resize(const TCounter newSize)
Resizes the array to new size.
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
void fill(const T &t)
Sets all elements of the array to given value.
INLINE bool empty() const noexcept
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.
virtual void finalize(Storage &storage)=0
Applies the boundary conditions after the derivatives are computed.
virtual void initialize(Storage &storage)=0
Applies the boundary conditions before the derivatives are computed.
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Non-owning wrapper of a material and particles with this material.
INLINE IndexSequence sequence()
Returns iterable index sequence.
Quaternion representing an axis of rotation and a (half of) rotation angle.
INLINE Vector axis() const
Returns the normalized rotational axis.
INLINE Float angle() const
Returns the angle of rotation (in radians).
TValue get(const TEnum idx, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0) const
Returns a value of given type from the settings.
Object holding various statistics about current run.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
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 > & getD2t(const QuantityId key)
Retrieves a quantity second derivative from the storage, given its key and value type.
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Symmetric tensor of 2nd order.
INLINE Float trace() const
Return the trace of the tensor.
static INLINE SymmetricTensor identity()
Returns an identity tensor.
static INLINE SymmetricTensor null()
Returns a tensor with all zeros.
INLINE Float radius() const
INLINE Vector grad(const Vector &r1, const Vector &r2) const
Generic 2nd-order tensor with 9 independent components.
Symmetric traceless 2nd order tensor.
static INLINE TracelessTensor null()
Returns a tensor with all zeros.
Creating code components based on values from settings.
@ ELASTIC_MODULUS
Elastic modulus lambda (a.k.a Lame's first parameter) of the material.
@ SHEAR_MODULUS
Shear modulus mu (a.k.a Lame's second parameter) of the material.
@ FRAME_CONSTANT_ACCELERATION
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
Overload of std::swap for Sph::Array.
Holds information about a neighbour particles.