BioDynaMo
v1.05.120-25dc9790
|
Contains code required by all agents. More...
#include <agent.h>
Public Member Functions | |
Agent () | |
Agent (TRootIOCtor *io_ctor) | |
Agent (const Agent &other) | |
virtual | ~Agent () |
virtual Agent * | New () const =0 |
Create a new instance of this object using the default constructor. More... | |
virtual Agent * | NewCopy () const =0 |
Create a copy of this object. More... | |
virtual void | Initialize (const NewAgentEvent &event) |
virtual void | Update (const NewAgentEvent &event) |
void | CreateNewAgents (const NewAgentEvent &event, const std::initializer_list< Agent * > &prototypes) |
virtual const char * | GetTypeName () const |
virtual Shape | GetShape () const =0 |
virtual std::set< std::string > | GetRequiredVisDataMembers () const |
virtual void | RunDiscretization () |
void | AssignNewUid () |
const AgentUid & | GetUid () const |
Spinlock * | GetLock () |
virtual void | CriticalRegion (std::vector< AgentPointer<>> *aptrs) |
uint32_t | GetBoxIdx () const |
void | SetBoxIdx (uint32_t idx) |
void | SetStaticnessNextTimestep (bool value) const |
bool | GetPropagateStaticness () const |
void | SetPropagateStaticness (bool value=true) |
void | PropagateStaticness (bool beginning=false) |
void | UpdateStaticness () |
bool | IsStatic () const |
template<typename TAgent = Agent> | |
AgentPointer< TAgent > | GetAgentPtr () const |
Return agent pointer. More... | |
void | AddBehavior (Behavior *behavior) |
Add a behavior to this agent. More... | |
void | RemoveBehavior (const Behavior *behavior) |
void | RunBehaviors () |
Execute all behaviorsq. More... | |
const InlineVector< Behavior *, 2 > & | GetAllBehaviors () const |
Return all behaviors. More... | |
virtual Real3 | CalculateDisplacement (const InteractionForce *force, real_t squared_radius, real_t dt)=0 |
virtual void | ApplyDisplacement (const Real3 &displacement)=0 |
virtual const Real3 & | GetPosition () const =0 |
virtual void | SetPosition (const Real3 &pos)=0 |
virtual real_t | GetDiameter () const =0 |
virtual void | SetDiameter (real_t diameter)=0 |
virtual void | RemoveFromSimulation () |
void * | operator new (size_t size) |
void | operator delete (void *p) |
Protected Member Functions | |
template<typename TFrom , typename TTo > | |
std::enable_if< std::is_base_of< TFrom, TTo >::value, TTo * >::type | Cast (TFrom *agent) const |
template<typename TFrom , typename TTo > | |
std::enable_if<!std::is_base_of< TFrom, TTo >::value, TTo * >::type | Cast (TFrom *agent) const |
Protected Attributes | |
AgentUid | uid_ |
unique id More... | |
uint32_t | box_idx_ = std::numeric_limits<uint32_t>::max() |
Grid box index. More... | |
InlineVector< Behavior *, 2 > | behaviors_ |
collection of behaviors which define the internal behavior More... | |
Private Member Functions | |
void | InitializeBehaviors (const NewAgentEvent &event) |
void | UpdateBehaviors (const NewAgentEvent &event) |
Function to invoke the Update method of the behavior or remove it from current . Forwards the call to Update to each behavior of the existing agent and removes behaviors if they are flagged. This function sets the attributes NewAgentEvent::existing_behavior and NewAgentEvent::new_behaviors to their correct value. More... | |
Private Attributes | |
Spinlock | lock_ |
uint16_t | run_behavior_loop_idx_ = 0 |
bool | is_static_ = false |
If an agent is static, we should not compute the mechanical forces. More... | |
bool | propagate_staticness_neighborhood_ = true |
bool | is_static_next_ts_ = false |
Flag to determine of an agent is static in the next timestep. More... | |
void bdm::Agent::AddBehavior | ( | Behavior * | behavior | ) |
|
pure virtual |
Implemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::SphericalAgent.
|
pure virtual |
Implemented in bdm::neuroscience::NeuriteElement, bdm::Cell, and bdm::SphericalAgent.
|
inlineprotected |
|
inlineprotected |
|
inline |
This method creates a new agent for each entry in prototypes.
The prototypes list defines the type of the new agent. This function calls prototype->New()
internally. New agents are automatically added to the execution context right after they are initialized. This function sets the attributes NewAgentEvent::existing_agent
and NewAgentEvent::new_agents
to their correct values. Lastly, this function calls this->Update(event)
The newly created and initialized agents can be found in event.new_agents
.
|
inlinevirtual |
If the thread-safety mechanism is set to user-specified this function will be called before the operations are executed for this agent.
Subclasses define the critical region by adding the AgentPointers of all agents that must not be processed in parallel.
Don't forget to add the current agent.
Here an example from NeuronSoma.
void NeuronSoma::CriticalRegion(std::vector<AgentPointer<>>* aptrs) { aptrs->reserve(daughters_.size() + 1); aptrs->push_back(Agent::GetAgentPtr<>()); for (auto& daughter : daughters_) { aptrs->push_back(daughter); } }
Param::thread_safety_mechanism
AgentPointer
NeuronSoma::CriticalRegion
Reimplemented in bdm::neuroscience::NeuriteElement, and bdm::neuroscience::NeuronSoma.
|
inline |
const InlineVector< Behavior *, 2 > & bdm::Agent::GetAllBehaviors | ( | ) | const |
|
pure virtual |
Implemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::SphericalAgent.
|
pure virtual |
Implemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::SphericalAgent.
|
inlinevirtual |
Returns the data members that are required to visualize this simulation object.
Reimplemented in bdm::neuroscience::NeuriteElement.
|
pure virtual |
Implemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::SphericalAgent.
|
inlinevirtual |
|
virtual |
This method is called to initialize new agents that are created during a NewAgentEvent. Override this method to initialize attributes of your own Agent subclasses. NB: Don't forget to call the implementation of the base class first. Base::Initialize(event);
Failing to do so will result in errors.
Reimplemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::neuroscience::NeuronSoma.
|
private |
Function to copy behaviors from existing Agent to this one and to initialize them. This function sets the attributes NewAgentEvent::existing_behavior
and NewAgentEvent::new_behaviors
to their correct value.
|
pure virtual |
Create a new instance of this object using the default constructor.
|
pure virtual |
Create a copy of this object.
void bdm::Agent::PropagateStaticness | ( | bool | beginning = false | ) |
If the agent is not static, a call to this method sets all neighbors to 'not static'.
This method will be called twice: 1) At the end of the iteration using an agent op (beginning=false
).
2) At the beginning of the iteration as pre_scheduled op (beginning=true
).
1 is faster because it can use cached neighbors, but it might miss some conditions. (Neighbors modifying an agent after PropagateStaticness has been called. Agent which is larger than the largest agent.) 2 is slower but able to process all conditions. Therefore, we use 1 whenever possible and 2 for the remaining conditions.
void bdm::Agent::RemoveBehavior | ( | const Behavior * | behavior | ) |
|
virtual |
Reimplemented in bdm::neuroscience::NeuriteElement.
|
pure virtual |
Implemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::SphericalAgent.
|
pure virtual |
Implemented in bdm::Cell, bdm::neuroscience::NeuriteElement, and bdm::SphericalAgent.
|
inline |
|
inline |
|
virtual |
This method is called to update the existing agent at the end of a NewAgentEvent. Override this method to update attributes of your own Agent subclasses. NB: Don't forget to call the implementation of the base class first. Base::Update(event);
Failing to do so will result in errors.
Reimplemented in bdm::neuroscience::NeuriteElement, and bdm::neuroscience::NeuronSoma.
|
private |
Function to invoke the Update method of the behavior or remove it from current
. Forwards the call to Update to each behavior of the existing agent and removes behaviors if they are flagged. This function sets the attributes NewAgentEvent::existing_behavior
and NewAgentEvent::new_behaviors
to their correct value.
|
protected |
|
protected |
|
private |
|
mutableprivate |
|
private |
|
private |