SPH
Public Member Functions | List of all members
AccelerationTemplate< TDerived > Class Template Reference

Helper template specifically used to implement forces. More...

#include <DerivativeHelpers.h>

Inheritance diagram for AccelerationTemplate< TDerived >:
IAcceleration ISymmetricDerivative IDerivative Polymorphic

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 ()
 

Detailed Description

template<typename TDerived>
class AccelerationTemplate< TDerived >

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.

Constructor & Destructor Documentation

◆ AccelerationTemplate()

template<typename TDerived >
AccelerationTemplate< TDerived >::AccelerationTemplate ( const RunSettings settings,
const Flags< DerivativeFlag flags = EMPTY_FLAGS 
)
inlineexplicit

Definition at line 169 of file DerivativeHelpers.h.

Member Function Documentation

◆ create()

template<typename TDerived >
virtual void AccelerationTemplate< TDerived >::create ( Accumulated results)
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.

◆ equals()

template<typename TDerived >
virtual bool AccelerationTemplate< TDerived >::equals ( const IDerivative other) const
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.

◆ evalAcceleration()

template<typename TDerived >
virtual void AccelerationTemplate< TDerived >::evalAcceleration ( const Size  idx,
ArrayView< const Size neighs,
ArrayView< const Vector grads,
ArrayView< Vector dv 
)
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.

Parameters
idxIndex of first interacting particle.
neighsArray containing all neighbours of idx-th particle.
gradsComputed gradients of the SPH kernel for each particle pair.
dvOutput view, where the pair-wise accelerations are stored.

Implements IAcceleration.

Definition at line 237 of file DerivativeHelpers.h.

◆ evalNeighs()

template<typename TDerived >
virtual void AccelerationTemplate< TDerived >::evalNeighs ( const Size  idx,
ArrayView< const Size neighs,
ArrayView< const Vector grads 
)
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.

Parameters
idxIndex of the first interacting particle.
neighsArray containing all neighbours of idx-th particle.
gradsComputed gradients of the SPH kernel for each particle pair.

Implements IDerivative.

Definition at line 209 of file DerivativeHelpers.h.

◆ evalSymmetric()

template<typename TDerived >
virtual void AccelerationTemplate< TDerived >::evalSymmetric ( const Size  idx,
ArrayView< const Size neighs,
ArrayView< const Vector grads 
)
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.

Parameters
idxIndex of first interacting particle.
neighsArray of some neighbours of idx-th particle. May be empty.
gradsComputed gradients of the SPH kernel for each particle pair.

Implements ISymmetricDerivative.

Definition at line 222 of file DerivativeHelpers.h.

◆ initialize()

template<typename TDerived >
virtual void AccelerationTemplate< TDerived >::initialize ( const Storage input,
Accumulated results 
)
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.

Parameters
inputStorage containing all the input quantities from which derivatives are computed. This storage is shared for all threads.
resultsThread-local storage where the computed derivatives are saved.

Implements IDerivative.

Definition at line 185 of file DerivativeHelpers.h.


The documentation for this class was generated from the following file: