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

Generated on Tue May 31 14:31:41 2011 for Chaste by  doxygen 1.5.5