diff_solver.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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" // deprecated
25 #include "libmesh/libmesh_common.h"
28 
29 // C++ includes
30 #include <vector>
31 #include <memory>
32 
33 namespace libMesh
34 {
35 
36 // Forward Declarations
37 class ImplicitSystem;
38 template <typename T> class NumericVector;
39 
44 {
45 public:
46  virtual void operator() (const NumericVector<Number> & delta_u,
47  const double & norm_delta_u,
48  const NumericVector<Number> & u,
49  const double & norm_u,
50  const NumericVector<Number> & res,
51  const double & norm_res,
52  const unsigned int iteration) = 0;
53  virtual ~LinearSolutionMonitor();
54 };
55 
57 
71 class DiffSolver : public ReferenceCountedObject<DiffSolver>,
72  public ParallelObject
73 {
74 public:
79 
84  DiffSolver (sys_type & s);
85 
92  static std::unique_ptr<DiffSolver> build(sys_type & s);
93 
97  virtual ~DiffSolver () {}
98 
103  virtual void init ();
104 
109  virtual void reinit ();
110 
116  virtual unsigned int solve () = 0;
117 
122  unsigned int total_outer_iterations() { return _outer_iterations; }
123 
128  unsigned int total_inner_iterations() { return _inner_iterations; }
129 
133  unsigned int solve_result() { return _solve_result; }
134 
138  const sys_type & system () const { return _system; }
139 
143  sys_type & system () { return _system; }
144 
149  unsigned int max_linear_iterations;
150 
158 
163  bool quiet;
164 
169  bool verbose;
170 
176 
182 
194 
206 
212 
217 
223  enum SolveResult {
228  INVALID_SOLVE_RESULT = 0,
229 
234  CONVERGED_NO_REASON = 1,
235 
240  CONVERGED_ABSOLUTE_RESIDUAL = 2,
241 
246  CONVERGED_RELATIVE_RESIDUAL = 4,
247 
252  CONVERGED_ABSOLUTE_STEP = 8,
253 
258  CONVERGED_RELATIVE_STEP = 16,
259 
264  DIVERGED_NO_REASON = 32,
265 
271  DIVERGED_MAX_NONLINEAR_ITERATIONS = 64,
272 
277  DIVERGED_BACKTRACKING_FAILURE = 128,
278 
283  DIVERGED_LINEAR_SOLVER_FAILURE = 256
284  };
285 
289  std::unique_ptr<LinearSolutionMonitor> linear_solution_monitor;
290 
291 protected:
292 
298 
305 
309  unsigned int _outer_iterations;
310 
314  unsigned int _inner_iterations;
315 
319  sys_type & _system;
320 
327  unsigned int _solve_result;
328 };
329 
330 
331 } // namespace libMesh
332 
333 
334 #endif // LIBMESH_DIFF_SOLVER_H
bool continue_after_max_iterations
Definition: diff_solver.h:175
virtual ~DiffSolver()
Definition: diff_solver.h:97
unsigned int solve_result()
Definition: diff_solver.h:133
unsigned int max_nonlinear_iterations
Definition: diff_solver.h:157
Real absolute_residual_tolerance
Definition: diff_solver.h:192
ImplicitSystem sys_type
Definition: diff_solver.h:78
unsigned int _solve_result
Definition: diff_solver.h:327
unsigned int _inner_iterations
Definition: diff_solver.h:314
unsigned int total_outer_iterations()
Definition: diff_solver.h:122
sys_type & _system
Definition: diff_solver.h:319
unsigned int max_linear_iterations
Definition: diff_solver.h:149
const sys_type & system() const
Definition: diff_solver.h:138
void init(triangulateio &t)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool continue_after_backtrack_failure
Definition: diff_solver.h:181
unsigned int _outer_iterations
Definition: diff_solver.h:309
sys_type & system()
Definition: diff_solver.h:143
unsigned int total_inner_iterations()
Definition: diff_solver.h:128
Real relative_residual_tolerance
Definition: diff_solver.h:193
std::unique_ptr< LinearSolutionMonitor > linear_solution_monitor
Definition: diff_solver.h:289
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.