CardiacElectroMechanicsProblem.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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> // this only inherits from this class so it can be passed to the tissue to
00074                                                    // allow deformation-based altering of the conductivity
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; //hardcoded for the time being ///\todo, allow user to set this
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 //    std::vector<BoundaryElement<DIM-1,DIM>*>* mpImpactRegion;
00172 //    std::vector<c_vector<double,DIM> > mImpactTractions;
00173 //    void ApplyImpactTractions(double time);
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 //    void SetImpactRegion(std::vector<BoundaryElement<DIM-1,DIM>*>& rImpactRegion);
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 /*CARDIACELECTROMECHANICSPROBLEM_HPP_*/

Generated on Mon Apr 18 11:35:28 2011 for Chaste by  doxygen 1.5.5