Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_NOX_Group.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_NLS_NOX_Group.h,v $
27 //
28 // Purpose : Interface to Xyce for NOX groups.
29 //
30 // Special Notes :
31 //
32 // Creator : Tammy Kolda, NLS, 8950
33 //
34 // Creation Date : 01/31/02
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.19 $
40 //
41 // Revision Date : $Date: 2014/02/24 23:49:24 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_NLS_NOX_Group_h
47 #define Xyce_N_NLS_NOX_Group_h
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 
53 // ---------- NOX Includes ----------
54 
55 #include "NOX_Abstract_Group.H"
56 #include "Teuchos_RefCountPtr.hpp"
57 
58 // ---------- Forward Declarations ----------
59 namespace N_NLS_NOX {
60  class Vector;
61  class SharedSystem;
62 }
63 namespace NOX {
64  namespace Abstract {
65  class Vector;
66  class Group;
67  }
68  namespace Parameter {
69  class List;
70  }
71 }
72 class Ifpack_IlukGraph;
73 class Ifpack_CrsRiluk;
74 
75 
76 // N_NLS_NOX namespace is for all NOX-related classes in the Xyce
77 // Nonlinear Solver Package
78 namespace N_NLS_NOX {
79 
80 
81 //-----------------------------------------------------------------------------
82 // Class : N_NLS::NOX::Group
83 //
84 // Purpose :
85 //
86 // NOX Group Interface for Xyce
87 //
88 // Creator : Tammy Kolda, SNL, 8950
89 //
90 // Creation Date : 2/1/02
91 //-----------------------------------------------------------------------------
92 
93 class Group : public virtual NOX::Abstract::Group {
94 
95 public:
96 
97  Group(SharedSystem& s);
98  Group(const Group& source, NOX::CopyType type = NOX::DeepCopy);
99 
100  ~Group();
101 
102  NOX::Abstract::Group& operator=(const Group& source);
103  NOX::Abstract::Group& operator=(const NOX::Abstract::Group& source);
104 
105  void setX(const Vector& input);
106  void setX(const NOX::Abstract::Vector& input);
107 
108  void computeX(const Group& grp, const Vector& d, double step);
109  void computeX(const NOX::Abstract::Group& grp, const NOX::Abstract::Vector& d, double step);
110 
111  NOX::Abstract::Group::ReturnType computeF();
112  NOX::Abstract::Group::ReturnType computeJacobian();
113  NOX::Abstract::Group::ReturnType computeGradient();
114  NOX::Abstract::Group::ReturnType computeNewton(Teuchos::ParameterList& params);
115  NOX::Abstract::Group::ReturnType applyJacobian(const Vector& input, Vector& result) const;
116  NOX::Abstract::Group::ReturnType applyJacobian(const NOX::Abstract::Vector& input, NOX::Abstract::Vector& result) const;
117 
118  NOX::Abstract::Group::ReturnType applyJacobianTranspose(const Vector& input, Vector& result) const;
119  NOX::Abstract::Group::ReturnType applyJacobianTranspose(const NOX::Abstract::Vector& input, NOX::Abstract::Vector& result) const;
120  NOX::Abstract::Group::ReturnType
121  applyJacobianInverse(Teuchos::ParameterList& params,
122  const Vector& input, Vector& result) const;
123  NOX::Abstract::Group::ReturnType
124  applyJacobianInverse(Teuchos::ParameterList& params,
125  const NOX::Abstract::Vector& input,
126  NOX::Abstract::Vector& result) const;
127 
128  NOX::Abstract::Group::ReturnType
129  applyRightPreconditioning(bool useTranspose,
130  Teuchos::ParameterList& params,
131  const Vector& input,
132  Vector& result) const;
133  NOX::Abstract::Group::ReturnType
134  applyRightPreconditioning(bool useTranspose,
135  Teuchos::ParameterList& params,
136  const NOX::Abstract::Vector& input,
137  NOX::Abstract::Vector& result) const;
138 
139  bool isF() const;
140  bool isJacobian() const;
141  bool isGradient() const;
142  bool isNewton() const;
143 
144  const NOX::Abstract::Vector& getX() const;
145  const NOX::Abstract::Vector& getF() const;
146  double getNormF() const;
147  const NOX::Abstract::Vector& getGradient() const;
148  const NOX::Abstract::Vector& getNewton() const;
149 
150  Teuchos::RefCountPtr<NOX::Abstract::Group>
151  clone(NOX::CopyType type = NOX::DeepCopy) const;
152 
153 protected:
154 
155  // resets the isValid flags to false
156  void resetIsValid_();
157 
158  // Throws an error
159  void throwError(std::string method, std::string message) const;
160 
161 
162 protected:
163 
164  // Reference to the shared Newton system
166 
167  // NOX Vectors for storing values
168  Teuchos::RefCountPtr<N_NLS_NOX::Vector> xVecPtr_;
170  Teuchos::RefCountPtr<N_NLS_NOX::Vector> fVecPtr_;
172  Teuchos::RefCountPtr<N_NLS_NOX::Vector> newtonVecPtr_;
173  Teuchos::RefCountPtr<N_NLS_NOX::Vector> gradVecPtr_;
174 
175  // Booleans for tracking whether or not these values have been
176  // computed for the currect x.
177  bool isValidF_;
182 
183  // Value of the 2-Norm of F
184  double normF_;
185 
186  // Flag to determine if the solver should refactor the
187  // preconditioner (iterative) or Jacobian (direct).
188  mutable bool haveSolverFactors_;
189 
190 }; // class SharedSystem
191 } // namespace N_NLS_NOX
192 
193 #endif // Xyce_N_NLS_NOX_SharedSystem_h
194