CardiacElectroMechanicsProblem.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 
00045 
00075 template<unsigned DIM>
00076 class CardiacElectroMechanicsProblem
00077 {
00078 
00079 friend class TestCardiacElectroMechanicsProblem;
00080 
00081 protected :
00083     ContractionModel mContractionModel;
00085     MonodomainProblem<DIM>* mpMonodomainProblem;
00087     AbstractCardiacMechanicsSolver<DIM>* mpCardiacMechSolver;
00088 
00090     double mEndTime;
00092     double mElectricsTimeStep;
00094     double mMechanicsTimeStep;
00096     unsigned mNumElecTimestepsPerMechTimestep;
00098     double mContractionModelOdeTimeStep;
00099 
00101     TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00103     QuadraticMesh<DIM>* mpMechanicsMesh;
00104 
00106     FineCoarseMeshPair<DIM>* mpMeshPair;
00107 
00109     std::string mOutputDirectory;
00111     std::string mDeformationOutputDirectory;
00113     bool mWriteOutput;
00115     bool mNoElectricsOutput;
00116 
00118     static const int WRITE_EVERY_NTH_TIME = 1; //hardcoded for the time being ///\todo, allow user to set this
00119 
00121     bool mIsWatchedLocation;
00123     c_vector<double,DIM> mWatchedLocation;
00125     unsigned mWatchedElectricsNodeIndex;
00127     unsigned mWatchedMechanicsNodeIndex;
00129     out_stream mpWatchedLocationFile;
00130 
00132     std::vector<unsigned> mFixedNodes;
00134     std::string mFibreSheetDirectionsFile;
00136     bool mFibreSheetDirectionsDefinedPerQuadraturePoint;
00137 
00139     std::vector<double> mStretchesForEachMechanicsElement;
00141     std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
00142 
00147     bool mNoMechanoElectricFeedback; 
00148 
00152     void DetermineWatchedNodes();
00153 
00154 
00161     void WriteWatchedLocationData(double time, Vec voltage);
00162 
00163 
00165 //    std::vector<BoundaryElement<DIM-1,DIM>*>* mpImpactRegion;
00166 //    std::vector<c_vector<double,DIM> > mImpactTractions;
00167 //    void ApplyImpactTractions(double time);
00168 
00169 public :
00170 
00184     CardiacElectroMechanicsProblem(ContractionModel contractionModel,
00185                                    TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00186                                    QuadraticMesh<DIM>* pMechanicsMesh,
00187                                    std::vector<unsigned> fixedMechanicsNodes,
00188                                    AbstractCardiacCellFactory<DIM>* pCellFactory,
00189                                    double endTime,
00190                                    double electricsPdeTimeStep,
00191                                    unsigned numElecTimeStepsPerMechTimestep,
00192                                    double contractionModelOdeTimeStep,
00193                                    std::string outputDirectory);
00194 
00203     virtual ~CardiacElectroMechanicsProblem();
00204 
00209     void Initialise();
00210 
00214     void Solve();
00215 
00220     double Max(std::vector<double>& vec);
00221 
00223     void SetNoElectricsOutput();
00224 
00235     void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00236 
00248     void SetVariableFibreSheetDirectionsFile(std::string orthoFile, bool definedPerQuadPoint);
00249 
00251     std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00252 
00267     void UseMechanoElectricFeedback()
00268     {
00269         mNoMechanoElectricFeedback = false;
00270     }
00271 
00273 //    void SetImpactRegion(std::vector<BoundaryElement<DIM-1,DIM>*>& rImpactRegion);
00274 
00275 };
00276 
00277 
00278 
00279 #endif /*CARDIACELECTROMECHANICSPROBLEM_HPP_*/

Generated on Mon Nov 1 12:35:17 2010 for Chaste by  doxygen 1.5.5