00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CellBasedSimulationWITHPDES_HPP_
00029 #define CellBasedSimulationWITHPDES_HPP_
00030
00031 #include <map>
00032 #include "ChasteSerialization.hpp"
00033
00034 #include "CellBasedSimulation.hpp"
00035
00036 #include "PdeAndBoundaryConditions.hpp"
00037 #include "TetrahedralMesh.hpp"
00038 #include "PetscTools.hpp"
00039
00040 #include "OutputFileHandler.hpp"
00041 #include "Cell.hpp"
00042
00047 template<unsigned DIM>
00048 class CellBasedSimulationWithPdes : public CellBasedSimulation<DIM>
00049 {
00050
00051 friend class TestCellBasedSimulationWithPdes;
00052
00053 private:
00054
00055 friend class boost::serialization::access;
00056 template<class Archive>
00057 void serialize(Archive & archive, const unsigned int version)
00058 {
00059
00060
00061 archive & boost::serialization::base_object<CellBasedSimulation<DIM> >(*this);
00062 archive & mWriteAverageRadialPdeSolution;
00063 archive & mWriteDailyAverageRadialPdeSolution;
00064 archive & mNumRadialIntervals;
00065 archive & mCellPdeElementMap;
00066 }
00067
00072 std::vector<PdeAndBoundaryConditions<DIM>*> mPdeAndBcCollection;
00073
00077 out_stream mpVizPdeSolutionResultsFile;
00078
00082 out_stream mpAverageRadialPdeSolutionResultsFile;
00083
00087 bool mWriteAverageRadialPdeSolution;
00088
00092 bool mWriteDailyAverageRadialPdeSolution;
00093
00098 unsigned mNumRadialIntervals;
00099
00103 TetrahedralMesh<DIM,DIM>* mpCoarsePdeMesh;
00104
00108 std::map<CellPtr, unsigned> mCellPdeElementMap;
00109
00113 void SetupSolve();
00114
00118 void SetupWritePdeSolution();
00119
00125 void WritePdeSolution(double time);
00126
00133 void WriteAverageRadialPdeSolution(double time, unsigned numIntervals);
00134
00138 void SolvePde();
00139
00143 void SolvePdeUsingCoarseMesh();
00144
00152 unsigned FindCoarseElementContainingCell(CellPtr pCell);
00153
00157 void PostSolve();
00158
00162 void AfterSolve();
00163
00171 void CreateCoarsePdeMesh(double coarseGrainScaleFactor);
00172
00176 void InitialiseCoarsePdeMesh();
00177
00183 void WriteVisualizerSetupFile();
00184
00185 public:
00186
00195 CellBasedSimulationWithPdes(AbstractCellPopulation<DIM>& rCellPopulation,
00196 std::vector<PdeAndBoundaryConditions<DIM>*> pdeAndBcCollection=std::vector<PdeAndBoundaryConditions<DIM>*>(),
00197 bool deleteCellPopulationAndForceCollection=false,
00198 bool initialiseCells=true);
00199
00206 ~CellBasedSimulationWithPdes();
00207
00217 void SetPdeAndBcCollection(std::vector<PdeAndBoundaryConditions<DIM>*> pdeAndBcCollection);
00218
00224 Vec GetCurrentPdeSolution(unsigned pdeIndex);
00225
00235 void SetWriteAverageRadialPdeSolution(unsigned numRadialIntervals=10,
00236 bool writeDailyResults=false);
00237
00244 void UseCoarsePdeMesh(double coarseGrainScaleFactor=10.0);
00245
00254 void OutputSimulationParameters(out_stream& rParamsFile);
00255 };
00256
00257
00258 #include "SerializationExportWrapper.hpp"
00259 EXPORT_TEMPLATE_CLASS_SAME_DIMS(CellBasedSimulationWithPdes)
00260
00261 namespace boost
00262 {
00263 namespace serialization
00264 {
00268 template<class Archive, unsigned DIM>
00269 inline void save_construct_data(
00270 Archive & ar, const CellBasedSimulationWithPdes<DIM> * t, const BOOST_PFTO unsigned int file_version)
00271 {
00272
00273 const AbstractCellPopulation<DIM> * p_cell_population = &(t->rGetCellPopulation());
00274 ar & p_cell_population;
00275 }
00276
00280 template<class Archive, unsigned DIM>
00281 inline void load_construct_data(
00282 Archive & ar, CellBasedSimulationWithPdes<DIM> * t, const unsigned int file_version)
00283 {
00284
00285 AbstractCellPopulation<DIM>* p_cell_population;
00286 ar >> p_cell_population;
00287
00288
00289 ::new(t)CellBasedSimulationWithPdes<DIM>(*p_cell_population, std::vector<PdeAndBoundaryConditions<DIM>*>(), true, false);
00290 }
00291 }
00292 }
00293
00294
00295 #endif