BioDynaMo  v1.05.120-25dc9790
continuum_interface.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 CONTINUUM_INTERFACE_H_
16 #define CONTINUUM_INTERFACE_H_
17 
18 #include <array>
19 #include <limits>
20 #include <string>
22 
23 namespace bdm {
24 
52 class Continuum {
53  public:
54  Continuum() = default;
55  explicit Continuum(const TRootIOCtor *) {}
56  virtual ~Continuum() = default;
57 
63 
70  virtual void Initialize() = 0;
71 
77  virtual void Update() = 0;
78 
84  virtual void Step(real_t dt) = 0;
85 
87  int GetContinuumId() const { return continuum_id_; }
88 
90  void SetContinuumId(int id) { continuum_id_ = id; }
91 
93  const std::string &GetContinuumName() const { return continuum_name_; }
94 
96  void SetContinuumName(const std::string &name) { continuum_name_ = name; }
97 
100 
105  void SetTimeStep(real_t dt);
106 
108  real_t GetTimeStep() const;
109 
110  private:
112  std::string continuum_name_ = "";
113 
117  real_t time_step_ = std::numeric_limits<real_t>::max();
118 
121 
124 
126  int continuum_id_ = -1;
127 
128  BDM_CLASS_DEF(Continuum, 1); // NOLINT
129 };
130 
132 class ScalarField : public Continuum {
133  public:
134  ScalarField() = default;
135  explicit ScalarField(const TRootIOCtor *) {}
136  ~ScalarField() override = default;
137 
139  virtual real_t GetValue(const Real3 &position) const = 0;
140 
142  virtual Real3 GetGradient(const Real3 &position) const = 0;
143 
144  BDM_CLASS_DEF_OVERRIDE(ScalarField, 1); // NOLINT
145 };
146 
148 class VectorField : public Continuum {
149  public:
150  VectorField() = default;
151  explicit VectorField(const TRootIOCtor *) {}
152  ~VectorField() override = default;
153 
155  virtual Real3 GetValue(const Real3 &position) const = 0;
156 
158  virtual real_t GetDiv(const Real3 &position) const = 0;
159 
161  virtual real_t GetCurl(const Real3 &position) const = 0;
162 
163  BDM_CLASS_DEF_OVERRIDE(VectorField, 1); // NOLINT
164 };
165 
166 } // namespace bdm
167 
168 #endif // CONTINUUM_INTERFACE_H_
bdm::VectorField::BDM_CLASS_DEF_OVERRIDE
BDM_CLASS_DEF_OVERRIDE(VectorField, 1)
bdm::Continuum::continuum_name_
std::string continuum_name_
Name of the continuum.
Definition: continuum_interface.h:112
bdm::Continuum::Continuum
Continuum()=default
bdm
Definition: agent.cc:39
bdm::VectorField::VectorField
VectorField(const TRootIOCtor *)
Definition: continuum_interface.h:151
bdm::Continuum::Step
virtual void Step(real_t dt)=0
bdm::Continuum::continuum_id_
int continuum_id_
Id of the continuum.
Definition: continuum_interface.h:126
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::ScalarField::ScalarField
ScalarField(const TRootIOCtor *)
Definition: continuum_interface.h:135
bdm::Continuum::BDM_CLASS_DEF
BDM_CLASS_DEF(Continuum, 1)
bdm::Continuum::time_to_simulate_
real_t time_to_simulate_
Time that the continuum (still) has to integrate.
Definition: continuum_interface.h:123
bdm::Continuum
Continuum class to interface with BioDynaMo for hybrid simulations.
Definition: continuum_interface.h:52
bdm::Continuum::~Continuum
virtual ~Continuum()=default
bdm::ScalarField::ScalarField
ScalarField()=default
bdm::Continuum::GetContinuumName
const std::string & GetContinuumName() const
Returns the name of the continuum.
Definition: continuum_interface.h:93
bdm::VectorField::~VectorField
~VectorField() override=default
bdm::ScalarField::GetGradient
virtual Real3 GetGradient(const Real3 &position) const =0
Returns the gradient of the scalar field at the given position.
bdm::Continuum::simulated_time_
real_t simulated_time_
Passed simulation time for the continuum.
Definition: continuum_interface.h:120
bdm::VectorField
Interface for vector fields. See Continuum for more information.
Definition: continuum_interface.h:148
bdm::Continuum::IntegrateTimeAsynchronously
void IntegrateTimeAsynchronously(real_t dt)
Definition: continuum_interface.cc:22
bdm::Continuum::GetTimeStep
real_t GetTimeStep() const
Returns the time step for the continuum.
Definition: continuum_interface.cc:60
bdm::Continuum::Update
virtual void Update()=0
bdm::Continuum::SetTimeStep
void SetTimeStep(real_t dt)
Definition: continuum_interface.cc:58
bdm::Continuum::Initialize
virtual void Initialize()=0
bdm::Continuum::SetContinuumId
void SetContinuumId(int id)
Sets the ID of the continuum.
Definition: continuum_interface.h:90
bdm::Continuum::GetContinuumId
int GetContinuumId() const
Returns the ID of the continuum.
Definition: continuum_interface.h:87
bdm::Continuum::time_step_
real_t time_step_
Definition: continuum_interface.h:117
math_array.h
bdm::Continuum::Continuum
Continuum(const TRootIOCtor *)
Definition: continuum_interface.h:55
bdm::ScalarField
Interface for scalar fields. See Continuum for more information.
Definition: continuum_interface.h:132
bdm::VectorField::GetDiv
virtual real_t GetDiv(const Real3 &position) const =0
Returns the divergence of the vector field at the given position.
bdm::ScalarField::GetValue
virtual real_t GetValue(const Real3 &position) const =0
Returns the value of the scalar field at the given position.
bdm::VectorField::GetValue
virtual Real3 GetValue(const Real3 &position) const =0
Returns the value of the vector field at the given position.
bdm::VectorField::VectorField
VectorField()=default
bdm::MathArray
Definition: math_array.h:36
bdm::Continuum::SetContinuumName
void SetContinuumName(const std::string &name)
Sets the name of the continuum.
Definition: continuum_interface.h:96
bdm::ScalarField::BDM_CLASS_DEF_OVERRIDE
BDM_CLASS_DEF_OVERRIDE(ScalarField, 1)
bdm::Continuum::GetSimulatedTime
real_t GetSimulatedTime() const
Returns the time simulated by the continuum.
Definition: continuum_interface.h:99
bdm::ScalarField::~ScalarField
~ScalarField() override=default
bdm::VectorField::GetCurl
virtual real_t GetCurl(const Real3 &position) const =0
Returns the curl of the vector field at the given position.