trilinos_nox_nonlinear_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_TRILINOS_NOX_NONLINEAR_SOLVER_H
21 #define LIBMESH_TRILINOS_NOX_NONLINEAR_SOLVER_H
22 
23 // It is possible to build Trilinos with NOX, but without Epetra. The
24 // way that libmesh uses NOX requires Epetra, however, so we have to
25 // check for both.
26 #if defined(LIBMESH_TRILINOS_HAVE_NOX) && defined(LIBMESH_TRILINOS_HAVE_EPETRA)
27 
28 // Local includes
30 
31 // Trilinos includes
33 #include "Epetra_Vector.h"
34 #include "Epetra_Operator.h"
35 #include "Epetra_RowMatrix.h"
36 #include "NOX_Epetra_Interface_Required.H" // base class
37 #include "NOX_Epetra_Interface_Jacobian.H" // base class
38 #include "NOX_Epetra_Interface_Preconditioner.H" // base class
39 #include "NOX.H"
41 
42 // C++ includes
43 #include <cstddef>
44 
45 namespace libMesh
46 {
47 
48 // Forward declarations
49 class Problem_Interface;
50 
51 
60 template <typename T>
62 {
63 public:
68 
72  explicit
74 
78  virtual ~NoxNonlinearSolver ();
79 
83  virtual void clear () override;
84 
88  virtual void init (const char * name = nullptr) override;
89 
94  virtual std::pair<unsigned int, Real>
95  solve (SparseMatrix<T> &, // System Jacobian Matrix
96  NumericVector<T> &, // Solution vector
97  NumericVector<T> &, // Residual vector
98  const double, // Stopping tolerance
99  const unsigned int) override; // N. Iterations
103  virtual int get_total_linear_iterations() override;
104 
112  virtual unsigned get_current_nonlinear_iteration_number() const override
113  { libmesh_not_implemented(); return 0; }
114 
115 private:
116 
120  NOX::Solver::Generic * _solver;
121 
126 
131 };
132 
133 
134 /*----------------------- functions ----------------------------------*/
135 template <typename T>
136 inline
138  NonlinearSolver<T>(system),
139  _solver(nullptr),
140  _interface(nullptr),
141  _n_linear_iterations(0)
142 {
143 }
144 
145 
146 
147 template <typename T>
148 inline
150 {
151  this->clear ();
152 }
153 
154 
155 } // namespace libMesh
156 
157 
158 #endif // LIBMESH_TRILINOS_HAVE_NOX && LIBMESH_TRILINOS_HAVE_EPETRA
159 #endif // LIBMESH_TRILINOS_NOX_NONLINEAR_SOLVER_H
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
virtual int get_total_linear_iterations() override
virtual void init(const char *name=nullptr) override
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: diff_context.h:40
virtual std::pair< unsigned int, Real > solve(SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int) override
const sys_type & system() const
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
virtual unsigned get_current_nonlinear_iteration_number() const override