1#ifndef ONKO3D_3_0_DIFFUSIONGRID_HPP
2#define ONKO3D_3_0_DIFFUSIONGRID_HPP
13#include <unordered_map>
59 for (
int i = 0; i < size; ++i) {
85 for (
int i = 0; i <
grid.size(); ++i) {
86 for (
int j = 0; j <
grid.size(); ++j) {
87 for(
int m = 0; m <
molecules.size(); ++m){
88 grid[i][j].prevQuantities[m] =
grid[i][j].quantities[m];
89 grid[i][j].quantities[m] = 0.;
90 grid[i][j].consumptions[m] = 0.;
106 for (
int i = -1; i <= 1; ++i) {
107 for (
int j = -1; j <= 1; ++j) {
108 if(i != 0 || j != 0){
112 if(xi < 0) xi =
width -1;
113 if(xi >=
width) xi = 0;
114 if(yj < 0) yj =
height -1;
116 for(
int m = 0; m <
molecules.size(); ++m){
120 if(xi < 0) xi =
width -1;
121 if(xi >=
width) xi = 0;
122 if(yj >= 0 && yj <
height){
123 for(
int m = 0; m <
molecules.size(); ++m){
126 }
else nbNeighbors --;
128 if(yj < 0) yj =
height -1;
130 if(xi >= 0 && xi <
width){
131 for(
int m = 0; m <
molecules.size(); ++m){
134 }
else nbNeighbors --;
136 if(xi >= 0 && xi < width && yj >= 0 && yj <
height){
137 for(
int m = 0; m <
molecules.size(); ++m){
146 for(
int m = 0; m <
molecules.size(); ++m){
160 for (
int i = 0; i <
grid.size(); ++i) {
161 for (
int j = 0; j <
grid.size(); ++j) {
173 template<
typename world_t>
175 for(
auto cell : w->cells){
176 int x = cell->getBody().get2DPosition().x();
177 int y = cell->getBody().get2DPosition().y();
178 for(
int m = 0; m <
molecules.size(); ++m){
179 grid[x][y].consumptions[m] += cell->getBody().getConsumptions()[m];
264 for(
int i = 0; i < w; ++i){
266 for(
int j = 0; j < h; ++j){
286 template<
typename world_t>
molecules grid based class
void initGrid(int size)
square grid initializer
void initGrid(int w, int h)
grid initializer
vector< Molecule > molecules
double getMolecule(int x, int y, int m)
molecule quantity getter
unordered_map< int, int > moleculesDict
int getWidth() const
grid's width getter
void setToreX(bool b)
toreX setter
void addMolecule(int n, Molecule m)
molecule adder
int getHeight() const
grid's height getter
vector< Molecule > getMolecules() const
molecules getter
void diffuse(int x, int y)
apply diffusion to the molecule m at position (x,y)
vector< vector< GridCell > > & getGrid()
grid getter
void updateConsumptions(world_t *w)
consumptions updater
void setToreY(bool b)
toreY setter
void preStep()
next step cells initializer
void computeStep()
molecules updater
void setTore(bool x, bool y)
tore setter
void computeMolecules(world_t *w)
molecules quantities updater
vector< vector< GridCell > > grid
void resize(size_t newSize)
Resizes the vector to contain the specified number of elements.
size_t size() const
Returns the number of elements in the vector.
GridCell(vector< Molecule > m)
constructor
vector< double > consumptions
vector< double > prevQuantities
GridCell()=default
default constructor
vector< double > quantities
Molecule(double dc, double dq, double de)
double defaultEvaporation