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 "AbstractCardiacMechanicsSolverInterface.hpp"
00044 #include "FineCoarseMeshPair.hpp"
00045 #include "AbstractConductivityModifier.hpp"
00046 #include "ElectroMechanicsProblemDefinition.hpp"
00047 
00073 template<unsigned DIM>
00074 class CardiacElectroMechanicsProblem
00075     : public AbstractConductivityModifier<DIM,DIM> // this only inherits from this class so it can be passed to the tissue to
00076                                                    // allow deformation-based altering of the conductivity
00077 {
00078 
00079 friend class TestCardiacElectroMechanicsProblem;
00080 friend class TestCardiacElectroMechanicsFurtherFunctionality;
00081 
00082 protected :
00084     CompressibilityType mCompressibilityType;
00085 
00087     MonodomainProblem<DIM>* mpMonodomainProblem;
00088 
00091     AbstractCardiacMechanicsSolverInterface<DIM>* mpCardiacMechSolver;
00094     AbstractNonlinearElasticitySolver<DIM>* mpMechanicsSolver;
00095 
00097     unsigned mNumElecTimestepsPerMechTimestep;
00098 
00099 
00101     TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00103     QuadraticMesh<DIM>* mpMechanicsMesh;
00104 
00106     ElectroMechanicsProblemDefinition<DIM>* mpProblemDefinition;
00107 
00108 
00110     FineCoarseMeshPair<DIM>* mpMeshPair;
00111 
00113     std::string mOutputDirectory;
00115     std::string mDeformationOutputDirectory;
00117     bool mWriteOutput;
00119     bool mNoElectricsOutput;
00120 
00122     static const int WRITE_EVERY_NTH_TIME = 1; //hardcoded for the time being ///\todo, allow user to set this
00123 
00125     bool mIsWatchedLocation;
00127     c_vector<double,DIM> mWatchedLocation;
00129     unsigned mWatchedElectricsNodeIndex;
00131     unsigned mWatchedMechanicsNodeIndex;
00133     out_stream mpWatchedLocationFile;
00134 
00136     std::vector<double> mStretchesForEachMechanicsElement;
00138     std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
00139 
00143     std::pair<unsigned, c_matrix<double,DIM,DIM> > mLastModifiedConductivity;
00144 
00145 
00149     void DetermineWatchedNodes();
00150 
00151 
00158     void WriteWatchedLocationData(double time, Vec voltage);
00159 
00160 
00162 //    std::vector<BoundaryElement<DIM-1,DIM>*>* mpImpactRegion;
00163 //    std::vector<c_vector<double,DIM> > mImpactTractions;
00164 //    void ApplyImpactTractions(double time);
00165 
00166 public :
00167 
00177     CardiacElectroMechanicsProblem(CompressibilityType compressibilityType,
00178                                    TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00179                                    QuadraticMesh<DIM>* pMechanicsMesh,
00180                                    AbstractCardiacCellFactory<DIM>* pCellFactory,
00181                                    ElectroMechanicsProblemDefinition<DIM>* pProblemDefinition,
00182                                    std::string outputDirectory);
00183 
00192     virtual ~CardiacElectroMechanicsProblem();
00193 
00198     void Initialise();
00199 
00203     void Solve();
00204 
00209     double Max(std::vector<double>& vec);
00210 
00212     void SetNoElectricsOutput();
00213 
00224     void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00225 
00227     std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00228 
00229 
00237     c_matrix<double,DIM,DIM>& rGetModifiedConductivityTensor(unsigned elementIndex, const c_matrix<double,DIM,DIM>& rOriginalConductivity);
00238 
00240 //    void SetImpactRegion(std::vector<BoundaryElement<DIM-1,DIM>*>& rImpactRegion);
00241 
00245     virtual void PrepareForSolve(){}
00246 
00251     virtual void OnEndOfTimeStep(unsigned counter)
00252     {
00253     }
00254 };
00255 
00256 
00257 
00258 #endif /*CARDIACELECTROMECHANICSPROBLEM_HPP_*/
Generated on Thu Dec 22 13:00:06 2011 for Chaste by  doxygen 1.6.3