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 #ifndef CARDIACELECTROMECHANICSPROBLEM_HPP_
00031 #define CARDIACELECTROMECHANICSPROBLEM_HPP_
00032
00033 #include <vector>
00034 #include <string>
00035 #include "UblasIncludes.hpp"
00036
00037 #include "AbstractCardiacCellFactory.hpp"
00038 #include "MonodomainProblem.hpp"
00039 #include "TetrahedralMesh.hpp"
00040 #include "QuadraticMesh.hpp"
00041 #include "AbstractOdeBasedContractionModel.hpp"
00042 #include "AbstractCardiacMechanicsSolver.hpp"
00043 #include "FineCoarseMeshPair.hpp"
00044 #include "AbstractConductivityModifier.hpp"
00045
00071 template<unsigned DIM>
00072 class CardiacElectroMechanicsProblem
00073 : public AbstractConductivityModifier<DIM,DIM>
00074
00075 {
00076
00077 friend class TestCardiacElectroMechanicsProblem;
00078
00079 protected :
00081 ContractionModel mContractionModel;
00083 MonodomainProblem<DIM>* mpMonodomainProblem;
00085 AbstractCardiacMechanicsSolver<DIM>* mpCardiacMechSolver;
00086
00088 double mEndTime;
00090 double mElectricsTimeStep;
00092 double mMechanicsTimeStep;
00094 unsigned mNumElecTimestepsPerMechTimestep;
00096 double mContractionModelOdeTimeStep;
00097
00099 TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00101 QuadraticMesh<DIM>* mpMechanicsMesh;
00102
00104 FineCoarseMeshPair<DIM>* mpMeshPair;
00105
00107 std::string mOutputDirectory;
00109 std::string mDeformationOutputDirectory;
00111 bool mWriteOutput;
00113 bool mNoElectricsOutput;
00114
00116 static const int WRITE_EVERY_NTH_TIME = 1;
00117
00119 bool mIsWatchedLocation;
00121 c_vector<double,DIM> mWatchedLocation;
00123 unsigned mWatchedElectricsNodeIndex;
00125 unsigned mWatchedMechanicsNodeIndex;
00127 out_stream mpWatchedLocationFile;
00128
00130 std::vector<unsigned> mFixedNodes;
00132 std::string mFibreSheetDirectionsFile;
00134 bool mFibreSheetDirectionsDefinedPerQuadraturePoint;
00135
00137 std::vector<double> mStretchesForEachMechanicsElement;
00139 std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
00140
00144 std::pair<unsigned, c_matrix<double,DIM,DIM> > mLastModifiedConductivity;
00145
00147 bool mConductivityAffectedByDeformationMef;
00148
00152 bool mCellModelsAffectedByDeformationMef;
00153
00154
00158 void DetermineWatchedNodes();
00159
00160
00167 void WriteWatchedLocationData(double time, Vec voltage);
00168
00169
00171
00172
00173
00174
00175 public :
00176
00190 CardiacElectroMechanicsProblem(ContractionModel contractionModel,
00191 TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00192 QuadraticMesh<DIM>* pMechanicsMesh,
00193 std::vector<unsigned> fixedMechanicsNodes,
00194 AbstractCardiacCellFactory<DIM>* pCellFactory,
00195 double endTime,
00196 double electricsPdeTimeStep,
00197 double mechanicsSolveTimestep,
00198 double contractionModelOdeTimeStep,
00199 std::string outputDirectory);
00200
00209 virtual ~CardiacElectroMechanicsProblem();
00210
00215 void Initialise();
00216
00220 void Solve();
00221
00226 double Max(std::vector<double>& vec);
00227
00229 void SetNoElectricsOutput();
00230
00241 void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00242
00254 void SetVariableFibreSheetDirectionsFile(std::string orthoFile, bool definedPerQuadPoint);
00255
00257 std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00258
00273 void UseMechanoElectricFeedback()
00274 {
00275 mConductivityAffectedByDeformationMef = true;
00276 mCellModelsAffectedByDeformationMef = true;
00277 }
00278
00286 c_matrix<double,DIM,DIM>& rGetModifiedConductivityTensor(unsigned elementIndex, const c_matrix<double,DIM,DIM>& rOriginalConductivity);
00287
00289
00290
00294 virtual void PrepareForSolve(){}
00295
00300 virtual void OnEndOfTimeStep(unsigned counter){}
00301
00305 AbstractCardiacMechanicsSolver<DIM>* GetCardiacMechanicsSolver()
00306 {
00307 assert(mpCardiacMechSolver);
00308 return mpCardiacMechSolver;
00309 }
00310
00311 };
00312
00313
00314
00315 #endif