BasicMonodomainSolver.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 "BasicMonodomainSolver.hpp"
00030 
00031 
00032 
00033 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00034 void BasicMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::SetupLinearSystem(Vec currentSolution, bool computeMatrix)
00035 {
00036     assert(this->mpLinearSystem->rGetLhsMatrix() != NULL);
00037     assert(this->mpLinearSystem->rGetRhsVector() != NULL);
00038     assert(currentSolution != NULL);
00039 
00040     // create assembler
00041     if(!this->mpMonodomainAssembler)
00042     {
00043         this->mpMonodomainAssembler = new MonodomainAssembler<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,this->mpMonodomainTissue,this->mNumQuadPoints);
00044     }        
00045 
00046     // use assembler to assemble LHS matrix and RHS vector
00047 
00048     this->mpMonodomainAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix());
00049     this->mpMonodomainAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(), true);
00050     this->mpMonodomainAssembler->SetApplyNeummanBoundaryConditionsToVector(this->mpBoundaryConditions);
00051     this->mpMonodomainAssembler->SetCurrentSolution(currentSolution);
00052    
00053     if(computeMatrix)
00054     {
00055         this->mpMonodomainAssembler->Assemble();
00056     }
00057     else
00058     {
00059         this->mpMonodomainAssembler->AssembleVector();
00060     }
00061 
00062     this->mpLinearSystem->AssembleRhsVector();
00063     this->mpLinearSystem->AssembleFinalLhsMatrix();
00064 }
00065         
00066 
00067 
00068 
00069 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00070 BasicMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::BasicMonodomainSolver(
00071                  AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00072                  MonodomainTissue<ELEMENT_DIM,SPACE_DIM>* pTissue,
00073                  BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,1>* pBoundaryConditions,
00074                  unsigned numQuadPoints)
00075     : AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>(pMesh,pTissue,pBoundaryConditions,numQuadPoints)
00076 {
00077     // Tell tissue there is a need to replicate ionic caches
00078     pTissue->SetCacheReplication(true);
00079     
00080     if(HeartConfig::Instance()->GetUseStateVariableInterpolation())
00081     {
00082         EXCEPTION("State variable interpolation only available when matrix-based assembly is switched on");
00083     }
00084 }
00085     
00086 
00087 
00088 
00089 
00090 
00092 // explicit instantiation
00094 
00095 template class BasicMonodomainSolver<1,1>;
00096 template class BasicMonodomainSolver<1,2>;
00097 template class BasicMonodomainSolver<1,3>;
00098 template class BasicMonodomainSolver<2,2>;
00099 template class BasicMonodomainSolver<3,3>;
00100 

Generated on Tue May 31 14:31:41 2011 for Chaste by  doxygen 1.5.5