Debian Codegraph @

packages/trilinoscouplings/src/ml/NonlinML/nlnml_linearsystem.H

raw
1 // @HEADER
2 // *****************************************************************************
3 // Trilinos: An Object-Oriented Solver Framework
4 //
5 // Copyright 2001-2024 NTESS and the Trilinos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 /* ******************************************************************** */
11 /* See the file COPYRIGHT for a complete copyright notice, contact */
12 /* person and disclaimer. */
13 /* ******************************************************************** */
14 // ML-headers
15 #include "ml_common.h"
16 #include "TrilinosCouplings_config.h"
17
18 #if defined(HAVE_ML_NOX) && defined(HAVE_ML_EPETRA) && defined(HAVE_ML_AZTECOO) && defined(HAVE_ML_TEUCHOS) && defined(HAVE_ML_IFPACK) && defined(HAVE_ML_AMESOS) && defined(HAVE_ML_EPETRAEXT)
19
20 #ifndef NLNML_LINEARSYSTEM_H
21 #define NLNML_LINEARSYSTEM_H
22
23 #include "NOX_Epetra_LinearSystem.H"
24 #include "NOX_Epetra_Interface_Required.H"
25 #include "NOX_Epetra_Interface_Preconditioner.H"
26 #include "NOX_Epetra_MatrixFree.H"
27
28 #include "nlnml_coarselevelnoxinterface.H"
29
30 using namespace Teuchos;
31 namespace NLNML
32 {
33
34 class NLNML_LinearSystem : public virtual NOX::Epetra::LinearSystem
35 {
36
37 public:
38
39 NLNML_LinearSystem(
40 RefCountPtr<NOX::Epetra::Interface::Jacobian> iJac,
41 RefCountPtr<Epetra_Operator> J,
42 RefCountPtr<NOX::Epetra::Interface::Preconditioner> iPrec,
43 RefCountPtr<NLNML::NLNML_CoarseLevelNoxInterface> coarseinterface,
44 RefCountPtr<Epetra_Operator> Prec,
45 //const Epetra_Vector& soln,
46 bool ismatrixfree,
47 int level,
48 int printlevel);
49
50 virtual ~NLNML_LinearSystem() {}
51
52 bool applyJacobian(const NOX::Epetra::Vector& input,
53 NOX::Epetra::Vector& result) const;
54
55 bool applyJacobianTranspose(const NOX::Epetra::Vector& input,
56 NOX::Epetra::Vector& result) const;
57
58 bool applyJacobianInverse(Teuchos::ParameterList &params,
59 const NOX::Epetra::Vector &input,
60 NOX::Epetra::Vector &result);
61
62 bool applyRightPreconditioning(bool useTranspose,
63 Teuchos::ParameterList& params,
64 const NOX::Epetra::Vector& input,
65 NOX::Epetra::Vector& result) const;
66
67 Teuchos::RefCountPtr<NOX::Epetra::Scaling> getScaling() { return null; }
68
69 void resetScaling(const Teuchos::RefCountPtr<NOX::Epetra::Scaling>& s) { return; }
70
71 bool computeJacobian(const NOX::Epetra::Vector& x);
72
73 bool createPreconditioner(const NOX::Epetra::Vector& x,
74 Teuchos::ParameterList& p,
75 bool recomputeGraph) const;
76
77 // Because of reuse features I prefer to do this myself
78 bool destroyPreconditioner() const { return true; }
79
80 // To be consistent with preventing preconditioner re-use, we flag this option
81 // as invalid for now. RWH
82
83 bool recomputePreconditioner(const NOX::Epetra::Vector& x,
84 Teuchos::ParameterList& linearSolverParams) const
85 { return false; }
86
87 // For now, we do not support reuse of the preconditioner. This could change in th future. RWH
88 PreconditionerReusePolicyType
89 getPreconditionerPolicy(bool advanceReuseCounter)
90 { return PRPT_REBUILD; }
91
92 // Because of reuse features I prefer to do this myself
93 bool checkPreconditionerReuse() { return true; }
94
95 // Always...
96 bool isPreconditionerConstructed() const { return true; }
97
98 // Always...
99 bool hasPreconditioner() const { return true; }
100
101 Teuchos::RefCountPtr<const Epetra_Operator> getJacobianOperator() const
102 { return J_; }
103
104 Teuchos::RefCountPtr<Epetra_Operator> getJacobianOperator()
105 { return J_; }
106
107 Teuchos::RefCountPtr<const Epetra_Operator> getGeneratedPrecOperator() const
108 { return Prec_; }
109
110 Teuchos::RefCountPtr<Epetra_Operator> getGeneratedPrecOperator()
111 { return Prec_; }
112
113 void setJacobianOperatorForSolve(
114 const Teuchos::RefCountPtr<const Epetra_Operator>& solveJacOp);
115
116 void setPrecOperatorForSolve(
117 const Teuchos::RefCountPtr<const Epetra_Operator>& solvePrecOp);
118
119
120 protected:
121
122 RefCountPtr<NOX::Epetra::Interface::Jacobian> iJac_;
123 RefCountPtr<Epetra_Operator> J_;
124 RefCountPtr<NOX::Epetra::Interface::Preconditioner> iPrec_;
125 RefCountPtr<NLNML::NLNML_CoarseLevelNoxInterface> coarseinterface_;
126 RefCountPtr<Epetra_Operator> Prec_;
127 //const Epetra_Vector& soln_;
128 bool ismatrixfree_;
129 int level_;
130 int printlevel_;
131
132
133 } ; // class NLNML_LinearSystem
134 } // namespace NLNML
135
136 #endif // ML_NOX_LINEARSYSTEM_H
137 #endif // defined(HAVE_ML_NOX) && defined(HAVE_ML_EPETRA)