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