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 "AbstractCardiacMechanicsSolverInterface.hpp"
00044 #include "FineCoarseMeshPair.hpp"
00045 #include "AbstractConductivityModifier.hpp"
00046
00072 template<unsigned DIM>
00073 class CardiacElectroMechanicsProblem
00074 : public AbstractConductivityModifier<DIM,DIM>
00075
00076 {
00077
00078 friend class TestCardiacElectroMechanicsProblem;
00079
00080 protected :
00082 ContractionModel mContractionModel;
00084 MonodomainProblem<DIM>* mpMonodomainProblem;
00085
00087
00088 AbstractCardiacMechanicsSolverInterface<DIM>* mpCardiacMechSolver;
00090 AbstractNonlinearElasticitySolver<DIM>* mpMechanicsSolver;
00091
00093 double mEndTime;
00095 double mElectricsTimeStep;
00097 double mMechanicsTimeStep;
00099 unsigned mNumElecTimestepsPerMechTimestep;
00101 double mContractionModelOdeTimeStep;
00102
00104 TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00106 QuadraticMesh<DIM>* mpMechanicsMesh;
00107
00109 FineCoarseMeshPair<DIM>* mpMeshPair;
00110
00112 std::string mOutputDirectory;
00114 std::string mDeformationOutputDirectory;
00116 bool mWriteOutput;
00118 bool mNoElectricsOutput;
00119
00121 static const int WRITE_EVERY_NTH_TIME = 1;
00122
00124 bool mIsWatchedLocation;
00126 c_vector<double,DIM> mWatchedLocation;
00128 unsigned mWatchedElectricsNodeIndex;
00130 unsigned mWatchedMechanicsNodeIndex;
00132 out_stream mpWatchedLocationFile;
00133
00135 std::vector<unsigned> mFixedNodes;
00137 std::string mFibreSheetDirectionsFile;
00139 bool mFibreSheetDirectionsDefinedPerQuadraturePoint;
00140
00142 std::vector<double> mStretchesForEachMechanicsElement;
00144 std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
00145
00149 std::pair<unsigned, c_matrix<double,DIM,DIM> > mLastModifiedConductivity;
00150
00152 bool mConductivityAffectedByDeformationMef;
00153
00157 bool mCellModelsAffectedByDeformationMef;
00158
00160 AbstractMaterialLaw<DIM>* mpMaterialLaw;
00161
00163 bool mAllocatedMaterialLawMemory;
00164
00165
00169 void DetermineWatchedNodes();
00170
00171
00178 void WriteWatchedLocationData(double time, Vec voltage);
00179
00180
00182
00183
00184
00185
00186 public :
00187
00201 CardiacElectroMechanicsProblem(ContractionModel contractionModel,
00202 TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00203 QuadraticMesh<DIM>* pMechanicsMesh,
00204 std::vector<unsigned> fixedMechanicsNodes,
00205 AbstractCardiacCellFactory<DIM>* pCellFactory,
00206 double endTime,
00207 double electricsPdeTimeStep,
00208 double mechanicsSolveTimestep,
00209 double contractionModelOdeTimeStep,
00210 std::string outputDirectory);
00211
00220 virtual ~CardiacElectroMechanicsProblem();
00221
00226 void Initialise();
00227
00231 void Solve();
00232
00237 double Max(std::vector<double>& vec);
00238
00240 void SetNoElectricsOutput();
00241
00252 void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00253
00265 void SetVariableFibreSheetDirectionsFile(std::string orthoFile, bool definedPerQuadPoint);
00266
00268 std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00269
00284 void UseMechanoElectricFeedback()
00285 {
00286 mConductivityAffectedByDeformationMef = true;
00287 mCellModelsAffectedByDeformationMef = true;
00288 }
00289
00297 c_matrix<double,DIM,DIM>& rGetModifiedConductivityTensor(unsigned elementIndex, const c_matrix<double,DIM,DIM>& rOriginalConductivity);
00298
00300
00301
00305 virtual void PrepareForSolve(){}
00306
00311 virtual void OnEndOfTimeStep(unsigned counter){}
00312
00318 AbstractNonlinearElasticitySolver<DIM>* GetCardiacMechanicsSolver()
00319 {
00320 assert(mpMechanicsSolver);
00321 return mpMechanicsSolver;
00322 }
00323
00328 void SetMaterialLaw(AbstractMaterialLaw<DIM>* pMaterialLaw)
00329 {
00330 assert(pMaterialLaw);
00331 assert(mpMaterialLaw == NULL);
00332 mpMaterialLaw = pMaterialLaw;
00333 mAllocatedMaterialLawMemory = false;
00334 }
00335 };
00336
00337
00338
00339 #endif