AbstractLinearPdeSolver.hpp
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 #ifndef ABSTRACTLINEARPDESOLVER_HPP_
00037 #define ABSTRACTLINEARPDESOLVER_HPP_
00038
00039 #include "LinearSystem.hpp"
00040 #include "BoundaryConditionsContainer.hpp"
00041 #include "AbstractTetrahedralMesh.hpp"
00042 #include "HeartEventHandler.hpp"
00043
00048 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00049 class AbstractLinearPdeSolver : private boost::noncopyable
00050 {
00051 protected:
00052
00054 LinearSystem* mpLinearSystem;
00055
00057 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* mpMesh;
00058
00059 public:
00060
00066 AbstractLinearPdeSolver(AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh)
00067 : mpLinearSystem(NULL),
00068 mpMesh(pMesh)
00069 {
00070 assert(pMesh!=NULL);
00071 }
00072
00076 virtual ~AbstractLinearPdeSolver()
00077 {
00078 if (mpLinearSystem)
00079 {
00080 delete mpLinearSystem;
00081 }
00082 }
00083
00093 virtual void InitialiseForSolve(Vec initialSolution = NULL);
00094
00101 virtual void PrepareForSetupLinearSystem(Vec currentSolution)
00102 {
00103 }
00104
00112 virtual void FinaliseLinearSystem(Vec currentSolution)
00113 {
00114 }
00115
00125 virtual void FollowingSolveLinearSystem(Vec currentSolution)
00126 {
00127 }
00128
00140 virtual void SetupLinearSystem(Vec currentSolution, bool computeMatrix)=0;
00141
00145 LinearSystem* GetLinearSystem()
00146 {
00147 return mpLinearSystem;
00148 }
00149 };
00150
00151 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00152 void AbstractLinearPdeSolver<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>::InitialiseForSolve(Vec initialSolution)
00153 {
00154 if (this->mpLinearSystem == NULL)
00155 {
00156 unsigned preallocation= PROBLEM_DIM * mpMesh->CalculateMaximumNodeConnectivityPerProcess();
00157
00158 HeartEventHandler::BeginEvent(HeartEventHandler::COMMUNICATION);
00159 if (initialSolution == NULL)
00160 {
00161
00162
00163
00164
00165 Vec template_vec = mpMesh->GetDistributedVectorFactory()->CreateVec(PROBLEM_DIM);
00166
00167 this->mpLinearSystem = new LinearSystem(template_vec, preallocation);
00168
00169 PetscTools::Destroy(template_vec);
00170 }
00171 else
00172 {
00173
00174
00175
00176
00177
00178 this->mpLinearSystem = new LinearSystem(initialSolution, preallocation);
00179 }
00180
00181 HeartEventHandler::EndEvent(HeartEventHandler::COMMUNICATION);
00182 }
00183 }
00184
00185 #endif