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 "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 ,
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
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
00102 SimpleLinearEllipticSolver<DIM,DIM>::InitialiseForSolve(initialSolution);
00103
00104 this->mpLinearSystem->SetMatrixIsSymmetric(true);
00105 }
00106
00107
00109
00111
00112 template class CellBasedSimulationWithPdesAssembler<1>;
00113 template class CellBasedSimulationWithPdesAssembler<2>;
00114 template class CellBasedSimulationWithPdesAssembler<3>;