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
00030
00031
00032
00033
00034
00035
00036 #include "SimpleLinearEllipticSolver.hpp"
00037
00038 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00039 c_matrix<double, 1*(ELEMENT_DIM+1), 1*(ELEMENT_DIM+1)>SimpleLinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>:: ComputeMatrixTerm(
00040 c_vector<double, ELEMENT_DIM+1>& rPhi,
00041 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi,
00042 ChastePoint<SPACE_DIM>& rX,
00043 c_vector<double,1>& rU,
00044 c_matrix<double,1,SPACE_DIM>& rGradU,
00045 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00046 {
00047 c_matrix<double, SPACE_DIM, SPACE_DIM> pde_diffusion_term = mpEllipticPde->ComputeDiffusionTerm(rX);
00048
00049
00050 if (mpEllipticPde->ComputeLinearInUCoeffInSourceTerm(rX,pElement)!=0)
00051 {
00052 return prod( trans(rGradPhi), c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>(prod(pde_diffusion_term, rGradPhi)) )
00053 - mpEllipticPde->ComputeLinearInUCoeffInSourceTerm(rX,pElement)*outer_prod(rPhi,rPhi);
00054 }
00055 else
00056 {
00057 return prod( trans(rGradPhi), c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>(prod(pde_diffusion_term, rGradPhi)) );
00058 }
00059 }
00060
00061 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00062 c_vector<double,1*(ELEMENT_DIM+1)> SimpleLinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>::ComputeVectorTerm(
00063 c_vector<double, ELEMENT_DIM+1>& rPhi,
00064 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi,
00065 ChastePoint<SPACE_DIM>& rX,
00066 c_vector<double,1>& rU,
00067 c_matrix<double,1,SPACE_DIM>& rGradU,
00068 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00069 {
00070 return mpEllipticPde->ComputeConstantInUSourceTerm(rX, pElement) * rPhi;
00071 }
00072
00073
00074 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00075 SimpleLinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>::SimpleLinearEllipticSolver(
00076 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00077 AbstractLinearEllipticPde<ELEMENT_DIM,SPACE_DIM>* pPde,
00078 BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,1>* pBoundaryConditions)
00079 : AbstractAssemblerSolverHybrid<ELEMENT_DIM,SPACE_DIM,1,NORMAL>(pMesh,pBoundaryConditions),
00080 AbstractStaticLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>(pMesh)
00081 {
00082 mpEllipticPde = pPde;
00083 }
00084
00085 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00086 void SimpleLinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>::InitialiseForSolve(Vec initialSolution)
00087 {
00088 AbstractLinearPdeSolver<ELEMENT_DIM,SPACE_DIM,1>::InitialiseForSolve(initialSolution);
00089 assert(this->mpLinearSystem);
00090 this->mpLinearSystem->SetMatrixIsSymmetric(true);
00091 this->mpLinearSystem->SetKspType("cg");
00092 }
00093
00095
00097
00098 template class SimpleLinearEllipticSolver<1,1>;
00099 template class SimpleLinearEllipticSolver<1,2>;
00100 template class SimpleLinearEllipticSolver<1,3>;
00101 template class SimpleLinearEllipticSolver<2,2>;
00102 template class SimpleLinearEllipticSolver<3,3>;