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 #ifndef SIMPLENEWTONNONLINEARSOLVER_HPP_
00031 #define SIMPLENEWTONNONLINEARSOLVER_HPP_
00032
00033 #include "LinearSystem.hpp"
00034 #include "AbstractNonlinearSolver.hpp"
00035 #include <vector>
00036
00037 class SimpleNewtonNonlinearSolver : public AbstractNonlinearSolver
00038 {
00039 private :
00040 double mLinearSolverRelativeTolerance;
00041 double mTolerance;
00042 bool mWriteStats;
00043
00044 std::vector<double> mTestDampingValues;
00045
00046 public :
00047 SimpleNewtonNonlinearSolver(double linearSolverRelativeTolerance = 1e-6);
00048 virtual ~SimpleNewtonNonlinearSolver();
00049
00095 virtual Vec Solve(PetscErrorCode (*pComputeResidual)(SNES,Vec,Vec,void*),
00096 PetscErrorCode (*pComputeJacobian)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),
00097 Vec initialGuess,
00098 void *pContext);
00099
00101 void SetTolerance(double tolerance);
00102
00104 void SetWriteStats(bool writeStats = true)
00105 {
00106 mWriteStats = writeStats;
00107 }
00108 };
00109
00110 #endif