ExplicitCardiacMechanicsSolver.cpp

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 #include "ExplicitCardiacMechanicsSolver.hpp"
00030 #include "Nash2004ContractionModel.hpp"
00031 #include "Kerchoffs2003ContractionModel.hpp"
00032 #include "NonPhysiologicalContractionModel.hpp"
00033 
00035 //#include "NhsModelWithBackSolver.hpp"
00036 
00037 template<class ELASTICITY_SOLVER,unsigned DIM>
00038 ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::ExplicitCardiacMechanicsSolver(ContractionModel contractionModel,
00039                                                                                       QuadraticMesh<DIM>* pQuadMesh,
00040                                                                                       std::string outputDirectory,
00041                                                                                       std::vector<unsigned>& rFixedNodes,
00042                                                                                       AbstractMaterialLaw<DIM>* pMaterialLaw)
00043     : AbstractCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>(pQuadMesh,
00044                                                             outputDirectory,
00045                                                             rFixedNodes,
00046                                                             pMaterialLaw)
00047 {
00048     switch(contractionModel)
00049     {
00050         case NONPHYSIOL1:
00051         case NONPHYSIOL2:
00052         case NONPHYSIOL3:
00053         {
00054             unsigned option = (contractionModel==NONPHYSIOL1 ? 1 : (contractionModel==NONPHYSIOL2? 2 : 3));
00055             for(unsigned i=0; i<this->mTotalQuadPoints; i++)
00056             {
00057                 this->mContractionModelSystems.push_back(new NonPhysiologicalContractionModel(option));
00058             }
00059             break;
00060         }
00061         case NASH2004: //stretch dependent, will this work with explicit??
00062         {
00063             for(unsigned i=0; i<this->mTotalQuadPoints; i++)
00064             {
00065                 this->mContractionModelSystems.push_back(new Nash2004ContractionModel);
00066             }
00067             break;
00068         }
00069         case KERCHOFFS2003: //stretch dependent, will this work with explicit? Answer: can be unstable
00070         {
00071             for(unsigned i=0; i<this->mTotalQuadPoints; i++)
00072             {
00073                 this->mContractionModelSystems.push_back(new Kerchoffs2003ContractionModel);
00074             }
00075             break;
00076         }
00077         default:
00078         {
00079             EXCEPTION("Unknown or stretch-rate-dependent contraction model");
00080         }
00081     }
00082 
00083     assert(!(this->mContractionModelSystems[0]->IsStretchRateDependent()));
00084 }
00085 
00086 template<class ELASTICITY_SOLVER,unsigned DIM>
00087 ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::~ExplicitCardiacMechanicsSolver()
00088 {
00089     for(unsigned i=0; i<this->mContractionModelSystems.size(); i++)
00090     {
00091         delete this->mContractionModelSystems[i];
00092     }
00093 }
00094 
00095 template<class ELASTICITY_SOLVER,unsigned DIM>
00096 void ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::GetActiveTensionAndTensionDerivs(double currentFibreStretch,
00097                                                                                              unsigned currentQuadPointGlobalIndex,
00098                                                                                              bool assembleJacobian,
00099                                                                                              double& rActiveTension,
00100                                                                                              double& rDerivActiveTensionWrtLambda,
00101                                                                                              double& rDerivActiveTensionWrtDLambdaDt)
00102 {
00103     // the active tensions have already been computed for each contraction model, so can
00104     // return it straightaway..
00105     rActiveTension = this->mContractionModelSystems[currentQuadPointGlobalIndex]->GetActiveTension();
00106 
00107     // these are unset
00108     rDerivActiveTensionWrtLambda = 0.0;
00109     rDerivActiveTensionWrtDLambdaDt = 0.0;
00110 
00111     // store the value of given for this quad point, so that it can be used when computing
00112     // the active tension at the next timestep
00113     this->mStretches[currentQuadPointGlobalIndex] = currentFibreStretch;
00114 }
00115 
00116 template<class ELASTICITY_SOLVER,unsigned DIM>
00117 void ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::Solve(double time, double nextTime, double odeTimestep)
00118 {
00119     assert(time < nextTime);
00120     this->mCurrentTime = time;
00121     this->mNextTime = nextTime;
00122     this->mOdeTimestep = odeTimestep;
00123 
00124     // assemble the residual again so that mStretches is set (in GetActiveTensionAndTensionDerivs)
00125     // using the current deformation.
00126     this->AssembleSystem(true,false);
00127 
00128     // integrate contraction models
00129     for(unsigned i=0; i<this->mContractionModelSystems.size(); i++)
00130     {
00131         this->mContractionModelSystems[i]->SetStretchAndStretchRate(this->mStretches[i], 0.0 /*dlam_dt*/);
00132         this->mContractionModelSystems[i]->RunAndUpdate(time, nextTime, odeTimestep);
00133     }
00134 
00135     // solve
00136     ELASTICITY_SOLVER::Solve();
00137 }
00138 
00139 
00140 
00141 template class ExplicitCardiacMechanicsSolver<NonlinearElasticitySolver<2>,2>;
00142 template class ExplicitCardiacMechanicsSolver<NonlinearElasticitySolver<3>,3>;

Generated on Tue May 31 14:31:42 2011 for Chaste by  doxygen 1.5.5