BioDynaMo  v1.05.159-3be850bb
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 
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 
164 };
165 
166 } // namespace bdm
167 
168 #endif // CONTINUUM_INTERFACE_H_
Continuum class to interface with BioDynaMo for hybrid simulations.
void SetContinuumId(int id)
Sets the ID of the continuum.
virtual void Initialize()=0
virtual ~Continuum()=default
Continuum(const TRootIOCtor *)
BDM_CLASS_DEF(Continuum, 1)
real_t GetTimeStep() const
Returns the time step for the continuum.
std::string continuum_name_
Name of the continuum.
void SetTimeStep(real_t dt)
real_t time_to_simulate_
Time that the continuum (still) has to integrate.
void IntegrateTimeAsynchronously(real_t dt)
real_t GetSimulatedTime() const
Returns the time simulated by the continuum.
virtual void Step(real_t dt)=0
real_t simulated_time_
Passed simulation time for the continuum.
virtual void Update()=0
int GetContinuumId() const
Returns the ID of the continuum.
void SetContinuumName(const std::string &name)
Sets the name of the continuum.
int continuum_id_
Id of the continuum.
const std::string & GetContinuumName() const
Returns the name of the continuum.
Continuum()=default
Interface for scalar fields. See Continuum for more information.
BDM_CLASS_DEF_OVERRIDE(ScalarField, 1)
virtual real_t GetValue(const Real3 &position) const =0
Returns the value of the scalar field at the given position.
ScalarField()=default
virtual Real3 GetGradient(const Real3 &position) const =0
Returns the gradient of the scalar field at the given position.
ScalarField(const TRootIOCtor *)
~ScalarField() override=default
Interface for vector fields. See Continuum for more information.
virtual real_t GetCurl(const Real3 &position) const =0
Returns the curl of the vector field at the given position.
BDM_CLASS_DEF_OVERRIDE(VectorField, 1)
VectorField(const TRootIOCtor *)
VectorField()=default
virtual real_t GetDiv(const Real3 &position) const =0
Returns the divergence of the vector field at the given position.
~VectorField() override=default
virtual Real3 GetValue(const Real3 &position) const =0
Returns the value of the vector field at the given position.
Definition: agent.cc:39
double real_t
Definition: real_t.h:21