CardiacElectroMechanicsProblem.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 "ImplicitCardiacMechanicsAssembler.hpp"
00040 #include "TetrahedralMesh.hpp"
00041 #include "QuadraticMesh.hpp"
00042 
00043 // if including Cinv in monobidomain equations
00044 //#include "NodewiseData.hpp"
00045 
00046 
00047 /* Todos:
00048  *  Go through and tidy/refactor, perhaps make elements and weights safer
00049  *  Think about architecture (of AbstractCardiacProblem) when this is done properly..
00050  */
00051 
00052 
00053 
00060 template<unsigned DIM>
00061 struct ElementAndWeights
00062 {
00063     unsigned ElementNum; 
00064     c_vector<double,DIM+1> Weights; 
00065 };
00066 
00067 
00068 
00098 template<unsigned DIM>
00099 class CardiacElectroMechanicsProblem
00100 {
00101 
00102 friend class TestCardiacElectroMechanicsProblem;
00103 
00104 protected :
00106     MonodomainProblem<DIM>* mpMonodomainProblem;
00108     ImplicitCardiacMechanicsAssembler<DIM>* mpCardiacMechAssembler;
00109 
00111     double mEndTime;
00113     double mElectricsTimeStep;
00115     double mMechanicsTimeStep;
00117     unsigned mNumElecTimestepsPerMechTimestep;
00119     double mNhsOdeTimeStep;
00120 
00122     TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00124     QuadraticMesh<DIM>* mpMechanicsMesh;
00125 
00131     std::vector<ElementAndWeights<DIM> > mElementAndWeightsForQuadPoints;
00132 
00134     std::string mOutputDirectory;
00136     std::string mDeformationOutputDirectory;
00138     bool mWriteOutput;
00140     bool mNoElectricsOutput;
00141 
00143     const static int WRITE_EVERY_NTH_TIME = 1; //hardcoded for the time being ///\todo, allow user to set this
00144 
00146     bool mIsWatchedLocation;
00148     c_vector<double,DIM> mWatchedLocation;
00150     unsigned mWatchedElectricsNodeIndex;
00152     unsigned mWatchedMechanicsNodeIndex;
00154     out_stream mpWatchedLocationFile;
00155 
00157     std::vector<unsigned> mFixedNodes;
00158 
00162     void DetermineWatchedNodes();
00163 
00164 
00172     void WriteWatchedLocationData(double time, Vec voltage);
00173 
00174 public :
00175 
00189     CardiacElectroMechanicsProblem(TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00190                                    QuadraticMesh<DIM>* pMechanicsMesh,
00191                                    std::vector<unsigned> fixedMechanicsNodes,
00192                                    AbstractCardiacCellFactory<DIM>* pCellFactory,
00193                                    double endTime,
00194                                    unsigned numElecTimeStepsPerMechTimestep,
00195                                    double nhsOdeTimeStep,
00196                                    std::string outputDirectory);
00197 
00206     virtual ~CardiacElectroMechanicsProblem();
00207 
00213     void Initialise();
00214 
00218     void Solve();
00219 
00226     double Max(std::vector<double>& vec);
00227 
00229     void SetNoElectricsOutput();
00230 
00241     void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00242 
00244     std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00245 };
00246 
00247 
00248 
00249 #endif /*CARDIACELECTROMECHANICSPROBLEM_HPP_*/

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5