37 #ifndef ABSTRACTCARDIACPROBLEM_HPP_
38 #define ABSTRACTCARDIACPROBLEM_HPP_
46 #include <boost/shared_ptr.hpp>
49 #include <boost/serialization/vector.hpp>
50 #include <boost/serialization/string.hpp>
51 #include <boost/serialization/split_member.hpp>
52 #include <boost/serialization/shared_ptr.hpp>
56 #include "AbstractTetrahedralMesh.hpp"
57 #include "AbstractCardiacCell.hpp"
58 #include "AbstractCardiacCellFactory.hpp"
59 #include "AbstractCardiacTissue.hpp"
60 #include "AbstractDynamicLinearPdeSolver.hpp"
61 #include "BoundaryConditionsContainer.hpp"
62 #include "DistributedVectorFactory.hpp"
63 #include "Hdf5DataReader.hpp"
64 #include "Hdf5DataWriter.hpp"
65 #include "Warnings.hpp"
66 #include "AbstractOutputModifier.hpp"
84 #include "DistributedTetrahedralMesh.hpp"
85 #include "TetrahedralMesh.hpp"
86 #include "MonodomainTissue.hpp"
87 #include "BidomainTissue.hpp"
114 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
117 friend class TestBidomainWithBath;
118 friend class TestMonodomainProblem;
119 friend class TestCardiacSimulationArchiver;
122 typedef typename boost::shared_ptr<BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM> >
127 friend class boost::serialization::access;
135 template<
class Archive>
136 void save(Archive & archive,
const unsigned int version)
const
140 const unsigned element_dim=ELEMENT_DIM;
141 archive & element_dim;
142 const unsigned space_dim=SPACE_DIM;
144 const unsigned problem_dim=PROBLEM_DIM;
145 archive & problem_dim;
152 assert(version >= 2);
169 archive & has_solution;
176 writer.DefineUnlimitedDimension(
"Time",
"msec", 1);
178 int vm_col = writer.DefineVariable(
"Vm",
"mV");
182 writer.EndDefineMode();
183 writer.PutUnlimitedVariable(0.0);
189 int phie_col = writer.DefineVariable(
"Phie",
"mV");
190 std::vector<int> variable_ids;
191 variable_ids.push_back(vm_col);
192 variable_ids.push_back(phie_col);
193 writer.EndDefineMode();
194 writer.PutUnlimitedVariable(0.0);
195 writer.PutStripedVector(variable_ids,
mSolution);
219 template<
class Archive>
220 void load(Archive & archive,
const unsigned int version)
224 unsigned element_dim;
226 unsigned problem_dim;
227 archive & element_dim;
229 archive & problem_dim;
230 if ( (element_dim != ELEMENT_DIM) ||(space_dim != SPACE_DIM) ||(problem_dim != PROBLEM_DIM) )
238 EXCEPTION(
"Failed to load from checkpoint because the dimensions of the archive do not match the object it's being read into.");
243 assert(mpMesh != NULL);
248 bool use_matrix_based_assembly;
249 archive & use_matrix_based_assembly;
263 archive & has_solution;
264 if ((has_solution) && PROBLEM_DIM < 3)
268 mSolution = mpMesh->GetDistributedVectorFactory()->CreateVec(PROBLEM_DIM);
271 Vec vm = mpMesh->GetDistributedVectorFactory()->CreateVec();
272 Vec phie = mpMesh->GetDistributedVectorFactory()->CreateVec();
282 DistributedVector vm_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(vm);
287 index != mSolution_distri.
End();
290 mSolution_vm[index] = vm_distri[index];
299 DistributedVector vm_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(vm);
300 DistributedVector phie_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(phie);
306 index != mSolution_distri.
End();
309 mSolution_vm[index] = vm_distri[index];
310 mSolution_phie[index] = phie_distri[index];
332 BOOST_SERIALIZATION_SPLIT_MEMBER()
341 template<class Archive>
356 template<
class Archive>
458 template<
unsigned DIM,
unsigned ELEC_PROB_DIM>
735 template<
class Archive>
763 template<
unsigned DIM>
766 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
767 template<class Archive>
772 archive >> p_mesh_factory;
776 unsigned orig_num_procs = 1;
777 if (p_original_factory)
779 orig_num_procs = p_original_factory->
GetNumProcs();
783 mpCardiacTissue->LoadCardiacCells(archive, version);
787 archive >> p_pde_factory;
788 assert(p_pde_factory == p_mesh_factory);
791 delete p_mesh_factory;
798 if (!mpBoundaryConditionsContainer)
800 mpBoundaryConditionsContainer = p_bcc;
801 mpBoundaryConditionsContainer->LoadFromArchive(archive, mpMesh);
807 #define COVERAGE_IGNORE
812 WARNING(
"Loading from a parallel archive which used a non-distributed mesh. This scenario should work but is not fully tested.");
814 #undef COVERAGE_IGNORE
815 mpBoundaryConditionsContainer->MergeFromArchive(archive, mpMesh);
819 archive >> p_default_bcc;
823 assert(p_bcc == p_default_bcc);
828 if (p_bidomain_problem)
830 assert(ELEMENT_DIM == SPACE_DIM);
836 namespace serialization {
843 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
#define TEMPLATED_CLASS_IS_ABSTRACT_3_UNSIGNED(T)
virtual void WriteOneStep(double time, Vec voltageVec)=0
BccType mpDefaultBoundaryConditionsContainer
Hdf5DataWriter * mpWriter
std::vector< boost::shared_ptr< AbstractOutputModifier > > mOutputModifiers
std::string mMeshFilename
void AddOutputModifier(boost::shared_ptr< AbstractOutputModifier > pOutputModifier)
unsigned mVoltageColumnId
void PrintOutput(bool rPrintOutput)
static bool IsAbsolutePath(const std::string &rPath)
#define EXCEPTION(message)
void save(Archive &archive, const unsigned int version) const
virtual Vec CreateInitialCondition()
void LoadExtraArchiveForBidomain(Archive &archive, unsigned version)
virtual void CreateMeshFromHeartConfig()
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
std::vector< unsigned > mExtraVariablesId
void SetNodesPerProcessorFilename(const std::string &rFilename)
AbstractTimeAdaptivityController * mpTimeAdaptivityController
virtual void SetUpAdditionalStoppingTimes(std::vector< double > &rAdditionalStoppingTimes)
boost::shared_ptr< BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM > > BccType
DistributedVectorFactory * GetOriginalFactory()
virtual void PreSolveChecks()
void GetVariableOverNodes(Vec data, const std::string &rVariableName, unsigned timestep=0)
void CloseFilesAndPostProcess()
static Archive * Get(void)
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * mpMesh
void SaveBoundaryConditions(Archive &archive, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, BccType pBcc) const
bool mAllocatedMemoryForMesh
Hdf5DataReader GetDataReader()
void SetUseTimeAdaptivityController(bool useAdaptivity, AbstractTimeAdaptivityController *pController=NULL)
virtual void WriteInfo(double time)=0
BccType mpBoundaryConditionsContainer
AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM > * GetTissue()
#define CHASTE_VERSION_CONTENT(N)
std::vector< unsigned > mNodesToOutput
virtual void OnEndOfTimestep(double time)
void load(Archive &archive, const unsigned int version)
void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
BccType LoadBoundaryConditions(Archive &archive, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
void LoadExtraArchive(Archive &archive, unsigned version)
virtual ~AbstractUntemplatedCardiacProblem()
AbstractCardiacCellFactory< ELEMENT_DIM, SPACE_DIM > * mpCellFactory
virtual bool GetHasBath()
void DefineFixedDimension(long dimensionSize)
void SetOutputNodes(std::vector< unsigned > &rNodesToOutput)
AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM > * mpSolver
virtual void DefineWriterColumns(bool extending)
virtual ~AbstractCardiacProblem()
virtual AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM > * CreateCardiacTissue()=0
void SetBoundaryConditionsContainer(BccType pBcc)
virtual void SetElectrodes()
AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM > * mpCardiacTissue
unsigned GetNumProcs() const
static std::string GetArchiveRelativePath()
void SetWriteInfo(bool writeInfo=true)
virtual AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM > * CreateSolver()=0
void WriteExtraVariablesOneStep()
DistributedVector GetSolutionDistributedVector()
virtual void AtBeginningOfTimestep(double time)
void DefineExtraVariablesWriterColumns(bool extending)