forked from mikahlbk/SpatialYeastModel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh_pt.cpp
87 lines (83 loc) · 2.35 KB
/
mesh_pt.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//mesh_pt.cpp
//****************************************************
//include dependencies
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <math.h>
#include <ctime>
#include <cstdio>
#include <memory>
#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
#include "parameters.h"
#include "coord.h"
#include "cell.h"
#include "colony.h"
#include "mesh.h"
#include "mesh_pt.h"
using namespace std;
//****************************************
//Public member functions for mesh_pts.cpp
//constructor
Mesh_Pt::Mesh_Pt(shared_ptr<Mesh> my_mesh, double x, double y, int index){
this->my_mesh = my_mesh;
this->center = Coord(x, y);
this->index = index;
this->nutrient_conc = 1;
return;
}
void Mesh_Pt::find_neighbor_bins(){
vector <pair<double,shared_ptr<Mesh_Pt>>> distances;
vector <shared_ptr<Mesh_Pt>> mesh_pts;
my_mesh->get_mesh_pts_vec(mesh_pts);
shared_ptr<Mesh_Pt> this_mesh_pt = shared_from_this();
for(unsigned int i = 0; i < mesh_pts.size();i++){
if(mesh_pts.at(i)!= this_mesh_pt){
distances.push_back(make_pair((mesh_pts.at(i)->get_center()-center).length(),mesh_pts.at(i)));
}
}
sort(distances.begin(),distances.end());
for(unsigned int i = 0; i<8; i++){
this->neighbors.push_back(distances.at(i).second);
//cout << distances.at(i).second->get_index() << endl;
}
return;
}
void Mesh_Pt::clear_cells_vec(){
this->cells.clear();
return;
}
void Mesh_Pt::get_cells(vector<shared_ptr<Cell>>& neighbors){
neighbors = this->cells;
return;
}
void Mesh_Pt::get_neighbor_bins(vector<shared_ptr<Mesh_Pt>>& neighbor_bins){
neighbor_bins = this->neighbors;
return;
}
void Mesh_Pt::add_cells_to_neighbor_vec(vector<shared_ptr<Cell>>& neighbor_cells){
for(unsigned int i =0; i < cells.size();i++){
neighbor_cells.push_back(cells.at(i));
}
return;
}
void Mesh_Pt::add_cell(shared_ptr<Cell>& new_cell){
this->cells.push_back(new_cell);
return;
}
void Mesh_Pt::calculate_nutrient_concentration(){
double curr_mass;
double total_mass = 0;
double multiplier;
for(unsigned int i = 0;i<cells.size();i++){
curr_mass = M_PI*pow(cells.at(i)->get_curr_radius(),2);
total_mass += curr_mass;
}
//cout << "Conc: " << nutrient_conc << endl;
multiplier = this->nutrient_conc -NUTRIENT_DECAY*(total_mass/K_MASS)*this->nutrient_conc*dt;
this->nutrient_conc = multiplier;
//cout << "Multiplier: " << multiplier << endl;
return;
}