BioDynaMo  v1.05.159-3be850bb
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_
Contains code required by all agents.
Definition: agent.h:79
virtual const Real3 & GetPosition() const =0
void ChangeConcentrationBy(const Real3 &position, real_t amount, InteractionMode mode=InteractionMode::kAdditive, bool scale_with_resolution=false)
DiffusionGrid * GetDiffusionGrid(size_t substance_id) const
Secrete substance at Agent position.
Definition: secretion.h:28
Secretion(const std::string &substance, real_t quantity=1, InteractionMode mode=InteractionMode::kAdditive)
Definition: secretion.h:33
InteractionMode mode_
Definition: secretion.h:61
Secretion()=default
BDM_BEHAVIOR_HEADER(Secretion, Behavior, 2)
Secretion(DiffusionGrid *dgrid, real_t quantity=1, InteractionMode mode=InteractionMode::kAdditive)
Definition: secretion.h:40
virtual ~Secretion()=default
void Run(Agent *agent) override
Definition: secretion.h:53
real_t quantity_
Definition: secretion.h:60
DiffusionGrid * dgrid_
Definition: secretion.h:59
void Initialize(const NewAgentEvent &event) override
Definition: secretion.h:46
ResourceManager * GetResourceManager()
Returns the ResourceManager instance.
Definition: simulation.cc:244
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68
Definition: agent.cc:39
InteractionMode
double real_t
Definition: real_t.h:21
Behavior * existing_behavior