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
00030
00031 #include "AbstractMonodomainSolver.hpp"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include "AbstractMonodomainSolver.hpp"
00062
00063
00064
00065 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00066 void AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::PrepareForSetupLinearSystem(Vec currentSolution)
00067 {
00068
00069 double time = PdeSimulationTime::GetTime();
00070 double dt = PdeSimulationTime::GetPdeTimeStep();
00071 mpMonodomainTissue->SolveCellSystems(currentSolution, time, time+dt);
00072 }
00073
00074
00075 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00076 void AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::InitialiseForSolve(Vec initialSolution)
00077 {
00078 if (this->mpLinearSystem != NULL)
00079 {
00080 return;
00081 }
00082
00083
00084 AbstractLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>::InitialiseForSolve(initialSolution);
00085
00086
00087 if(HeartConfig::Instance()->GetUseAbsoluteTolerance())
00088 {
00089 this->mpLinearSystem->SetAbsoluteTolerance(HeartConfig::Instance()->GetAbsoluteTolerance());
00090 }
00091 else
00092 {
00093 this->mpLinearSystem->SetRelativeTolerance(HeartConfig::Instance()->GetRelativeTolerance());
00094 }
00095
00096 this->mpLinearSystem->SetKspType(HeartConfig::Instance()->GetKSPSolver());
00097 this->mpLinearSystem->SetPcType(HeartConfig::Instance()->GetKSPPreconditioner());
00098 this->mpLinearSystem->SetMatrixIsSymmetric(true);
00099 this->mpLinearSystem->SetUseFixedNumberIterations(HeartConfig::Instance()->GetUseFixedNumberIterationsLinearSolver(), HeartConfig::Instance()->GetEvaluateNumItsEveryNSolves());
00100 }
00101
00102
00103
00104 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00105 AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::AbstractMonodomainSolver(
00106 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00107 MonodomainTissue<ELEMENT_DIM,SPACE_DIM>* pTissue,
00108 BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,1>* pBoundaryConditions,
00109 unsigned numQuadPoints)
00110 : AbstractDynamicLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>(pMesh),
00111 mpBoundaryConditions(pBoundaryConditions),
00112 mpMonodomainTissue(pTissue),
00113 mNumQuadPoints(numQuadPoints)
00114 {
00115 assert(pTissue);
00116 assert(pBoundaryConditions);
00117 this->mMatrixIsConstant = true;
00118
00119 mpMonodomainAssembler = NULL;
00120 }
00121
00122
00123 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00124 AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::~AbstractMonodomainSolver()
00125 {
00126 if(mpMonodomainAssembler)
00127 {
00128 delete mpMonodomainAssembler;
00129 }
00130 }
00131
00132
00133
00134
00136
00138
00139 template class AbstractMonodomainSolver<1,1>;
00140 template class AbstractMonodomainSolver<1,2>;
00141 template class AbstractMonodomainSolver<1,3>;
00142 template class AbstractMonodomainSolver<2,2>;
00143 template class AbstractMonodomainSolver<3,3>;
00144