BioDynaMo
v1.05.120-25dc9790
|
#include <simulation.h>
Public Member Functions | |
Simulation (TRootIOCtor *p) | |
Simulation (int argc, const char **argv, const std::vector< std::string > &config_files={}) | |
Simulation (CommandLineOptions *clo, const std::vector< std::string > &config_files={}) | |
Simulation (const std::string &simulation_name, const std::vector< std::string > &config_files={}) | |
Simulation (int argc, const char **argv, const std::function< void(Param *)> &set_param, const std::vector< std::string > &config_files={}) | |
Simulation (CommandLineOptions *clo, const std::function< void(Param *)> &set_param, const std::vector< std::string > &config_files={}) | |
Simulation (const std::string &simulation_name, const std::function< void(Param *)> &set_param, const std::vector< std::string > &config_files={}) | |
~Simulation () | |
void | Restore (Simulation &&restored) |
void | Activate () |
Activates this simulation. More... | |
ResourceManager * | GetResourceManager () |
Returns the ResourceManager instance. More... | |
void | SetResourceManager (ResourceManager *rm) |
const Param * | GetParam () const |
Returns the simulation parameters. More... | |
AgentUidGenerator * | GetAgentUidGenerator () |
Environment * | GetEnvironment () |
void | SetEnvironment (Environment *env) |
Scheduler * | GetScheduler () |
void | Simulate (uint64_t steps) |
Random * | GetRandom () |
Returns a thread local random number generator. More... | |
std::vector< Random * > & | GetAllRandom () |
Returns all thread local random number generator. More... | |
ExecutionContext * | GetExecutionContext () |
Returns a thread local execution context. More... | |
std::vector< ExecutionContext * > & | GetAllExecCtxts () |
Returns all thread local execution contexts. More... | |
void | SetAllExecCtxts (const std::vector< ExecutionContext * > &exec_ctxts) |
MemoryManager * | GetMemoryManager () |
OpenCLState * | GetOpenCLState () |
Return helper class for OpenCL environment. More... | |
const std::string & | GetUniqueName () const |
Returns the name of the simulation. More... | |
const std::string & | GetOutputDir () const |
Returns the output directory for this specific simulation. More... | |
experimental::TimeSeries * | GetTimeSeries () |
void | ReplaceScheduler (Scheduler *scheduler) |
Static Public Member Functions | |
static Simulation * | GetActive () |
This function returns the currently active Simulation simulation. More... | |
Private Member Functions | |
void | Initialize (CommandLineOptions *clo, const std::function< void(Param *)> &set_param, const std::vector< std::string > &config_files) |
Initialize Simulation. More... | |
void | InitializeMembers () |
Initialize data members that have a dependency on Simulation. More... | |
void | InitializeRuntimeParams (CommandLineOptions *clo, const std::function< void(Param *)> &set_param, const std::vector< std::string > &ctor_config) |
This function parses command line parameters and the configuration file. More... | |
void | LoadConfigFiles (const std::vector< std::string > &ctor_configs, const std::vector< std::string > &cli_configs) |
void | InitializeUniqueName (const std::string &simulation_name) |
This function initializes unique_name_ More... | |
void | InitializeOutputDir () |
Initializes output_dir_ and creates dir if it does not exist. More... | |
BDM_CLASS_DEF_NV (Simulation, 1) | |
Private Attributes | |
std::vector< Random * > | random_ |
random number generator for each thread More... | |
std::vector< ExecutionContext * > | exec_ctxt_ |
Execution Context for each thread. More... | |
ResourceManager * | rm_ = nullptr |
Param * | param_ = nullptr |
AgentUidGenerator * | agent_uid_generator_ = nullptr |
std::string | name_ |
Environment * | environment_ = nullptr |
Scheduler * | scheduler_ = nullptr |
OpenCLState * | ocl_state_ = nullptr |
bool | is_gpu_environment_initialized_ = false |
uint64_t | id_ = 0 |
This id is unique for each simulation within the same process. More... | |
std::string | unique_name_ |
std::string | output_dir_ |
cached value where unique_name_ is appended to Param::output_dir More... | |
std::string | command_line_parameter_str_ |
MemoryManager * | mem_mgr_ = nullptr |
BioDynaMo memory manager. If nullptr, default allocator will be used. More... | |
int64_t | ctor_ts_ = 0 |
Timestep when constructor was called. More... | |
int64_t | dtor_ts_ = 0 |
Timestep when destructor was called. More... | |
experimental::TimeSeries * | time_series_ = nullptr |
Collects time series information during the simulation. More... | |
friend | SimulationTest |
friend | ParaviewAdaptorTest |
Static Private Attributes | |
static Simulation * | active_ = nullptr |
Currently active simulation. More... | |
static std::atomic< uint64_t > | counter_ |
Number of simulations in this process. More... | |
Friends | |
class | DiffusionTest_CopyOldData_Test |
std::ostream & | operator<< (std::ostream &os, Simulation &sim) |
This is the central BioDynaMo object. It contains pointers to e.g. the ResourceManager, the scheduler, parameters, ...
It is possible to create multiple simulations, but only one can be active at the same time. Creating a new agent automatically activates it.
Definition at line 50 of file simulation.h.
|
explicit |
Definition at line 70 of file simulation.cc.
bdm::Simulation::Simulation | ( | int | argc, |
const char ** | argv, | ||
const std::vector< std::string > & | config_files = {} |
||
) |
Constructor that takes the arguments from main
to parse command line arguments. The simulation name is extracted from the executable name. Creation of a new simulation automatically activates it.
Definition at line 72 of file simulation.cc.
|
explicit |
Definition at line 82 of file simulation.cc.
|
explicit |
Alternative constructor, if the arguments from function main
are not available, or if a different simulation name should be chosen.
Command line arguments are not parsed!
Creation of a new simulation automatically activates it.
config_file | Use a different config file than the default bdm.toml or bdm.json |
Definition at line 77 of file simulation.cc.
bdm::Simulation::Simulation | ( | int | argc, |
const char ** | argv, | ||
const std::function< void(Param *)> & | set_param, | ||
const std::vector< std::string > & | config_files = {} |
||
) |
Definition at line 94 of file simulation.cc.
bdm::Simulation::Simulation | ( | CommandLineOptions * | clo, |
const std::function< void(Param *)> & | set_param, | ||
const std::vector< std::string > & | config_files = {} |
||
) |
Definition at line 88 of file simulation.cc.
bdm::Simulation::Simulation | ( | const std::string & | simulation_name, |
const std::function< void(Param *)> & | set_param, | ||
const std::vector< std::string > & | config_files = {} |
||
) |
Definition at line 101 of file simulation.cc.
bdm::Simulation::~Simulation | ( | ) |
Definition at line 191 of file simulation.cc.
void bdm::Simulation::Activate | ( | ) |
Activates this simulation.
Definition at line 241 of file simulation.cc.
|
private |
|
static |
This function returns the currently active Simulation simulation.
Definition at line 68 of file simulation.cc.
AgentUidGenerator * bdm::Simulation::GetAgentUidGenerator | ( | ) |
Definition at line 256 of file simulation.cc.
std::vector< ExecutionContext * > & bdm::Simulation::GetAllExecCtxts | ( | ) |
Returns all thread local execution contexts.
Definition at line 275 of file simulation.cc.
std::vector< Random * > & bdm::Simulation::GetAllRandom | ( | ) |
Returns all thread local random number generator.
Definition at line 269 of file simulation.cc.
Environment * bdm::Simulation::GetEnvironment | ( | ) |
Definition at line 260 of file simulation.cc.
ExecutionContext * bdm::Simulation::GetExecutionContext | ( | ) |
Returns a thread local execution context.
Definition at line 271 of file simulation.cc.
|
inline |
Definition at line 127 of file simulation.h.
OpenCLState * bdm::Simulation::GetOpenCLState | ( | ) |
Return helper class for OpenCL environment.
Definition at line 279 of file simulation.cc.
const std::string & bdm::Simulation::GetOutputDir | ( | ) | const |
Returns the output directory for this specific simulation.
Returns the path to the simulation's output directory.
Definition at line 285 of file simulation.cc.
const Param * bdm::Simulation::GetParam | ( | ) | const |
Returns the simulation parameters.
Definition at line 254 of file simulation.cc.
Random * bdm::Simulation::GetRandom | ( | ) |
Returns a thread local random number generator.
Returns a random number generator (thread-specific)
Definition at line 267 of file simulation.cc.
ResourceManager * bdm::Simulation::GetResourceManager | ( | ) |
Returns the ResourceManager instance.
Definition at line 244 of file simulation.cc.
Scheduler * bdm::Simulation::GetScheduler | ( | ) |
Definition at line 262 of file simulation.cc.
experimental::TimeSeries * bdm::Simulation::GetTimeSeries | ( | ) |
Definition at line 287 of file simulation.cc.
const std::string & bdm::Simulation::GetUniqueName | ( | ) | const |
Returns the name of the simulation.
unique_name_
Definition at line 282 of file simulation.cc.
|
private |
Initialize Simulation.
Definition at line 294 of file simulation.cc.
|
private |
Initialize data members that have a dependency on Simulation.
Definition at line 314 of file simulation.cc.
|
private |
Initializes output_dir_
and creates dir if it does not exist.
Definition at line 540 of file simulation.cc.
|
private |
This function parses command line parameters and the configuration file.
Definition at line 380 of file simulation.cc.
|
private |
This function initializes unique_name_
Definition at line 530 of file simulation.cc.
|
private |
Definition at line 460 of file simulation.cc.
void bdm::Simulation::ReplaceScheduler | ( | Scheduler * | scheduler | ) |
Replaces the scheduler for this simulation. Existing scheduler will be deleted! Therefore, pointers to the old scheduler (obtained with GetScheduler()
) will be invalidated.
Simulation will take ownership of the passed pointer
Definition at line 289 of file simulation.cc.
void bdm::Simulation::Restore | ( | Simulation && | restored | ) |
Copies / moves values from a restored simulation into this object. Thus, pointers to rm_
, param_
, ... are not invalidated.
Definition at line 109 of file simulation.cc.
void bdm::Simulation::SetAllExecCtxts | ( | const std::vector< ExecutionContext * > & | exec_ctxts | ) |
Definition at line 363 of file simulation.cc.
void bdm::Simulation::SetEnvironment | ( | Environment * | env | ) |
Set a specific environment for the simulation. *env must point to an object instance of a subclass of Environment.
Definition at line 356 of file simulation.cc.
void bdm::Simulation::SetResourceManager | ( | ResourceManager * | rm | ) |
Definition at line 246 of file simulation.cc.
void bdm::Simulation::Simulate | ( | uint64_t | steps | ) |
Definition at line 264 of file simulation.cc.
|
friend |
Definition at line 211 of file simulation.h.
|
friend |
Definition at line 138 of file simulation.cc.
|
staticprivate |
Currently active simulation.
Definition at line 148 of file simulation.h.
|
private |
Definition at line 160 of file simulation.h.
|
private |
Stores command line arguments if (argc,argv) or CommandLineOptions are passed to the constructor.
Definition at line 177 of file simulation.h.
|
staticprivate |
Number of simulations in this process.
Implementation for Simulation
: It must be separate to avoid circular dependencies.
Definition at line 150 of file simulation.h.
|
private |
Timestep when constructor was called.
Definition at line 181 of file simulation.h.
|
private |
Timestep when destructor was called.
Definition at line 183 of file simulation.h.
|
private |
Definition at line 162 of file simulation.h.
|
private |
Execution Context for each thread.
Definition at line 156 of file simulation.h.
|
private |
This id is unique for each simulation within the same process.
Definition at line 167 of file simulation.h.
|
private |
Definition at line 165 of file simulation.h.
|
private |
BioDynaMo memory manager. If nullptr, default allocator will be used.
Definition at line 179 of file simulation.h.
|
private |
Definition at line 161 of file simulation.h.
|
private |
Definition at line 164 of file simulation.h.
|
private |
cached value where unique_name_
is appended to Param::output_dir
Definition at line 174 of file simulation.h.
|
private |
Definition at line 159 of file simulation.h.
|
private |
Definition at line 210 of file simulation.h.
|
private |
random number generator for each thread
Definition at line 153 of file simulation.h.
|
private |
Definition at line 158 of file simulation.h.
|
private |
Definition at line 163 of file simulation.h.
|
private |
Definition at line 209 of file simulation.h.
|
private |
Collects time series information during the simulation.
Definition at line 185 of file simulation.h.
|
private |
cached value where id_
is appended to name_
if id_
is not zero.
e.g. name_ = "my-sim"
and id_ = 0
-> "my-sim"
e.g. name_ = "my-sim"
and id_ = 4
-> "my-sim4"
Definition at line 172 of file simulation.h.