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, SPACE_DIM, ELEMENT_DIM+1> &rGradPhi,
00038     ChastePoint<SPACE_DIM> &rX,
00039     c_vector<double,1> &rU,
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) * rU(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 phiI, const Node<SPACE_DIM> *pNode)
00058 {
00059     mSourceTerm += phiI * 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 existingSolution, double time)
00066 {
00067     mpMonodomainPde->SolveCellSystems(existingSolution, time, time+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     
00079     // linear system created here
00080     BaseClassType::InitialiseForSolve(initialSolution);
00081     
00082     if(HeartConfig::Instance()->GetUseAbsoluteTolerance())
00083     {
00084         this->mpLinearSystem->SetAbsoluteTolerance(HeartConfig::Instance()->GetAbsoluteTolerance());
00085     }
00086     else
00087     {
00088         this->mpLinearSystem->SetRelativeTolerance(HeartConfig::Instance()->GetRelativeTolerance());
00089     }
00090     
00091     this->mpLinearSystem->SetKspType(HeartConfig::Instance()->GetKSPSolver());
00092     this->mpLinearSystem->SetPcType(HeartConfig::Instance()->GetKSPPreconditioner());
00093     this->mpLinearSystem->SetMatrixIsSymmetric(true);
00094 }
00095 
00096 
00097 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00098 MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::MonodomainDg0Assembler(
00099             AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00100             MonodomainPde<ELEMENT_DIM, SPACE_DIM>* pPde,
00101             BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, 1>* pBcc,
00102             unsigned numQuadPoints)
00103     : AbstractAssembler<ELEMENT_DIM,SPACE_DIM,1>(),
00104       BaseClassType(pMesh, pPde, NULL /*bcs - set below*/, numQuadPoints)
00105 {
00106     mpMonodomainPde = pPde;
00107 
00108     this->mpBoundaryConditions = pBcc;
00109 
00110     this->SetMesh(pMesh);
00111 
00112     this->SetMatrixIsConstant();
00113 }
00114 
00115 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00116 MonodomainDg0Assembler<ELEMENT_DIM,SPACE_DIM>::~MonodomainDg0Assembler()
00117 {
00118 }
00119 
00120 
00122 // Explicit instantiation
00124 
00125 template class MonodomainDg0Assembler<1,1>;
00126 template class MonodomainDg0Assembler<1,2>;
00127 template class MonodomainDg0Assembler<1,3>;
00128 template class MonodomainDg0Assembler<2,2>;
00129 template class MonodomainDg0Assembler<3,3>;
00130 
00131 #include "SimpleDg0ParabolicAssemblerImplementation.hpp"
00132 
00133 template class SimpleDg0ParabolicAssembler<1, 1, false, MonodomainDg0Assembler<1, 1> >;
00134 template class SimpleDg0ParabolicAssembler<1, 2, false, MonodomainDg0Assembler<1, 2> >;
00135 template class SimpleDg0ParabolicAssembler<1, 3, false, MonodomainDg0Assembler<1, 3> >;
00136 template class SimpleDg0ParabolicAssembler<2, 2, false, MonodomainDg0Assembler<2, 2> >;
00137 template class SimpleDg0ParabolicAssembler<3, 3, false, MonodomainDg0Assembler<3, 3> >;

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5