Xyce  6.1
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-2015 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.73 $
42 //
43 // Revision Date : $Date: 2015/07/11 23:40:30 $
44 //
45 // Current Owner : $Author: erkeite $
46 //-------------------------------------------------------------------------
47 
48 #ifndef Xyce_N_NLS_NOX_Interface_h
49 #define Xyce_N_NLS_NOX_Interface_h
50 
51 #include <N_IO_fwd.h>
52 #include <N_LOA_fwd.h>
53 #include <N_PDS_fwd.h>
54 
55 #include <N_IO_InitialConditions.h>
56 #include <N_NLS_Manager.h> // defines AnalysisMode
57 #include <N_NLS_NonLinearSolver.h>
58 #include <N_NLS_NOX_ParameterSet.h>
59 
60 namespace NOX {
61  namespace Parameter {
62  class List;
63  }
64  namespace StatusTest {
65  class Generic;
66  }
67 }
68 
69 //-----------------------------------------------------------------------------
70 // Class : N_NLS_NonLinearSolver
71 // Purpose : Nonlinear Solver Abstract Class
72 // Creator : Tammy Kolda, SNL, 8950
73 // Creation Date : 2/5/02
74 //-----------------------------------------------------------------------------
75 
76 namespace Xyce {
77 namespace Nonlinear {
78 namespace N_NLS_NOX {
79 
81  {
82 
83  public:
84 
85  Interface(const Xyce::IO::CmdParse & cp);
86  ~Interface();
87 
88  bool setOptions(const Xyce::Util::OptionBlock& OB);
89  bool setTranOptions(const Xyce::Util::OptionBlock& OB);
90  bool setHBOptions(const Xyce::Util::OptionBlock& OB);
91  bool setNLPOptions(const Xyce::Util::OptionBlock& OB);
92 
93  bool setLocaOptions(const Xyce::Util::OptionBlock& OB);
94  bool setDCOPRestartOptions(const Xyce::Util::OptionBlock& OB);
95  bool setICOptions(const Xyce::Util::OptionBlock& OB);
96  bool setNodeSetOptions(const Xyce::Util::OptionBlock& OB);
97  bool initializeAll();
98 
99  int solve (Xyce::Nonlinear::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  int sourceSteppingSolve ( ParameterSet* paramsPtr );
116 
117  int takeFirstSolveStep (Xyce::Nonlinear::NonLinearSolver * nlsTmpPtr = NULL);
118  int takeOneSolveStep ();
119 
120  Teuchos::RCP<N_NLS_LOCA::Group> getSolutionGroup ();
121 
122  int getNumIterations() const;
123  double getMaxNormF() const;
124  int getMaxNormFindex() const;
125 
126  int getDebugLevel() const;
127  bool getScreenOutputFlag () const;
128  double getDebugMinTime() const;
129  double getDebugMaxTime() const;
130  int getDebugMinTimeStep() const;
131  int getDebugMaxTimeStep() const;
132  bool getMMFormat () const;
133 
134  // Returns the continuation step number if available.
135  int getContinuationStep() const;
136 
137  // Returns the parameter number:
138  int getParameterNumber() const;
139 
140  // Returns true if this is the first continuation param
141  bool isFirstContinuationParam() const;
142 
143  // Returns true if this is the first solve has been completed
144  bool isFirstSolveComplete() const;
145  bool getLocaFlag ();
148  bool copySolnVectors();
149 
150  bool computeF();
151 
152  bool computeJacobian();
153 
154  bool applyJacobian(const Xyce::Linear::Vector& input, Xyce::Linear::Vector& result);
155 
156  bool computeNewton(Teuchos::ParameterList& p);
157 
158  bool computeGradient();
159 
160  bool computeDfDpMulti (const std::vector< int > & paramIDs,
161  NOX::Abstract::MultiVector & dfdp,
162  bool isValidF);
163 
165 
166  protected:
167  // Resets the stepper by destroying and reallocating.
168  void resetStepper(const Teuchos::RCP<LOCA::GlobalData>& gd,
169  const Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup>& initialGuess,
170  const Teuchos::RCP<NOX::StatusTest::Generic>& test,
171  const Teuchos::RCP<Teuchos::ParameterList>& p);
172 
173  // Functions for DC_OP restart and other initial condition options.
174  bool opStartCont0 (ParameterSet* paramsPtr, int found, int icType, Xyce::IO::InitialConditionsData::NodeNamePairMap & op, const Xyce::NodeNameMap & allNodes, N_PDS_Comm * pdsCommPtr);
175  bool opStartCont1 (ParameterSet* paramsPtr);
176 
177  bool icCont (ParameterSet* paramsPtr);
178  bool icCont3 (ParameterSet* paramsPtr);
179 
180  bool nodesetCont0 (ParameterSet* paramsPtr);
181  bool nodesetCont1 (ParameterSet* paramsPtr);
182  private:
183 
184  // Parameters for DC_OP
186 
187  bool DCOPused_;
191 
192  // Parameters for Transient
194 
195  // Parameters for HB:
197 
198  // Parameters for NLPoisson:
200 
201  // Shared system
203 
204  // Global data for loca groups
205  Teuchos::RCP<LOCA::GlobalData> globalDataPtr_;
206 
207  // LOCA Wrapper Status Tests
208  Teuchos::RCP<LOCA::StatusTest::Wrapper> locaTransientStatusTestPtr_;
209  Teuchos::RCP<LOCA::StatusTest::Wrapper> locaDCOpStatusTestPtr_;
210  Teuchos::RCP<LOCA::StatusTest::Wrapper> locaStatusTestPtr_;
211 
212  Teuchos::RCP<LOCA::StatusTest::Wrapper> locaHBStatusTestPtr_;
213  Teuchos::RCP<LOCA::StatusTest::Wrapper> locaDC_NLPStatusTestPtr_;
214 
215  // Nox group
216  Teuchos::RCP<N_NLS_LOCA::Group> groupPtr_;
217 
218  // NOX Solver
219  Teuchos::RCP<NOX::Solver::Generic> solverPtr_;
220 
221  // LOCA Stepper
222  Teuchos::RCP<LOCA::Stepper> stepperPtr_;
223 
224  // Current analysis mode
226 
227  // Whether or not we should use the current analysis mode
228  bool usemode_;
229 
230  // save the parameters mode.
233 
235 
236  // Keep track of whether to set the linear solver tolerance
237  // (Only do this if adaptive forcing is on)
240 
241  //are we on the first LOCA continuation parameter?
243 
244  //is first solve completed?
246 
247  //parameter index
248  int iParam_;
249  };
250 
251 }}} // namespace N_NLS_NOX
252 
253 #endif
254 
Xyce::Nonlinear::AnalysisMode lastParametersMode_
bool setLocaOptions(const Xyce::Util::OptionBlock &OB)
bool setOptions(const Xyce::Util::OptionBlock &OB)
bool opStartCont0(ParameterSet *paramsPtr, int found, int icType, Xyce::IO::InitialConditionsData::NodeNamePairMap &op, const Xyce::NodeNameMap &allNodes, N_PDS_Comm *pdsCommPtr)
void setAnalysisMode(Xyce::Nonlinear::AnalysisMode mode)
int mosfetContinuationSolve6(ParameterSet *paramsPtr)
Pure virtual class to augment a linear system.
bool setHBOptions(const Xyce::Util::OptionBlock &OB)
int mosfetContinuationSolve2(ParameterSet *paramsPtr)
int spiceStrategy(ParameterSet *paramsPtr)
bool nodesetCont1(ParameterSet *paramsPtr)
Teuchos::RCP< NOX::Solver::Generic > solverPtr_
Teuchos::RCP< LOCA::Stepper > stepperPtr_
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaTransientStatusTestPtr_
int stdNewtonSolve(ParameterSet *paramsPtr)
int mosfetContinuationSolve(ParameterSet *paramsPtr)
bool computeNewton(Teuchos::ParameterList &p)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaDC_NLPStatusTestPtr_
int blockGainscaleMosfetSolve(ParameterSet *paramsPtr)
int naturalParameterContinuationSolve(ParameterSet *paramsPtr)
int solve(Xyce::Nonlinear::NonLinearSolver *nlsTmpPtr=NULL)
int mosfetContinuationSolve3(ParameterSet *paramsPtr)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaDCOpStatusTestPtr_
bool setTranOptions(const Xyce::Util::OptionBlock &OB)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaHBStatusTestPtr_
bool computeDfDpMulti(const std::vector< int > &paramIDs, NOX::Abstract::MultiVector &dfdp, bool isValidF)
bool icCont(ParameterSet *paramsPtr)
int pseudoTransientSolve(ParameterSet *paramsPtr)
Teuchos::RCP< N_NLS_LOCA::Group > getSolutionGroup()
bool opStartCont1(ParameterSet *paramsPtr)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaStatusTestPtr_
Xyce::Nonlinear::AnalysisMode parametersMode_
void resetAll(Xyce::Nonlinear::AnalysisMode mode)
int artificialParameterHomotopy(ParameterSet *paramsPtr)
Interface(const Xyce::IO::CmdParse &cp)
int takeFirstSolveStep(Xyce::Nonlinear::NonLinearSolver *nlsTmpPtr=NULL)
bool applyJacobian(const Xyce::Linear::Vector &input, Xyce::Linear::Vector &result)
bool setNodeSetOptions(const Xyce::Util::OptionBlock &OB)
bool setDCOPRestartOptions(const Xyce::Util::OptionBlock &OB)
int gminSteppingSolve(ParameterSet *paramsPtr)
Xyce::Loader::NonlinearEquationLoader & getLoader() const
bool setICOptions(const Xyce::Util::OptionBlock &OB)
int sourceSteppingSolve(ParameterSet *paramsPtr)
int mosfetContinuationSolve5(ParameterSet *paramsPtr)
bool icCont3(ParameterSet *paramsPtr)
Teuchos::RCP< N_NLS_LOCA::Group > groupPtr_
bool nodesetCont0(ParameterSet *paramsPtr)
bool setNLPOptions(const Xyce::Util::OptionBlock &OB)
Xyce::Nonlinear::AnalysisMode mode_
int mosfetContinuationSolve4(ParameterSet *paramsPtr)
Definition: N_NLS_fwd.h:108
Teuchos::RCP< LOCA::GlobalData > globalDataPtr_
void resetStepper(const Teuchos::RCP< LOCA::GlobalData > &gd, const Teuchos::RCP< LOCA::MultiContinuation::AbstractGroup > &initialGuess, const Teuchos::RCP< NOX::StatusTest::Generic > &test, const Teuchos::RCP< Teuchos::ParameterList > &p)