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.20 $
40 //
41 // Revision Date : $Date: 2014/08/07 23:08:54 $
42 //
43 // Current Owner : $Author: dgbaur $
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 // namespace Xyce {
76 namespace N_NLS_NOX {
77 
78 //-----------------------------------------------------------------------------
79 // Class : N_NLS::NOX::Group
80 //
81 // Purpose :
82 //
83 // NOX Group Interface for Xyce
84 //
85 // Creator : Tammy Kolda, SNL, 8950
86 //
87 // Creation Date : 2/1/02
88 //-----------------------------------------------------------------------------
89 
90 class Group : public virtual NOX::Abstract::Group {
91 
92 public:
93 
94  Group(SharedSystem& s);
95  Group(const Group& source, NOX::CopyType type = NOX::DeepCopy);
96 
97  ~Group();
98 
99  NOX::Abstract::Group& operator=(const Group& source);
100  NOX::Abstract::Group& operator=(const NOX::Abstract::Group& source);
101 
102  void setX(const Vector& input);
103  void setX(const NOX::Abstract::Vector& input);
104 
105  void computeX(const Group& grp, const Vector& d, double step);
106  void computeX(const NOX::Abstract::Group& grp, const NOX::Abstract::Vector& d, double step);
107 
108  NOX::Abstract::Group::ReturnType computeF();
109  NOX::Abstract::Group::ReturnType computeJacobian();
110  NOX::Abstract::Group::ReturnType computeGradient();
111  NOX::Abstract::Group::ReturnType computeNewton(Teuchos::ParameterList& params);
112  NOX::Abstract::Group::ReturnType applyJacobian(const Vector& input, Vector& result) const;
113  NOX::Abstract::Group::ReturnType applyJacobian(const NOX::Abstract::Vector& input, NOX::Abstract::Vector& result) const;
114 
115  NOX::Abstract::Group::ReturnType applyJacobianTranspose(const Vector& input, Vector& result) const;
116  NOX::Abstract::Group::ReturnType applyJacobianTranspose(const NOX::Abstract::Vector& input, NOX::Abstract::Vector& result) const;
117  NOX::Abstract::Group::ReturnType
118  applyJacobianInverse(Teuchos::ParameterList& params,
119  const Vector& input, Vector& result) const;
120  NOX::Abstract::Group::ReturnType
121  applyJacobianInverse(Teuchos::ParameterList& params,
122  const NOX::Abstract::Vector& input,
123  NOX::Abstract::Vector& result) const;
124 
125  NOX::Abstract::Group::ReturnType
126  applyRightPreconditioning(bool useTranspose,
127  Teuchos::ParameterList& params,
128  const Vector& input,
129  Vector& result) const;
130  NOX::Abstract::Group::ReturnType
131  applyRightPreconditioning(bool useTranspose,
132  Teuchos::ParameterList& params,
133  const NOX::Abstract::Vector& input,
134  NOX::Abstract::Vector& result) const;
135 
136  bool isF() const;
137  bool isJacobian() const;
138  bool isGradient() const;
139  bool isNewton() const;
140 
141  const NOX::Abstract::Vector& getX() const;
142  const NOX::Abstract::Vector& getF() const;
143  double getNormF() const;
144  const NOX::Abstract::Vector& getGradient() const;
145  const NOX::Abstract::Vector& getNewton() const;
146 
147  Teuchos::RefCountPtr<NOX::Abstract::Group>
148  clone(NOX::CopyType type = NOX::DeepCopy) const;
149 
150 protected:
151 
152  // resets the isValid flags to false
153  void resetIsValid_();
154 
155  // Throws an error
156  void throwError(std::string method, std::string message) const;
157 
158 
159 protected:
160 
161  // Reference to the shared Newton system
163 
164  // NOX Vectors for storing values
165  Teuchos::RefCountPtr<N_NLS_NOX::Vector> xVecPtr_;
167  Teuchos::RefCountPtr<N_NLS_NOX::Vector> fVecPtr_;
169  Teuchos::RefCountPtr<N_NLS_NOX::Vector> newtonVecPtr_;
170  Teuchos::RefCountPtr<N_NLS_NOX::Vector> gradVecPtr_;
171 
172  // Booleans for tracking whether or not these values have been
173  // computed for the currect x.
174  bool isValidF_;
179 
180  // Value of the 2-Norm of F
181  double normF_;
182 
183  // Flag to determine if the solver should refactor the
184  // preconditioner (iterative) or Jacobian (direct).
185  mutable bool haveSolverFactors_;
186 
187 }; // class SharedSystem
188 
189 } // namespace N_NLS_NOX
190 // } // namespace Xyce
191 
192 #endif // Xyce_N_NLS_NOX_SharedSystem_h
193