BasicBidomainSolver.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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     // create assembler
00054     if(!this->mpBidomainAssembler)
00055     {
00056         InitialiseAssembler();
00057     } 
00058 
00059     // use assembler to assemble LHS matrix and RHS vector
00060 
00061     this->mpBidomainAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix());
00062     this->mpBidomainAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(), true);
00063 
00064     // MUST be called every timestep in case the bcc has been reset, see comment in
00065     // this->ResetBoundaryConditionsContainer()
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 // explicit instantiation
00114 
00115 template class BasicBidomainSolver<1,1>;
00116 template class BasicBidomainSolver<2,2>;
00117 template class BasicBidomainSolver<3,3>;
00118 

Generated on Mon Nov 1 12:35:17 2010 for Chaste by  doxygen 1.5.5