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 #ifndef ABSTRACTLINEARPDESOLVER_HPP_
00030 #define ABSTRACTLINEARPDESOLVER_HPP_
00031
00032 #include "LinearSystem.hpp"
00033 #include "BoundaryConditionsContainer.hpp"
00034 #include "AbstractTetrahedralMesh.hpp"
00035 #include "HeartEventHandler.hpp"
00036
00041 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00042 class AbstractLinearPdeSolver : boost::noncopyable
00043 {
00044 protected :
00049 LinearSystem* mpLinearSystem;
00050
00054 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* mpMesh;
00055
00056 public :
00061 AbstractLinearPdeSolver(AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh)
00062 : mpLinearSystem(NULL),
00063 mpMesh(pMesh)
00064 {
00065 assert(pMesh!=NULL);
00066 }
00067
00071 virtual ~AbstractLinearPdeSolver()
00072 {
00073 if(mpLinearSystem)
00074 {
00075 delete mpLinearSystem;
00076 }
00077 }
00078
00088 virtual void InitialiseForSolve(Vec initialSolution = NULL);
00089
00090
00096 virtual void PrepareForSetupLinearSystem(Vec currentSolution)
00097 {
00098 }
00099
00105 virtual void FinaliseLinearSystem(Vec currentSolution)
00106 {
00107 }
00108
00118 virtual void FollowingSolveLinearSystem(Vec currentSolution)
00119 {
00120 }
00121
00122
00133 virtual void SetupLinearSystem(Vec currentSolution, bool computeMatrix)=0;
00134
00138 LinearSystem* GetLinearSystem()
00139 {
00140 return mpLinearSystem;
00141 }
00142 };
00143
00144 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00145 void AbstractLinearPdeSolver<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>::InitialiseForSolve(Vec initialSolution)
00146 {
00147 if (this->mpLinearSystem == NULL)
00148 {
00149 unsigned preallocation=(mpMesh->CalculateMaximumContainingElementsPerProcess() + ELEMENT_DIM);
00150 if (ELEMENT_DIM > 1)
00151 {
00152
00153 preallocation--;
00154 }
00155 preallocation*=PROBLEM_DIM;
00156
00157 HeartEventHandler::BeginEvent(HeartEventHandler::COMMUNICATION);
00158 if (initialSolution == NULL)
00159 {
00160
00161
00162
00163 Vec template_vec = mpMesh->GetDistributedVectorFactory()->CreateVec(PROBLEM_DIM);
00164
00165 this->mpLinearSystem = new LinearSystem(template_vec, preallocation);
00166
00167 VecDestroy(template_vec);
00168 }
00169 else
00170 {
00171
00172
00173
00174 this->mpLinearSystem = new LinearSystem(initialSolution, preallocation);
00175 }
00176
00177 HeartEventHandler::EndEvent(HeartEventHandler::COMMUNICATION);
00178 }
00179 }
00180
00181
00182
00183 #endif