BioDynaMo  v1.05.120-25dc9790
secretion.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_BEHAVIOR_SECRETION_H_
16 #define CORE_BEHAVIOR_SECRETION_H_
17 
18 #include <string>
19 
20 #include "core/agent/cell.h"
21 #include "core/behavior/behavior.h"
23 #include "core/resource_manager.h"
24 
25 namespace bdm {
26 
28 class Secretion : public Behavior {
30 
31  public:
32  Secretion() = default;
33  explicit Secretion(const std::string& substance, real_t quantity = 1,
35  : quantity_(quantity), mode_(mode) {
37  substance);
38  }
39 
40  explicit Secretion(DiffusionGrid* dgrid, real_t quantity = 1,
42  : dgrid_(dgrid), quantity_(quantity), mode_(mode) {}
43 
44  virtual ~Secretion() = default;
45 
46  void Initialize(const NewAgentEvent& event) override {
47  Base::Initialize(event);
48  auto* other = bdm_static_cast<Secretion*>(event.existing_behavior);
49  dgrid_ = other->dgrid_;
50  quantity_ = other->quantity_;
51  }
52 
53  void Run(Agent* agent) override {
54  auto& secretion_position = agent->GetPosition();
55  dgrid_->ChangeConcentrationBy(secretion_position, quantity_, mode_);
56  }
57 
58  private:
59  DiffusionGrid* dgrid_ = nullptr;
62 };
63 
64 } // namespace bdm
65 
66 #endif // CORE_BEHAVIOR_SECRETION_H_
bdm::NewAgentEvent
Definition: new_agent_event.h:61
bdm::Secretion::dgrid_
DiffusionGrid * dgrid_
Definition: secretion.h:59
bdm::Secretion::mode_
InteractionMode mode_
Definition: secretion.h:61
bdm::Secretion::quantity_
real_t quantity_
Definition: secretion.h:60
bdm::Secretion::Initialize
void Initialize(const NewAgentEvent &event) override
Definition: secretion.h:46
bdm::Secretion
Secrete substance at Agent position.
Definition: secretion.h:28
bdm
Definition: agent.cc:39
bdm::NewAgentEvent::existing_behavior
Behavior * existing_behavior
Definition: new_agent_event.h:77
bdm::Behavior
Definition: behavior.h:29
bdm::InteractionMode::kAdditive
@ kAdditive
bdm::ResourceManager::GetDiffusionGrid
DiffusionGrid * GetDiffusionGrid(size_t substance_id) const
Definition: resource_manager.h:167
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::DiffusionGrid
Definition: diffusion_grid.h:90
bdm::Secretion::~Secretion
virtual ~Secretion()=default
bdm::InteractionMode
InteractionMode
Definition: diffusion_grid.h:43
bdm::Secretion::Secretion
Secretion()=default
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::Secretion::Secretion
Secretion(DiffusionGrid *dgrid, real_t quantity=1, InteractionMode mode=InteractionMode::kAdditive)
Definition: secretion.h:40
diffusion_grid.h
bdm::Simulation::GetResourceManager
ResourceManager * GetResourceManager()
Returns the ResourceManager instance.
Definition: simulation.cc:244
bdm::Secretion::Secretion
Secretion(const std::string &substance, real_t quantity=1, InteractionMode mode=InteractionMode::kAdditive)
Definition: secretion.h:33
bdm::Secretion::Run
void Run(Agent *agent) override
Definition: secretion.h:53
behavior.h
bdm::Secretion::BDM_BEHAVIOR_HEADER
BDM_BEHAVIOR_HEADER(Secretion, Behavior, 2)
bdm::DiffusionGrid::ChangeConcentrationBy
void ChangeConcentrationBy(const Real3 &position, real_t amount, InteractionMode mode=InteractionMode::kAdditive, bool scale_with_resolution=false)
Definition: diffusion_grid.cc:355
bdm::Agent::GetPosition
virtual const Real3 & GetPosition() const =0
resource_manager.h
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68
cell.h