Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_NOX_Interface.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_Interface.h,v $
27 //
28 // Purpose : Specification file which declares an interface common to
29 // all supported nonlinear solver algorithms. The Manager
30 // class uses this interface to call a concrete algorithm.
31 //
32 // Special Notes : This is the "Strategy" class in the Strategy design
33 // pattern.
34 //
35 // Creator : Scott A. Hutchinson, SNL, Parallel Computational Sciences
36 //
37 // Creation Date : 04/28/00
38 //
39 // Revision Information:
40 // ---------------------
41 //
42 // Revision Number: $Revision: 1.53 $
43 //
44 // Revision Date : $Date: 2014/02/24 23:49:24 $
45 //
46 // Current Owner : $Author: tvrusso $
47 //-------------------------------------------------------------------------
48 
49 #ifndef Xyce_N_NLS_NOX_Interface_h
50 #define Xyce_N_NLS_NOX_Interface_h
51 
52 #include <N_UTL_Misc.h>
53 #include <N_PDS_fwd.h>
54 #include <N_IO_fwd.h>
55 
56 #include <N_NLS_Manager.h> // defines AnalysisMode
57 #include <N_NLS_NonLinearSolver.h>
58 #include <N_NLS_NOX_ParameterSet.h>
59 
60 class N_PDS_Manager;
61 
62 namespace NOX {
63  namespace Parameter {
64  class List;
65  }
66  namespace StatusTest {
67  class Generic;
68  }
69 }
70 
71 namespace LOCA {
72  class Stepper;
73  namespace MultiContinuation {
74  class AbstractGroup;
75  }
76  class GlobalData;
77  namespace StatusTest {
78  class Wrapper;
79  }
80 }
81 
82 namespace N_NLS_NOX {
83  class SharedSystem;
84  class Group;
85  class Vector;
86 }
87 
88 namespace N_NLS_LOCA {
89  class Group;
90 }
91 
92 class N_LOA_Loader;
93 
94 //-----------------------------------------------------------------------------
95 // Class : N_NLS_NonLinearSolver
96 // Purpose : Nonlinear Solver Abstract Class
97 // Creator : Tammy Kolda, SNL, 8950
98 // Creation Date : 2/5/02
99 //-----------------------------------------------------------------------------
100 
101 namespace N_NLS_NOX {
103 {
104 
105 public:
106 
107  Interface(N_IO_CmdParse & cp);
108  ~Interface();
109 
110  bool setOptions(const N_UTL_OptionBlock& OB);
111  bool setTranOptions(const N_UTL_OptionBlock& OB);
112  bool setHBOptions(const N_UTL_OptionBlock& OB);
113 
114 
115  bool setLocaOptions(const N_UTL_OptionBlock& OB);
116  bool setDCOPRestartOptions(const N_UTL_OptionBlock& OB);
117  bool setICOptions(const N_UTL_OptionBlock& OB);
118  bool setNodeSetOptions(const N_UTL_OptionBlock& OB);
119  bool initializeAll();
120  int solve (N_NLS_NonLinearSolver * nlsTmpPtr = NULL);
121 
122  int takeFirstSolveStep (N_NLS_NonLinearSolver * nlsTmpPtr = NULL);
123  int takeOneSolveStep ();
124 
125  Teuchos::RefCountPtr<N_NLS_LOCA::Group> getSolutionGroup ();
126 
127  int getNumIterations() const;
128  double getMaxNormF() const;
129  int getMaxNormFindex() const;
130 
131  int getDebugLevel() const;
132  bool getScreenOutputFlag () const;
133  double getDebugMinTime() const;
134  double getDebugMaxTime() const;
135  int getDebugMinTimeStep() const;
136  int getDebugMaxTimeStep() const;
137  bool getMMFormat () const;
138 
139  // Returns the continuation step number if available.
140  int getContinuationStep() const;
141 
142  // Returns the parameter number:
143  int getParameterNumber() const;
144 
145  // Returns true if this is the first continuation param
146  bool isFirstContinuationParam() const;
147 
148  // Returns true if this is the first solve has been completed
149  bool isFirstSolveComplete() const;
150  bool getLocaFlag ();
151  void setAnalysisMode(AnalysisMode mode);
152  void resetAll (AnalysisMode mode);
153  bool copySolnVectors();
154 
155  // Returns flag for Matrix free loads
156  bool getMatrixFreeFlag();
157 
158  bool computeF();
159 
160  bool computeJacobian();
161 
162  bool applyJacobian(const N_LAS_Vector& input, N_LAS_Vector& result);
163 
164  bool computeNewton(Teuchos::ParameterList& p);
165 
166  bool computeGradient();
167 
168  N_LOA_Loader& getLoader() const;
169 
170 protected:
171  // Resets the stepper by destroying and reallocating.
172  void resetStepper(const Teuchos::RefCountPtr<LOCA::GlobalData>& gd,
173  const Teuchos::RefCountPtr<LOCA::MultiContinuation::AbstractGroup>& initialGuess,
174  const Teuchos::RefCountPtr<NOX::StatusTest::Generic>& test,
175  const Teuchos::RefCountPtr<Teuchos::ParameterList>& p);
176 
177  // Functions for DC_OP restart and other initial condition options.
178  bool opStartCont0 (ParameterSet* paramsPtr);
179  bool opStartCont1 (ParameterSet* paramsPtr);
180 
181  bool icCont (ParameterSet* paramsPtr);
182  bool icCont3 (ParameterSet* paramsPtr);
183 
184  bool nodesetCont0 (ParameterSet* paramsPtr);
185  bool nodesetCont1 (ParameterSet* paramsPtr);
186 private:
187 
188  // Parameters for DC_OP
190 
191  bool DCOPused_;
195 
196  // Parameters for Transient
198 
200 
201  // Shared system
203 
204  // Global data for loca groups
205  Teuchos::RefCountPtr<LOCA::GlobalData> globalDataPtr_;
206 
207  // LOCA Wrapper Status Tests
208  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaTransientStatusTestPtr_;
209  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaDCOpStatusTestPtr_;
210  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaStatusTestPtr_;
211 
212  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaHBStatusTestPtr_;
213 
214  // Nox group
215  Teuchos::RefCountPtr<N_NLS_LOCA::Group> groupPtr_;
216 
217  // NOX Solver
218  Teuchos::RefCountPtr<NOX::Solver::Generic> solverPtr_;
219 
220  // LOCA Stepper
221  Teuchos::RefCountPtr<LOCA::Stepper> stepperPtr_;
222 
223  // Current analysis mode
225 
226  // Whether or not we should use the current analysis mode
227  bool usemode_;
228 
229  // save the parameters mode.
232 
234 
235  // Keep track of whether to set the linear solver tolerance
236  // (Only do this if adaptive forcing is on)
239 
240  //are we on the first LOCA continuation parameter?
242 
243  //is first solve completed?
245 
246  //parameter index
247  int iParam_;
248 };
249 } // namespace N_NLS_NOX
250 
251 #endif
252