CellBasedPdeHandler.hpp
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
00029 #ifndef CELLBASEDPDEHANDLER_HPP_
00030 #define CELLBASEDPDEHANDLER_HPP_
00031
00032 #include <map>
00033
00034 #include "ChasteSerialization.hpp"
00035 #include <boost/serialization/vector.hpp>
00036
00037 #include "AbstractCellPopulation.hpp"
00038 #include "PdeAndBoundaryConditions.hpp"
00039 #include "TetrahedralMesh.hpp"
00040 #include "Identifiable.hpp"
00041
00050 template<unsigned DIM>
00051 class CellBasedPdeHandler : public Identifiable
00052 {
00053
00054 friend class TestCellBasedPdeHandler;
00055 friend class TestOffLatticeSimulationWithPdes;
00056
00057 private:
00058
00060 friend class boost::serialization::access;
00067 template<class Archive>
00068 void serialize(Archive & archive, const unsigned int version)
00069 {
00070 archive & mPdeAndBcCollection;
00071 archive & mWriteAverageRadialPdeSolution;
00072 archive & mWriteDailyAverageRadialPdeSolution;
00073 archive & mSetBcsOnCoarseBoundary;
00074 archive & mNumRadialIntervals;
00075 }
00076
00077 protected:
00078
00080 AbstractCellPopulation<DIM>* mpCellPopulation;
00081
00083 std::vector<PdeAndBoundaryConditions<DIM>*> mPdeAndBcCollection;
00084
00086 out_stream mpVizPdeSolutionResultsFile;
00087
00089 out_stream mpAverageRadialPdeSolutionResultsFile;
00090
00092 bool mWriteAverageRadialPdeSolution;
00093
00095 bool mWriteDailyAverageRadialPdeSolution;
00096
00098 bool mSetBcsOnCoarseBoundary;
00099
00101 unsigned mNumRadialIntervals;
00102
00104 TetrahedralMesh<DIM,DIM>* mpCoarsePdeMesh;
00105
00107 std::map<CellPtr, unsigned> mCellPdeElementMap;
00108
00113 bool mDeleteMemberPointersInDestructor;
00114
00121 void InitialiseCellPdeElementMap();
00122
00128 virtual void WritePdeSolution(double time);
00129
00135 void WriteAverageRadialPdeSolution(double time);
00136
00137 public:
00138
00145 CellBasedPdeHandler(AbstractCellPopulation<DIM>* pCellPopulation, bool deleteMemberPointersInDestructor=false);
00146
00150 virtual ~CellBasedPdeHandler();
00151
00157 const AbstractCellPopulation<DIM>* GetCellPopulation() const;
00158
00162 TetrahedralMesh<DIM,DIM>* GetCoarsePdeMesh();
00163
00170 void OpenResultsFiles(std::string outputDirectory);
00171
00176 void CloseResultsFiles();
00177
00181 bool GetWriteAverageRadialPdeSolution();
00182
00186 bool GetWriteDailyAverageRadialPdeSolution();
00187
00194 void UpdateCellPdeElementMap();
00195
00199 bool GetImposeBcsOnCoarseBoundary();
00200
00204 unsigned GetNumRadialIntervals();
00205
00212 virtual void SolvePdeAndWriteResultsToFile(unsigned samplingTimestepMultiple);
00213
00221 unsigned FindCoarseElementContainingCell(CellPtr pCell);
00222
00228 virtual Vec GetPdeSolution(unsigned pdeIndex);
00229
00239 void SetWriteAverageRadialPdeSolution(unsigned numRadialIntervals=10,
00240 bool writeDailyResults=false);
00241
00249 void SetImposeBcsOnCoarseBoundary(bool setBcsOnCoarseBoundary);
00250
00257 virtual void UseCoarsePdeMesh(double stepSize, double meshWidth);
00258
00264 void AddPdeAndBc(PdeAndBoundaryConditions<DIM>* pPdeAndBc);
00265
00271 virtual void OutputParameters(out_stream& rParamsFile);
00272 };
00273
00274 #include "SerializationExportWrapper.hpp"
00275 EXPORT_TEMPLATE_CLASS_SAME_DIMS(CellBasedPdeHandler)
00276
00277 namespace boost
00278 {
00279 namespace serialization
00280 {
00285 template<class Archive, unsigned DIM>
00286 inline void save_construct_data(
00287 Archive & ar, const CellBasedPdeHandler<DIM> * t, const BOOST_PFTO unsigned int file_version)
00288 {
00289
00290 const AbstractCellPopulation<DIM>* p_cell_population = t->GetCellPopulation();
00291 ar & p_cell_population;
00292 }
00293
00297 template<class Archive, unsigned DIM>
00298 inline void load_construct_data(
00299 Archive & ar, CellBasedPdeHandler<DIM> * t, const unsigned int file_version)
00300 {
00301
00302 AbstractCellPopulation<DIM>* p_cell_population;
00303 ar >> p_cell_population;
00304
00305
00306 ::new(t)CellBasedPdeHandler<DIM>(p_cell_population, true);
00307 }
00308 }
00309 }
00310
00311 #endif