SPH
|
Helper template specifically used to implement forces. More...
#include <DerivativeHelpers.h>
Public Member Functions | |
AccelerationTemplate (const RunSettings &settings, const Flags< DerivativeFlag > flags=EMPTY_FLAGS) | |
virtual void | create (Accumulated &results) override final |
Emplace all needed buffers into shared storage. More... | |
virtual void | initialize (const Storage &input, Accumulated &results) override final |
Initialize derivative before iterating over neighbours. More... | |
virtual bool | equals (const IDerivative &other) const override final |
Returns true if this derivative is equal to the given derivative. More... | |
virtual void | evalNeighs (const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads) override |
Compute derivatives of given particle. More... | |
virtual void | evalSymmetric (const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads) override |
Compute a part of derivatives from interaction of particle pairs. More... | |
virtual void | evalAcceleration (const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads, ArrayView< Vector > dv) override |
Computes the pair-wise accelerations of given particle and its neighbours. More... | |
Public Member Functions inherited from ISymmetricDerivative | |
virtual DerivativePhase | phase () const final |
Symmetric derivatives are always in EVALUATION phase. More... | |
Public Member Functions inherited from Polymorphic | |
virtual | ~Polymorphic () |
Helper template specifically used to implement forces.
Similarly to DerivativeTemplate, this is mainly used to reduce the boilerplate code and avoid error by implementing the member functions of IAcceleration inconsistently. Derived must implement Tuple<Vector, Float> eval(), returning force and heating.
Acceleration is never corrected! That would break the conservation of momentum.
Definition at line 159 of file DerivativeHelpers.h.
|
inlineexplicit |
Definition at line 169 of file DerivativeHelpers.h.
|
inlinefinaloverridevirtual |
Emplace all needed buffers into shared storage.
Called only once at the beginning of the run.
Implements IDerivative.
Definition at line 178 of file DerivativeHelpers.h.
|
inlinefinaloverridevirtual |
Returns true if this derivative is equal to the given derivative.
This is always false if the derivative is a different type, but a derivative may also have an inner state and result in different value, even if the type is the same. This function is only used to check that we do not try to add two derivatives of the same type, but with different internal state.
Reimplemented from IDerivative.
Definition at line 201 of file DerivativeHelpers.h.
|
inlineoverridevirtual |
Computes the pair-wise accelerations of given particle and its neighbours.
If the implementation of evalNeighs and evalNeighs also modify other quantity derivatives besides accelerations, this function shall also modify these in order to be consistent. Here, the evaluation is asymmetric, so the call of evalAcceleration should have the same effect as evalNeighs for all quantities except accelerations and energy derivative. Implementation may (but does not have to) modify energy derivatives arbitrarily; they are later overriden by EnergyConservingSolver anyway.
To ensure the computation of accelerations is internally consistent with other methods of derivative evaluation, consider using AccelerationTemplate helper class.
idx | Index of first interacting particle. |
neighs | Array containing all neighbours of idx-th particle. |
grads | Computed gradients of the SPH kernel for each particle pair. |
dv | Output view, where the pair-wise accelerations are stored. |
Implements IAcceleration.
Definition at line 237 of file DerivativeHelpers.h.
|
inlineoverridevirtual |
Compute derivatives of given particle.
Derivatives are computed by summing up pair-wise interaction between the given particle and its neighbours. Derivatives of the neighbours should not be modified by the function. Note that the given particle is NOT included in its own neighbours.
idx | Index of the first interacting particle. |
neighs | Array containing all neighbours of idx-th particle. |
grads | Computed gradients of the SPH kernel for each particle pair. |
Implements IDerivative.
Definition at line 209 of file DerivativeHelpers.h.
|
inlineoverridevirtual |
Compute a part of derivatives from interaction of particle pairs.
The function computes derivatives of the given particle as well as all of its neighbours. Each particle pair is visited only once when evaluating the derivatives. Note that it computes only a part of the total sum, the rest of the sum is computed when executing the function for neighbouring particles. The derivatives are completed only after all particles have been processed.
Implementation must be consistent with evalNeighs, both must evaluate to the same derivative values. To ensure the derivative is internally consistent, consider using DerivativeTemplate helper class.
idx | Index of first interacting particle. |
neighs | Array of some neighbours of idx-th particle. May be empty. |
grads | Computed gradients of the SPH kernel for each particle pair. |
Implements ISymmetricDerivative.
Definition at line 222 of file DerivativeHelpers.h.
|
inlinefinaloverridevirtual |
Initialize derivative before iterating over neighbours.
All pointers and arrayviews used to access storage quantities must be initialized in this function, as they may have been invalidated.
input | Storage containing all the input quantities from which derivatives are computed. This storage is shared for all threads. |
results | Thread-local storage where the computed derivatives are saved. |
Implements IDerivative.
Definition at line 185 of file DerivativeHelpers.h.