00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 ,
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
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
00101 SimpleLinearEllipticSolver<DIM,DIM>::InitialiseForSolve(initialSolution);
00102
00103 this->mpLinearSystem->SetMatrixIsSymmetric(true);
00104 }
00105
00107
00109
00110 template class CellBasedPdeSolver<1>;
00111 template class CellBasedPdeSolver<2>;
00112 template class CellBasedPdeSolver<3>;