CardiacElectroMechanicsProblem.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 CARDIACELECTROMECHANICSPROBLEM_HPP_
00038 #define CARDIACELECTROMECHANICSPROBLEM_HPP_
00039
00040 #include <vector>
00041 #include <string>
00042 #include "UblasIncludes.hpp"
00043
00044 #include "AbstractCardiacCellFactory.hpp"
00045 #include "MonodomainProblem.hpp"
00046 #include "TetrahedralMesh.hpp"
00047 #include "QuadraticMesh.hpp"
00048 #include "AbstractOdeBasedContractionModel.hpp"
00049 #include "AbstractCardiacMechanicsSolver.hpp"
00050 #include "AbstractCardiacMechanicsSolverInterface.hpp"
00051 #include "FineCoarseMeshPair.hpp"
00052 #include "AbstractConductivityModifier.hpp"
00053 #include "ElectroMechanicsProblemDefinition.hpp"
00054
00059 typedef enum ElectricsProblemType_
00060 {
00061 MONODOMAIN,
00062 BIDOMAIN,
00063 BIDOMAIN_WITH_BATH
00064
00065 } ElectricsProblemType;
00066
00093 template<unsigned DIM, unsigned ELEC_PROB_DIM=1>
00094 class CardiacElectroMechanicsProblem
00095 : public AbstractConductivityModifier<DIM,DIM>
00096
00097 {
00098 friend class TestAbstractContractionCellFactory;
00099 friend class TestCardiacElectroMechanicsProblem;
00100 friend class TestCardiacElectroMechanicsFurtherFunctionality;
00101 friend class TestElectroMechanicsExactSolution;
00102
00103 protected :
00105 CompressibilityType mCompressibilityType;
00106
00108 AbstractCardiacProblem<DIM,DIM,ELEC_PROB_DIM>* mpElectricsProblem;
00109
00112 AbstractCardiacMechanicsSolverInterface<DIM>* mpCardiacMechSolver;
00115 AbstractNonlinearElasticitySolver<DIM>* mpMechanicsSolver;
00116
00118 unsigned mNumElecTimestepsPerMechTimestep;
00119
00124 std::vector<double> mInterpolatedCalciumConcs;
00125
00130 std::vector<double> mInterpolatedVoltages;
00131
00133 TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00135 QuadraticMesh<DIM>* mpMechanicsMesh;
00136
00138 ElectroMechanicsProblemDefinition<DIM>* mpProblemDefinition;
00139
00141 bool mHasBath;
00142
00144 FineCoarseMeshPair<DIM>* mpMeshPair;
00145
00147 std::string mOutputDirectory;
00149 std::string mDeformationOutputDirectory;
00151 bool mWriteOutput;
00153 bool mNoElectricsOutput;
00154
00156 static const int WRITE_EVERY_NTH_TIME = 1;
00157
00159 bool mIsWatchedLocation;
00161 c_vector<double,DIM> mWatchedLocation;
00163 unsigned mWatchedElectricsNodeIndex;
00165 unsigned mWatchedMechanicsNodeIndex;
00167 out_stream mpWatchedLocationFile;
00168
00170 unsigned mNumTimestepsToOutputDeformationGradientsAndStress;
00171
00173 std::vector<double> mStretchesForEachMechanicsElement;
00175 std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
00176
00178 c_matrix<double,DIM,DIM> mModifiedConductivityTensor;
00179
00183 void DetermineWatchedNodes();
00184
00185
00192 void WriteWatchedLocationData(double time, Vec voltage);
00193
00194
00195 public :
00196
00207 CardiacElectroMechanicsProblem(CompressibilityType compressibilityType,
00208 ElectricsProblemType electricsProblemType,
00209 TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00210 QuadraticMesh<DIM>* pMechanicsMesh,
00211 AbstractCardiacCellFactory<DIM>* pCellFactory,
00212 ElectroMechanicsProblemDefinition<DIM>* pProblemDefinition,
00213 std::string outputDirectory);
00214
00223 virtual ~CardiacElectroMechanicsProblem();
00224
00229 void Initialise();
00230
00234 void Solve();
00235
00241 double Max(std::vector<double>& vec);
00242
00244 void SetNoElectricsOutput();
00245
00256 void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00257
00265 void SetOutputDeformationGradientsAndStress(double timestep);
00266
00268 std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00269
00270
00279 c_matrix<double,DIM,DIM>& rCalculateModifiedConductivityTensor(unsigned elementIndex, const c_matrix<double,DIM,DIM>& rOriginalConductivity, unsigned domainIndex);
00280
00281
00285 virtual void PrepareForSolve(){}
00286
00291 virtual void OnEndOfTimeStep(unsigned counter)
00292 {
00293 }
00294
00300 AbstractNonlinearElasticitySolver<DIM>* GetMechanicsSolver()
00301 {
00302 assert(mpMechanicsSolver);
00303 return mpMechanicsSolver;
00304 }
00305 };
00306
00307
00308
00309 #endif