00001 00005 class NonLinEqSolverState 00006 00007 { 00008 public: 00009 00010 NonLinEqMethod method; 00011 int iteration_no; 00012 real eps; 00013 VecSimple(real) conv_rate; 00014 real residual_norm; 00015 real Krylov_eps_r; 00016 bool Jacobian_update; 00017 real continuation_prm; 00018 int cont_iter_no; 00019 }; 00020 00021 00022 00023 class NonLinEqSolver : public HandleId 00024 00025 { 00026 protected: 00027 00028 NonLinEqSolverUDC* udc; 00029 00030 Handle(LinEqVector) nonlinear_sol; 00031 Handle(LinEqVector) linear_subproblem_sol; 00032 00033 Handle(LinEqVector) residual; 00034 Handle(LinEqMatrix) coeff_matrix; 00035 00036 NonLinEqSolverState current_state; 00037 00038 real eps; 00039 int nincreases; 00040 int niterations; 00041 real rnorm; 00042 VecSimple(real) eps_development; 00043 VecSimple(real) rnorm_development; 00044 int nouter_iter; 00045 real lambda; 00046 00047 Handle(SubdCommAdm) comm_adm; 00048 00049 bool redim (const NonLinEqSolver_prm& pm); 00050 void rememberConvData (); 00051 void fillCurrentState (NonLinEqMethod scheme); 00052 00053 public: 00054 00055 Handle(NonLinEqSolver_prm) params; 00056 00057 NonLinEqSolver (const NonLinEqSolver_prm& pm); 00058 virtual ~NonLinEqSolver (); 00059 00060 bool ok () const; 00061 00062 void attachUserCode (NonLinEqSolverUDC& user_code); 00063 00064 void attachNonLinSol (LinEqVector & nonlinear_solution); 00065 void attachNonLinSol (Vector(NUMT)& nonlinear_solution); 00066 void attachLinSol (LinEqVector & linear_subproblem_solution); 00067 void attachLinSol (Vector(NUMT)& linear_subproblem_solution); 00068 00069 00070 void attachResidual (LinEqVector & residual); 00071 void attachResidual (Vector(NUMT)& residual); 00072 void attachMatrix (LinEqMatrix & coeff_matrix); 00073 void attachMatrix (Matrix(NUMT)& coeff_matrix); 00074 00075 const NonLinEqSolverState& getCurrentState () const { return current_state; } 00076 00077 virtual bool solve (); 00078 virtual bool continuationSolve (); 00079 virtual bool ordinarySolve () =0; 00080 virtual void initSingleStep (); 00081 virtual bool singleStep (); 00082 00083 00084 void plotEps (CurvePlotFile& file); 00085 void plotResidualNorm (CurvePlotFile& file); 00086 00087 static void writeHeadings (StringList& headings); 00088 void writeResults (StringList& results); 00089 void writeExtendedResults (MultipleReporter& rep, VerbosityLevel level, 00090 CurvePlotFile& cplotfile); 00091 00092 protected: 00093 00094 void startIterations (); 00095 virtual bool converged (); 00096 bool success (); 00097 void getResidualNorm (); 00098 bool gotResidualNorm (); 00099 00100 public: 00101 00102 CLASS_INFO 00103 DEF_VIRTUAL_CAST(NewtonRaphson) 00104 DEF_VIRTUAL_CAST(SuccessiveSubst) 00105 DEF_VIRTUAL_CAST(ConjGradNonLin) 00106 DEF_VIRTUAL_CAST(NonLinML) 00107 00108 NonLinEqSolver (); 00109 00110 void attachCommAdm (const SubdCommAdm& adm_); 00111 }; 00112 00113