CellModules
PluginDiffusion.hpp
Go to the documentation of this file.
1#ifndef ONKO3D_3_0_PLUGINDIFFUSION_HPP
2#define ONKO3D_3_0_PLUGINDIFFUSION_HPP
3
11#include <vector>
12#include <mecacell/mecacell.h>
13#include <math.h>
14#include "DiffusionGrid.hpp"
15
20namespace Diffusion {
21
28 template<typename cell_t>
30
31 private:
34 public:
35
39 PluginDiffusion() = default;
40
46 inline PluginDiffusion(double dx, double accuracy): grid(dx, accuracy) {}
47
52 inline void setDx(double dx) { grid.setDx(dx); }
53
58 inline void setAccuracy(double a) { grid.setAccuracy(a); }
59
64 inline DiffusionGrid* getGrid() { return &grid; }
65
71 inline void addMolecule(int n, Molecule m) { grid.addMolecule(n, m); }
72
78 template<typename world_t>
79 void onAddCell(world_t *w) {
80 for (cell_t *c : w->newCells){
81 c->getBody().setDiffusionGrid(&grid); // Transmits the diffusion grid
82 }
83 }
84
93 template<typename world_t>
94 void preBehaviorUpdate(world_t *w) {
97 }
98 };
99}
100
101#endif //ONKO3D_3_0_PLUGINDIFFUSION_HPP
molecules 2D Grid manager
Class representing a grid for molecule diffusion.
void setDx(double _dx)
Sets the grid cell size.
void setAccuracy(double a)
Sets the diffusion accuracy.
void updateBoundary(world_t *w)
Updates the grid boundaries and consumptions.
void addMolecule(int n, Molecule m)
Adds a molecule to the grid.
void computeMolecules(world_t *w)
Updates the quantities of molecules in the grid.
Template class for a grid diffusion-based plugin.
PluginDiffusion(double dx, double accuracy)
Constructor with grid parameters.
void addMolecule(int n, Molecule m)
Adds a new molecule to the grid.
void preBehaviorUpdate(world_t *w)
Hook called before the behavior update of the world.
DiffusionGrid * getGrid()
Gets the diffusion grid.
void onAddCell(world_t *w)
Hook called when a cell is added to the world.
void setAccuracy(double a)
Sets the diffusion accuracy.
void setDx(double dx)
Sets the grid cell size.
PluginDiffusion()=default
Default constructor.
Namespace for diffusion-related structures and classes.
Structure representing a molecule in the diffusion grid.