Author: Lukas Breitwieser
In this tutorial we want to demonstrate how to add and remove agents from the simulation.
Let's start by setting up BioDynaMo notebooks.
%jsroot on
gROOT->LoadMacro("${BDMSYS}/etc/rootlogon.C");
INFO: Created simulation object 'simulation' with UniqueName='simulation'.
auto* ctxt = simulation.GetExecutionContext();
auto* scheduler = simulation.GetScheduler();
auto* rm = simulation.GetResourceManager();
Let's define our initial model: One cell at origin.
We also create an agent pointer for our cell, because raw pointers might be invalidated after a call to Scheduler::Simulate
auto* cell = new Cell();
ctxt->AddAgent(cell);
auto cell_aptr = cell->GetAgentPtr<Cell>();
scheduler->FinalizeInitialization();
VisualizeInNotebook();
Adding an agent to the simulation is as easy as constructing one and adding it to the execution context.
Our default execution context will add the new agent to the simulation at the end of the iteration.
Therefore, the visualization still shows only one agent.
ctxt->AddAgent(new SphericalAgent({3, 0, 0}));
VisualizeInNotebook()