00001 00002 #include <CompuCell3D/Simulator.h> 00003 00004 #include <CompuCell3D/Field3D/Point3D.h> 00005 #include <CompuCell3D/Automaton/Automaton.h> 00006 #include <CompuCell3D/Potts3D/Potts3D.h> 00007 #include <CompuCell3D/Potts3D/CellInventory.h> 00008 #include <CompuCell3D/plugins/SimpleClock/SimpleClockPlugin.h> 00009 #include <BasicUtils/BasicClassAccessor.h> 00010 #include <CompuCell3D/steppables/PDESolvers/DiffusableVector.h> 00011 #include <CompuCell3D/Field3D/Field3D.h> 00012 #include <CompuCell3D/Field3D/WatchableField3D.h> 00013 00014 #include <CompuCell3D/ClassRegistry.h> 00015 #include <CompuCell3D/Field3D/Field3D.h> 00016 00017 00018 00019 using namespace CompuCell3D; 00020 using namespace std; 00021 00022 #define EXP_STL 00023 #include "DictyChemotaxisSteppable.h" 00024 00025 00027 DictyChemotaxisSteppable::DictyChemotaxisSteppable():potts(0),cellInventoryPtr(0) 00028 { 00029 00030 clockReloadValue=0; 00031 chemotactUntil=0; 00032 chetmotaxisActivationThreshold=0.0; 00033 chemotactingCellsCounter=0; 00034 ignoreFirstSteps=0; 00035 00036 00037 } 00039 00040 void DictyChemotaxisSteppable::update(CC3DXMLElement *_xmlData, bool _fullInitFlag){ 00041 00042 if(_xmlData->findElement("ClockReloadValue")) 00043 clockReloadValue=_xmlData->getFirstElement("ClockReloadValue")->getUInt(); 00044 00045 if(_xmlData->findElement("ChemotactUntil")) 00046 chemotactUntil=_xmlData->getFirstElement("ChemotactUntil")->getUInt(); 00047 00048 if(_xmlData->findElement("ChemotactUntil")) 00049 chemotactUntil=_xmlData->getFirstElement("ChemotactUntil")->getUInt(); 00050 00051 if(_xmlData->findElement("ChetmotaxisActivationThreshold")) 00052 chetmotaxisActivationThreshold=_xmlData->getFirstElement("ChetmotaxisActivationThreshold")->getDouble(); 00053 00054 if(_xmlData->findElement("IgnoreFirstSteps")) 00055 ignoreFirstSteps=_xmlData->getFirstElement("IgnoreFirstSteps")->getUInt(); 00056 00057 if(_xmlData->findElement("ChemicalField")){ 00058 chemicalFieldName=_xmlData->getFirstElement("ChemicalField")->getText(); 00059 chemicalFieldSource=_xmlData->getFirstElement("ChemicalField")->getAttribute("Source"); 00060 } 00061 00062 ASSERT_OR_THROW("ChemotactUntil has to be smaller than Clock Reload Value!",chemotactUntil<clockReloadValue); 00063 00064 } 00065 00066 void DictyChemotaxisSteppable::init(Simulator *_simulator, CC3DXMLElement *_xmlData){ 00067 00068 update(_xmlData,true); 00069 00070 simulator=_simulator; 00071 potts = simulator->getPotts(); 00072 cellFieldG = (WatchableField3D<CellG*>*)potts->getCellFieldG(); 00073 00074 cellInventoryPtr=& potts->getCellInventory(); 00075 00076 bool pluginAlreadyRegisteredFlag; 00077 SimpleClockPlugin * simpleClockPlugin = (SimpleClockPlugin *) Simulator::pluginManager.get("SimpleClock",&pluginAlreadyRegisteredFlag); //this will load PlasticityTracker plugin if it is not already loaded 00078 if(!pluginAlreadyRegisteredFlag) 00079 simpleClockPlugin->init(simulator); 00080 00081 simpleClockAccessorPtr = simpleClockPlugin->getSimpleClockAccessorPtr(); 00082 00083 simulator->registerSteerableObject(this); 00084 } 00085 00087 00088 00089 void DictyChemotaxisSteppable::extraInit(Simulator *_simulator){ 00090 00091 ClassRegistry *classRegistry=simulator->getClassRegistry(); 00092 Steppable * steppable=classRegistry->getStepper(chemicalFieldSource); 00093 00094 field=((DiffusableVector<float> *) steppable)->getConcentrationField(chemicalFieldName); 00095 00096 ASSERT_OR_THROW("No chemical field has been loaded!", field); 00097 cerr<<"GOT FIELD INTO CHEMOTAXIS STEPPABLE: "<<field<<endl; 00098 00099 fieldDim=field->getDim(); 00100 00101 } 00103 00104 void DictyChemotaxisSteppable::start(){ 00105 } 00106 00108 void DictyChemotaxisSteppable::step(const unsigned int currentStep){ 00109 00110 cerr<<"ignoreFirstSteps="<<ignoreFirstSteps<<endl; 00111 00112 if(currentStep < ignoreFirstSteps) 00113 return; 00114 00115 Point3D pt; 00116 CellG * currentCellPtr; 00117 int * currentClockPtr; 00118 char * clockFlagPtr; 00119 float currentConcentration; 00120 00121 for (pt.z = 0; pt.z < fieldDim.z; ++pt.z) 00122 for (pt.y = 0; pt.y < fieldDim.y; ++pt.y) 00123 for (pt.x = 0; pt.x < fieldDim.x; ++pt.x){ 00124 00125 currentCellPtr=cellFieldG->get(pt); 00126 /*cerr<<"currentCellPtr="<<currentCellPtr<<endl;*/ 00127 if(!currentCellPtr) continue; 00128 //cerr<<"1 currentCellPtr="<<currentCellPtr<<endl; 00129 //cerr<<"Type currentCellPtr="<<(int)currentCellPtr->type<<endl; 00130 00131 currentClockPtr = &(simpleClockAccessorPtr->get(currentCellPtr->extraAttribPtr)->clock); 00132 clockFlagPtr = &(simpleClockAccessorPtr->get(currentCellPtr->extraAttribPtr)->flag); 00133 currentConcentration=field->get(pt); 00134 00135 if(currentConcentration > chetmotaxisActivationThreshold && *currentClockPtr==0){ 00136 //simpleClockAccessorPtr->get(currentCellPtr->extraAttribPtr)->clock = clockReloadValue; 00137 *currentClockPtr=clockReloadValue; 00138 *clockFlagPtr = 1; 00139 cerr<<endl<<endl; 00140 //cerr<<"\t\treloading clock and activating chemotaxis"<<endl; 00141 cerr<<endl<<endl; 00142 ++chemotactingCellsCounter; 00143 } 00144 00145 } 00146 00148 CellInventory::cellInventoryIterator cInvItr; 00149 for(cInvItr=cellInventoryPtr->cellInventoryBegin() ; cInvItr !=cellInventoryPtr->cellInventoryEnd() ;++cInvItr ){ 00150 00151 currentCellPtr=*cInvItr; 00152 currentClockPtr = &(simpleClockAccessorPtr->get(currentCellPtr->extraAttribPtr)->clock); 00153 clockFlagPtr = &simpleClockAccessorPtr->get(currentCellPtr->extraAttribPtr)->flag; 00154 00155 if(*currentClockPtr>=1){ 00156 --(*currentClockPtr); 00157 } 00158 00159 if( *currentClockPtr < chemotactUntil && *clockFlagPtr){ 00160 *clockFlagPtr=0; 00161 //cerr<<"Deactivating chemotaxis"<<endl; 00162 --chemotactingCellsCounter; 00163 } 00164 00165 } 00166 00167 // cerr<<"\n\n \t\t THERE ARE "<<chemotactingCellsCounter<<" CELLS CHEMOTACTING\n"<<endl; 00168 } 00169 00170 std::string DictyChemotaxisSteppable::toString(){ 00171 return "DictyChemotaxisSteppable"; 00172 } 00173 00174 00175 std::string DictyChemotaxisSteppable::steerableName(){ 00176 return toString(); 00177 } 00178 00179
1.5.6