Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
NonLinearSolver_decl.hpp
1#ifndef NONLINEARSOLVER_DECL_hpp
2#define NONLINEARSOLVER_DECL_hpp
3#include "feddlib/problems/problems_config.h"
4#include "feddlib/problems/abstract/NonLinearProblem.hpp"
5#include "feddlib/problems/abstract/TimeProblem.hpp"
6#include "feddlib/core/General/ExporterTxt.hpp"
7
8#include <boost/function.hpp>
9
10#ifdef FEDD_HAVE_NOX
11#include <NOX.H>
12#include <NOX_Thyra.H>
13#include <NOX_SolverStats.hpp>
14#endif
23
33
34namespace FEDD{
35template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
36class NonLinearSolver {
37
38public:
39
40 typedef Problem<SC,LO,NO,GO> Problem_Type;
41 typedef Teuchos::RCP<Problem_Type> ProblemPtr_Type;
42
43 typedef TimeProblem<SC,LO,GO,NO> TimeProblem_Type;
44 typedef NonLinearProblem<SC,LO,GO,NO> NonLinearProblem_Type;
45
46 typedef typename Problem_Type::Matrix_Type Matrix_Type;
47 typedef typename Problem_Type::MatrixPtr_Type MatrixPtr_Type;
48
49 typedef Teuchos::RCP<ExporterTxt> ExporterTxtPtr_Type;
50
51 // boost function type for switching strategy
52 typedef boost::function<bool( std::string& , int, double, ParameterListPtr_Type parameterList)> SwitchingStrategyFunc;
53
54
55 NonLinearSolver();
56
58 NonLinearSolver(std::string type);
59
60 ~NonLinearSolver();
61
67 void solve(NonLinearProblem_Type& problem,vec_dbl_ptr_Type valuesForExport = Teuchos::null );
68
75 void solve(TimeProblem_Type& problem, double time=0., vec_dbl_ptr_Type valuesForExport = Teuchos::null );
76
78 int getNonLinIts() {return nonLinearIts_;}
79
84 void addSwitchingStrategyFunction( SwitchingStrategyFunc switchingStrategy ) {
85 switchingStrategy_ = switchingStrategy;
86 }
87
88
89
90private:
91#ifdef FEDD_HAVE_NOX
97 void solveNOX(NonLinearProblem_Type& problem,vec_dbl_ptr_Type valuesForExport = Teuchos::null);
98
104 void solveNOX( TimeProblem_Type& problem, vec_dbl_ptr_Type valuesForExport = Teuchos::null );
105
106#endif
112 void solveFixedPoint(NonLinearProblem_Type& problem,vec_dbl_ptr_Type valuesForExport = Teuchos::null);
113
119 void solveNewton(NonLinearProblem_Type& problem, vec_dbl_ptr_Type valuesForExport = Teuchos::null );
120
129 void solveFixedPointNewton(NonLinearProblem_Type& problem, vec_dbl_ptr_Type valuesForExport = Teuchos::null );
130
131
137 void solveFixedPoint(TimeProblem_Type& problem, double time);
138
145 void solveNewton(TimeProblem_Type& problem, double time, vec_dbl_ptr_Type valuesForExport = Teuchos::null );
146
147
148
155 void solveExtrapolation(TimeProblem_Type& problem, double time);
156
157 std::string type_;
158
159 int nonLinearIts_ =0;
160
161 // Create a default switching strategy function which does nothing
162 SwitchingStrategyFunc switchingStrategy_ = []( std::string& currentLinearization , int nlIts, double criterionValue, ParameterListPtr_Type parameterList ) {return false;};
163
164
165};
166}
167#endif
Definition NonLinearProblem_decl.hpp:28
int getNonLinIts()
return the number of nonlinear iterations needed
Definition NonLinearSolver_decl.hpp:78
void addSwitchingStrategyFunction(SwitchingStrategyFunc switchingStrategy)
Add a switching strategy function for the FixedPointNewton method.
Definition NonLinearSolver_decl.hpp:84
void solve(NonLinearProblem_Type &problem, vec_dbl_ptr_Type valuesForExport=Teuchos::null)
Call for solving a nonlinear problem, depending on linearization solveNOX/solveFixedPoint/solveNewton...
Definition NonLinearSolver_def.hpp:33
Definition Problem_decl.hpp:42
Definition TimeProblem_decl.hpp:31
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36