faunus
Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Attributes | List of all members
Faunus::Energy::EnergyAccumulatorBase Class Referenceabstract

Interface for energy accumulators. More...

#include <energy.h>

Inheritance diagram for Faunus::Energy::EnergyAccumulatorBase:
Inheritance graph
[legend]

Public Types

enum  Scheme { SERIAL, OPENMP, PARALLEL, INVALID }
 

Public Member Functions

 EnergyAccumulatorBase (double value)
 
virtual void reserve (size_t number_of_particles)
 
virtual void clear ()
 
virtual void from_json (const json &j)
 
virtual void to_json (json &j) const
 
virtual operator double ()
 
virtual EnergyAccumulatorBaseoperator= (double new_value)=0
 
virtual EnergyAccumulatorBaseoperator+= (double new_value)=0
 
virtual EnergyAccumulatorBaseoperator+= (ParticlePair &&pair)=0
 
template<typename TOtherAccumulator >
EnergyAccumulatorBaseoperator+= (TOtherAccumulator &acc)
 

Public Attributes

Scheme scheme = Scheme::SERIAL
 

Protected Types

using ParticleRef = const std::reference_wrapper< const Particle >
 Particle reference.
 
using ParticlePair = std::pair< ParticleRef, ParticleRef >
 References to two particles.
 

Protected Attributes

double value = 0.0
 accumulated energy
 

Detailed Description

Interface for energy accumulators.

The energy accumulator is used to add up energies between two particles. This can be done instantly (see InstantEnergyAccumulator) or delaying the evaluation until the energy is needed (DelayedEnergyAccumulator). The latter may be used with parallelism.

Todo:
See https://www.youtube.com/watch?v=3LsRYnRDSRA for a bizarre example where a custom struct Tpair { const Particle &first, second; }; outperforms std::pair due to missed compiler optimization.

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