AbstractMonodomainSolver.cpp

00001 
00002 /*
00003 
00004 Copyright (C) University of Oxford, 2005-2010
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Chaste is free software: you can redistribute it and/or modify it
00013 under the terms of the GNU Lesser General Public License as published
00014 by the Free Software Foundation, either version 2.1 of the License, or
00015 (at your option) any later version.
00016 
00017 Chaste is distributed in the hope that it will be useful, but WITHOUT
00018 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00019 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00020 License for more details. The offer of Chaste under the terms of the
00021 License is subject to the License being interpreted in accordance with
00022 English Law and subject to any action against the University of Oxford
00023 being under the jurisdiction of the English Courts.
00024 
00025 You should have received a copy of the GNU Lesser General Public License
00026 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00027 
00028 */
00029 
00030 
00031 #include "AbstractMonodomainSolver.hpp"
00032 
00033 /*
00034 
00035 Copyright (C) University of Oxford, 2005-2010
00036 
00037 University of Oxford means the Chancellor, Masters and Scholars of the
00038 University of Oxford, having an administrative office at Wellington
00039 Square, Oxford OX1 2JD, UK.
00040 
00041 This file is part of Chaste.
00042 
00043 Chaste is free software: you can redistribute it and/or modify it
00044 under the terms of the GNU Lesser General Public License as published
00045 by the Free Software Foundation, either version 2.1 of the License, or
00046 (at your option) any later version.
00047 
00048 Chaste is distributed in the hope that it will be useful, but WITHOUT
00049 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00050 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00051 License for more details. The offer of Chaste under the terms of the
00052 License is subject to the License being interpreted in accordance with
00053 English Law and subject to any action against the University of Oxford
00054 being under the jurisdiction of the English Courts.
00055 
00056 You should have received a copy of the GNU Lesser General Public License
00057 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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     // solve cell models
00069     double time = PdeSimulationTime::GetTime();
00070     mpMonodomainTissue->SolveCellSystems(currentSolution, time, time+this->mDt);
00071 }
00072 
00073 
00074 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00075 void AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::InitialiseForSolve(Vec initialSolution)
00076 {
00077     if (this->mpLinearSystem != NULL)
00078     {
00079         return;
00080     }
00081    
00082     // call base class version...
00083     AbstractLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>::InitialiseForSolve(initialSolution);
00084 
00085     //..then do a bit extra
00086     if(HeartConfig::Instance()->GetUseAbsoluteTolerance())
00087     {
00088         this->mpLinearSystem->SetAbsoluteTolerance(HeartConfig::Instance()->GetAbsoluteTolerance());
00089     }
00090     else
00091     {
00092         this->mpLinearSystem->SetRelativeTolerance(HeartConfig::Instance()->GetRelativeTolerance());
00093     }
00094 
00095     this->mpLinearSystem->SetKspType(HeartConfig::Instance()->GetKSPSolver());
00096     this->mpLinearSystem->SetPcType(HeartConfig::Instance()->GetKSPPreconditioner());
00097     this->mpLinearSystem->SetMatrixIsSymmetric(true);
00098 }
00099 
00100 
00101 
00102 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00103 AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::AbstractMonodomainSolver(
00104                  AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00105                  MonodomainTissue<ELEMENT_DIM,SPACE_DIM>* pTissue,
00106                  BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,1>* pBoundaryConditions,
00107                  unsigned numQuadPoints)
00108     : AbstractDynamicLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>(pMesh),
00109       mpBoundaryConditions(pBoundaryConditions),
00110       mpMonodomainTissue(pTissue),
00111       mNumQuadPoints(numQuadPoints)
00112 {
00113     assert(pTissue);
00114     assert(pBoundaryConditions);
00115     this->mMatrixIsConstant = true;
00116 
00117     mpMonodomainAssembler = NULL; // can't initialise until know what dt is
00118 }
00119     
00120 
00121 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00122 AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::~AbstractMonodomainSolver()
00123 {
00124     if(mpMonodomainAssembler)
00125     {
00126         delete mpMonodomainAssembler;
00127     }
00128 }
00129 
00130 
00131 
00132 
00134 // explicit instantiation
00136 
00137 template class AbstractMonodomainSolver<1,1>;
00138 template class AbstractMonodomainSolver<1,2>;
00139 template class AbstractMonodomainSolver<1,3>;
00140 template class AbstractMonodomainSolver<2,2>;
00141 template class AbstractMonodomainSolver<3,3>;
00142 

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