Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92061350
signalAndMechanicalForces.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 17, 01:00
Size
5 KB
Mime Type
text/x-c
Expires
Tue, Nov 19, 01:00 (2 d)
Engine
blob
Format
Raw Data
Handle
22370078
Attached To
R9411 tisue modeling
signalAndMechanicalForces.cpp
View Options
#include "signalAndMechanicalForces.hpp"
#include <limits>
using namespace std;
template<class Interactor>
void SignalAndMechanicalForces<Interactor>::initParameters(){ //TODO
we_min= 0.01;
we_r = 10.0;
hill_co = 4.0;
h_pressure = 2;
HC_pressure = 10;
k_sig=0.3;
k_pressure=0.0;
k_tension=0.2;
max_pert = 0.001;
small_cell=false;
hfdp = 3;
#ifdef REAL_LATTICE
h_we = 15;//220;//200
small_cell_thresh= 0.3;//0.3;
tau_sig= 0;//20;
small_bound_thresh = 1.0;
#else
h_we = 600;//220;//200
small_cell_thresh= 0.1;//0.25;
tau_sig= 10;
small_bound_thresh = 0.2;
#endif
tau_mech=0.05;
k_pressure*=tau_mech;
k_tension*=tau_mech;
}
template<class Interactor>
void SignalAndMechanicalForces<Interactor>::operator()(const state_type &y,state_type &dydt,const double t){
fill(dydt.begin(), dydt.end(), 0); //necessary
// cout<<"signaling..."<<endl;
MechanicalForces::fromState(y);
signaling(y,dydt,t);
double n2= norm2(dydt);
// cout<<t<<" - "<<n2<<endl;
// updatePressure(y);
uint nbcells = lattice->getNbCells();
// cout<<"computing forces"<<endl;
for (uint c=0;c<nbcells;c++){
Cell& ce = lattice->getCell(c);
if(!ce.isEmpty() && ! ce.isFrozen()){
dTensionAndPressure(&ce,y,dydt);
}
}
n2= norm2(dydt);
// cout<<t<<" "<<n2<<endl;
addPerturbations(dydt);
// cout<<"pert"<<endl;
checkIntegrity(y,dydt);
// cout<<"OK"<<endl;
//#endif
}
template<class Interactor>
void SignalAndMechanicalForces<Interactor>::initState(state_type &s, double *delta){
s.resize(state_dim);
uint idx = MechanicalForces::initState(s,false);
signaling.initState(s,delta);
// int n= lattice->getNbCells();
// uint m = cellStateDim();
// std::cout<<"filling in..."<<m<<" "<<n<<std::endl;
// for (int c=0;c<n;c++){
// // std::cout<<c<<std::endl;
// uint idx = lattice->getCell(c).stateVectorIndex();
// for (uint i=0;i<m;i++){
// s[idx++] = delta[c*m+i];
// }
// }
}
template<class Interactor>
void SignalAndMechanicalForces<Interactor>::updateState(state_type &s){
s.resize(state_dim);
cout<<"base init"<<endl;
MechanicalForces::initState(s,false);
cout<<"signal init"<<endl;
signaling.updateDeadCellState(s);
cout<<"signal done"<<endl;
}
template<class Interactor>
void SignalAndMechanicalForces<Interactor>::setLattice(Lattice *lat){
lattice = lat;
signaling.setLattice(lat);
// signaling.setMechanics(this);
uint n= lat->getNbCells();
m_pressure.resize(n);
// m_signal.resize(n);
m_area.resize(n);
m_perimeter.resize(n);
uint m = setStateVectorIndex();
state_dim= m;
// observer.resize(m);
}
template<class Interactor>
uint SignalAndMechanicalForces<Interactor>::setStateVectorIndex(){
uint n = MechanicalForces::setStateVectorIndex();
return signaling.setStateVectorIndex(n);
}
template<class Interactor>
float SignalAndMechanicalForces<Interactor>::getWeight(Boundary *b, const state_type &y){
return signaling.getWeight(b,y);
}
template<class Interactor>
void SignalAndMechanicalForces<Interactor>::delaminate(int c){
vector<Boundary *> mem;
Cell& ce = lattice->getCell(c);
while(ce.getNbBoundaries()>3){
double min_score=std::numeric_limits<double>::max();
Boundary *min_b=NULL;
BoundaryIterator it(&ce);
for(Boundary *b=it.first();!it.isLast();b=it.next()){
double score = signaling.delaminationScore(b);
// double ori = abs(rpos.sinAngle(Vec2(1,0)));//TODO find something smarter
if(score<min_score){
min_score=score;
min_b = b;
}
// cout<< "checking "<<b->oppositeCell()->id()<<" "<<ori<<endl;
}
if(min_b){
cout<<"T1 trans "<<min_b->oppositeCell()->id()<<endl;
min_b->doT1Transition();
mem.push_back(min_b);
}
}
cout<<"handing over"<<endl;
ce.doT2Transition();
}
// void SignalAndMechanicalForces::checkT1Transition(Boundary *b){
// // std::cout<<"check"<<std::endl;
// if(isHC(b->cell()) && isHC(b->oppositeCell())){
// double len = b->scaledLength(Vec2(getScaleX(),getScaleY()));
// if(len < 0.2){
// // cout<<"correcting between "<<b->cell()->id()<<" "<< b->oppositeCell()->id()<<endl;
// b->doT1Transition();
// }
// }
// }
// template void checkT1TransitionWrapper<SignalAndMechanicalForces>(Boundary *b, void *arg);
// void myWrapper(Boundary *b, void *args){
// checkT1TransitionWrapper<SignalAndMechanicalForces>(b,args);
// }
// void SignalAndMechanicalForces::findT1Transitions(){
// // lattice->forAllBoundaries(MechanicalForces::checkT1TransitionWrapper,(void *)this);
// lattice->forAllBoundaries(myWrapper,(void *)this);
// }
// void SignalAndMechanicalForces::checkT1TransitionWrapper(Boundary *b, void *arg){
// MechanicalForces *forces = (MechanicalForces *)arg;
// if(!b->isGhost()){
// forces->checkT1Transition(b);
// }
// }
// void MechanicalForces::checkT1Transition(Boundary *b){
// if(isHC(b->cell()) && isHC(b->oppositeCell())){
// double len = b->scaledLength(Vec2(getScaleX(),getScaleY()));
// if(len < 0.2){
// // cout<<"correcting between "<<b->cell()->id()<<" "<< b->oppositeCell()->id()<<endl;
// b->doT1Transition();
// }
// }
// }
// void SignalAndMechanicalForces::findT1Transitions(){
// lattice->forAllBoundaries(SignalAndMechanicalForces::checkT1TransitionWrapper,(void *)this);
// }
Event Timeline
Log In to Comment