ExplicitCardiacMechanicsSolver.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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:
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:
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
00108
00109 rActiveTension = this->mContractionModelSystems[currentQuadPointGlobalIndex]->GetActiveTension();
00110
00111
00112 rDerivActiveTensionWrtLambda = 0.0;
00113 rDerivActiveTensionWrtDLambdaDt = 0.0;
00114
00115
00116
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
00129
00130 this->AssembleSystem(true,false);
00131
00132
00133 for(unsigned i=0; i<this->mContractionModelSystems.size(); i++)
00134 {
00135 this->mContractionModelSystems[i]->SetStretchAndStretchRate(this->mStretches[i], 0.0 );
00136 this->mContractionModelSystems[i]->RunAndUpdate(time, nextTime, odeTimestep);
00137 }
00138
00139
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>;