36 #include "ImplicitCardiacMechanicsSolver.hpp"
38 template<
class ELASTICITY_SOLVER,
unsigned DIM>
42 std::string outputDirectory)
50 template<
class ELASTICITY_SOLVER,
unsigned DIM>
56 template<
class ELASTICITY_SOLVER,
unsigned DIM>
60 assert(time < nextTime);
61 this->mCurrentTime = time;
62 this->mNextTime = nextTime;
63 this->mOdeTimestep = odeTimestep;
66 ELASTICITY_SOLVER::Solve();
71 if(this->GetNumNewtonIterations() > 0)
73 this->AssembleSystem(
true,
false);
78 for(std::map<unsigned,DataAtQuadraturePoint>::iterator iter = this->mQuadPointToDataAtQuadPointMap.begin();
79 iter != this->mQuadPointToDataAtQuadPointMap.end();
83 iter->second.StretchLastTimeStep = iter->second.Stretch;
91 template<
class ELASTICITY_SOLVER,
unsigned DIM>
93 unsigned currentQuadPointGlobalIndex,
94 bool assembleJacobian,
95 double& rActiveTension,
96 double& rDerivActiveTensionWrtLambda,
97 double& rDerivActiveTensionWrtDLambdaDt)
101 assert(this->mMapIterator->first==currentQuadPointGlobalIndex);
106 r_data_at_quad_point.
Stretch = currentFibreStretch;
109 double dlam_dt = (currentFibreStretch-r_data_at_quad_point.
StretchLastTimeStep)/(this->mNextTime-this->mCurrentTime);
118 p_contraction_model->
RunDoNotUpdate(this->mCurrentTime,this->mNextTime,this->mOdeTimestep);
123 #define COVERAGE_IGNORE
128 EXCEPTION(
"Failure in solving contraction models using current stretches for assembling Jacobian");
132 rActiveTension = DBL_MAX;
133 std::cout <<
"WARNING: could not solve contraction model with this stretch and stretch rate. "
134 <<
"Setting active tension to infinity (DBL_MAX) so that the residual(-norm) is also infinite\n" << std::flush;
137 #undef COVERAGE_IGNORE
144 double h1 = std::max(1e-6, currentFibreStretch/100);
146 p_contraction_model->
RunDoNotUpdate(this->mCurrentTime,this->mNextTime,this->mOdeTimestep);
150 double h2 = std::max(1e-6, dlam_dt/100);
152 p_contraction_model->
RunDoNotUpdate(this->mCurrentTime,this->mNextTime,this->mOdeTimestep);
155 rDerivActiveTensionWrtLambda = (active_tension_at_lam_plus_h - rActiveTension)/h1;
156 rDerivActiveTensionWrtDLambdaDt = (active_tension_at_dlamdt_plus_h - rActiveTension)/h2;
160 this->mMapIterator++;
161 if(this->mMapIterator==this->mQuadPointToDataAtQuadPointMap.end())
163 this->mMapIterator = this->mQuadPointToDataAtQuadPointMap.begin();
ImplicitCardiacMechanicsSolver(QuadraticMesh< DIM > &rQuadMesh, ElectroMechanicsProblemDefinition< DIM > &rProblemDefinition, std::string outputDirectory)
virtual ~ImplicitCardiacMechanicsSolver()
virtual void UpdateStateVariables()=0
void GetActiveTensionAndTensionDerivs(double currentFibreStretch, unsigned currentQuadPointGlobalIndex, bool assembleJacobian, double &rActiveTension, double &rDerivActiveTensionWrtLambda, double &rDerivActiveTensionWrtDLambdaDt)
#define EXCEPTION(message)
double StretchLastTimeStep
virtual void SetStretchAndStretchRate(double stretch, double stretchRate)=0
AbstractContractionModel * ContractionModel
virtual void RunDoNotUpdate(double startTime, double endTime, double timeStep)=0
virtual double GetNextActiveTension()=0
void Solve(double time, double nextTime, double odeTimestep)