37 #ifndef ABSTRACTCARDIACPROBLEM_HPP_ 38 #define ABSTRACTCARDIACPROBLEM_HPP_ 44 #include <boost/shared_ptr.hpp> 47 #include <boost/serialization/vector.hpp> 48 #include <boost/serialization/string.hpp> 49 #include <boost/serialization/split_member.hpp> 50 #include <boost/serialization/shared_ptr.hpp> 54 #include "AbstractTetrahedralMesh.hpp" 55 #include "AbstractCardiacCell.hpp" 56 #include "AbstractCardiacCellFactory.hpp" 57 #include "AbstractCardiacTissue.hpp" 58 #include "AbstractDynamicLinearPdeSolver.hpp" 59 #include "BoundaryConditionsContainer.hpp" 60 #include "DistributedVectorFactory.hpp" 61 #include "Hdf5DataReader.hpp" 62 #include "Hdf5DataWriter.hpp" 63 #include "Warnings.hpp" 64 #include "AbstractOutputModifier.hpp" 82 #include "DistributedTetrahedralMesh.hpp" 83 #include "TetrahedralMesh.hpp" 84 #include "MonodomainTissue.hpp" 85 #include "BidomainTissue.hpp" 112 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
115 friend class TestBidomainWithBath;
116 friend class TestMonodomainProblem;
117 friend class TestCardiacSimulationArchiver;
120 typedef typename boost::shared_ptr<BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM> >
125 friend class boost::serialization::access;
133 template<
class Archive>
134 void save(Archive & archive,
const unsigned int version)
const 138 const unsigned element_dim=ELEMENT_DIM;
139 archive & element_dim;
140 const unsigned space_dim=SPACE_DIM;
142 const unsigned problem_dim=PROBLEM_DIM;
143 archive & problem_dim;
145 archive & mMeshFilename;
150 assert(version >= 2);
156 archive & mWriteInfo;
157 archive & mPrintOutput;
158 archive & mNodesToOutput;
164 archive & mpCardiacTissue;
166 bool has_solution = (mSolution != NULL);
167 archive & has_solution;
174 writer.DefineUnlimitedDimension(
"Time",
"msec", 1);
176 int vm_col = writer.DefineVariable(
"Vm",
"mV");
180 writer.EndDefineMode();
181 writer.PutUnlimitedVariable(0.0);
182 writer.PutVector(vm_col, mSolution);
187 int phie_col = writer.DefineVariable(
"Phie",
"mV");
188 std::vector<int> variable_ids;
189 variable_ids.push_back(vm_col);
190 variable_ids.push_back(phie_col);
191 writer.EndDefineMode();
192 writer.PutUnlimitedVariable(0.0);
193 writer.PutStripedVector(variable_ids, mSolution);
199 archive & mCurrentTime;
202 SaveBoundaryConditions(archive, mpMesh, mpBoundaryConditionsContainer);
203 SaveBoundaryConditions(archive, mpMesh, mpDefaultBoundaryConditionsContainer);
207 archive & mOutputModifiers;
212 archive & mUseHdf5DataWriterCache;
213 archive & mHdf5DataWriterChunkSizeAndAlignment;
223 template<
class Archive>
224 void load(Archive & archive,
const unsigned int version)
228 unsigned element_dim;
230 unsigned problem_dim;
231 archive & element_dim;
233 archive & problem_dim;
234 if ((element_dim != ELEMENT_DIM) ||(space_dim != SPACE_DIM) ||(problem_dim != PROBLEM_DIM))
242 EXCEPTION(
"Failed to load from checkpoint because the dimensions of the archive do not match the object it's being read into.");
245 archive & mMeshFilename;
247 assert(mpMesh != NULL);
252 bool use_matrix_based_assembly;
253 archive & use_matrix_based_assembly;
256 archive & mWriteInfo;
257 archive & mPrintOutput;
258 archive & mNodesToOutput;
264 archive & mpCardiacTissue;
267 archive & has_solution;
268 if ((has_solution) && PROBLEM_DIM < 3)
272 mSolution = mpMesh->GetDistributedVectorFactory()->CreateVec(PROBLEM_DIM);
273 DistributedVector mSolution_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(mSolution);
275 Vec vm = mpMesh->GetDistributedVectorFactory()->CreateVec();
276 Vec phie = mpMesh->GetDistributedVectorFactory()->CreateVec();
286 DistributedVector vm_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(vm);
291 index != mSolution_distri.
End();
294 mSolution_vm[index] = vm_distri[index];
303 DistributedVector vm_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(vm);
304 DistributedVector phie_distri = mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(phie);
310 index != mSolution_distri.
End();
313 mSolution_vm[index] = vm_distri[index];
314 mSolution_phie[index] = phie_distri[index];
324 archive & mCurrentTime;
327 mpBoundaryConditionsContainer = LoadBoundaryConditions(archive, mpMesh);
328 mpDefaultBoundaryConditionsContainer = LoadBoundaryConditions(archive, mpMesh);
332 archive & mOutputModifiers;
337 archive & mUseHdf5DataWriterCache;
338 archive & mHdf5DataWriterChunkSizeAndAlignment;
342 BOOST_SERIALIZATION_SPLIT_MEMBER()
351 template<
class Archive>
366 template<
class Archive>
461 virtual void CreateMeshFromHeartConfig();
466 template<
unsigned DIM,
unsigned ELEC_PROB_DIM>
521 void SetNodesPerProcessorFilename(
const std::string& rFilename);
527 void SetBoundaryConditionsContainer(
BccType pBcc);
536 virtual void PreSolveChecks();
551 virtual Vec CreateInitialCondition();
565 void PrintOutput(
bool rPrintOutput);
572 void SetWriteInfo(
bool writeInfo =
true);
596 double GetCurrentTime();
626 void CloseFilesAndPostProcess();
635 virtual void WriteInfo(
double time)=0;
641 virtual void DefineWriterColumns(
bool extending);
647 void DefineExtraVariablesWriterColumns(
bool extending);
655 virtual void WriteOneStep(
double time,
Vec voltageVec) = 0;
660 void WriteExtraVariablesOneStep();
672 bool InitialiseWriter();
680 void SetUseHdf5DataWriterCache(
bool useCache=
true);
701 void SetHdf5DataWriterTargetChunkSizeAndAlignment(
hsize_t size);
712 void SetOutputNodes(std::vector<unsigned> & rNodesToOutput);
757 void SetUseTimeAdaptivityController(
bool useAdaptivity,
780 template<
class Archive>
781 void LoadExtraArchive(Archive & archive,
unsigned version);
786 virtual bool GetHasBath();
792 virtual void SetElectrodes();
801 mOutputModifiers.push_back(pOutputModifier);
808 template<
unsigned DIM>
811 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
812 template<
class Archive>
817 archive >> p_mesh_factory;
821 unsigned orig_num_procs = 1;
822 if (p_original_factory)
824 orig_num_procs = p_original_factory->
GetNumProcs();
832 archive >> p_pde_factory;
833 assert(p_pde_factory == p_mesh_factory);
836 delete p_mesh_factory;
857 WARNING(
"Loading from a parallel archive which used a non-distributed mesh. This scenario should work but is not fully tested.");
864 archive >> p_default_bcc;
868 assert(p_bcc == p_default_bcc);
873 if (p_bidomain_problem)
875 assert(ELEMENT_DIM == SPACE_DIM);
881 namespace serialization {
888 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
#define TEMPLATED_CLASS_IS_ABSTRACT_3_UNSIGNED(T)
BccType mpDefaultBoundaryConditionsContainer
Hdf5DataWriter * mpWriter
std::vector< boost::shared_ptr< AbstractOutputModifier > > mOutputModifiers
std::string mMeshFilename
void AddOutputModifier(boost::shared_ptr< AbstractOutputModifier > pOutputModifier)
unsigned mVoltageColumnId
static bool IsAbsolutePath(const std::string &rPath)
hsize_t mHdf5DataWriterChunkSizeAndAlignment
#define EXCEPTION(message)
void save(Archive &archive, const unsigned int version) const
void LoadExtraArchiveForBidomain(Archive &archive, unsigned version)
std::vector< unsigned > mExtraVariablesId
AbstractTimeAdaptivityController * mpTimeAdaptivityController
virtual void SetUpAdditionalStoppingTimes(std::vector< double > &rAdditionalStoppingTimes)
boost::shared_ptr< BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM > > BccType
DistributedVectorFactory * GetOriginalFactory()
void GetVariableOverNodes(Vec data, const std::string &rVariableName, unsigned timestep=0)
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
BccType mpBoundaryConditionsContainer
#define CHASTE_VERSION_CONTENT(N)
std::vector< unsigned > mNodesToOutput
virtual void OnEndOfTimestep(double time)
void load(Archive &archive, const unsigned int version)
BccType LoadBoundaryConditions(Archive &archive, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
void LoadExtraArchive(Archive &archive, unsigned version)
virtual ~AbstractUntemplatedCardiacProblem()
AbstractCardiacCellFactory< ELEMENT_DIM, SPACE_DIM > * mpCellFactory
bool mUseHdf5DataWriterCache
void DefineFixedDimension(long dimensionSize)
AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM > * mpSolver
gcov doesn't like this file...
AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM > * mpCardiacTissue
unsigned GetNumProcs() const
static std::string GetArchiveRelativePath()
virtual void AtBeginningOfTimestep(double time)