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 :
33 //
34 // Creator : Tammy Kolda
35 //
36 // Creation Date : 01/31/2002
37 //
38 // Revision Information:
39 // ---------------------
40 //
41 // Revision Number: $Revision: 1.55 $
42 //
43 // Revision Date : $Date: 2014/08/07 23:08:54 $
44 //
45 // Current Owner : $Author: dgbaur $
46 //-------------------------------------------------------------------------
47 
48 #ifndef Xyce_N_NLS_NOX_Interface_h
49 #define Xyce_N_NLS_NOX_Interface_h
50 
51 #include <N_UTL_Misc.h>
52 #include <N_PDS_fwd.h>
53 #include <N_IO_fwd.h>
54 
55 #include <N_NLS_Manager.h> // defines AnalysisMode
56 #include <N_NLS_NonLinearSolver.h>
57 #include <N_NLS_NOX_ParameterSet.h>
58 
59 class N_PDS_Manager;
60 
61 namespace NOX {
62  namespace Parameter {
63  class List;
64  }
65  namespace StatusTest {
66  class Generic;
67  }
68 }
69 
70 class N_LOA_Loader;
71 
72 //-----------------------------------------------------------------------------
73 // Class : N_NLS_NonLinearSolver
74 // Purpose : Nonlinear Solver Abstract Class
75 // Creator : Tammy Kolda, SNL, 8950
76 // Creation Date : 2/5/02
77 //-----------------------------------------------------------------------------
78 
79 namespace N_NLS_NOX {
81  {
82 
83  public:
84 
85  Interface(N_IO_CmdParse & cp);
86  ~Interface();
87 
88  bool setOptions(const N_UTL_OptionBlock& OB);
89  bool setTranOptions(const N_UTL_OptionBlock& OB);
90  bool setHBOptions(const N_UTL_OptionBlock& OB);
91 
92 
93  bool setLocaOptions(const N_UTL_OptionBlock& OB);
94  bool setDCOPRestartOptions(const N_UTL_OptionBlock& OB);
95  bool setICOptions(const N_UTL_OptionBlock& OB);
96  bool setNodeSetOptions(const N_UTL_OptionBlock& OB);
97  bool initializeAll();
98 
99  int solve (N_NLS_NonLinearSolver * nlsTmpPtr = NULL);
100 
101  int spiceStrategy ( ParameterSet* paramsPtr );
102 
103  int stdNewtonSolve ( ParameterSet* paramsPtr );
105  int mosfetContinuationSolve ( ParameterSet* paramsPtr );
106  int mosfetContinuationSolve2 ( ParameterSet* paramsPtr );
107  int mosfetContinuationSolve3 ( ParameterSet* paramsPtr );
108  int mosfetContinuationSolve4 ( ParameterSet* paramsPtr );
109  int mosfetContinuationSolve5 ( ParameterSet* paramsPtr );
110  int mosfetContinuationSolve6 ( ParameterSet* paramsPtr );
111  int blockGainscaleMosfetSolve ( ParameterSet* paramsPtr );
112  int gminSteppingSolve ( ParameterSet* paramsPtr );
113  int pseudoTransientSolve ( ParameterSet* paramsPtr );
114  int artificialParameterHomotopy ( ParameterSet* paramsPtr );
115 
116  int takeFirstSolveStep (N_NLS_NonLinearSolver * nlsTmpPtr = NULL);
117  int takeOneSolveStep ();
118 
119  Teuchos::RefCountPtr<N_NLS_LOCA::Group> getSolutionGroup ();
120 
121  int getNumIterations() const;
122  double getMaxNormF() const;
123  int getMaxNormFindex() const;
124 
125  int getDebugLevel() const;
126  bool getScreenOutputFlag () const;
127  double getDebugMinTime() const;
128  double getDebugMaxTime() const;
129  int getDebugMinTimeStep() const;
130  int getDebugMaxTimeStep() const;
131  bool getMMFormat () const;
132 
133  // Returns the continuation step number if available.
134  int getContinuationStep() const;
135 
136  // Returns the parameter number:
137  int getParameterNumber() const;
138 
139  // Returns true if this is the first continuation param
140  bool isFirstContinuationParam() const;
141 
142  // Returns true if this is the first solve has been completed
143  bool isFirstSolveComplete() const;
144  bool getLocaFlag ();
147  bool copySolnVectors();
148 
149  // Returns flag for Matrix free loads
150  bool getMatrixFreeFlag();
151 
152  bool computeF();
153 
154  bool computeJacobian();
155 
156  bool applyJacobian(const N_LAS_Vector& input, N_LAS_Vector& result);
157 
158  bool computeNewton(Teuchos::ParameterList& p);
159 
160  bool computeGradient();
161 
162  N_LOA_Loader& getLoader() const;
163 
164  protected:
165  // Resets the stepper by destroying and reallocating.
166  void resetStepper(const Teuchos::RefCountPtr<LOCA::GlobalData>& gd,
167  const Teuchos::RefCountPtr<LOCA::MultiContinuation::AbstractGroup>& initialGuess,
168  const Teuchos::RefCountPtr<NOX::StatusTest::Generic>& test,
169  const Teuchos::RefCountPtr<Teuchos::ParameterList>& p);
170 
171  // Functions for DC_OP restart and other initial condition options.
172  bool opStartCont0 (ParameterSet* paramsPtr);
173  bool opStartCont1 (ParameterSet* paramsPtr);
174 
175  bool icCont (ParameterSet* paramsPtr);
176  bool icCont3 (ParameterSet* paramsPtr);
177 
178  bool nodesetCont0 (ParameterSet* paramsPtr);
179  bool nodesetCont1 (ParameterSet* paramsPtr);
180  private:
181 
182  // Parameters for DC_OP
184 
185  bool DCOPused_;
189 
190  // Parameters for Transient
192 
194 
195  // Shared system
197 
198  // Global data for loca groups
199  Teuchos::RefCountPtr<LOCA::GlobalData> globalDataPtr_;
200 
201  // LOCA Wrapper Status Tests
202  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaTransientStatusTestPtr_;
203  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaDCOpStatusTestPtr_;
204  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaStatusTestPtr_;
205 
206  Teuchos::RefCountPtr<LOCA::StatusTest::Wrapper> locaHBStatusTestPtr_;
207 
208  // Nox group
209  Teuchos::RefCountPtr<N_NLS_LOCA::Group> groupPtr_;
210 
211  // NOX Solver
212  Teuchos::RefCountPtr<NOX::Solver::Generic> solverPtr_;
213 
214  // LOCA Stepper
215  Teuchos::RefCountPtr<LOCA::Stepper> stepperPtr_;
216 
217  // Current analysis mode
219 
220  // Whether or not we should use the current analysis mode
221  bool usemode_;
222 
223  // save the parameters mode.
226 
228 
229  // Keep track of whether to set the linear solver tolerance
230  // (Only do this if adaptive forcing is on)
233 
234  //are we on the first LOCA continuation parameter?
236 
237  //is first solve completed?
239 
240  //parameter index
241  int iParam_;
242  };
243 } // namespace N_NLS_NOX
244 
245 #endif
246