MonodomainDg0Assembler.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 "MonodomainDg0Assembler.hpp"
00030 #include "GaussianQuadratureRule.hpp"
00031 #include "HeartConfig.hpp"
00032 
00033 
00034 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00035 c_vector<double,1*(ELEMENT_DIM+1)> MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::ComputeVectorTerm(
00036     c_vector<double, ELEMENT_DIM+1> &rPhi,
00037     c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> &rGradPhi,
00038     ChastePoint<SPACE_DIM> &rX,
00039     c_vector<double,1> &u,
00040     c_matrix<double, 1, SPACE_DIM> &rGradU /* not used */,
00041     Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00042 {
00043     return  rPhi * (mSourceTerm + this->mDtInverse *
00044                     mpMonodomainPde->ComputeDuDtCoefficientFunction(rX) * u(0));
00045 }
00046 
00047 
00048 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00049 void MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::ResetInterpolatedQuantities( void )
00050 {
00051     mSourceTerm=0;
00052 }
00053 
00054 
00055 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00056 void MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::IncrementInterpolatedQuantities(
00057             double phi_i, const Node<SPACE_DIM> *pNode)
00058 {
00059     mSourceTerm += phi_i * mpMonodomainPde->ComputeNonlinearSourceTermAtNode(*pNode, this->mCurrentSolutionOrGuessReplicated[ pNode->GetIndex() ] );
00060 }
00061 
00062 
00063 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00064 void MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::PrepareForAssembleSystem(
00065             Vec currentSolution, double currentTime)
00066 {
00067     mpMonodomainPde->SolveCellSystems(currentSolution, currentTime, currentTime+this->mDt);
00068 }
00069 
00070 
00071 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00072 void MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::InitialiseForSolve(Vec initialSolution)
00073 {
00074     if (this->mpLinearSystem != NULL)
00075     {
00076         return;
00077     }
00078     BaseClassType::InitialiseForSolve(initialSolution);
00079     if(HeartConfig::Instance()->GetUseAbsoluteTolerance())
00080     {
00081         this->mpLinearSystem->SetAbsoluteTolerance(HeartConfig::Instance()->GetAbsoluteTolerance());
00082     }
00083     else
00084     {
00085         this->mpLinearSystem->SetRelativeTolerance(HeartConfig::Instance()->GetRelativeTolerance());
00086     }
00087     this->mpLinearSystem->SetKspType(HeartConfig::Instance()->GetKSPSolver());
00088     this->mpLinearSystem->SetPcType(HeartConfig::Instance()->GetKSPPreconditioner());        
00089 }
00090 
00091 
00092 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00093 MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::MonodomainDg0Assembler(
00094             AbstractMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00095             MonodomainPde<SPACE_DIM>* pPde,
00096             BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, 1>* pBcc,
00097             unsigned numQuadPoints)
00098     : AbstractAssembler<ELEMENT_DIM,SPACE_DIM,1>(),
00099       BaseClassType(pMesh, pPde, NULL /*bcs - set below*/, numQuadPoints)
00100 {
00101     mpMonodomainPde = pPde;
00102 
00103     this->mpBoundaryConditions = pBcc;
00104 
00105     this->SetMesh(pMesh);
00106 
00107     this->SetMatrixIsConstant();
00108 }
00109 
00110 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00111 MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::~MonodomainDg0Assembler()
00112 {
00113 }
00114 
00115 
00117 // Explicit instantiation
00119 
00120 template class MonodomainDg0Assembler<1,1>;
00121 template class MonodomainDg0Assembler<2,2>;
00122 template class MonodomainDg0Assembler<3,3>;
00123 
00124 #include "SimpleDg0ParabolicAssemblerImplementation.hpp"
00125 
00126 template class SimpleDg0ParabolicAssembler<1, 1, false, MonodomainDg0Assembler<1, 1> >;
00127 template class SimpleDg0ParabolicAssembler<2, 2, false, MonodomainDg0Assembler<2, 2> >;
00128 template class SimpleDg0ParabolicAssembler<3, 3, false, MonodomainDg0Assembler<3, 3> >;

Generated on Wed Mar 18 12:51:52 2009 for Chaste by  doxygen 1.5.5