36 #include "OffLatticeSimulation.hpp"
37 #include "AbstractCentreBasedCellPopulation.hpp"
38 #include "VertexBasedCellPopulation.hpp"
39 #include "T2SwapCellKiller.hpp"
40 #include "AbstractVertexBasedDivisionRule.hpp"
41 #include "Cylindrical2dMesh.hpp"
42 #include "Cylindrical2dVertexMesh.hpp"
43 #include "AbstractTwoBodyInteractionForce.hpp"
44 #include "CellBasedEventHandler.hpp"
45 #include "LogFile.hpp"
46 #include "Version.hpp"
47 #include "ExecutableSupport.hpp"
49 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
51 bool deleteCellPopulationInDestructor,
57 EXCEPTION(
"OffLatticeSimulations require a subclass of AbstractOffLatticeCellPopulation.");
63 this->
mDt = 1.0/120.0;
84 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
87 mForceCollection.push_back(pForce);
90 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
93 mForceCollection.clear();
96 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
99 mBoundaryConditions.push_back(pBoundaryCondition);
102 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
105 mBoundaryConditions.clear();
108 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
116 node_iter != this->mrCellPopulation.rGetMesh().GetNodeIteratorEnd();
119 node_iter->ClearAppliedForce();
124 iter != mForceCollection.end();
127 (*iter)->AddForceContribution(this->mrCellPopulation);
133 UpdateNodePositions();
137 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
149 c_vector<double, SPACE_DIM> parent_coords = this->mrCellPopulation.GetLocationOfCellCentre(pParentCell);
150 c_vector<double, SPACE_DIM> daughter_coords;
156 c_vector<double, SPACE_DIM> random_vector;
169 random_vector(0) = 0.5*separation*random_direction;
176 random_vector(0) = 0.5*separation*cos(random_angle);
177 random_vector(1) = 0.5*separation*sin(random_angle);
191 double random_azimuth_angle = 2*M_PI*u;
192 double random_zenith_angle = std::acos(2*v - 1);
194 random_vector(0) = 0.5*separation*cos(random_azimuth_angle)*sin(random_zenith_angle);
195 random_vector(1) = 0.5*separation*sin(random_azimuth_angle)*sin(random_zenith_angle);
196 random_vector(2) = 0.5*separation*cos(random_zenith_angle);
204 parent_coords = parent_coords - random_vector;
205 daughter_coords = parent_coords + random_vector;
209 unsigned node_index = this->mrCellPopulation.GetLocationIndexUsingCell(pParentCell);
210 this->mrCellPopulation.SetNode(node_index, parent_coords_point);
212 return daughter_coords;
217 boost::shared_ptr<AbstractVertexBasedDivisionRule<SPACE_DIM> > p_division_rule = p_vertex_population->
GetVertexBasedDivisionRule();
219 return p_division_rule->CalculateCellDivisionVector(pParentCell, *p_vertex_population);
230 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
235 for (
unsigned i=0; i<this->mForceCollection.size(); i++)
240 boost::shared_ptr<AbstractForce<ELEMENT_DIM,SPACE_DIM> > p_force = this->mForceCollection[i];
244 *(this->mpVizSetupFile) <<
"Cutoff\t" << cutoff <<
"\n";
253 *this->mpVizSetupFile <<
"MeshWidth\t" << this->mrCellPopulation.GetWidth(0) <<
"\n";
260 *this->mpVizSetupFile <<
"MeshWidth\t" << this->mrCellPopulation.GetWidth(0) <<
"\n";
266 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
273 std::map<Node<SPACE_DIM>*, c_vector<double, SPACE_DIM> > old_node_locations;
275 node_iter != this->mrCellPopulation.rGetMesh().GetNodeIteratorEnd();
278 old_node_locations[&(*node_iter)] = (node_iter)->rGetLocation();
286 bcs_iter != mBoundaryConditions.end();
289 (*bcs_iter)->ImposeBoundaryCondition(old_node_locations);
294 bcs_iter != mBoundaryConditions.end();
297 if (!((*bcs_iter)->VerifyBoundaryCondition()))
299 EXCEPTION(
"The cell population boundary conditions are incompatible.");
304 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
309 node_iter != this->mrCellPopulation.rGetMesh().GetNodeIteratorEnd();
312 node_iter->ClearAppliedForce();
317 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
321 *rParamsFile <<
"\n\t<Forces>\n";
323 iter != mForceCollection.end();
327 (*iter)->OutputForceInfo(rParamsFile);
329 *rParamsFile <<
"\t</Forces>\n";
332 *rParamsFile <<
"\n\t<CellPopulationBoundaryConditions>\n";
334 iter != mBoundaryConditions.end();
338 (*iter)->OutputCellPopulationBoundaryConditionInfo(rParamsFile);
340 *rParamsFile <<
"\t</CellPopulationBoundaryConditions>\n";
343 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
void AddCellKiller(boost::shared_ptr< AbstractCellKiller< SPACE_DIM > > pCellKiller)
void OutputAdditionalSimulationSetup(out_stream &rParamsFile)
virtual void WriteVisualizerSetupFile()
virtual void SetupSolve()
#define EXCEPTION(message)
static void BeginEvent(unsigned event)
virtual void UpdateNodeLocations(double dt)=0
double GetMeinekeDivisionSeparation()
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > GetVertexBasedDivisionRule()
void AddForce(boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > pForce)
void RemoveAllCellPopulationBoundaryConditions()
virtual void OutputSimulationParameters(out_stream &rParamsFile)=0
virtual void UpdateNodePositions()
static RandomNumberGenerator * Instance()
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
virtual c_vector< double, SPACE_DIM > CalculateCellDivisionVector(CellPtr pParentCell)
static void EndEvent(unsigned event)
OffLatticeSimulation(AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > &rCellPopulation, bool deleteCellPopulationInDestructor=false, bool initialiseCells=true)
#define MAKE_PTR_ARGS(TYPE, NAME, ARGS)
virtual void OutputSimulationParameters(out_stream &rParamsFile)
virtual void UpdateCellLocationsAndTopology()
void AddCellPopulationBoundaryCondition(boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, SPACE_DIM > > pBoundaryCondition)