BioDynaMo  v1.05.120-25dc9790
Public Member Functions | List of all members
bdm::ExecutionContext Class Referenceabstract

#include <execution_context.h>

Inheritance diagram for bdm::ExecutionContext:
[legend]

Public Member Functions

virtual ~ExecutionContext ()=default
 
virtual void SetupAgentOpsAll (const std::vector< ExecutionContext * > &all_exec_ctxts)=0
 
virtual void TearDownAgentOpsAll (const std::vector< ExecutionContext * > &all_exec_ctxts)=0
 
virtual void SetupIterationAll (const std::vector< ExecutionContext * > &all_exec_ctxts)=0
 
virtual void TearDownIterationAll (const std::vector< ExecutionContext * > &all_exec_ctxts)=0
 
virtual void Execute (Agent *agent, AgentHandle ah, const std::vector< Operation * > &operations)=0
 
virtual void ForEachNeighbor (Functor< void, Agent * > &lambda, const Agent &query, void *criteria)=0
 
virtual void ForEachNeighbor (Functor< void, Agent *, real_t > &lambda, const Agent &query, real_t squared_radius)=0
 
virtual void ForEachNeighbor (Functor< void, Agent *, real_t > &lambda, const Real3 &query_position, real_t squared_radius)=0
 
virtual void AddAgent (Agent *new_agent)=0
 Adds the agent to the simulation (threadsafe, takes ownership). Note that we avoid the use of smart pointers for the agents to avoid unnecessary overhead during construction of the agent (performance argument). usage example: More...
 
virtual void RemoveAgent (const AgentUid &uid)=0
 
virtual AgentGetAgent (const AgentUid &uid)=0
 
virtual const AgentGetConstAgent (const AgentUid &uid)=0
 

Detailed Description

Definition at line 31 of file execution_context.h.

Constructor & Destructor Documentation

◆ ~ExecutionContext()

virtual bdm::ExecutionContext::~ExecutionContext ( )
virtualdefault

Member Function Documentation

◆ AddAgent()

virtual void bdm::ExecutionContext::AddAgent ( Agent new_agent)
pure virtual

Adds the agent to the simulation (threadsafe, takes ownership). Note that we avoid the use of smart pointers for the agents to avoid unnecessary overhead during construction of the agent (performance argument). usage example:

ctxt->AddAgent(new Agent());

or

auto* agent = new Agent();
// modify agent
ctxt->AddAgent(agent);
Parameters
new_agentThe agent to be added to the simulation

Implemented in bdm::InPlaceExecutionContext.

◆ Execute()

virtual void bdm::ExecutionContext::Execute ( Agent agent,
AgentHandle  ah,
const std::vector< Operation * > &  operations 
)
pure virtual

Execute a series of operations on an agent in the order given in the argument

Implemented in bdm::InPlaceExecutionContext, and bdm::experimental::CopyExecutionContext.

◆ ForEachNeighbor() [1/3]

virtual void bdm::ExecutionContext::ForEachNeighbor ( Functor< void, Agent * > &  lambda,
const Agent query,
void *  criteria 
)
pure virtual

Applies the lambda lambda for each neighbor of the given query agent within the given criteria. Does not support caching.

Implemented in bdm::InPlaceExecutionContext.

◆ ForEachNeighbor() [2/3]

virtual void bdm::ExecutionContext::ForEachNeighbor ( Functor< void, Agent *, real_t > &  lambda,
const Agent query,
real_t  squared_radius 
)
pure virtual

Applies the lambda lambda for each neighbor of the given query agent within the given search radius sqrt(squared_radius)

Implemented in bdm::InPlaceExecutionContext.

◆ ForEachNeighbor() [3/3]

virtual void bdm::ExecutionContext::ForEachNeighbor ( Functor< void, Agent *, real_t > &  lambda,
const Real3 query_position,
real_t  squared_radius 
)
pure virtual

Applies the lambda lambda for each neighbor of the given query_position within the given search radius sqrt(squared_radius)

Implemented in bdm::InPlaceExecutionContext.

◆ GetAgent()

virtual Agent* bdm::ExecutionContext::GetAgent ( const AgentUid uid)
pure virtual

◆ GetConstAgent()

virtual const Agent* bdm::ExecutionContext::GetConstAgent ( const AgentUid uid)
pure virtual

◆ RemoveAgent()

virtual void bdm::ExecutionContext::RemoveAgent ( const AgentUid uid)
pure virtual

◆ SetupAgentOpsAll()

virtual void bdm::ExecutionContext::SetupAgentOpsAll ( const std::vector< ExecutionContext * > &  all_exec_ctxts)
pure virtual

This function is called before all agent operations are executed.
This function is not thread-safe. NB: Invalidates references and pointers to agents.

Implemented in bdm::InPlaceExecutionContext.

◆ SetupIterationAll()

virtual void bdm::ExecutionContext::SetupIterationAll ( const std::vector< ExecutionContext * > &  all_exec_ctxts)
pure virtual

This function is called at the beginning of each iteration to setup all execution contexts. This function is not thread-safe. NB: Invalidates references and pointers to agents.

Implemented in bdm::InPlaceExecutionContext, and bdm::experimental::CopyExecutionContext.

◆ TearDownAgentOpsAll()

virtual void bdm::ExecutionContext::TearDownAgentOpsAll ( const std::vector< ExecutionContext * > &  all_exec_ctxts)
pure virtual

This function is called after all agent operations were executed.
This function is not thread-safe.
NB: Invalidates references and pointers to agents.

Implemented in bdm::InPlaceExecutionContext, and bdm::experimental::CopyExecutionContext.

◆ TearDownIterationAll()

virtual void bdm::ExecutionContext::TearDownIterationAll ( const std::vector< ExecutionContext * > &  all_exec_ctxts)
pure virtual

This function is called at the end of each iteration to tear down all execution contexts. This function is not thread-safe.
NB: Invalidates references and pointers to agents.

Implemented in bdm::InPlaceExecutionContext.


The documentation for this class was generated from the following file:
bdm::ExecutionContext::AddAgent
virtual void AddAgent(Agent *new_agent)=0
Adds the agent to the simulation (threadsafe, takes ownership). Note that we avoid the use of smart p...
bdm::Simulation::GetExecutionContext
ExecutionContext * GetExecutionContext()
Returns a thread local execution context.
Definition: simulation.cc:271
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68