AbstractMonodomainSolver.cpp

00001 
00002 /*
00003 
00004 Copyright (C) University of Oxford, 2005-2011
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-2011
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     double dt = PdeSimulationTime::GetPdeTimeStep();
00071     mpMonodomainTissue->SolveCellSystems(currentSolution, time, time+dt);
00072 }
00073 
00074 
00075 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00076 void AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::InitialiseForSolve(Vec initialSolution)
00077 {
00078     if (this->mpLinearSystem != NULL)
00079     {
00080         return;
00081     }
00082    
00083     // call base class version...
00084     AbstractLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>::InitialiseForSolve(initialSolution);
00085 
00086     //..then do a bit extra
00087     if(HeartConfig::Instance()->GetUseAbsoluteTolerance())
00088     {
00089         this->mpLinearSystem->SetAbsoluteTolerance(HeartConfig::Instance()->GetAbsoluteTolerance());
00090     }
00091     else
00092     {
00093         this->mpLinearSystem->SetRelativeTolerance(HeartConfig::Instance()->GetRelativeTolerance());
00094     }
00095 
00096     this->mpLinearSystem->SetKspType(HeartConfig::Instance()->GetKSPSolver());
00097     this->mpLinearSystem->SetPcType(HeartConfig::Instance()->GetKSPPreconditioner());
00098     this->mpLinearSystem->SetMatrixIsSymmetric(true);
00099     this->mpLinearSystem->SetUseFixedNumberIterations(HeartConfig::Instance()->GetUseFixedNumberIterationsLinearSolver(), HeartConfig::Instance()->GetEvaluateNumItsEveryNSolves());
00100 }
00101 
00102 
00103 
00104 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00105 AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::AbstractMonodomainSolver(
00106                  AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00107                  MonodomainTissue<ELEMENT_DIM,SPACE_DIM>* pTissue,
00108                  BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,1>* pBoundaryConditions,
00109                  unsigned numQuadPoints)
00110     : AbstractDynamicLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>(pMesh),
00111       mpBoundaryConditions(pBoundaryConditions),
00112       mpMonodomainTissue(pTissue),
00113       mNumQuadPoints(numQuadPoints)
00114 {
00115     assert(pTissue);
00116     assert(pBoundaryConditions);
00117     this->mMatrixIsConstant = true;
00118 
00119     mpMonodomainAssembler = NULL; // can't initialise until know what dt is
00120 }
00121     
00122 
00123 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00124 AbstractMonodomainSolver<ELEMENT_DIM,SPACE_DIM>::~AbstractMonodomainSolver()
00125 {
00126     if(mpMonodomainAssembler)
00127     {
00128         delete mpMonodomainAssembler;
00129     }
00130 }
00131 
00132 
00133 
00134 
00136 // explicit instantiation
00138 
00139 template class AbstractMonodomainSolver<1,1>;
00140 template class AbstractMonodomainSolver<1,2>;
00141 template class AbstractMonodomainSolver<1,3>;
00142 template class AbstractMonodomainSolver<2,2>;
00143 template class AbstractMonodomainSolver<3,3>;
00144 

Generated on Mon Apr 18 11:35:28 2011 for Chaste by  doxygen 1.5.5