Swarm-NG
1.1
|
ensemble data structure containing nbody systems. More...
#include <ensemble.hpp>
Classes | |
struct | Body |
Concrete structure of Body This class is specifically designed to be used with CoalescedStruct array. More... | |
struct | range_t |
A simple data structure to calculate statistical measures on a range of values. More... | |
struct | Sys |
Structure for quantities stored per system. More... | |
class | SystemRef |
Reference to a system within an ensemble. More... | |
class | SystemRefConst |
Constant encapsulation of SystemRef If the ens is constant use: SystemRefConst s = ens[i];. More... | |
Public Types | |
typedef CoalescedStructArray < Body, double, CHUNK_SIZE > | BodyArray |
Type of array that we want to use for Body. | |
typedef CoalescedStructArray < Sys, double, CHUNK_SIZE > | SysArray |
Type of array that we want to use for Sys. | |
Public Member Functions | |
GENERIC const int & | nbod () const |
Number of bodies per system. | |
GENERIC const int & | nsys () const |
Number of systems. | |
BodyArray & | bodies () |
Coalsed array of bodies. For INTERNAL use only. | |
SysArray & | systems () |
Coalsed array of systems. For INTERNAL use only. | |
GENERIC SystemRef | operator[] (const int &i) |
Index into systems array to access a system. More... | |
GENERIC void | get_barycenter (const int &sys, double &x, double &y, double &z, double &vx, double &vy, double &vz, const int &max_body_id=MAX_NBODIES) const |
Deprecated function: this function uses a very bad signature and too many arguments. More... | |
GENERIC double | calc_total_energy (int sys) const |
Total energy (potential+kinetic) of a system. | |
GENERIC void | calc_total_energy (double *E) const |
Calculate the total energy of a system and store it in E. More... | |
GENERIC range_t | time_ranges () const |
Range of times of systems (average,min,max) Averages the time for all systems and finds min and max Useful to find the best value for destination time. | |
Static Public Member Functions | |
static GENERIC size_t | body_element_count (const int &nbod, const int &nsys) |
Size of Body[] array required for an ensemble of size nbod,nsys. | |
static GENERIC size_t | sys_element_count (const int &nsys) |
Size of Sys[] array required for an ensemble of size nsys. | |
Static Public Attributes | |
static const int | CHUNK_SIZE = _CHUNK_SIZE |
CHUNK_SIZE for Coalesced access. c.f CoalescedStructArray. | |
static const int | NUM_BODY_ATTRIBUTES = _NUM_BODY_ATTRIBUTES |
Number of extra attributes. | |
static const int | NUM_SYS_ATTRIBUTES = _NUM_SYS_ATTRIBUTES |
Number of extra attributes per system. | |
Protected Member Functions | |
GENERIC | EnsembleBase () |
Trivial constructor, creates an invalid ensemble. More... | |
GENERIC | EnsembleBase (const int &nbod, const int &nsys, PBody body_array, PSys sys_array) |
Create an ensemble from pre-allocated body_array and sys_array arrays. | |
Protected Attributes | |
int | _nbod |
Number of bodies. | |
int | _nsys |
Number of systems. | |
BodyArray | _body |
Coalesced array of Body. | |
SysArray | _sys |
Coalesced array of Sys. | |
ensemble data structure containing nbody systems.
Internal Usage: Contains an ensemble of nsys() systems each containing nbod() bodies. use operator [] to peek into the data structure:
Example:
Public Usage: There are accessors:
Two utility functions are provided for ease of use: calc_total_energy(sys) and get_barycenter(sys)
This class does not contain memory management routines and cannot be instantiated. It should be used as the ensemble typedef only for parameter definition in functions and should be passed as a reference. To create an ensemble use one of defaultEnsemble, deviceEnsemble or hostEnsemble
The bodies and systems can have extra attributes. The constants used here for number of attributes are set in the configuration file which is set by CMake. You can change these values using the CMake system.
Definition at line 110 of file ensemble.hpp.
|
inlineprotected |
Trivial constructor, creates an invalid ensemble.
Definition at line 477 of file ensemble.hpp.
|
inline |
Calculate the total energy of a system and store it in E.
Definition at line 699 of file ensemble.hpp.
|
inline |
Deprecated function: this function uses a very bad signature and too many arguments.
It is used to find a barycenter for first max_body_id planets in the system. If max_body_id is not specified, then the result is the barycenter for the whole planetary system.
Definition at line 665 of file ensemble.hpp.
Referenced by calc_semimajor_axes(), generate_ensemble_with_initial_conditions_cartesian_from_file(), generate_ensemble_with_initial_conditions_keplerian_from_file(), and print_system().
|
inline |
Index into systems array to access a system.
Use: ens[i]
Finds the first body of a system to set as Body* parameter The hierarchy is like this: Blocks ( nsys / CHUNK_SIZE ) Bodies ( nbod ) Warps ( nsys % CHUNK_SIZE )
body index should come in the middle to provide efficient dynamic addressing.
Definition at line 512 of file ensemble.hpp.
Referenced by swarm::EnsembleBase< ENSEMBLE_CHUNK_SIZE >::calc_total_energy().