BioDynaMo  v1.05.120-25dc9790
spherical_agent.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_AGENT_SPHERICAL_AGENT_H_
16 #define CORE_AGENT_SPHERICAL_AGENT_H_
17 
18 #include "core/agent/agent.h"
20 #include "core/interaction_force.h"
21 #include "core/shape.h"
22 #include "core/util/math.h"
23 
24 namespace bdm {
25 
26 class SphericalAgent : public Agent {
28 
29  public:
31 
32  explicit SphericalAgent(real_t diameter) : diameter_(diameter) {}
33 
34  explicit SphericalAgent(const Real3& position)
35  : position_(position), diameter_(1.0) {}
36 
37  virtual ~SphericalAgent() = default;
38 
39  Shape GetShape() const override { return Shape::kSphere; }
40 
41  real_t GetDiameter() const override { return diameter_; }
42 
43  const Real3& GetPosition() const override { return position_; }
44 
45  void SetDiameter(real_t diameter) override {
46  if (diameter > diameter_) {
48  }
49  diameter_ = diameter;
50  }
51 
52  void SetPosition(const Real3& position) override {
53  position_ = position;
55  }
56 
60  real_t squared_radius, real_t dt) override {
61  return {0, 0, 0};
62  }
63 
64  void ApplyDisplacement(const Real3& displacement) override {
65  if (displacement[0] == 0 && displacement[1] == 0 && displacement[2] == 0) {
66  return;
67  }
68  position_ += displacement;
70  }
71 
72  private:
74  Real3 position_ = {{0, 0, 0}};
77 };
78 
79 } // namespace bdm
80 
81 #endif // CORE_AGENT_SPHERICAL_AGENT_H_
bdm::SphericalAgent::SetPosition
void SetPosition(const Real3 &position) override
Definition: spherical_agent.h:52
shape.h
bdm::Shape
Shape
Definition: shape.h:20
bdm::SphericalAgent::SphericalAgent
SphericalAgent()
Definition: spherical_agent.h:30
bdm::SphericalAgent::SphericalAgent
SphericalAgent(real_t diameter)
Definition: spherical_agent.h:32
bdm::SphericalAgent::~SphericalAgent
virtual ~SphericalAgent()=default
bdm
Definition: agent.cc:39
bdm::InteractionForce
Definition: interaction_force.h:26
bdm::SphericalAgent
Definition: spherical_agent.h:26
bdm::SphericalAgent::ApplyDisplacement
void ApplyDisplacement(const Real3 &displacement) override
Definition: spherical_agent.h:64
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::SphericalAgent::diameter_
real_t diameter_
NB: Use setter and don't assign values directly.
Definition: spherical_agent.h:76
bdm::SphericalAgent::GetDiameter
real_t GetDiameter() const override
Definition: spherical_agent.h:41
bdm::SphericalAgent::position_
Real3 position_
NB: Use setter and don't assign values directly.
Definition: spherical_agent.h:74
math.h
bdm::Agent::SetPropagateStaticness
void SetPropagateStaticness(bool value=true)
Definition: agent.h:184
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::SphericalAgent::GetPosition
const Real3 & GetPosition() const override
Definition: spherical_agent.h:43
bdm::SphericalAgent::BDM_AGENT_HEADER
BDM_AGENT_HEADER(SphericalAgent, Agent, 1)
bdm::SphericalAgent::GetShape
Shape GetShape() const override
Definition: spherical_agent.h:39
bdm::SphericalAgent::CalculateDisplacement
Real3 CalculateDisplacement(const InteractionForce *force, real_t squared_radius, real_t dt) override
Definition: spherical_agent.h:59
bdm::kSphere
@ kSphere
Definition: shape.h:20
math_array.h
bdm::SphericalAgent::SetDiameter
void SetDiameter(real_t diameter) override
Definition: spherical_agent.h:45
agent.h
bdm::SphericalAgent::SphericalAgent
SphericalAgent(const Real3 &position)
Definition: spherical_agent.h:34
bdm::MathArray< real_t, 3 >
interaction_force.h