CellBasedPdeSolver.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 "CellBasedPdeSolver.hpp"
00030 #include "TetrahedralMesh.hpp"
00031 #include "SimpleLinearEllipticSolver.hpp"
00032 #include "GaussianQuadratureRule.hpp"
00033 
00034 template<unsigned DIM>
00035 CellBasedPdeSolver<DIM>::CellBasedPdeSolver(TetrahedralMesh<DIM,DIM>* pMesh,
00036                               AbstractLinearEllipticPde<DIM,DIM>* pPde,
00037                               BoundaryConditionsContainer<DIM,DIM,1>* pBoundaryConditions,
00038                               unsigned numQuadPoints) :
00039         SimpleLinearEllipticSolver<DIM, DIM>(pMesh, pPde, pBoundaryConditions, numQuadPoints)
00040 {
00041 }
00042 
00043 template<unsigned DIM>
00044 CellBasedPdeSolver<DIM>::~CellBasedPdeSolver()
00045 {
00046 }
00047 
00048 template<unsigned DIM>
00049 c_vector<double, 1*(DIM+1)> CellBasedPdeSolver<DIM>::ComputeVectorTerm(
00050         c_vector<double, DIM+1>& rPhi,
00051         c_matrix<double, DIM, DIM+1>& rGradPhi,
00052         ChastePoint<DIM>& rX,
00053         c_vector<double, 1>& rU,
00054         c_matrix<double, 1, DIM>& rGradU /* not used */,
00055         Element<DIM, DIM>* pElement)
00056 {
00057     return mConstantInUSourceTerm * rPhi;
00058 }
00059 
00060 template<unsigned DIM>
00061 c_matrix<double, 1*(DIM+1), 1*(DIM+1)> CellBasedPdeSolver<DIM>::ComputeMatrixTerm(
00062         c_vector<double, DIM+1>& rPhi,
00063         c_matrix<double, DIM, DIM+1>& rGradPhi,
00064         ChastePoint<DIM>& rX,
00065         c_vector<double, 1>& rU,
00066         c_matrix<double, 1, DIM>& rGradU,
00067         Element<DIM, DIM>* pElement)
00068 {
00069     c_matrix<double, DIM, DIM> pde_diffusion_term = this->mpEllipticPde->ComputeDiffusionTerm(rX);
00070 
00071     // This if statement just saves computing phi*phi^T if it is to be multiplied by zero
00072     if (mLinearInUCoeffInSourceTerm != 0)
00073     {
00074         return   prod( trans(rGradPhi), c_matrix<double, DIM, DIM+1>(prod(pde_diffusion_term, rGradPhi)) )
00075                - mLinearInUCoeffInSourceTerm * outer_prod(rPhi,rPhi);
00076     }
00077     else
00078     {
00079         return   prod( trans(rGradPhi), c_matrix<double, DIM, DIM+1>(prod(pde_diffusion_term, rGradPhi)) );
00080     }
00081 }
00082 
00083 template<unsigned DIM>
00084 void CellBasedPdeSolver<DIM>::ResetInterpolatedQuantities()
00085 {
00086     mConstantInUSourceTerm = 0;
00087     mLinearInUCoeffInSourceTerm = 0;
00088 }
00089 
00090 template<unsigned DIM>
00091 void CellBasedPdeSolver<DIM>::IncrementInterpolatedQuantities(double phiI, const Node<DIM>* pNode)
00092 {
00093     mConstantInUSourceTerm += phiI * this->mpEllipticPde->ComputeConstantInUSourceTermAtNode(*pNode);
00094     mLinearInUCoeffInSourceTerm += phiI * this->mpEllipticPde->ComputeLinearInUCoeffInSourceTermAtNode(*pNode);
00095 }
00096 
00097 template<unsigned DIM>
00098 void CellBasedPdeSolver<DIM>::InitialiseForSolve(Vec initialSolution)
00099 {
00100     // Linear system created here
00101     SimpleLinearEllipticSolver<DIM,DIM>::InitialiseForSolve(initialSolution);
00102 
00103     this->mpLinearSystem->SetMatrixIsSymmetric(true);
00104 }
00105 
00107 // Explicit instantiation
00109 
00110 template class CellBasedPdeSolver<1>;
00111 template class CellBasedPdeSolver<2>;
00112 template class CellBasedPdeSolver<3>;
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3