CardiacElectroMechanicsProblem.hpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 
00037 #ifndef CARDIACELECTROMECHANICSPROBLEM_HPP_
00038 #define CARDIACELECTROMECHANICSPROBLEM_HPP_
00039 
00040 #include <vector>
00041 #include <string>
00042 #include "UblasIncludes.hpp"
00043 
00044 #include "AbstractCardiacCellFactory.hpp"
00045 #include "MonodomainProblem.hpp"
00046 #include "TetrahedralMesh.hpp"
00047 #include "QuadraticMesh.hpp"
00048 #include "AbstractOdeBasedContractionModel.hpp"
00049 #include "AbstractCardiacMechanicsSolver.hpp"
00050 #include "AbstractCardiacMechanicsSolverInterface.hpp"
00051 #include "FineCoarseMeshPair.hpp"
00052 #include "AbstractConductivityModifier.hpp"
00053 #include "ElectroMechanicsProblemDefinition.hpp"
00054 
00059 typedef enum ElectricsProblemType_
00060 {
00061     MONODOMAIN,
00062     BIDOMAIN,   
00063     BIDOMAIN_WITH_BATH
00064     //EXTENDED_BIDOMAIN
00065 } ElectricsProblemType;
00066 
00093 template<unsigned DIM, unsigned ELEC_PROB_DIM=1>
00094 class CardiacElectroMechanicsProblem
00095     : public AbstractConductivityModifier<DIM,DIM> // this only inherits from this class so it can be passed to the tissue to
00096                                                    // allow deformation-based altering of the conductivity
00097 {
00098 friend class TestAbstractContractionCellFactory;
00099 friend class TestCardiacElectroMechanicsProblem;
00100 friend class TestCardiacElectroMechanicsFurtherFunctionality;
00101 friend class TestElectroMechanicsExactSolution;
00102 
00103 protected :
00105     CompressibilityType mCompressibilityType;
00106 
00108     AbstractCardiacProblem<DIM,DIM,ELEC_PROB_DIM>* mpElectricsProblem;
00109 
00112     AbstractCardiacMechanicsSolverInterface<DIM>* mpCardiacMechSolver;
00115     AbstractNonlinearElasticitySolver<DIM>* mpMechanicsSolver;
00116 
00118     unsigned mNumElecTimestepsPerMechTimestep;
00119 
00124     std::vector<double> mInterpolatedCalciumConcs;
00125 
00130     std::vector<double> mInterpolatedVoltages;
00131 
00133     TetrahedralMesh<DIM,DIM>* mpElectricsMesh;
00135     QuadraticMesh<DIM>* mpMechanicsMesh;
00136 
00138     ElectroMechanicsProblemDefinition<DIM>* mpProblemDefinition;
00139 
00141     bool mHasBath;
00142 
00144     FineCoarseMeshPair<DIM>* mpMeshPair;
00145 
00147     std::string mOutputDirectory;
00149     std::string mDeformationOutputDirectory;
00151     bool mWriteOutput;
00153     bool mNoElectricsOutput;
00154 
00156     static const int WRITE_EVERY_NTH_TIME = 1; //hardcoded for the time being ///\todo, allow user to set this
00157 
00159     bool mIsWatchedLocation;
00161     c_vector<double,DIM> mWatchedLocation;
00163     unsigned mWatchedElectricsNodeIndex;
00165     unsigned mWatchedMechanicsNodeIndex;
00167     out_stream mpWatchedLocationFile;
00168 
00170     unsigned mNumTimestepsToOutputDeformationGradientsAndStress;
00171 
00173     std::vector<double> mStretchesForEachMechanicsElement;
00175     std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
00176 
00178     c_matrix<double,DIM,DIM> mModifiedConductivityTensor;
00179 
00183     void DetermineWatchedNodes();
00184 
00185 
00192     void WriteWatchedLocationData(double time, Vec voltage);
00193 
00194 
00195 public :
00196 
00207     CardiacElectroMechanicsProblem(CompressibilityType compressibilityType,
00208                                    ElectricsProblemType electricsProblemType,
00209                                    TetrahedralMesh<DIM,DIM>* pElectricsMesh,
00210                                    QuadraticMesh<DIM>* pMechanicsMesh,
00211                                    AbstractCardiacCellFactory<DIM>* pCellFactory,
00212                                    ElectroMechanicsProblemDefinition<DIM>* pProblemDefinition,
00213                                    std::string outputDirectory);
00214 
00223     virtual ~CardiacElectroMechanicsProblem();
00224 
00229     void Initialise();
00230 
00234     void Solve();
00235 
00241     double Max(std::vector<double>& vec);
00242 
00244     void SetNoElectricsOutput();
00245 
00256     void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
00257 
00265     void SetOutputDeformationGradientsAndStress(double timestep);
00266 
00268     std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
00269 
00270 
00279     c_matrix<double,DIM,DIM>& rCalculateModifiedConductivityTensor(unsigned elementIndex, const c_matrix<double,DIM,DIM>& rOriginalConductivity, unsigned domainIndex);
00280 
00281 
00285     virtual void PrepareForSolve(){}
00286 
00291     virtual void OnEndOfTimeStep(unsigned counter)
00292     {
00293     }
00294 
00300     AbstractNonlinearElasticitySolver<DIM>* GetMechanicsSolver()
00301     {
00302         assert(mpMechanicsSolver);
00303         return mpMechanicsSolver;
00304     }
00305 };
00306 
00307 
00308 
00309 #endif /*CARDIACELECTROMECHANICSPROBLEM_HPP_*/

Generated by  doxygen 1.6.2