BidomainProblem.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
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef BIDOMAINPROBLEM_HPP_
00038 #define BIDOMAINPROBLEM_HPP_
00039
00040 #include "ChasteSerialization.hpp"
00041 #include <boost/serialization/base_object.hpp>
00042
00043 #include <vector>
00044 #include <boost/shared_ptr.hpp>
00045 #include <boost/serialization/shared_ptr.hpp>
00046
00047 #include "AbstractCardiacProblem.hpp"
00048 #include "AbstractCardiacTissue.hpp"
00049 #include "AbstractBidomainSolver.hpp"
00050 #include "AbstractCardiacCellFactory.hpp"
00051 #include "Electrodes.hpp"
00052 #include "BidomainTissue.hpp"
00053 #include "HeartRegionCodes.hpp"
00054 #include "DistributedTetrahedralMesh.hpp"
00055
00064 template<unsigned DIM>
00065 class BidomainProblem : public AbstractCardiacProblem<DIM,DIM, 2>
00066 {
00068 friend class boost::serialization::access;
00069
00070
00071 friend class TestPCTwoLevelsBlockDiagonal;
00072
00079 template<class Archive>
00080 void save(Archive & archive, const unsigned int version) const
00081 {
00082 archive & boost::serialization::base_object<AbstractCardiacProblem<DIM, DIM, 2> >(*this);
00083 archive & mpBidomainTissue;
00084
00085 archive & mRowForAverageOfPhiZeroed;
00086 archive & mHasBath;
00087 archive & mpElectrodes;
00088 }
00089
00096 template<class Archive>
00097 void load(Archive & archive, const unsigned int version)
00098 {
00099 archive & boost::serialization::base_object<AbstractCardiacProblem<DIM, DIM, 2> >(*this);
00100 archive & mpBidomainTissue;
00101
00102 archive & mRowForAverageOfPhiZeroed;
00103 archive & mHasBath;
00104 archive & mpElectrodes;
00105
00106 if (mHasBath)
00107 {
00108
00109 AnalyseMeshForBath();
00110 }
00111 }
00112 BOOST_SERIALIZATION_SPLIT_MEMBER()
00113
00114 friend class TestBidomainWithBathProblem;
00115 friend class TestCardiacSimulationArchiver;
00116
00117 protected:
00119 BidomainTissue<DIM>* mpBidomainTissue;
00120
00122 std::vector<unsigned> mFixedExtracellularPotentialNodes;
00124 unsigned mExtracelluarColumnId;
00129 unsigned mRowForAverageOfPhiZeroed;
00130
00132 bool mHasBath;
00133
00135 boost::shared_ptr<Electrodes<DIM> > mpElectrodes;
00136
00142 Vec CreateInitialCondition();
00143
00148 void AnalyseMeshForBath();
00149
00155 AbstractBidomainSolver<DIM,DIM>* mpSolver;
00156
00158 virtual AbstractCardiacTissue<DIM> *CreateCardiacTissue();
00159
00161 virtual AbstractDynamicLinearPdeSolver<DIM,DIM,2>* CreateSolver();
00162
00163 public:
00173 BidomainProblem(AbstractCardiacCellFactory<DIM>* pCellFactory, bool hasBath=false);
00174
00178 BidomainProblem();
00179
00190 void SetFixedExtracellularPotentialNodes(std::vector<unsigned> nodes);
00191
00199 void SetNodeForAverageOfPhiZeroed(unsigned node);
00200
00204 BidomainTissue<DIM>* GetBidomainTissue();
00205
00210 void WriteInfo(double time);
00211
00217 virtual void DefineWriterColumns(bool extending);
00218
00226 virtual void WriteOneStep(double time, Vec voltageVec);
00227
00232 void PreSolveChecks();
00233
00234
00235
00243 void AtBeginningOfTimestep(double time);
00244
00252 void OnEndOfTimestep(double time);
00253
00261 void SetUpAdditionalStoppingTimes(std::vector<double>& rAdditionalStoppingTimes);
00262
00280 template<class Archive>
00281 void LoadExtraArchiveForBidomain(Archive & archive, unsigned version);
00282
00286 bool GetHasBath();
00287
00292 void SetElectrodes();
00293 };
00294
00295 #include "SerializationExportWrapper.hpp" // Must be last
00296 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BidomainProblem)
00297
00298
00299 template<unsigned DIM>
00300 template<class Archive>
00301 void BidomainProblem<DIM>::LoadExtraArchiveForBidomain(Archive & archive, unsigned version)
00302 {
00303
00304 if (mpElectrodes)
00305 {
00306
00307 assert(mpElectrodes->GetBoundaryConditionsContainer());
00308
00309
00310
00311 boost::shared_ptr<BoundaryConditionsContainer<DIM, DIM, 2> > p_bcc;
00312 archive >> p_bcc;
00313 if (mpElectrodes->GetBoundaryConditionsContainer() != this->mpBoundaryConditionsContainer)
00314 {
00315
00316 DistributedTetrahedralMesh<DIM,DIM>* p_dist_mesh = dynamic_cast<DistributedTetrahedralMesh<DIM,DIM>*>(this->mpMesh);
00317 if (p_dist_mesh)
00318 {
00319 mpElectrodes->GetBoundaryConditionsContainer()->MergeFromArchive(archive, this->mpMesh);
00320 }
00321 else
00322 {
00323
00324 p_bcc->LoadFromArchive(archive, this->mpMesh);
00326 }
00327 }
00328 }
00329 }
00330
00331 #endif