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 "BasicBidomainSolver.hpp"
00030
00031
00032
00033 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00034 BasicBidomainSolver<ELEMENT_DIM,SPACE_DIM>::BasicBidomainSolver(
00035 bool bathSimulation,
00036 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00037 BidomainTissue<SPACE_DIM>* pTissue,
00038 BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, 2>* pBcc,
00039 unsigned numQuadPoints)
00040 : AbstractBidomainSolver<ELEMENT_DIM,SPACE_DIM>(bathSimulation,pMesh,pTissue,pBcc,numQuadPoints)
00041 {
00042 pTissue->SetCacheReplication(true);
00043
00044 if(HeartConfig::Instance()->GetUseStateVariableInterpolation())
00045 {
00046 EXCEPTION("State variable interpolation only available when matrix-based assembly is switched on");
00047 }
00048 }
00049
00050
00051 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00052 void BasicBidomainSolver<ELEMENT_DIM,SPACE_DIM>::SetupLinearSystem(Vec currentSolution, bool computeMatrix)
00053 {
00054 assert(this->mpLinearSystem->rGetLhsMatrix() != NULL);
00055 assert(this->mpLinearSystem->rGetRhsVector() != NULL);
00056 assert(currentSolution != NULL);
00057
00058
00059 if(!this->mpBidomainAssembler)
00060 {
00061 InitialiseAssembler();
00062 }
00063
00064
00065
00066 this->mpBidomainAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix());
00067 this->mpBidomainAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(), true);
00068
00069
00070
00071 this->mpBidomainAssembler->SetApplyNeummanBoundaryConditionsToVector(this->mpBoundaryConditions);
00072
00073 this->mpBidomainAssembler->SetCurrentSolution(currentSolution);
00074
00075 if(computeMatrix)
00076 {
00077 this->mpBidomainAssembler->Assemble();
00078 }
00079 else
00080 {
00081 this->mpBidomainAssembler->AssembleVector();
00082 }
00083
00084 this->mpLinearSystem->AssembleRhsVector();
00085
00086 this->mpBoundaryConditions->ApplyDirichletToLinearProblem(*(this->mpLinearSystem), computeMatrix);
00087
00088 if(this->mBathSimulation)
00089 {
00090 this->mpLinearSystem->AssembleFinalLhsMatrix();
00091 this->FinaliseForBath(computeMatrix,true);
00092 }
00093
00094 this->mpLinearSystem->AssembleRhsVector();
00095 this->mpLinearSystem->AssembleFinalLhsMatrix();
00096 }
00097
00098
00099 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00100 void BasicBidomainSolver<ELEMENT_DIM,SPACE_DIM>::InitialiseAssembler()
00101 {
00102 if(!this->mpBidomainAssembler)
00103 {
00104 if(this->mBathSimulation)
00105 {
00106 this->mpBidomainAssembler = new BidomainWithBathAssembler<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,this->mpBidomainTissue,this->mNumQuadPoints);
00107 }
00108 else
00109 {
00110 this->mpBidomainAssembler = new BidomainAssembler<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,this->mpBidomainTissue,this->mNumQuadPoints);
00111 }
00112 }
00113 }
00114
00115
00117
00119
00120 template class BasicBidomainSolver<1,1>;
00121 template class BasicBidomainSolver<2,2>;
00122 template class BasicBidomainSolver<3,3>;
00123