SPH
Public Member Functions | List of all members
CachedGravity Class Reference

Wrapper of other IGravity implementation that approximates the gravity using cached values. More...

#include <CachedGravity.h>

Inheritance diagram for CachedGravity:
IGravity Polymorphic

Public Member Functions

 CachedGravity (const Float recomputationPeriod, AutoPtr< IGravity > &&gravity)
 Creates the cached gravity. More...
 
virtual void build (IScheduler &scheduler, const Storage &storage) override
 Builds the accelerating structure. More...
 
virtual void evalAll (IScheduler &scheduler, ArrayView< Vector > dv, Statistics &stats) const override
 Evaluates the gravitational acceleration concurrently. More...
 
virtual Vector eval (const Vector &r0) const override
 Evaluates the gravitational acceleration at given point. More...
 
virtual Float evalEnergy (IScheduler &scheduler, Statistics &stats) const override
 Computes the total potential energy of the particles. More...
 
virtual RawPtr< const IBasicFindergetFinder () const override
 Optionally returns a finder used by the gravity implementation. More...
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 

Detailed Description

Wrapper of other IGravity implementation that approximates the gravity using cached values.

Particle accelerations are recomputed with given period and used in time steps between the subsequent recomputations instead of computing all accelerations every time step. This is mainly useful if particles move only slightly in one time step. Gravity is recomputed unconditionally if the number of particles change.

Definition at line 20 of file CachedGravity.h.

Constructor & Destructor Documentation

◆ CachedGravity()

CachedGravity::CachedGravity ( const Float  recomputationPeriod,
AutoPtr< IGravity > &&  gravity 
)
inlineexplicit

Creates the cached gravity.

Parameters
recomputationPeriodPeriod of gravity recomputation in simulation time.
gravityActual implementation that computes the gravitational accelerations (roughly) every recomputation period. Cannot be nullptr.

Definition at line 34 of file CachedGravity.h.

Member Function Documentation

◆ build()

virtual void CachedGravity::build ( IScheduler scheduler,
const Storage storage 
)
inlineoverridevirtual

Builds the accelerating structure.

Needs to be called every time step.

Parameters
schedulerScheduler used for parallelization of the build. Use SEQUENTAIL for sequential (single-threaded) execution.

Implements IGravity.

Definition at line 41 of file CachedGravity.h.

◆ eval()

virtual Vector CachedGravity::eval ( const Vector r0) const
inlineoverridevirtual

Evaluates the gravitational acceleration at given point.

The point must NOT correspond to any particle, as this case could formally lead to infinite acceleration if no smoothing kernel is used.

Parameters
r0Point where the gravity is evaluated.

Implements IGravity.

Definition at line 67 of file CachedGravity.h.

◆ evalAll()

virtual void CachedGravity::evalAll ( IScheduler scheduler,
ArrayView< Vector dv,
Statistics stats 
) const
inlineoverridevirtual

Evaluates the gravitational acceleration concurrently.

The function is blocking, it must exit after the gravity is evaluated.

Parameters
schedulerScheduler used for parallelization.
dvAcceleration values; it may already contain some accelerations computed by other code components, gravity should add acceleration instead of replacing the current values.
statsOutput statistics of the gravitational solver.

Implements IGravity.

Definition at line 47 of file CachedGravity.h.

◆ evalEnergy()

virtual Float CachedGravity::evalEnergy ( IScheduler scheduler,
Statistics stats 
) const
inlineoverridevirtual

Computes the total potential energy of the particles.

The zero point is implementation-specific; it is not required that the energy is strictly negative.

Parameters
schedulerScheduler used for parallelization.
statsOutput statistics of the gravitational solver.

Implements IGravity.

Definition at line 73 of file CachedGravity.h.

◆ getFinder()

virtual RawPtr<const IBasicFinder> CachedGravity::getFinder ( ) const
inlineoverridevirtual

Optionally returns a finder used by the gravity implementation.

If the gravity uses an acceleration structure that implements the IBasicFinder interface, this function allows the user to obtain the object and re-use in other parts of the code. Finder is assumed to be initialized after build is called.

If the gravity does not use any such structure or it simply does not implement the IBasicFinder interface, the function returns nullptr.

Implements IGravity.

Definition at line 77 of file CachedGravity.h.


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