diff_solver.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_DIFF_SOLVER_H
21 #define LIBMESH_DIFF_SOLVER_H
22 
23 // Local includes
24 #include "libmesh/auto_ptr.h"
25 #include "libmesh/libmesh_common.h"
28 
29 // C++ includes
30 #include <vector>
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 class ImplicitSystem;
37 template <typename T> class NumericVector;
38 
43 {
44 public:
45  virtual void operator() (const NumericVector<Number> & delta_u,
46  const double & norm_delta_u,
47  const NumericVector<Number> & u,
48  const double & norm_u,
49  const NumericVector<Number> & res,
50  const double & norm_res,
51  const unsigned int iteration) = 0;
52  virtual ~LinearSolutionMonitor();
53 };
54 
56 
70 class DiffSolver : public ReferenceCountedObject<DiffSolver>,
71  public ParallelObject
72 {
73 public:
78 
83  DiffSolver (sys_type & s);
84 
89  static UniquePtr<DiffSolver> build(sys_type & s);
90 
94  virtual ~DiffSolver () {}
95 
100  virtual void init ();
101 
106  virtual void reinit ();
107 
113  virtual unsigned int solve () = 0;
114 
119  unsigned int total_outer_iterations() { return _outer_iterations; }
120 
125  unsigned int total_inner_iterations() { return _inner_iterations; }
126 
130  unsigned int solve_result() { return _solve_result; }
131 
135  const sys_type & system () const { return _system; }
136 
140  sys_type & system () { return _system; }
141 
146  unsigned int max_linear_iterations;
147 
155 
160  bool quiet;
161 
166  bool verbose;
167 
173 
179 
191 
203 
209 
214 
220  enum SolveResult {
225  INVALID_SOLVE_RESULT = 0,
226 
231  CONVERGED_NO_REASON = 1,
232 
237  CONVERGED_ABSOLUTE_RESIDUAL = 2,
238 
243  CONVERGED_RELATIVE_RESIDUAL = 4,
244 
249  CONVERGED_ABSOLUTE_STEP = 8,
250 
255  CONVERGED_RELATIVE_STEP = 16,
256 
261  DIVERGED_NO_REASON = 32,
262 
268  DIVERGED_MAX_NONLINEAR_ITERATIONS = 64,
269 
274  DIVERGED_BACKTRACKING_FAILURE = 128,
275 
280  DIVERGED_LINEAR_SOLVER_FAILURE = 256
281  };
282 
287 
288 protected:
289 
295 
302 
306  unsigned int _outer_iterations;
307 
311  unsigned int _inner_iterations;
312 
316  sys_type & _system;
317 
324  unsigned int _solve_result;
325 };
326 
327 
328 } // namespace libMesh
329 
330 
331 #endif // LIBMESH_DIFF_SOLVER_H
bool continue_after_max_iterations
Definition: diff_solver.h:172
virtual ~DiffSolver()
Definition: diff_solver.h:94
unsigned int solve_result()
Definition: diff_solver.h:130
unsigned int max_nonlinear_iterations
Definition: diff_solver.h:154
Real absolute_residual_tolerance
Definition: diff_solver.h:189
ImplicitSystem sys_type
Definition: diff_solver.h:77
unsigned int _solve_result
Definition: diff_solver.h:324
unsigned int _inner_iterations
Definition: diff_solver.h:311
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
unsigned int total_outer_iterations()
Definition: diff_solver.h:119
sys_type & _system
Definition: diff_solver.h:316
unsigned int max_linear_iterations
Definition: diff_solver.h:146
const sys_type & system() const
Definition: diff_solver.h:135
void init(triangulateio &t)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool continue_after_backtrack_failure
Definition: diff_solver.h:178
unsigned int _outer_iterations
Definition: diff_solver.h:306
sys_type & system()
Definition: diff_solver.h:140
UniquePtr< LinearSolutionMonitor > linear_solution_monitor
Definition: diff_solver.h:286
unsigned int total_inner_iterations()
Definition: diff_solver.h:125
Real relative_residual_tolerance
Definition: diff_solver.h:190
virtual void operator()(const NumericVector< Number > &delta_u, const double &norm_delta_u, const NumericVector< Number > &u, const double &norm_u, const NumericVector< Number > &res, const double &norm_res, const unsigned int iteration)=0
Used for solving implicit systems of equations.