AbstractCardiacMechanicsSolver.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 #ifndef ABSTRACTCARDIACMECHANICSSOLVER_HPP_
00037 #define ABSTRACTCARDIACMECHANICSSOLVER_HPP_
00038 
00039 #include <map>
00040 #include "IncompressibleNonlinearElasticitySolver.hpp"
00041 #include "CompressibleNonlinearElasticitySolver.hpp"
00042 #include "QuadraticBasisFunction.hpp"
00043 #include "LinearBasisFunction.hpp"
00044 #include "AbstractContractionModel.hpp"
00045 #include "FibreReader.hpp"
00046 #include "FineCoarseMeshPair.hpp"
00047 #include "AbstractCardiacMechanicsSolverInterface.hpp"
00048 #include "HeartRegionCodes.hpp"
00049 #include "ElectroMechanicsProblemDefinition.hpp"
00050 
00051 
00058 typedef struct DataAtQuadraturePoint_
00059 {
00060     AbstractContractionModel* ContractionModel; 
00061 //    bool Active;/**<whether this quad point is active or not*/
00062     double Stretch; 
00063     double StretchLastTimeStep; 
00065 } DataAtQuadraturePoint;
00066 
00067 
00080 template<class ELASTICITY_SOLVER, unsigned DIM>
00081 class AbstractCardiacMechanicsSolver : public ELASTICITY_SOLVER, public AbstractCardiacMechanicsSolverInterface<DIM>
00082 {
00083 protected:
00084     static const unsigned NUM_VERTICES_PER_ELEMENT = ELASTICITY_SOLVER::NUM_VERTICES_PER_ELEMENT; 
00096     std::map<unsigned,DataAtQuadraturePoint> mQuadPointToDataAtQuadPointMap;
00097 
00101     std::map<unsigned,DataAtQuadraturePoint>::iterator mMapIterator;
00102 
00104     FineCoarseMeshPair<DIM>* mpMeshPair;
00105 
00107     unsigned mTotalQuadPoints;
00108 
00110     double mCurrentTime;
00111 
00113     double mNextTime;
00114 
00116     double mOdeTimestep;
00117 
00122     c_matrix<double,DIM,DIM> mConstantFibreSheetDirections;
00123 
00128     std::vector<c_matrix<double,DIM,DIM> >* mpVariableFibreSheetDirections;
00129 
00134     bool mFibreSheetDirectionsDefinedByQuadraturePoint;
00135 
00137     c_vector<double,DIM> mCurrentElementFibreDirection;
00138 
00140     c_vector<double,DIM> mCurrentElementSheetDirection;
00141 
00143     c_vector<double,DIM> mCurrentElementSheetNormalDirection;
00144 
00145 
00149     ElectroMechanicsProblemDefinition<DIM>& mrElectroMechanicsProblemDefinition;
00150 
00155     virtual bool IsImplicitSolver()=0;
00156 
00157 
00172     void AddActiveStressAndStressDerivative(c_matrix<double,DIM,DIM>& rC,
00173                                             unsigned elementIndex,
00174                                             unsigned currentQuadPointGlobalIndex,
00175                                             c_matrix<double,DIM,DIM>& rT,
00176                                             FourthOrderTensor<DIM,DIM,DIM,DIM>& rDTdE,
00177                                             bool addToDTdE);
00178 
00179 
00187     void SetupChangeOfBasisMatrix(unsigned elementIndex, unsigned currentQuadPointGlobalIndex);
00188 
00194     void Initialise();
00195 
00208     virtual void GetActiveTensionAndTensionDerivs(double currentFibreStretch,
00209                                                   unsigned currentQuadPointGlobalIndex,
00210                                                   bool assembleJacobian,
00211                                                   double& rActiveTension,
00212                                                   double& rDerivActiveTensionWrtLambda,
00213                                                   double& rDerivActiveTensionWrtDLambdaDt)=0;
00214 public:
00222     AbstractCardiacMechanicsSolver(QuadraticMesh<DIM>& rQuadMesh,
00223                                    ElectroMechanicsProblemDefinition<DIM>& rProblemDefinition,
00224                                    std::string outputDirectory);
00225 
00229     virtual ~AbstractCardiacMechanicsSolver();
00230 
00238     void SetFineCoarseMeshPair(FineCoarseMeshPair<DIM>* pMeshPair);
00239 
00241     unsigned GetTotalNumQuadPoints()
00242     {
00243         return mTotalQuadPoints;
00244     }
00245 
00247     virtual GaussianQuadratureRule<DIM>* GetQuadratureRule()
00248     {
00249         return this->mpQuadratureRule;
00250     }
00251 
00255     std::map<unsigned,DataAtQuadraturePoint>& rGetQuadPointToDataAtQuadPointMap()
00256     {
00257         return mQuadPointToDataAtQuadPointMap;
00258     }
00259 
00260 
00267     void SetConstantFibreSheetDirections(const c_matrix<double,DIM,DIM>& rFibreSheetMatrix);
00268 
00280     void SetVariableFibreSheetDirections(const FileFinder& rOrthoFile, bool definedPerQuadraturePoint);
00281 
00294     void SetCalciumAndVoltage(std::vector<double>& rCalciumConcentrations,
00295                               std::vector<double>& rVoltages);
00296 
00304     virtual void Solve(double time, double nextTime, double odeTimestep)=0;
00305 
00306 
00307 
00327     void ComputeDeformationGradientAndStretchInEachElement(std::vector<c_matrix<double,DIM,DIM> >& rDeformationGradients,
00328                                                            std::vector<double>& rStretches);
00329 };
00330 
00331 
00332 #endif /*ABSTRACTCARDIACMECHANICSSOLVER_HPP_*/

Generated by  doxygen 1.6.2