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
00045
00046 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00047 void BasicBidomainSolver<ELEMENT_DIM,SPACE_DIM>::SetupLinearSystem(Vec currentSolution, bool computeMatrix)
00048 {
00049 assert(this->mpLinearSystem->rGetLhsMatrix() != NULL);
00050 assert(this->mpLinearSystem->rGetRhsVector() != NULL);
00051 assert(currentSolution != NULL);
00052
00053
00054 if(!this->mpBidomainAssembler)
00055 {
00056 InitialiseAssembler();
00057 }
00058
00059
00060
00061 this->mpBidomainAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix());
00062 this->mpBidomainAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(), true);
00063
00064
00065
00066 this->mpBidomainAssembler->SetApplyNeummanBoundaryConditionsToVector(this->mpBoundaryConditions);
00067
00068 this->mpBidomainAssembler->SetCurrentSolution(currentSolution);
00069
00070 if(computeMatrix)
00071 {
00072 this->mpBidomainAssembler->Assemble();
00073 }
00074 else
00075 {
00076 this->mpBidomainAssembler->AssembleVector();
00077 }
00078
00079 this->mpLinearSystem->AssembleRhsVector();
00080
00081 this->mpBoundaryConditions->ApplyDirichletToLinearProblem(*(this->mpLinearSystem), computeMatrix);
00082
00083 if(this->mBathSimulation)
00084 {
00085 this->mpLinearSystem->AssembleFinalLhsMatrix();
00086 this->FinaliseForBath(computeMatrix,true);
00087 }
00088
00089 this->mpLinearSystem->AssembleRhsVector();
00090 this->mpLinearSystem->AssembleFinalLhsMatrix();
00091 }
00092
00093
00094 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00095 void BasicBidomainSolver<ELEMENT_DIM,SPACE_DIM>::InitialiseAssembler()
00096 {
00097 if(!this->mpBidomainAssembler)
00098 {
00099 if(this->mBathSimulation)
00100 {
00101 this->mpBidomainAssembler = new BidomainWithBathAssembler<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,this->mpBidomainTissue,this->mDt,this->mNumQuadPoints);
00102 }
00103 else
00104 {
00105 this->mpBidomainAssembler = new BidomainAssembler<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,this->mpBidomainTissue,this->mDt,this->mNumQuadPoints);
00106 }
00107 }
00108 }
00109
00110
00112
00114
00115 template class BasicBidomainSolver<1,1>;
00116 template class BasicBidomainSolver<2,2>;
00117 template class BasicBidomainSolver<3,3>;
00118