36 #include "OffLatticeSimulation.hpp" 38 #include <boost/make_shared.hpp> 40 #include "CellBasedEventHandler.hpp" 41 #include "ForwardEulerNumericalMethod.hpp" 42 #include "StepSizeException.hpp" 44 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
46 bool deleteCellPopulationInDestructor,
52 EXCEPTION(
"OffLatticeSimulations require a subclass of AbstractOffLatticeCellPopulation.");
56 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
62 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
68 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
74 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
80 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
86 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
92 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
98 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
103 double time_advanced_so_far = 0;
104 double target_time_step = this->
mDt;
105 double present_time_step = this->
mDt;
107 while (time_advanced_so_far < target_time_step)
110 std::map<Node<SPACE_DIM>*, c_vector<double, SPACE_DIM> > old_node_locations;
116 old_node_locations[&(*node_iter)] = (node_iter)->rGetLocation();
126 time_advanced_so_far += present_time_step;
132 double timestep_increase = 0.01;
133 present_time_step = std::min((1+timestep_increase)*present_time_step, target_time_step - time_advanced_so_far);
144 present_time_step = std::min(e.
GetSuggestedNewStep(), target_time_step - time_advanced_so_far);
157 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
164 (node_iter)->rGetModifiableLocation() = oldNodeLoctions[&(*node_iter)];
168 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
176 (*bcs_iter)->ImposeBoundaryCondition(oldNodeLoctions);
184 if (!((*bcs_iter)->VerifyBoundaryCondition()))
186 EXCEPTION(
"The cell population boundary conditions are incompatible.");
191 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
205 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
213 node_iter->ClearAppliedForce();
219 mpNumericalMethod = boost::make_shared<ForwardEulerNumericalMethod<ELEMENT_DIM, SPACE_DIM> >();
225 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
229 *rParamsFile <<
"\n\t<Forces>\n";
235 (*iter)->OutputForceInfo(rParamsFile);
237 *rParamsFile <<
"\t</Forces>\n";
240 *rParamsFile <<
"\n\t<CellPopulationBoundaryConditions>\n";
246 (*iter)->OutputCellPopulationBoundaryConditionInfo(rParamsFile);
248 *rParamsFile <<
"\t</CellPopulationBoundaryConditions>\n";
251 *rParamsFile <<
"\n\t<NumericalMethod>\n";
253 *rParamsFile <<
"\t</NumericalMethod>\n";
256 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
boost::shared_ptr< AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM > > mpNumericalMethod
const boost::shared_ptr< AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM > > GetNumericalMethod() const
virtual const char * what() const
void OutputAdditionalSimulationSetup(out_stream &rParamsFile)
virtual void WriteVisualizerSetupFile()
virtual void SetupSolve()
#define EXCEPTION(message)
static void BeginEvent(unsigned event)
const std::vector< boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > > & rGetForceCollection() const
std::vector< boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, SPACE_DIM > > > mBoundaryConditions
void SetNumericalMethod(boost::shared_ptr< AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM > > pNumericalMethod)
out_stream mpVizSetupFile
double GetSuggestedNewStep()
void ApplyBoundaries(std::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > oldNodeLoctions)
void AddForce(boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > pForce)
void RemoveAllCellPopulationBoundaryConditions()
virtual void OutputSimulationParameters(out_stream &rParamsFile)=0
void RevertToOldLocations(std::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > oldNodeLoctions)
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
std::vector< boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > > mForceCollection
static void EndEvent(unsigned event)
OffLatticeSimulation(AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > &rCellPopulation, bool deleteCellPopulationInDestructor=false, bool initialiseCells=true)
virtual void OutputSimulationParameters(out_stream &rParamsFile)
virtual void UpdateCellLocationsAndTopology()
void AddCellPopulationBoundaryCondition(boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, SPACE_DIM > > pBoundaryCondition)
AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation