Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_NOX_Interface.C
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.C,v $
27 //
28 // Purpose : Interface to Xyce vectors for NOX.
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.163.2.1 $
40 //
41 // Revision Date : $Date: 2014/08/25 20:12:51 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 
53 #ifndef HAVE_CONFIG_H
54 #define HAVE_CONFIG_H
55 #endif
56 
57 #include <sstream>
58 
59 #include "N_NLS_NOX_Interface.h"
60 #include "N_NLS_NOX_SharedSystem.h"
61 #include "N_NLS_NOX_Group.h"
62 #include "N_NLS_LOCA_Group.h"
63 #include "LOCA_GlobalData.H"
64 #include "LOCA_StatusTest_Wrapper.H"
65 #include "NOX_Solver_Factory.H"
66 
69 
70 #include "N_NLS_NOX_XyceTests.h"
72 #include "N_LAS_Solver.h"
73 #include "N_LAS_Builder.h"
74 #include "N_LAS_System.h"
75 #include "N_LAS_QueryUtil.h"
76 #include "N_LOA_Loader.h"
77 #include "N_IO_CmdParse.h"
78 #include "N_IO_OutputMgr.h"
79 #include "N_ANP_AnalysisManager.h"
80 #include <N_ERH_ErrorMgr.h>
81 
82 #ifdef Xyce_PARALLEL_MPI
83 #include <N_PDS_ParComm.h>
84 #else
85 #include <N_PDS_SerialComm.h>
86 #endif
87 
88 
89 // ---------- NOX Includes ----------
90 #include <LOCA.H>
91 
92 // ----------- Forward declarations -------
93 namespace N_NLS_NOX {
94 
95 //-----------------------------------------------------------------------------
96 // Function : N_NLS_NOX::Interface::Interface
97 // Purpose : constructor
98 // Special Notes :
99 // Scope : public
100 // Creator :
101 // Creation Date :
102 //-----------------------------------------------------------------------------
103 Interface::Interface(N_IO_CmdParse & cp) :
105  dcParams_(Xyce::Nonlinear::DC_OP),
106  transientParams_(Xyce::Nonlinear::TRANSIENT),
107  hbParams_(Xyce::Nonlinear::HB_MODE),
108  sharedSystemPtr_(0),
109  mode_(Xyce::Nonlinear::DC_OP),
110  lastParametersMode_(Xyce::Nonlinear::DC_OP),
111  parametersMode_(Xyce::Nonlinear::DC_OP),
112  usemode_(true),
113  copiedGroupFlag_(false),
114  DCOPused_(false),
115  ICspecified_(false),
116  NODESETspecified_(false),
117  isFirstContinuationParam_(true),
118  firstSolveComplete_(false),
119  iParam_(0)
120 {
121 }
122 
123 //-----------------------------------------------------------------------------
124 // Function : N_NLS_NOX::Interface::~Interface
125 // Purpose : destructor
126 // Special Notes :
127 // Scope : public
128 // Creator :
129 // Creation Date :
130 //-----------------------------------------------------------------------------
132 {
133  delete sharedSystemPtr_;
134  if (!Teuchos::is_null(globalDataPtr_))
135  {
136  LOCA::destroyGlobalData(globalDataPtr_);
137  }
138 }
139 
140 //-----------------------------------------------------------------------------
141 // Function : N_NLS_NOX::Interface::setOptions
142 // Purpose : Passes option block corresponding to "NONLIN" onto
143 // nonlinear solver. These parameters set convergence
144 // tolerances, the type of method used, and so on.
145 // Special Notes :
146 // Return Type : boolean
147 //
148 // See also : setTranOptions, setAnalysisMode
149 //
150 // - Input Arguments -
151 //
152 // OB : Option block containing options corresponding to
153 // "NONLIN" in the netlist.
154 // Scope : public
155 // Creator :
156 // Creation Date :
157 //-----------------------------------------------------------------------------
158 bool Interface::setOptions(const N_UTL_OptionBlock& OB)
159 {
160  return dcParams_.setOptions(OB);
161 }
162 
163 
164 //-----------------------------------------------------------------------------
165 // Function : N_NLS_NOX::Interface::setTranOptions
166 //
167 // Purpose : Passes option block corresponding to "NONLIN-TRAN" onto
168 // nonlinear solver. This affects the settings used when
169 // the mode is Transient.
170 //
171 // Special Notes :
172 // Return Type : boolean
173 //
174 // See also : setOptions, setAnalysisMode
175 //
176 // - Input Arguments -
177 // OB : Option block containing options corresponding to
178 // "NONLIN-TRAN" in the netlist.
179 // Scope : public
180 // Creator :
181 // Creation Date :
182 //-----------------------------------------------------------------------------
183 bool Interface::setTranOptions(const N_UTL_OptionBlock& OB)
184 {
185  return transientParams_.setOptions(OB);
186 }
187 
188 //-----------------------------------------------------------------------------
189 // Function : N_NLS_NOX::Interface::setHBOptions
190 // Purpose :
191 // Scope : public
192 // Creator :
193 // Creation Date :
194 //-----------------------------------------------------------------------------
195 bool Interface::setHBOptions(const N_UTL_OptionBlock& OB)
196 {
197  return hbParams_.setOptions(OB);
198 }
199 
200 
201 //-----------------------------------------------------------------------------
202 // Function : N_NLS_NOX::Interface::setLocaOptions
203 // Purpose :
204 // Special Notes :
205 // Scope : public
206 // Creator :
207 // Creation Date :
208 //-----------------------------------------------------------------------------
209 bool Interface::setLocaOptions(const N_UTL_OptionBlock& OB)
210 {
211  return dcParams_.setLocaOptions(OB);
212 }
213 
214 //-----------------------------------------------------------------------------
215 // Function : N_NLS_NOX::Interface::setDCOPRestartOptions
216 // Purpose :
217 // Special Notes :
218 // Scope : public
219 // Creator :
220 // Creation Date :
221 //-----------------------------------------------------------------------------
222 bool Interface::setDCOPRestartOptions(const N_UTL_OptionBlock& OB)
223 {
224  DCOPspecified_ = true;
225  return true;
226 }
227 
228 //-----------------------------------------------------------------------------
229 // Function : N_NLS_NOX::Interface::setICOptions
230 // Purpose :
231 // Special Notes :
232 // Scope : public
233 // Creator :
234 // Creation Date :
235 //-----------------------------------------------------------------------------
236 bool Interface::setICOptions(const N_UTL_OptionBlock& OB)
237 {
238  ICspecified_ = true;
239  return true;
240 }
241 
242 //-----------------------------------------------------------------------------
243 // Function : N_NLS_NOX::Interface::setNodeSetOptions
244 // Purpose :
245 // Special Notes :
246 // Scope : public
247 // Creator :
248 // Creation Date :
249 //-----------------------------------------------------------------------------
250 bool Interface::setNodeSetOptions(const N_UTL_OptionBlock& OB)
251 {
252  NODESETspecified_ = true;
253  return true;
254 }
255 
256 //-----------------------------------------------------------------------------
257 // Function : N_NLS_NOX::Interface::initializeAll
258 //
259 // Purpose : Called after all register and set functions.
260 // Once the various registrations have taken place,
261 // this function sets the remaining pointers.
262 //
263 // Special Notes :
264 // Derived Notes : This function also calls the base object initializeAll.
265 //
266 // Special Notes: This function obtains the solution, temporary solution and
267 // f vectors from the LAS system class.
268 //
269 // Return Type : boolean
270 // Scope : public
271 // Creator : Eric Keiter
272 // Creation Date :
273 //-----------------------------------------------------------------------------
275 {
276  // Use the base class initialization
277  bool initok = N_NLS_NonLinearSolver::initializeAll();
278  if (!initok)
279  {
280  return false;
281  }
282 
283  // Set the processor ID for printing in the nonlinear solver
284  // For now, processor 0 will output information to the screen
285  //int myPID = ((**nextSolVectorPtrPtr_).epetraObj()).Comm().MyPID();
286  int myPID = pdsMgrPtr_->getPDSComm()->procID();
287  dcParams_.setOutputOptions(myPID, 0);
289 
290  // get var type list
291  std::vector<char> varTypeVec;
292 #if 0
293  topologyRcp_->returnVarTypeVec( varTypeVec );
294 #endif
295  hbParams_.setOutputOptions(myPID, 0);
296 
297  // Set up the status tests
298 #ifdef Xyce_NLS_MASKED_WRMS_NORMS
299  bool testsok =
301  lasSysPtr_->getNonTrivialDeviceMaskFlag(), lasSysPtr_->getDeviceMaskVector()) &&
303  lasSysPtr_->getNonTrivialDeviceMaskFlag(), lasSysPtr_->getDeviceMaskVector()) &&
305  lasSysPtr_->getNonTrivialDeviceMaskFlag(), lasSysPtr_->getDeviceMaskVector());
306 #else
307  bool testsok =
311 #endif
312 
313  if (!testsok)
314  return false;
315 
316  // Set up any linear solver options
317  // We only set the tolerance if adaptive forcing is being used.
318  setAZ_Tol_DC = false;
319  setAZ_Tol_Transient = false;
320  if (!(dcParams_.getNoxParams()->sublist("Direction").sublist("Newton")
321  .get("Forcing Term Method","Constant") == std::string("Constant")))
322  {
323  setAZ_Tol_DC = true;
324  //Xyce::dout() << "NOX is overriding DC LS tol." << std::endl;
325  }
326  if (!(transientParams_.getNoxParams()->sublist("Direction").sublist("Newton")
327  .get("Forcing Term Method", "Constant") == std::string("Constant")))
328  {
329  setAZ_Tol_Transient = true;
330  //Xyce::dout() << "NOX is overriding Transient LS tol." << std::endl;
331  }
332  if (!(hbParams_.getNoxParams()->sublist("Direction").sublist("Newton")
333  .get("Forcing Term Method", "Constant") == std::string("Constant")))
334  {
335  setAZ_Tol_Transient = true;
336  //Xyce::dout() << "NOX is overriding Transient LS tol." << std::endl;
337  }
338 
339  return true;
340 }
341 
342 //-----------------------------------------------------------------------------
343 // Function : N_NLS_NOX::Interface::spiceStrategy
344 //
345 // Purpose : This function attempts a stdNewton solve first, and if that
346 // fails then does gmin stepping. This is only done for DCOP
347 // calculations.
348 //
349 // Special Notes :
350 // Scope : public
351 // Creator : Eric Keiter
352 // Creation Date : 5/7/2014
353 //-----------------------------------------------------------------------------
355 {
356  groupPtr_->setNonContinuationFlag (true);
357  int isuccess = stdNewtonSolve (paramsPtr);
358 
359  if (isuccess < 0) // attempt gmin stepping.
360  {
361  paramsPtr->setNoxSolverType(3);
362  groupPtr_->setNonContinuationFlag (false);
363 
364  rhsVectorPtr_->putScalar(0.0);
365  NewtonVectorPtr_->putScalar(0.0);
366  gradVectorPtr_->putScalar(0.0);
367  (*nextSolVectorPtrPtr_)->putScalar(0.0);
368 
370  groupPtr_->setX(tmpVec);
371 
373  *rhsVectorPtr_,
377  *lasSysPtr_,
378  *this);
379 
380  return gminSteppingSolve ( paramsPtr );
381  }
382  else
383  {
384  return isuccess;
385  }
386 }
387 
388 //-----------------------------------------------------------------------------
389 // Function : N_NLS_NOX::Interface::stdNewtonSolve
390 // Purpose :
391 // Special Notes : This corresponds to
392 // .options nonlin continuation=stan or
393 // .options nonlin continuation=0
394 // Scope : public
395 // Creator : Roger Pawlowski, Eric Keiter
396 // Creation Date :
397 //-----------------------------------------------------------------------------
399 {
400  bool usedIC=false;
401  bool usedNODESET=false;
402  bool usedOP=false;
403 
404  // RPP: needed for tensor method. DO NOT UNCOMMENT!
405  // This somehow breaks the one-shot test circuit.
406  // ERK: it breaks it (and probably many other circuits) b/c voltage
407  // limiting is fragile and cannot handle extra (unexpected)
408  // F-loads.
409  //groupPtr_->computeF();
410 
411  // Set up nox nonlinear solver. solverPtr is only needed for
412  // non-LOCA (i.e. just Newton's method, no continuation) solves.
413  if (Teuchos::is_null(solverPtr_))
414  {
415 #ifdef Xyce_DEBUG_NONLINEAR
416  Xyce::dout() << "Creating new NLS solver b/c it is 0." <<std::endl;
417 #endif
418  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
419  paramsPtr->getStatusTests(),
420  paramsPtr->getNoxParams());
421 
422  // If .IC, .NODESET or .OP have been specified, then set up the
423  // augmented linear systems
425  {
426  if (ICspecified_)
427  {
428  usedIC=icCont (paramsPtr);
429  }
430  else if (NODESETspecified_)
431  {
432  usedNODESET=nodesetCont0 (paramsPtr);
433  }
434  else
435  {
436  usedOP = opStartCont0 (paramsPtr);
437  }
438  }
439  }
440  else if ((usemode_) && (lastParametersMode_ != parametersMode_))
441  {
442 #ifdef Xyce_DEBUG_NONLINEAR
443  Xyce::dout() << "Creating new NLS solver b/c starting next phase, post-DC." <<std::endl;
444 #endif
445  // Create a new solver for the next phase of the simulation.
446  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
447  paramsPtr->getStatusTests(),
448  paramsPtr->getNoxParams());
449  }
450  else // solverPtr is not null, and the mode didn't change since last call.
451  {
452 #ifdef Xyce_DEBUG_NONLINEAR
453  Xyce::dout() << "NOT Creating new NLS solver, just resetting." <<std::endl;
454 #endif
455  solverPtr_->reset(groupPtr_->getX());
456  }
457 
458  NOX::StatusTest::StatusType status = solverPtr_->solve();
459  firstSolveComplete_ = true;
460 
461  if (usedIC)
462  {
463  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> alsNull; // 0
464  groupPtr_->setAugmentLinearSystem(false, alsNull);
465  }
466  // Send back the correct return code
467 #ifdef Xyce_DEBUG_NONLINEAR
468  Xyce::dout() << "return code for transient params: " << transientParams_.getStatusTestReturnCode() <<std::endl;;
469  Xyce::dout() << "return code for hb params: " << hbParams_.getStatusTestReturnCode() << std::endl;
470  Xyce::dout() << "return code for dc params: " << dcParams_.getStatusTestReturnCode () <<std::endl;
471 #endif
472  return (paramsPtr->getStatusTestReturnCode());
473 }
474 
475 //-----------------------------------------------------------------------------
476 // Function : N_NLS_NOX::Interface::naturalParameterContinuationSolve
477 // Purpose :
478 // Special Notes : This corresponds to
479 // .options nonlin continuation=nat or
480 // .options nonlin continuation=1
481 // Scope : public
482 // Creator : Roger Pawlowski, Eric Keiter
483 // Creation Date :
484 //-----------------------------------------------------------------------------
486 {
487  std::vector<std::string> pars;
488  std::string con;
489  int j, numParam = 0;
490  double value;
491  bool usedOP=false;
492  bool usedNODESET=false;
493  bool usedIC=false;
494 
496  {
497  if (ICspecified_)
498  {
499  usedIC=icCont (paramsPtr);
500  }
501  else if (NODESETspecified_)
502  {
503  usedNODESET=nodesetCont1 (paramsPtr);
504  }
505  else
506  {
507  usedOP = opStartCont1 (paramsPtr);
508  }
509  }
510 
511  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList =
512  paramsPtr->getLocaParams();
513 
514  // Create Parameter Vector and get the stepper parameter list.
515  LOCA::ParameterVector locaPVec;
516  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
517  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
518 
519  while (paramsPtr->getVectorParam("CONPARAM", numParam, con))
520  {
521  pars.push_back(con);
522  numParam++;
523  }
524 
525  // Fail out if no parameters have been specified.
526  if ( numParam == 0 ) {
527  std::string message = "Using \"continuation=1\" requires a parameter to be set with the conparam keyword in the loca option block!";
528  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_FATAL, message);
529  }
530 
531  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als;
532  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> alsNull; // 0
533 
534  std::vector<double> minValue(numParam, 0.);
535  std::vector<double> maxValue(numParam, 0.);
536  std::vector<double> initialValue(numParam, 0.);
537  std::vector<double> initialStepSize(numParam, 0.);
538  std::vector<double> minStepSize(numParam, 0.);
539  std::vector<double> maxStepSize(numParam, 0.);
540  std::vector<double> aggressiveness(numParam, 0.);
541 
542  // Check the size of params to make sure users provided all required data
543  std::vector<std::string> paramNames(0);
544  paramNames.push_back("MINVALUE");
545  paramNames.push_back("MAXVALUE");
546  paramNames.push_back("INITIALVALUE");
547  paramNames.push_back("INITIALSTEPSIZE");
548  paramNames.push_back("MINSTEPSIZE");
549  paramNames.push_back("MAXSTEPSIZE");
550  paramNames.push_back("AGGRESSIVENESS");
551 
552  for (std::size_t p = 0 ; p < paramNames.size() ; ++p) {
553  if ( paramsPtr->getVectorParamSize(paramNames[p]) != numParam) {
554  std::string msg = "The parameter \"" +
555  paramNames[p] +
556  "\" must have a list of values with size equal to the numParamber of parameters specified in \"conparam\".";
557  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, msg);
558  }
559  }
560 
561  for (iParam_=0 ; iParam_<numParam ; ++iParam_)
562  {
563  paramsPtr->getVectorParam("MINVALUE", iParam_, value);
564  minValue[iParam_] = value;
565 
566  paramsPtr->getVectorParam("MAXVALUE", iParam_, value);
567  maxValue[iParam_] = value;
568 
569  paramsPtr->getVectorParam("INITIALVALUE", iParam_, value);
570  initialValue[iParam_] = value;
571 
572  paramsPtr->getVectorParam("INITIALSTEPSIZE", iParam_, value);
573  initialStepSize[iParam_] = value;
574 
575  paramsPtr->getVectorParam("MINSTEPSIZE", iParam_, value);
576  minStepSize[iParam_] = value;
577 
578  paramsPtr->getVectorParam("MAXSTEPSIZE", iParam_, value);
579  maxStepSize[iParam_] = value;
580 
581  paramsPtr->getVectorParam("AGGRESSIVENESS", iParam_, value);
582  aggressiveness[iParam_] = value;
583 
584  locaPVec.addParameter (pars[iParam_], initialValue[iParam_]);
585 
586  }
587 
588  if (usedOP || usedNODESET)
589  {
590  const N_NLS_LOCA::Group & conLocaGrp =
591  dynamic_cast<const N_NLS_LOCA::Group&>(solverPtr_->getSolutionGroup());
592  *groupPtr_ = const_cast<N_NLS_LOCA::Group&>(conLocaGrp);
593  solverPtr_ = Teuchos::null;
594  }
595 
596  groupPtr_->setParams(locaPVec);
597 
598  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
599 
600  for (iParam_=0 ; iParam_<numParam ; ++iParam_)
601  {
602  // Copy out the solution and use it in the next run
603  if (iParam_ > 0)
604  {
605  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
606  }
607 
608  stepperList.set("Continuation Parameter", pars[iParam_]);
609  stepperList.set("Initial Value", initialValue[iParam_]);
610  stepperList.set("Max Value", maxValue[iParam_]);
611  stepperList.set("Min Value", minValue[iParam_]);
612  stepSizeList.set("Initial Step Size", initialStepSize[iParam_]);
613  stepSizeList.set("Min Step Size", minStepSize[iParam_]);
614  stepSizeList.set("Max Step Size", maxStepSize[iParam_]);
615  stepSizeList.set("Aggressiveness", aggressiveness[iParam_]);
616 
617  for (j=0 ; j<iParam_ ; ++j)
618  {
619  locaPVec.setValue(pars[j], maxValue[j]);
620  }
621  for (j=iParam_ ; j<numParam ; ++j)
622  {
623  locaPVec.setValue(pars[j], initialValue[j]);
624  }
625  groupPtr_->setParams(locaPVec);
626 
627  if (iParam_==0)
628  {
629  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
630  {
631  groupPtr_->computeF();
632  }
633  }
634 
635  // RPP 03/08/2006 If this is a special parameter used in voltage
636  // node resistance (Spice's GMIN stepping) then we need to
637  // intercept and handle the parameter in the solver (in the LOCA
638  // Group) - the device package does nothing for this parameter.
639  if (pars[iParam_] != "GSTEPPING")
640  {
641  // Do the continuation run
643  locaStatus = stepperPtr_->run();
644  if (usedIC || usedNODESET)
645  {
646  groupPtr_->setAugmentLinearSystem(false, alsNull);
647  }
648  }
649  else
650  {
651  if (iParam_ == 0 && DCOPused_)
652  {
653  std::string message = "'.dcop input=' and gstepping are incompatible";
654  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_FATAL, message);
655  }
656  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
658  groupPtr_->setAugmentLinearSystem(true, als);
659 
660  // Do the continuation run
662  locaStatus = stepperPtr_->run();
663 
664  groupPtr_->setAugmentLinearSystem(false, alsNull);
665  }
666 
667  // Kick out if continuation failed
668  if (locaStatus != LOCA::Abstract::Iterator::Finished)
669  return (-1);
670 
671  // Increment Param Number Tracking
673  firstSolveComplete_ = true;
674  }
675  return (paramsPtr->getStatusTestReturnCode());
676 }
677 
678 //-----------------------------------------------------------------------------
679 // Function : N_NLS_NOX::Interface::mosfetContinuationSolve
680 // Purpose :
681 // Special Notes : This corresponds to
682 // .options nonlin continuation=mos or
683 // .options nonlin continuation=2
684 // Scope : public
685 // Creator : Roger Pawlowski, Eric Keiter
686 // Creation Date :
687 //-----------------------------------------------------------------------------
689 {
690  bool usedOP=false;
691  bool usedNODESET=false;
692  bool usedIC=false;
693  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> alsNull; // 0
694 
696  {
697  if (ICspecified_)
698  {
699  usedIC=icCont (paramsPtr);
700  }
701  else if (NODESETspecified_)
702  {
703  usedNODESET=nodesetCont1 (paramsPtr);
704  }
705  else
706  {
707  usedOP = opStartCont1 (paramsPtr);
708  }
709  }
710 
711  // check if use specified vector params. If so, flag a warning.
712  std::vector<std::string> pars;
713  std::string con;
714  int numParam;
715  while (paramsPtr->getVectorParam("CONPARAM", numParam, con))
716  {
717  pars.push_back(con);
718  numParam++;
719  }
720 
721  if ( numParam > 1 ) {
722  std::string message = "WARNING: Using \"continuation=2\" currently does not support vectorized loca parameters. Only the first values in each list will be used.";
723  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING, message);
724  }
725 
726  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
727 
728  // Create the continuation parameter names
729  std::string gain = "mosfet:gainscale";
730  std::string nonlinear = "mosfet:nltermscale";
731 
732  // Create Parameter Vector and get the stepper parameter list.
733  LOCA::ParameterVector locaPVec;
734  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
735  Teuchos::ParameterList& predictorList = locaList->sublist("Predictor");
736  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
737 
738  // Continuation solve from alpha2 (gain) = 0.0 -> 1.0
739  // with alpha1 (nlterm) = 0.0 (constant)
740  locaPVec.addParameter(gain, 0.0);
741  locaPVec.addParameter(nonlinear, 0.0);
742  groupPtr_->setParams(locaPVec);
743  stepperList.set("Continuation Parameter", gain);
744 
745  stepperList.set("Initial Value", 0.0);
746  stepperList.set("Max Value", 1.0);
747  stepperList.set("Min Value",-1.0);
748 
749  stepSizeList.set("Initial Step Size", 0.2);
750  stepSizeList.set("Min Step Size", 1.0e-4);
751  stepSizeList.set("Max Step Size", 1.0);
752  stepSizeList.set("Aggressiveness", 1.0);
753 
754  // assert the user-specified defaults, if any.
756 
757  // Initialize parameters in xyce
758  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
759  {
760  groupPtr_->computeF();
761  }
762 
763  // Do the continuation run
764  iParam_ = 0;
766  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
767 
768  // Kick out if continuation failed
769  if (locaStatus != LOCA::Abstract::Iterator::Finished)
770  return (-1);
771 
772  // Increment Param Number Tracking
774  firstSolveComplete_ = true;
775 
776  // Copy out the solution and use it in the next run
777  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
778 
779  // Continuation solve from alpha1 (nlterm) = 0.0 -> 1.0
780  // with alpha2 (gain) = 1.0 (constant)
781  stepperList.set("Continuation Parameter", nonlinear);
782 
783  stepperList.set("Initial Value", 0.0);
784  stepperList.set("Max Value", 1.0);
785  stepperList.set("Min Value",-1.0);
786 
787  stepSizeList.set("Initial Step Size", 0.2);
788  stepSizeList.set("Min Step Size", 1.0e-4);
789  stepSizeList.set("Max Step Size", 1.0);
790  stepSizeList.set("Aggressiveness", 1.0);
791 
792  // assert the user-specified defaults, if any.
794 
795  locaPVec.setValue(gain, 1.0);
796  locaPVec.setValue(nonlinear, 0.0);
797  groupPtr_->setParams(locaPVec);
798 
799  // Do the continuation run
800  iParam_ = 1;
802  locaStatus = stepperPtr_->run();
803 
804  if (usedIC)
805  {
806  groupPtr_->setAugmentLinearSystem(false, alsNull);
807  }
808 
809  // Return the solution status
810  if (locaStatus != LOCA::Abstract::Iterator::Finished)
811  return (-1);
812  else
813  return (paramsPtr->getStatusTestReturnCode());
814 }
815 
816 //-----------------------------------------------------------------------------
817 // Function : N_NLS_NOX::Interface::mosfetContinuationSolve2
818 // Purpose :
819 // Return Type :
820 // Special Notes : This corresponds to
821 // .options nonlin continuation=newmos or
822 // .options nonlin continuation=4
823 // Scope : public
824 // Creator : Roger Pawlowski, Eric Keiter
825 // Creation Date : 2/21/2004
826 //-----------------------------------------------------------------------------
828 {
829  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
830 
831  // Create the continuation parameter names
832  std::string gain = "mosfet:gainscale";
833  std::string nonlinear = "mosfet:nltermscale";
834  std::string size = "mosfet:sizescale";
835 
836  // Create Parameter Vector and get the stepper parameter list.
837  LOCA::ParameterVector locaPVec;
838  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
839 
840  // Continuation solve from alpha2 (gain) = 0.0 -> 1.0
841  // with alpha1 (nlterm) = 0.0 (constant)
842  // sizeScale = 0.0 (constant)
843  locaPVec.addParameter(gain, 0.0);
844  locaPVec.addParameter(nonlinear, 0.0);
845  locaPVec.addParameter(size, 0.0);
846  groupPtr_->setParams(locaPVec);
847  stepperList.set("Continuation Parameter", gain);
848  stepperList.set("Initial Value", 0.0);
849  stepperList.set("Max Value", 1.0);
850 
851  // Initialize parameters in xyce
852  groupPtr_->computeF();
853 
854  // Do the continuation run
856  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
857 
858  // Kick out if continuation failed
859  if (locaStatus != LOCA::Abstract::Iterator::Finished)
860  return (-1);
861 
862  // Increment Param Number Tracking
864  firstSolveComplete_ = true;
865 
866  // Copy out the solution and use it in the next run
867  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
868 
869  // Continuation solve from alpha1 (nlterm) = 0.0 -> 1.0
870  // with alpha2 (gain) = 1.0 (constant)
871  // with size (scale) = 0.0 (constant)
872  stepperList.set("Continuation Parameter", nonlinear);
873  stepperList.set("Initial Value", 0.0);
874  stepperList.set("Max Value", 1.0);
875  locaPVec.setValue(gain, 1.0);
876  locaPVec.setValue(nonlinear, 0.0);
877  locaPVec.setValue(size, 0.0);
878  groupPtr_->setParams(locaPVec);
879 
880  // Do the continuation run
882  locaStatus = stepperPtr_->run();
883 
884  // Kick out if continuation failed
885  if (locaStatus != LOCA::Abstract::Iterator::Finished)
886  return (-1);
887 
888  // Copy out the solution and use it in the next run
889  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
890 
891  // Continuation solve from alpha1 (nlterm) = 1.0 -> 1.0
892  // with alpha2 (gain) = 1.0 (constant)
893  // with size (scale) = 0.0 -> 1.0
894  stepperList.set("Continuation Parameter", size);
895  stepperList.set("Initial Value", 0.0);
896  stepperList.set("Max Value", 1.0);
897  locaPVec.setValue(gain, 1.0);
898  locaPVec.setValue(nonlinear, 1.0);
899  locaPVec.setValue(size, 0.0);
900  groupPtr_->setParams(locaPVec);
901 
902  // Do the continuation run
904  locaStatus = stepperPtr_->run();
905 
906  // Return the solution status
907  if (locaStatus != LOCA::Abstract::Iterator::Finished)
908  return (-1);
909  else
910  return (paramsPtr->getStatusTestReturnCode());
911 }
912 
913 //-----------------------------------------------------------------------------
914 // Function : N_NLS_NOX::Interface::mosfetContinuationSolve3
915 // Purpose : (5) Mosfet:BSIM3:Inverter specific continuation
916 // Special Notes : This corresponds to
917 // .options nonlin continuation=bsim3inv1 or
918 // .options nonlin continuation=5
919 // Scope : public
920 // Creator : Roger Pawlowski, Eric Keiter
921 // Creation Date : 2/25/2004
922 //-----------------------------------------------------------------------------
924 {
925  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
926 
927  // Create the continuation parameter names
928  //std::string gain = "mosfet:gainscale";
929  std::string nonlinear = "mosfet:nltermscale";
930  std::string size = "mosfet:sizescale";
931 
932  // Create Parameter Vector and get the stepper parameter list.
933  LOCA::ParameterVector locaPVec;
934  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
935 
936  // Continuation solve from alpha2 (gain) = 0.0 -> 1.0
937  // with alpha1 (nlterm) = 0.0 (constant)
938  // sizeScale = 0.0 (constant)
939  //locaPVec.addParameter(gain, 0.0);
940  locaPVec.addParameter(nonlinear, 0.0);
941  locaPVec.addParameter(size, 0.0);
942  groupPtr_->setParams(locaPVec);
943  stepperList.set("Continuation Parameter", nonlinear);
944  stepperList.set("Initial Value", 0.0);
945  stepperList.set("Max Value", 1.0);
946 
947  // Initialize parameters in xyce
948  groupPtr_->computeF();
949 
950  // Do the continuation run
952  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
953 
954  // Kick out if continuation failed
955  if (locaStatus != LOCA::Abstract::Iterator::Finished)
956  return (-1);
957 
958  // Increment Param Number Tracking
960  firstSolveComplete_ = true;
961 
962  // Copy out the solution and use it in the next run
963  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
964 
965  // Continuation solve from alpha1 (nlterm) = 0.0 -> 1.0
966  // with alpha2 (gain) = 1.0 (constant)
967  // with size (scale) = 0.0 (constant)
968  stepperList.set("Continuation Parameter", size);
969  stepperList.set("Initial Value", 0.0);
970  stepperList.set("Max Value", 1.0);
971  //locaPVec.setValue(gain, 1.0);
972  locaPVec.setValue(nonlinear, 1.0);
973  locaPVec.setValue(size, 0.0);
974  groupPtr_->setParams(locaPVec);
975 
976  // Do the continuation run
978  locaStatus = stepperPtr_->run();
979 
980  // Return the solution status
981  if (locaStatus != LOCA::Abstract::Iterator::Finished)
982  return (-1);
983  else
984  return (paramsPtr->getStatusTestReturnCode());
985 }
986 
987 //-----------------------------------------------------------------------------
988 // Function : N_NLS_NOX::Interface::mosfetContinuationSolve4
989 // Purpose : (6) Mosfet:BSIM3:Inverter specific continuation
990 // Special Notes : This corresponds to
991 // .options nonlin continuation=bsim3inv2 or
992 // .options nonlin continuation=6
993 // Scope : public
994 // Creator : Roger Pawlowski, Eric Keiter
995 // Creation Date : 2/25/2004
996 //-----------------------------------------------------------------------------
998 {
999  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1000 
1001  // Create the continuation parameter names
1002  std::string gain = "mosfet:gainscale";
1003  std::string nonlinear = "mosfet:nltermscale";
1004  std::string size = "mosfet:sizescale";
1005 
1006  // Create Parameter Vector and get the stepper parameter list.
1007  LOCA::ParameterVector locaPVec;
1008  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1009 
1010  // Continuation solve
1011  locaPVec.addParameter(gain, 1.0);
1012  locaPVec.addParameter(nonlinear, 1.0);
1013  locaPVec.addParameter(size, 0.0);
1014  groupPtr_->setParams(locaPVec);
1015  stepperList.set("Continuation Parameter", size);
1016  stepperList.set("Initial Value", 0.0);
1017  stepperList.set("Max Value", 1.0);
1018 
1019  // Initialize parameters in xyce
1020  groupPtr_->computeF();
1021 
1022  // Do the continuation run
1024  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1025 
1026  // Return the solution status
1027  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1028  return (-1);
1029  else
1030  {
1031  firstSolveComplete_ = true;
1032  return (paramsPtr->getStatusTestReturnCode());
1033  }
1034 }
1035 
1036 //-----------------------------------------------------------------------------
1037 // Function : N_NLS_NOX::Interface::mosfetContinuationSolve5
1038 // Purpose :
1039 // Return Type :
1040 // Special Notes : This corresponds to
1041 // .options nonlin continuation=test or
1042 // .options nonlin continuation=8
1043 // Scope : public
1044 // Creator : Roger Pawlowski, Eric Keiter
1045 // Creation Date : 2/25/2004
1046 //-----------------------------------------------------------------------------
1048 {
1049  // Get some initial objects
1050  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1051  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1052  LOCA::ParameterVector locaPVec;
1053 
1054  // Create storage for continuation objects
1055  int numHomotopyContinuationRuns = 1;
1056  std::vector<std::string> names(numHomotopyContinuationRuns);
1057  std::vector<double> initialVal(numHomotopyContinuationRuns);
1058  std::vector<double> finalVal(numHomotopyContinuationRuns);
1059  std::vector<double> minVal(numHomotopyContinuationRuns);
1060  std::vector<double> maxVal(numHomotopyContinuationRuns);
1061 
1062  // Set up continuation steps
1063  // ***************************************************
1064  // Changes vals below for continuation
1065  // ***************************************************
1066  names[0] = "mosfet:gainscale";
1067  //names[1] = "mosfet:nltermscale";
1068  //names[2] = "mosfet:sizescale";
1069  //names[2] = "mosfet:l";
1070  initialVal[0] = 0.0;
1071  //initialVal[1] = 0.0;
1072  //initialVal[2] = 0.0;
1073  finalVal[0] = 1.0;
1074  //finalVal[1] = 1.0;
1075  //finalVal[2] = 1.0;
1076  // ***************************************************
1077  std::string n1 = "mosfet:nltermscale";
1078  locaPVec.addParameter(n1, 0.0);
1079  //std::string n2 = "mosfet:sizescale";
1080  //locaPVec.addParameter(n2, 0.0);
1081  // ***************************************************
1082  // ***************************************************
1083 
1084  // Ste up max/min bounds
1085  for (int i = 0; i < names.size(); ++i) {
1086  if (finalVal[i] > initialVal[i]) {
1087  minVal[i] = initialVal[i];
1088  maxVal[i] = finalVal[i];
1089  }
1090  else {
1091  minVal[i] = finalVal[i];
1092  maxVal[i] = initialVal[i];
1093  }
1094  }
1095 
1096  // Initialize loca parameter vector
1097  for (int i = 0; i < names.size(); ++i)
1098  locaPVec.addParameter(names[i], initialVal[i]);
1099 
1100  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
1101 
1102  LOCA::StatusTest::Wrapper test(paramsPtr->getStatusTests());
1103 
1104  // Loop over the number of homotopy steps
1105  for (int hs = 0; hs < names.size(); ++hs) {
1106  for (int i = 0; i < names.size(); ++i) {
1107  if (i >= hs)
1108  locaPVec.setValue(names[i], initialVal[i]);
1109  else
1110  locaPVec.setValue(names[i], finalVal[i]);
1111  }
1112  groupPtr_->setParams(locaPVec);
1113  stepperList.set("Continuation Parameter", names[hs]);
1114  stepperList.set("Initial Value", initialVal[hs]);
1115  stepperList.set("Min Value", minVal[hs]);
1116  stepperList.set("Max Value", maxVal[hs]);
1117 
1118  // Initialize parameters in xyce
1119  groupPtr_->computeF();
1120 
1121  // Do the continuation run
1123  locaStatus = stepperPtr_->run();
1124 
1125  // Kick out if continuation failed
1126  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1127  return (-1);
1128 
1129  // Increment Param Number Tracking
1130  isFirstContinuationParam_ = false;
1131  firstSolveComplete_ = true;
1132 
1133  // Copy out the solution and use it in the next run
1134  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1135  }
1136 
1137  // Return converged solver code
1138  return (paramsPtr->getStatusTestReturnCode());
1139 }
1140 
1141 //-----------------------------------------------------------------------------
1142 // Function : N_NLS_NOX::Interface::mosfetContinuationSolve6
1143 // Purpose :
1144 // Special Notes : This corresponds to
1145 // .options nonlin continuation=power or
1146 // .options nonlin continuation=10
1147 // Scope : public
1148 // Creator : Roger Pawlowski, Eric Keiter
1149 // Creation Date : 2/25/2004
1150 //-----------------------------------------------------------------------------
1152 {
1153  // Get some initial objects
1154  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1155  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1156  LOCA::ParameterVector locaPVec;
1157 
1158  // Create storage for continuation objects
1159  int numHomotopyContinuationRuns = 4;
1160  std::vector<std::string> names(numHomotopyContinuationRuns);
1161  std::vector<double> initialVal(numHomotopyContinuationRuns);
1162  std::vector<double> finalVal(numHomotopyContinuationRuns);
1163  std::vector<double> minVal(numHomotopyContinuationRuns);
1164  std::vector<double> maxVal(numHomotopyContinuationRuns);
1165 
1166  // Set up continuation steps
1167  // ***************************************************
1168  // Changes vals below for continuation
1169  // ***************************************************
1170  names[0] = stepperList.get("Power Node", "VA:V0");
1171  names[1] = "mosfet:gainscale";
1172  names[2] = "mosfet:nltermscale";
1173  names[3] = "mosfet:sizescale";
1174  initialVal[0] = 0.0;
1175  initialVal[1] = 0.0;
1176  initialVal[2] = 0.0;
1177  initialVal[3] = 0.0;
1178  finalVal[0] = 1.0;
1179  finalVal[1] = 1.0;
1180  finalVal[2] = 1.0;
1181  finalVal[3] = 1.0;
1182  // ***************************************************
1183  //std::string n1 = "mosfet:nltermscale";
1184  //locaPVec.addParameter(n1, 0.0);
1185  //std::string n2 = "mosfet:sizescale";
1186  //locaPVec.addParameter(n2, 0.0);
1187  // ***************************************************
1188  // ***************************************************
1189 
1190  // Set up max/min bounds
1191  for (int i = 0; i < names.size(); ++i) {
1192  if (finalVal[i] > initialVal[i]) {
1193  minVal[i] = initialVal[i];
1194  maxVal[i] = finalVal[i];
1195  }
1196  else {
1197  minVal[i] = finalVal[i];
1198  maxVal[i] = initialVal[i];
1199  }
1200  }
1201 
1202  // Initialize loca parameter vector
1203  for (int i = 0; i < names.size(); ++i)
1204  locaPVec.addParameter(names[i], initialVal[i]);
1205 
1206  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
1207 
1208  // Loop over the number of homotopy steps
1209  for (int hs = 0; hs < names.size(); ++hs) {
1210  for (int i = 0; i < names.size(); ++i) {
1211  if (i >= hs)
1212  locaPVec.setValue(names[i], initialVal[i]);
1213  else
1214  locaPVec.setValue(names[i], finalVal[i]);
1215  }
1216  groupPtr_->setParams(locaPVec);
1217  stepperList.set("Continuation Parameter", names[hs]);
1218  stepperList.set("Initial Value", initialVal[hs]);
1219  stepperList.set("Min Value", minVal[hs]);
1220  stepperList.set("Max Value", maxVal[hs]);
1221 
1222  // Initialize parameters in xyce
1223  groupPtr_->computeF();
1224 
1225  // Do the continuation run
1227  locaStatus = stepperPtr_->run();
1228 
1229  // Kick out if continuation failed
1230  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1231  return (-1);
1232 
1233  firstSolveComplete_ = true;
1234 
1235  // Copy out the solution and use it in the next run
1236  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1237  }
1238 
1239  // Return converged solver code
1240  return (paramsPtr->getStatusTestReturnCode());
1241 }
1242 
1243 //-----------------------------------------------------------------------------
1244 // Function : N_NLS_NOX::Interface::blockGainscaleMosfetSolve
1245 // Purpose :
1246 // Special Notes : This corresponds to
1247 // .options nonlin continuation=blockgain or
1248 // .options nonlin continuation=7
1249 // Scope : public
1250 // Creator : Roger Pawlowski, Eric Keiter
1251 // Creation Date :
1252 //-----------------------------------------------------------------------------
1254 {
1255  // Get some initial objects
1256  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1257  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1258  LOCA::ParameterVector locaPVec;
1259 
1260  // Create storage for continuation objects
1261  int numGainBlocks = loaderPtr_->getHomotopyBlockSize();
1262  int numHomotopyContinuationRuns = 1 + numGainBlocks;
1263  std::vector<std::string> names(numHomotopyContinuationRuns);
1264  std::vector<double> initialVal(numHomotopyContinuationRuns);
1265  std::vector<double> finalVal(numHomotopyContinuationRuns);
1266  std::vector<double> minVal(numHomotopyContinuationRuns);
1267  std::vector<double> maxVal(numHomotopyContinuationRuns);
1268 
1269  // Set up continuation steps
1270  // ***************************************************
1271  // Changes vals below for continuation
1272  // ***************************************************
1273  for (int i = 0; i < numGainBlocks; ++i) {
1274  std::stringstream s;
1275  s << i;
1276  names[i] = "mosfet:gainscale_block_" + s.str();
1277  initialVal[i] = 0.0;
1278  finalVal[i] = 1.0;
1279  }
1280  names[numHomotopyContinuationRuns - 1] = "mosfet:nltermscale";
1281  initialVal[numHomotopyContinuationRuns - 1] = 0.0;
1282  finalVal[numHomotopyContinuationRuns - 1] = 1.0;
1283  // ***************************************************
1284  // ***************************************************
1285 
1286  // Ste up max/min bounds
1287  for (int i = 0; i < names.size(); ++i) {
1288  if (finalVal[i] > initialVal[i]) {
1289  minVal[i] = initialVal[i];
1290  maxVal[i] = finalVal[i];
1291  }
1292  else {
1293  minVal[i] = finalVal[i];
1294  maxVal[i] = initialVal[i];
1295  }
1296  }
1297 
1298  // Initialize loca parameter vector
1299  for (int i = 0; i < names.size(); ++i)
1300  locaPVec.addParameter(names[i], initialVal[i]);
1301 
1302  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
1303 
1304  // Loop over the number of homotopy steps
1305  for (int hs = 0; hs < names.size(); ++hs) {
1306  for (int i = 0; i < names.size(); ++i) {
1307  if (i >= hs)
1308  locaPVec.setValue(names[i], initialVal[i]);
1309  else
1310  locaPVec.setValue(names[i], finalVal[i]);
1311  }
1312  groupPtr_->setParams(locaPVec);
1313  stepperList.set("Continuation Parameter", names[hs]);
1314  stepperList.set("Initial Value", initialVal[hs]);
1315  stepperList.set("Min Value", minVal[hs]);
1316  stepperList.set("Max Value", maxVal[hs]);
1317 
1318  // Initialize parameters in xyce
1319  groupPtr_->computeF();
1320 
1321  // Do the continuation run
1323  locaStatus = stepperPtr_->run();
1324 
1325  // Kick out if continuation failed
1326  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1327  return (-1);
1328 
1329  // Increment Param Number Tracking
1330  isFirstContinuationParam_ = false;
1331  firstSolveComplete_ = true;
1332 
1333  // Copy out the solution and use it in the next run
1334  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1335  }
1336 
1337  // Return converged solver code
1338  return (paramsPtr->getStatusTestReturnCode());
1339 }
1340 
1341 //-----------------------------------------------------------------------------
1342 // Function : N_NLS_NOX::Interface::gminSteppingSolve
1343 // Purpose :
1344 // Special Notes : This corresponds to
1345 // .options nonlin continuation=gmin or
1346 // .options nonlin continuation=3
1347 // Scope : public
1348 // Creator : Roger Pawlowski, Eric Keiter
1349 // Creation Date :
1350 //-----------------------------------------------------------------------------
1352 {
1353  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1354 
1355  // Create the continuation parameter names
1356  std::string gmin = "GSTEPPING";
1357 
1358  // Create Parameter Vector and get the stepper parameter list.
1359  LOCA::ParameterVector locaPVec;
1360  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1361  Teuchos::ParameterList& predictorList = locaList->sublist("Predictor");
1362  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
1363 
1364  // Continuation solve using Gmin stepping.
1365  locaPVec.addParameter(gmin, 0.0);
1366  groupPtr_->setParams(locaPVec);
1367  stepperList.set("Continuation Parameter", gmin);
1368  stepperList.set("Continuation Method", "Natural");
1369 
1370  stepSizeList.set("Method", "Adaptive");
1371  predictorList.set("Method", "Constant");
1372 
1373  stepperList.set("Initial Value", 4.0);
1374  stepperList.set("Min Value", -4.0);
1375  paramsPtr->set_gstepping_min_value (-4.0);
1376  stepperList.set("Max Value", 4.0);
1377 
1378  stepSizeList.set("Initial Step Size", -2.0);
1379  stepSizeList.set("Min Step Size", 1.0e-6);
1380  stepSizeList.set("Max Step Size", 1.0e+12);
1381  stepSizeList.set("Aggressiveness", 0.01);
1382 
1383  stepperList.set("Max Steps", 400);
1384  stepperList.set("Max Nonlinear Iterations", 20);
1385 
1386  // the following set of if-statemtents call functions that
1387  // allocate augmented linear systems for various scenarios.
1388  // It is important that the augmented systems get allocated
1389  // after the paramter (above) have been set.
1390  bool usedOP=false;
1391  bool usedNODESET=false;
1392  bool usedIC=false;
1393  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> alsNull; // 0
1394 
1396  {
1397  if (ICspecified_)
1398  {
1399  usedIC=icCont3 (paramsPtr);
1400  }
1401  else if (NODESETspecified_)
1402  {
1403  usedNODESET=nodesetCont1 (paramsPtr);
1404  }
1405  else
1406  {
1407  usedOP = opStartCont1 (paramsPtr);
1408  }
1409  }
1410 
1411  // Initialize parameters in xyce
1412  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
1413  {
1414  groupPtr_->computeF();
1415  }
1416 
1417  // Do the continuation run
1418  iParam_ = 0;
1419  if (iParam_ == 0 && DCOPused_)
1420  {
1421  std::string message = "'.dcop input=' and gstepping are incompatible";
1422  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_FATAL, message);
1423  }
1424  if (!usedIC)
1425  {
1426  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
1428  groupPtr_->setAugmentLinearSystem(true, als);
1429  }
1430 
1431  // Do the continuation run
1433  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1434 
1435  groupPtr_->setAugmentLinearSystem(false, alsNull);
1436 
1437  // Kick out if continuation failed
1438  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1439  return (-1);
1440  else
1441  return (paramsPtr->getStatusTestReturnCode());
1442 }
1443 
1444 //-----------------------------------------------------------------------------
1445 // Function : N_NLS_NOX::Interface::pseudoTransientSolve
1446 // Purpose :
1447 // Special Notes : This corresponds to
1448 // .options nonlin continuation=pseudo or
1449 // .options nonlin continuation=9
1450 // Scope :
1451 // Creator :
1452 // Creation Date :
1453 //-----------------------------------------------------------------------------
1455 {
1456  Teuchos::RefCountPtr<NOX::StatusTest::Combo> ctest =
1457  Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR));
1458 
1459  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList =
1460  paramsPtr->getLocaParams();
1461  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1462  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
1463  double initialStepSize =
1464  stepSizeList.get("Initial Step Size", 1.0e-3);
1465  double minStepSize = stepSizeList.get("Min Step Size", 1.0e-12);
1466  double maxStepSize = stepSizeList.get("Max Step Size", 1.0e4);
1467  Teuchos::RefCountPtr<Teuchos::ParameterList> noxList =
1468  paramsPtr->getNoxParams();
1469 
1470  // Create Pseudo Transient status tests.
1471  //paramsPtr->getStatusTests()
1472  Teuchos::RefCountPtr<NOX::StatusTest::MaxIters> mi =
1473  Teuchos::rcp(new NOX::StatusTest::MaxIters(stepperList.get("Max Steps", 200)));
1474  Teuchos::RefCountPtr<NOX::StatusTest::FiniteValue> fv =
1475  Teuchos::rcp(new NOX::StatusTest::FiniteValue);
1476  Teuchos::RefCountPtr<N_NLS_NOX::PseudoTransientTest> pt =
1477  Teuchos::rcp(new N_NLS_NOX::PseudoTransientTest(maxStepSize, 1.0e-8));
1478 
1479  ctest->addStatusTest(mi);
1480  ctest->addStatusTest(fv);
1481  ctest->addStatusTest(pt);
1482 
1483  // First solve - pseudo transient
1484 
1485  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
1487 
1488  solverPtr_ = Teuchos::rcp(new N_NLS_NOX::PseudoTransientBased(als,
1489  groupPtr_,
1490  ctest,
1491  noxList,
1492  initialStepSize,
1493  minStepSize,
1494  maxStepSize));
1495 
1496  NOX::StatusTest::StatusType status = solverPtr_->solve();
1497  firstSolveComplete_ = true;
1498 
1499  // RPP 3/7/2006: We don't care if pseudo transient solve fails the
1500  // solve() call above. This is just to get an inital guess for
1501  // the corrector step in the next solve. So we don't check the
1502  // status at this point.
1503 
1504  // Turn off pseudo transient in groups. (this is also done in the
1505  // pseudo transient solver, but just being safe - groups could be
1506  // different).
1507  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> dummy;
1508  groupPtr_->setAugmentLinearSystem(false, dummy);
1509 
1510  // Second solve is the correct steady state solve
1511  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
1512  paramsPtr->getStatusTests(),
1513  paramsPtr->getNoxParams());
1514  status = solverPtr_->solve();
1515 
1516  // Send back the correct return code
1517  return (paramsPtr->getStatusTestReturnCode());
1518 }
1519 
1520 //-----------------------------------------------------------------------------
1521 // Function : N_NLS_NOX::Interface::artificialParameterHomotopy
1522 // Purpose :
1523 // Special Notes : This corresponds to
1524 // .options nonlin continuation=art or
1525 // .options nonlin continuation=33
1526 // Scope :
1527 // Creator :
1528 // Creation Date :
1529 //-----------------------------------------------------------------------------
1531 {
1532 #ifdef Xyce_NOX_LOCA_ARTIFICIAL_HOMOTOPY_SUPPORT
1533  Teuchos::RefCountPtr<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1534  Teuchos::ParameterList& locaUtilsList = locaList->sublist("Utilities");
1535 
1536  Teuchos::RefCountPtr<LOCA::Homotopy::Group> hGrp =
1537  Teuchos::rcp(new LOCA::Homotopy::Group(*locaList, globalDataPtr_, groupPtr_, 1.0, 0.0));
1538 
1539  hGrp->computeF();
1540 
1541  locaList->sublist("Predictor").set("Secant", 0.999);
1542  locaList->sublist("Stepper").set("Max Value", 0.999);
1543 
1545 
1546  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1547  firstSolveComplete_ = true;
1548 
1549  Teuchos::RefCountPtr<LOCA::Homotopy::Group> hGrp2 =
1550  Teuchos::rcp(new LOCA::Homotopy::Group(*locaList, globalDataPtr_, groupPtr_, 0.1, 1.0));
1551 
1552  locaList->sublist("Predictor").set("Secant", 0.999);
1553  locaList->sublist("Stepper").set("Initial Value", 0.999);
1554  locaList->sublist("Stepper").set("Max Value", 1.0);
1555  locaList->sublist("Step Size").set("Method", "Constant");
1556  locaList->sublist("Step Size").set("Initial Step Size", 0.0001);
1557  locaList->sublist("Step Size").set("Min Step Size", 0.0001);
1558 
1560 
1561  locaStatus = stepperPtr_->run();
1562 
1563  // Return the solution status
1564  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1565  return (-1);
1566  else
1567  return (paramsPtr->getStatusTestReturnCode());
1568 
1569 #else
1570  Xyce::Report::UserFatal0() << "Nonlinear Solver (NOX::Interface) Artificial parameter continuation requires "
1571  << "building xyce with the define: -DXyce_NOX_LOCA_ARTIFICIAL_HOMOTOPY_SUPPORT to "
1572  << "allow LOCA to augment the diagonal of Jacobian! Either rebuild Xyce or do not "
1573  << "run Xyce with \"continuation=33\"";
1574  return -1;
1575 #endif
1576 }
1577 
1578 //-----------------------------------------------------------------------------
1579 // Function : N_NLS_NOX::Interface::solve
1580 //
1581 // Purpose : Reset all the counters and parameters and solve the
1582 // nonlinear problem for this time step. The solution is
1583 // stored in nextSolVector (obtained from the N_LAS_System
1584 // registered above by registerLinearSystem).
1585 //
1586 // Special Notes : Should not be called until *after* initializeAll() has
1587 // been called.
1588 //
1589 // Return Type : Integer - postive for sucess, negative for failure.
1590 // Special Notes :
1591 // Scope : public
1592 // Creator : Roger Pawlowski, SNL 9233
1593 // Creation Date :
1594 //-----------------------------------------------------------------------------
1596 {
1597 
1598  try
1599  {
1600  // For base object
1602 
1603 #ifdef Xyce_DEBUG_NONLINEAR
1604  N_NLS_NonLinearSolver::setDebugFlags ();
1605 #endif
1606 
1607  // Setup the status tests
1608  if (Teuchos::is_null(locaStatusTestPtr_))
1609  {
1611  Teuchos::rcp(new LOCA::StatusTest::Wrapper(dcParams_.getStatusTests()));
1613  Teuchos::rcp(new LOCA::StatusTest::Wrapper(transientParams_.getStatusTests()));
1615  Teuchos::rcp(new LOCA::StatusTest::Wrapper(hbParams_.getStatusTests()));
1616 
1617  }
1618 
1619  // Pick the parameter set to use.
1620  ParameterSet* paramsPtr;
1622  {
1623  paramsPtr = &transientParams_;
1627  }
1628  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
1629  {
1630  paramsPtr = &hbParams_;
1634  }
1635  else
1636  {
1637  paramsPtr = &dcParams_;
1641  }
1642 
1643  if (Teuchos::is_null(globalDataPtr_))
1644  {
1645  globalDataPtr_ = LOCA::createGlobalData(paramsPtr->getAllParams());
1646  }
1647 
1648  // set the xyce return codes:
1649  paramsPtr->setStatusTestReturnCodes(retCodes_);
1650 
1651  // Set up the shared system (we have to redo this every time because
1652  // the object pointed to by nextSolVectorPtrPtr may have changed.
1653  //delete sharedSystemPtr_;
1654  if (sharedSystemPtr_ == 0)
1656  *rhsVectorPtr_,
1659  *gradVectorPtr_,
1660  *lasSysPtr_,
1661  *this);
1662  else
1664  *rhsVectorPtr_,
1667  *gradVectorPtr_,
1668  *lasSysPtr_,
1669  *this);
1670 
1671  //////////////////////////////////////////////////////////////////////////
1672  // erkeite: Group handling required by 2-level Newton:
1673  // Reset up the corresponding group as well
1674  if (nlsTmpPtr==0)
1675  {
1676  if (Teuchos::is_null(groupPtr_))
1677  {
1678  groupPtr_ = Teuchos::rcp(new N_NLS_LOCA::Group(globalDataPtr_,
1680  getLoader(),
1681  *outMgrPtr_,
1682  *anaIntPtr_)
1683  );
1684  }
1685  else
1686  {
1688  groupPtr_->setX(tmpVec);
1689  }
1690  }
1691  else
1692  {
1693  copiedGroupFlag_ = true;
1694  Interface * nlsOtherPtr = dynamic_cast<Interface*>(nlsTmpPtr);
1695  groupPtr_ = nlsOtherPtr->getSolutionGroup();
1696  }
1697  // End of block needed by 2-level Newton.
1698  //////////////////////////////////////////////////////////////////////////
1699 
1700  int solverType = paramsPtr->getNoxSolverType();
1701  bool continuationSpecified = paramsPtr->getContinuationSpecifiedFlag();
1702 
1703  if (mode_ == Xyce::Nonlinear::DC_OP && !continuationSpecified)
1704  {
1705  return spiceStrategy(paramsPtr);
1706  }
1707  else
1708  {
1709 
1710  // Setting the nonContinuation flag is required to prevent incorrect
1711  // N_DEV_DeviceMgr::setParam calls.
1712  if (solverType==0)
1713  {
1714  groupPtr_->setNonContinuationFlag (true);
1715  }
1716  else
1717  {
1718  groupPtr_->setNonContinuationFlag (false);
1719  }
1720 
1721 #ifdef Xyce_DEBUG_NONLINEAR
1722  Xyce::dout() << "solverType is " << solverType << std::endl;
1723 #endif
1724 
1725  // (0) Standard Newton Method Solve (includes line search and
1726  // trust region based methods
1727  if (solverType == 0)
1728  {
1729  return stdNewtonSolve(paramsPtr);
1730  }
1731  // (1) Natural Parameter Continuation
1732  else if (solverType == 1)
1733  {
1734  return naturalParameterContinuationSolve ( paramsPtr );
1735  }
1736  // (2) Mosfet specific continuation
1737  else if (solverType == 2)
1738  {
1739  return mosfetContinuationSolve ( paramsPtr );
1740  }
1741  else if (solverType == 3) // GMIN stepping, simple specification
1742  {
1743  return gminSteppingSolve ( paramsPtr );
1744  }
1745  // (4) Mosfet specific continuation (ERK, new 2/21/2004)
1746  else if (solverType == 4)
1747  {
1748  return mosfetContinuationSolve2 (paramsPtr);
1749  }
1750  // (5) Mosfet:BSIM3:Inverter specific continuation (RPP, new 2/25/2004)
1751  else if (solverType == 5)
1752  {
1753  return mosfetContinuationSolve3 (paramsPtr);
1754  }
1755  // (6) Mosfet:BSIM3:Inverter specific continuation (RPP, new 2/25/2004)
1756  else if (solverType == 6)
1757  {
1758  return mosfetContinuationSolve4 (paramsPtr);
1759  } // Block gainscale
1760  else if (solverType == 7)
1761  {
1762  return blockGainscaleMosfetSolve ( paramsPtr );
1763  } // Test suite
1764  else if (solverType == 8)
1765  {
1766  return mosfetContinuationSolve5 (paramsPtr);
1767  } // Pseudo Transient
1768  else if (solverType == 9)
1769  {
1770  return pseudoTransientSolve( paramsPtr );
1771  } // continuation = 4 + power node
1772  else if (solverType == 10)
1773  {
1774  return mosfetContinuationSolve6 (paramsPtr);
1775  }
1776  else if (solverType == 33) // artificial parameter
1777  {
1778  return artificialParameterHomotopy (paramsPtr);
1779  } // End of if (solverType == )
1780  }
1781  } // try
1782  catch (const char* error_msg) {
1783  std::string nox_error = "NOX Error";
1784  std::string err_msg = std::string(error_msg);
1785  if (err_msg == nox_error) {
1786  const std::string message =
1787  "Caught a NOX Exception in N_NLS_NOX::Interface::solve()!";
1788  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1789  }
1790  else // Otherwise, rethrow...
1791  throw;
1792  }
1793 #ifndef Xyce_CHARON
1794  catch (const std::exception& e) {
1795  Xyce::dout() << e.what() << std::endl;
1796  const std::string message =
1797  "Caught std::exception in N_NLS_NOX::Interface::solve()!";
1798  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1799  }
1800  catch (...) {
1801  const std::string message =
1802  "Caught Unknown Exception in N_NLS_NOX::Interface::solve()!";
1803  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1804  }
1805 #endif
1806 
1807  // Should never get this far
1808  return -1;
1809 }
1810 
1811 
1812 //-----------------------------------------------------------------------------
1813 // Function : N_NLS_NOX::Interface::opStartCont0
1814 // Purpose :
1815 // Special Notes : returns true if DCOP restart is being used.
1816 //
1817 // The "found" variable indicates if any of the nodes specified
1818 // in the dcop start file were found in this circuit. If not,
1819 // then don't bother with this.
1820 //
1821 // Scope : public
1822 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
1823 // Creation Date : 09/15/07
1824 //-----------------------------------------------------------------------------
1826 {
1827  bool usedOP(false);
1828 
1829 #ifdef Xyce_DEBUG_OP_START
1830  Xyce::dout() << "NOX_Interface: Inside continuation=0 OP_START code (case 1)" << std::endl;
1831 #endif
1832  if (!DCOPused_)
1833  {
1834  int found = 0;
1835  int icType;
1836  Xyce::NodeNamePairMap & op = outMgrPtr_->getICData(found, icType);
1837  const Xyce::NodeNamePairMap & allNodes = outMgrPtr_->getAllNodes( );
1838 #ifdef Xyce_PARALLEL_MPI
1839  N_PDS_Comm * pdsCommPtr = pdsMgrPtr_->getPDSComm();
1840 #endif
1841 
1842  if (found > 0 && icType == Xyce::IO::InitialConditionsData::IC_TYPE_DCOP_RESTART)
1843  {
1844  DCOPused_ = true;
1845  usedOP = true;
1846  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
1847 #ifdef Xyce_PARALLEL_MPI
1848  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, allNodes, pdsCommPtr);
1849 #else
1850  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, allNodes);
1851 #endif
1852  groupPtr_->setAugmentLinearSystem(true, als);
1853  NOX::StatusTest::StatusType status = solverPtr_->solve();
1854  // Create a new solver after performing the initial op_start solve.
1855  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
1856  paramsPtr->getStatusTests(),
1857  paramsPtr->getNoxParams());
1858  firstSolveComplete_ = true;
1859  groupPtr_->setAugmentLinearSystem(false, als);
1861 
1862 #ifdef Xyce_DEBUG_OP_START
1863  // DNS: Uncommenting this will set debug output of linear system for every step
1864 #ifdef Xyce_PARALLEL_MPI
1865  groupPtr_->setOutputLinear (&op, &allNodes, pdsCommPtr);
1866 #else
1867  groupPtr_->setOutputLinear (&op, &allNodes);
1868 #endif
1869 #endif // debug op start
1870 
1871  }
1872  }
1873  return usedOP;
1874 }
1875 
1876 //-----------------------------------------------------------------------------
1877 // Function : N_NLS_NOX::Interface::opStartCont1
1878 // Purpose :
1879 // Special Notes : returns true if DCOP restart is being used.
1880 //
1881 // The "found" variable indicates if any of the nodes specified
1882 // in the dcop start file were found in this circuit. If not,
1883 // then don't bother with this.
1884 //
1885 // Scope : public
1886 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
1887 // Creation Date : 09/15/07
1888 //-----------------------------------------------------------------------------
1890 {
1891  bool usedOP(false);
1892 
1893 #ifdef Xyce_DEBUG_OP_START
1894  Xyce::dout() << "NOX_Interface: Inside continuation=1 OP_START code (case 2)" << std::endl;
1895 #endif
1896  if (!DCOPused_)
1897  {
1898  int found = 0;
1899  int icType;
1900  Xyce::NodeNamePairMap & op = outMgrPtr_->getICData(found, icType);
1901  const Xyce::NodeNamePairMap & allNodes = outMgrPtr_->getAllNodes( );
1902 #ifdef Xyce_PARALLEL_MPI
1903  N_PDS_Comm * pdsCommPtr = pdsMgrPtr_->getPDSComm();
1904 #endif
1905 
1906  if (found > 0 && icType == Xyce::IO::InitialConditionsData::IC_TYPE_DCOP_RESTART)
1907  {
1908  DCOPused_ = true;
1909  usedOP = true;
1910  // Set up nox nonlinear solver
1911  if (Teuchos::is_null(solverPtr_))
1912  {
1913  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
1914  paramsPtr->getStatusTests(),
1915  paramsPtr->getNoxParams());
1916  }
1917 
1918  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
1919 #ifdef Xyce_PARALLEL_MPI
1920  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, allNodes, pdsCommPtr);
1921 #else
1922  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, allNodes);
1923 #endif
1924  groupPtr_->setAugmentLinearSystem(true, als);
1925  NOX::StatusTest::StatusType status = solverPtr_->solve();
1926 
1927  firstSolveComplete_ = true;
1928  groupPtr_->setAugmentLinearSystem(false, als);
1930 
1931 #ifdef Xyce_DEBUG_OP_START
1932  // DNS: Uncommenting this will set debug output of linear system for every step
1933 #ifdef Xyce_PARALLEL_MPI
1934  groupPtr_->setOutputLinear (&op, &allNodes, pdsCommPtr);
1935 #else
1936  groupPtr_->setOutputLinear (&op, &allNodes);
1937 #endif
1938 #endif // debug op start
1939 
1940  }
1941  }
1942  return usedOP;
1943 }
1944 
1945 //-----------------------------------------------------------------------------
1946 // Function : N_NLS_NOX::Interface::icCont
1947 // Purpose :
1948 // Special Notes : returns true if IC is being used.
1949 //
1950 // The "found" variable indicates if any of the nodes specified
1951 // in the dcop start file were found in this circuit. If not,
1952 // then don't bother with this.
1953 //
1954 // Scope : public
1955 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
1956 // Creation Date : 09/15/07
1957 //-----------------------------------------------------------------------------
1959 {
1960  bool usedIC(false);
1961 
1962 #ifdef Xyce_DEBUG_IC
1963  Xyce::dout() << "NOX_Interface: Inside continuation=0 .IC code." << std::endl;
1964 #endif
1965  int found = 0;
1966  int icType;
1967  Xyce::NodeNamePairMap & op = outMgrPtr_->getICData(found, icType);
1968 
1969  usedIC = (icType==Xyce::IO::InitialConditionsData::IC_TYPE_IC && found > 0);
1970  if (usedIC)
1971  {
1972  bool useGminStepping=false;
1973  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
1974  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, useGminStepping);
1975  groupPtr_->setAugmentLinearSystem(true, als);
1976  }
1977  return usedIC;
1978 }
1979 
1980 //-----------------------------------------------------------------------------
1981 // Function : N_NLS_NOX::Interface::icCont3
1982 // Purpose : IC with gmin stepping
1983 // Special Notes : returns true if IC is being used.
1984 //
1985 // The "found" variable indicates if any of the nodes specified
1986 // in the dcop start file were found in this circuit. If not,
1987 // then don't bother with this.
1988 //
1989 // Scope : public
1990 // Creator : Eric R. Keiter, SNL
1991 // Creation Date : 04/29/2012
1992 //-----------------------------------------------------------------------------
1994 {
1995  bool usedIC(false);
1996 
1997 #ifdef Xyce_DEBUG_IC
1998  Xyce::dout() << "NOX_Interface: Inside continuation=3 .IC code." << std::endl;
1999 #endif
2000  int found = 0;
2001  int icType;
2002  Xyce::NodeNamePairMap & op = outMgrPtr_->getICData(found, icType);
2003 
2004  usedIC = (icType==Xyce::IO::InitialConditionsData::IC_TYPE_IC && found > 0);
2005  if (usedIC)
2006  {
2007  bool useGminStepping=true;
2008  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
2009  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, useGminStepping);
2010  groupPtr_->setAugmentLinearSystem(true, als);
2011  }
2012  return usedIC;
2013 }
2014 
2015 //-----------------------------------------------------------------------------
2016 // Function : N_NLS_NOX::Interface::nodesetCont0
2017 // Purpose :
2018 // Special Notes : returns true if is being used.
2019 // Scope : public
2020 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
2021 // Creation Date : 09/15/07
2022 //-----------------------------------------------------------------------------
2024 {
2025  bool usedNODESET(false);
2026 
2027 #ifdef Xyce_DEBUG_IC
2028  Xyce::dout() << "NOX_Interface: Inside continuation=0 .NODESET code (case 1)" << std::endl;
2029 #endif
2030  int found = 0;
2031  int icType;
2032  Xyce::NodeNamePairMap & op = outMgrPtr_->getICData(found, icType);
2033 #ifdef Xyce_PARALLEL_MPI
2034  N_PDS_Comm * pdsCommPtr = pdsMgrPtr_->getPDSComm();
2035 #endif
2036 
2037  usedNODESET = (icType==Xyce::IO::InitialConditionsData::IC_TYPE_NODESET && found > 0);
2038  if (usedNODESET)
2039  {
2040  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
2041  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op);
2042 
2043  groupPtr_->setAugmentLinearSystem(true, als);
2044  NOX::StatusTest::StatusType status = solverPtr_->solve();
2045 
2046  // Create a new solver after performing the initial nodeset solve.
2047  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
2048  paramsPtr->getStatusTests(),
2049  paramsPtr->getNoxParams());
2050  firstSolveComplete_ = true;
2051  groupPtr_->setAugmentLinearSystem(false, als);
2053  }
2054  return usedNODESET;
2055 }
2056 
2057 
2058 //-----------------------------------------------------------------------------
2059 // Function : N_NLS_NOX::Interface::nodesetCont1
2060 // Purpose :
2061 // Special Notes : returns true if .NODESET is being used.
2062 // Scope : public
2063 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
2064 // Creation Date : 09/15/07
2065 //-----------------------------------------------------------------------------
2067 {
2068  bool usedNODESET(false);
2069 
2070 #ifdef Xyce_DEBUG_IC
2071  Xyce::dout() << "NOX_Interface: Inside continuation=1 .NODESET code (case 2)" << std::endl;
2072 #endif
2073 
2074  int found = 0;
2075  int icType;
2076  Xyce::NodeNamePairMap & op = outMgrPtr_->getICData(found, icType);
2077 #ifdef Xyce_PARALLEL_MPI
2078  N_PDS_Comm * pdsCommPtr = pdsMgrPtr_->getPDSComm();
2079 #endif
2080 
2081  usedNODESET = (icType==Xyce::IO::InitialConditionsData::IC_TYPE_NODESET && found > 0);
2082  if (usedNODESET)
2083  {
2084  // Set up nox nonlinear solver
2085  if (Teuchos::is_null(solverPtr_))
2086  {
2087  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
2088  paramsPtr->getStatusTests(),
2089  paramsPtr->getNoxParams());
2090  }
2091 
2092  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als =
2093  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op);
2094 
2095  groupPtr_->setAugmentLinearSystem(true, als);
2096  NOX::StatusTest::StatusType status = solverPtr_->solve();
2097 
2098  firstSolveComplete_ = true;
2099  groupPtr_->setAugmentLinearSystem(false, als);
2101  }
2102  return usedNODESET;
2103 }
2104 
2105 //-----------------------------------------------------------------------------
2106 // Function : N_NLS_NOX::Interface::takeFirstSolveStep
2107 // Purpose : same as Interface::solve, except that solverPtr_->iterate is
2108 // called instead of solverPtr_->solve.
2109 // Special Notes :
2110 // Scope : public
2111 // Creator :
2112 // Creation Date :
2113 //-----------------------------------------------------------------------------
2115 {
2116  // For base object
2118 
2119  // Pick the parameter set to use.
2120  ParameterSet* paramsPtr;
2122  paramsPtr = &transientParams_;
2123  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2124  paramsPtr = &hbParams_;
2125  else
2126  paramsPtr = &dcParams_;
2127 
2128  // set the xyce return codes:
2129  paramsPtr->setStatusTestReturnCodes(retCodes_);
2130 
2131  if (Teuchos::is_null(globalDataPtr_))
2132  globalDataPtr_ = LOCA::createGlobalData(paramsPtr->getAllParams());
2133 
2134  // Set up the shared system (we have to redo this every time because
2135  // the object pointed to by nextSolVectorPtrPtr may have changed.
2136  delete sharedSystemPtr_;
2137  sharedSystemPtr_ = new SharedSystem(**nextSolVectorPtrPtr_,
2138  *rhsVectorPtr_,
2141  *gradVectorPtr_,
2142  *lasSysPtr_,
2143  *this);
2144 
2145  // Reset up the corresponding group as well
2146  //delete groupPtr_;
2147  if (nlsTmpPtr==0)
2148  {
2149  if (Teuchos::is_null(groupPtr_))
2150  {
2151  Xyce::dout() << "takeFirstSolveStep: allocating a new group!" << std::endl;
2152  groupPtr_ = Teuchos::rcp(new N_NLS_LOCA::Group(globalDataPtr_,
2153  *sharedSystemPtr_,
2154  getLoader(),
2155  *outMgrPtr_,
2156  *anaIntPtr_));
2157  }
2158  else
2159  {
2160  Xyce::dout() << "takeFirstSolveStep: using the old group!" << std::endl;
2162  groupPtr_->setX(tmpVec);
2163  }
2164  }
2165  else
2166  {
2167  Xyce::dout() << "takeFirstSolveStep: copying over the passed group!" << std::endl;
2168  copiedGroupFlag_ = true;
2169  Interface * nlsOtherPtr = dynamic_cast<Interface*>(nlsTmpPtr);
2170  groupPtr_ = nlsOtherPtr->getSolutionGroup();
2171  }
2172 
2173  // Set up solver
2174  if (Teuchos::is_null(solverPtr_))
2175  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
2176  paramsPtr->getStatusTests(),
2177  paramsPtr->getNoxParams());
2178  else
2179  solverPtr_->reset(groupPtr_->getX());
2180 
2181  // Solve
2182  NOX::StatusTest::StatusType status = solverPtr_->step();
2183 
2184  // Return the solution status
2185  return (status == NOX::StatusTest::Converged) ? 1 : -1;
2186 }
2187 
2188 //-----------------------------------------------------------------------------
2189 // Function : N_NLS_NOX::Interface::takeOneSolveStep
2190 // Purpose : same as Interface::takeFirstSolveStep, except that none of the
2191 // set up stuff (like allocating the solverPtr) is done here.
2192 // Special Notes :
2193 // Scope : public
2194 // Creator :
2195 // Creation Date :
2196 //-----------------------------------------------------------------------------
2198 {
2199  // Solve
2200  NOX::StatusTest::StatusType status = solverPtr_->step();
2201 
2202  // Return the solution status
2203  return (status == NOX::StatusTest::Converged) ? 1 : -1;
2204 }
2205 
2206 //-----------------------------------------------------------------------------
2207 // Function : N_NLS_NOX::Interface::getNumIterations
2208 // Purpose :
2209 // Special Notes :
2210 // Return Type : Integer (current number of nonlinear iterations)
2211 // Scope : public
2212 // Creator :
2213 // Creation Date :
2214 //-----------------------------------------------------------------------------
2216 {
2217  // Pick the parameter set to use.
2218  const ParameterSet* paramsPtr;
2220  paramsPtr = &transientParams_;
2221  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2222  paramsPtr = &hbParams_;
2223  else
2224  paramsPtr = &dcParams_;
2225 
2226  int solverType = paramsPtr->getNoxSolverType();
2227 
2228  if ((!Teuchos::is_null(solverPtr_)) && (solverType == 0))
2229  return solverPtr_->getNumIterations();
2230  else if ((!Teuchos::is_null(solverPtr_)) && (solverType == 1))
2231  return solverPtr_->getNumIterations();
2232  else if ((!Teuchos::is_null(solverPtr_)) && (solverType == 9))
2233  return solverPtr_->getNumIterations();
2234  else if ((!Teuchos::is_null(stepperPtr_)) && (solverType != 0))
2235  {
2236  return stepperPtr_->getSolver()->getNumIterations();
2237  }
2238 
2239  // Sometimes this is called before solve() itself, in which calse
2240  // the solverPtr_ has not yet been initialized, so we just return 0.
2241  return 0;
2242 }
2243 
2244 //-----------------------------------------------------------------------------
2245 // Function : N_NLS_NOX::Interface::getMaxNormF() const
2246 // Purpose :
2247 // Special Notes :
2248 // Return Type : double (norm of F)
2249 // Scope : public
2250 // Creator :
2251 // Creation Date :
2252 //-----------------------------------------------------------------------------
2254 {
2255  // Pick the parameter set to use.
2256  const ParameterSet* paramsPtr;
2258  {
2259  paramsPtr = &transientParams_;
2260  }
2261  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2262  {
2263  paramsPtr = &hbParams_;
2264  }
2265  else
2266  {
2267  paramsPtr = &dcParams_;
2268  }
2269 
2270  double maxNormF = paramsPtr->getMaxNormF();
2271  return maxNormF;
2272 }
2273 
2274 
2275 //-----------------------------------------------------------------------------
2276 // Function : N_NLS_NOX::Interface::getMaxNormFindex() const
2277 // Purpose :
2278 // Special Notes :
2279 // Return Type : int (vector index norm of F)
2280 // Scope : public
2281 // Creator :
2282 // Creation Date :
2283 //-----------------------------------------------------------------------------
2285 {
2286  // Pick the parameter set to use.
2287  const ParameterSet* paramsPtr;
2289  {
2290  paramsPtr = &transientParams_;
2291  }
2292  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2293  {
2294  paramsPtr = &hbParams_;
2295  }
2296  else
2297  {
2298  paramsPtr = &dcParams_;
2299  }
2300 
2301  int maxNormFindex = paramsPtr->getMaxNormFindex();
2302  return maxNormFindex;
2303 }
2304 
2305 //-----------------------------------------------------------------------------
2306 // Function : N_NLS_NOX::Interface::getDebugLevel
2307 // Purpose :
2308 // Special Notes :
2309 // Scope : public
2310 // Creator : Eric Keiter, SNL
2311 // Creation Date : 9/17/2007
2312 //-----------------------------------------------------------------------------
2314 {
2315  const ParameterSet* paramsPtr;
2317  {
2318  paramsPtr = &transientParams_;
2319  }
2320  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2321  {
2322  paramsPtr = &hbParams_;
2323  }
2324  else
2325  {
2326  paramsPtr = &dcParams_;
2327  }
2328 
2329  return (paramsPtr->getDebugLevel());
2330 }
2331 
2332 //-----------------------------------------------------------------------------
2333 // Function : N_NLS_NOX::Interface::getScreenOutputFlag
2334 // Purpose :
2335 // Special Notes :
2336 // Scope : public
2337 // Creator : Eric Keiter, SNL
2338 // Creation Date : 9/17/2007
2339 //-----------------------------------------------------------------------------
2341 {
2342  const ParameterSet* paramsPtr;
2344  {
2345  paramsPtr = &transientParams_;
2346  }
2347  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2348  {
2349  paramsPtr = &hbParams_;
2350  }
2351  else
2352  {
2353  paramsPtr = &dcParams_;
2354  }
2355 
2356  return (paramsPtr->getScreenOutputFlag());
2357 }
2358 
2359 //-----------------------------------------------------------------------------
2360 // Function : N_NLS_NOX::Interface::getDebugMinTime
2361 // Purpose :
2362 // Special Notes :
2363 // Scope : public
2364 // Creator : Eric Keiter, SNL
2365 // Creation Date : 9/17/2007
2366 //-----------------------------------------------------------------------------
2368 {
2369  const ParameterSet* paramsPtr;
2371  {
2372  paramsPtr = &transientParams_;
2373  }
2374  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2375  {
2376  paramsPtr = &hbParams_;
2377  }
2378  else
2379  {
2380  paramsPtr = &dcParams_;
2381  }
2382 
2383  return (paramsPtr->getDebugMinTime());
2384 }
2385 
2386 //-----------------------------------------------------------------------------
2387 // Function : N_NLS_NOX::Interface::getDebugMaxTime
2388 // Purpose :
2389 // Special Notes :
2390 // Scope : public
2391 // Creator : Eric Keiter, SNL
2392 // Creation Date : 9/17/2007
2393 //-----------------------------------------------------------------------------
2395 {
2396  const ParameterSet* paramsPtr;
2398  {
2399  paramsPtr = &transientParams_;
2400  }
2401  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2402  {
2403  paramsPtr = &hbParams_;
2404  }
2405  else
2406  {
2407  paramsPtr = &dcParams_;
2408  }
2409 
2410  return (paramsPtr->getDebugMaxTime());
2411 }
2412 
2413 //-----------------------------------------------------------------------------
2414 // Function : N_NLS_NOX::Interface::getDebugMinTimeStep
2415 // Purpose :
2416 // Special Notes :
2417 // Scope : public
2418 // Creator : Eric Keiter, SNL
2419 // Creation Date : 9/17/2007
2420 //-----------------------------------------------------------------------------
2422 {
2423  const ParameterSet* paramsPtr;
2425  {
2426  paramsPtr = &transientParams_;
2427  }
2428  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2429  {
2430  paramsPtr = &hbParams_;
2431  }
2432  else
2433  {
2434  paramsPtr = &dcParams_;
2435  }
2436 
2437  return (paramsPtr->getDebugMinTimeStep());
2438 }
2439 
2440 //-----------------------------------------------------------------------------
2441 // Function : N_NLS_NOX::Interface::getDebugMaxTimeStep
2442 // Purpose :
2443 // Special Notes :
2444 // Scope : public
2445 // Creator : Eric Keiter, SNL
2446 // Creation Date : 9/17/2007
2447 //-----------------------------------------------------------------------------
2449 {
2450  const ParameterSet* paramsPtr;
2452  {
2453  paramsPtr = &transientParams_;
2454  }
2455  else if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2456  {
2457  paramsPtr = &hbParams_;
2458  }
2459  else
2460  {
2461  paramsPtr = &dcParams_;
2462  }
2463 
2464  return (paramsPtr->getDebugMaxTimeStep());
2465 }
2466 
2467 //-----------------------------------------------------------------------------
2468 // Function : N_NLS_NOX::Interface::getMMFormat
2469 // Purpose :
2470 // Special Notes :
2471 // Scope : public
2472 // Creator : Eric Keiter, SNL
2473 // Creation Date : 3/2/2011
2474 //-----------------------------------------------------------------------------
2476 {
2477  return false;
2478 }
2479 
2480 //-----------------------------------------------------------------------------
2481 // Function : N_NLS_NOX::Interface::isFirstContinuationParam
2482 // Purpose :
2483 // Special Notes :
2484 // Scope : public
2485 // Creator :
2486 // Creation Date :
2487 //-----------------------------------------------------------------------------
2489 {
2491 }
2492 
2493 //-----------------------------------------------------------------------------
2494 // Function : N_NLS_NOX::Interface::isFirstSolveComplete
2495 // Purpose :
2496 // Special Notes :
2497 // Scope : public
2498 // Creator :
2499 // Creation Date :
2500 //-----------------------------------------------------------------------------
2502 {
2503  return firstSolveComplete_;
2504 }
2505 
2506 //-----------------------------------------------------------------------------
2507 // Function : N_NLS_NOX::Interface::getContinuationStep
2508 // Purpose :
2509 // Special Notes :
2510 // Scope : public
2511 // Creator :
2512 // Creation Date :
2513 //-----------------------------------------------------------------------------
2515 {
2516  if (!Teuchos::is_null(stepperPtr_))
2517  {
2518  return stepperPtr_->getStepNumber();
2519  }
2520  return 0;
2521 }
2522 
2523 //-----------------------------------------------------------------------------
2524 // Function : N_NLS_NOX::Interface::getContinuationStep
2525 // Purpose :
2526 // Special Notes :
2527 // Scope : public
2528 // Creator :
2529 // Creation Date :
2530 //-----------------------------------------------------------------------------
2532 {
2533  return iParam_;
2534 }
2535 
2536 //-----------------------------------------------------------------------------
2537 // Function : N_NLS_NOX::Interface::setAnalysisMode
2538 //
2539 // Purpose : Specify the analysis mode to be used by the nonlinear
2540 // solver in the next call to solve(). This *may* affect
2541 // the parameters used by the solver.
2542 //
2543 // See Also : setOptions, setTranOptions
2544 //
2545 // - Input Arguments -
2546 //
2547 // mode : Mode to be used in the next nonlinear solve.
2548 // Special Notes :
2549 // Scope : public
2550 // Creator :
2551 // Creation Date :
2552 //-----------------------------------------------------------------------------
2554 {
2555  mode_ = mode;
2556 }
2557 
2558 //-----------------------------------------------------------------------------
2559 // Function : N_NLS_NOX::Interface::resetAll
2560 // Purpose : This is used when Xyce is doing a STEP loop, and
2561 // needs to act like it is at the beginning of a transient
2562 // simulation again, for the next parameter in the STEP loop.
2563 // Special Notes :
2564 // Scope : public
2565 // Creator : Eric Keiter
2566 // Creation Date :
2567 //-----------------------------------------------------------------------------
2569 {
2570  setAnalysisMode(mode);
2571 }
2572 
2573 //-----------------------------------------------------------------------------
2574 // Function : N_NLS_NOX::Interface::copySolnVectors()
2575 //
2576 // Purpose : To be called at the beginning of each nonlinear
2577 // iteration. It equates the tmp and next vectors as
2578 // well as some special hidden vectors.
2579 //
2580 // See Also : setX0_
2581 // Special Notes :
2582 // Scope : public
2583 // Creator :
2584 // Creation Date :
2585 //-----------------------------------------------------------------------------
2587 {
2589  return true;
2590 }
2591 
2592 //-----------------------------------------------------------------------------
2593 // Function : N_NLS_NOX::Interface::getMatrixFreeFlag()
2594 //
2595 // Purpose :
2596 // See Also :
2597 // Special Notes :
2598 // Scope : public
2599 // Creator : Todd Coffey, Ting Mei
2600 // Creation Date : 07/29/08
2601 //-----------------------------------------------------------------------------
2603 {
2605 }
2606 
2607 //-----------------------------------------------------------------------------
2608 // Function : N_NLS_NOX::Interface::computeF()
2609 // Purpose :
2610 // Special Notes :
2611 // Scope : public
2612 // Creator :
2613 // Creation Date :
2614 //-----------------------------------------------------------------------------
2616 {
2617  return N_NLS_NonLinearSolver::rhs_();
2618 }
2619 
2620 //-----------------------------------------------------------------------------
2621 // Function : N_NLS_NOX::Interface::computeNewton
2622 // Purpose : Set up the parameters for the linear solver and then
2623 // call newton_()
2624 // Special Notes :
2625 // Scope : public
2626 // Creator :
2627 // Creation Date :
2628 //-----------------------------------------------------------------------------
2629 bool Interface::computeNewton(Teuchos::ParameterList& params)
2630 {
2632  {
2633  lasSolverPtr_->setTolerance(params.get("Tolerance", 1.0e-12));
2634  }
2636  {
2637  lasSolverPtr_->setTolerance(params.get("Tolerance", 1.0e-12));
2638  }
2639 
2641 }
2642 
2643 //-----------------------------------------------------------------------------
2644 // Function : N_NLS_NOX::Interface::computeJacobian()
2645 // Purpose :
2646 // Special Notes :
2647 // Scope : public
2648 // Creator :
2649 // Creation Date :
2650 //-----------------------------------------------------------------------------
2652 {
2653  bool status = N_NLS_NonLinearSolver::jacobian_();
2654  return status;
2655 }
2656 
2657 //-----------------------------------------------------------------------------
2658 // Function : N_NLS_NOX::Interface::applyJacobian(const N_LAS_Vector& input, N_LAS_Vector& result)
2659 // Purpose :
2660 // Special Notes :
2661 // Scope : public
2662 // Creator :
2663 // Creation Date :
2664 //-----------------------------------------------------------------------------
2665 bool Interface::applyJacobian(const N_LAS_Vector& input, N_LAS_Vector& result)
2666 {
2667  return N_NLS_NonLinearSolver::applyJacobian(input,result);
2668 }
2669 
2670 //-----------------------------------------------------------------------------
2671 // Function : N_NLS_NOX::Interface::computeGradient()
2672 // Purpose :
2673 // Special Notes :
2674 // Scope : public
2675 // Creator :
2676 // Creation Date :
2677 //-----------------------------------------------------------------------------
2679 {
2680  bool status = N_NLS_NonLinearSolver::gradient_();
2681  return status;
2682 }
2683 
2684 //-----------------------------------------------------------------------------
2685 // Function : N_NLS_NOX::Interface::getSolutionGroup
2686 // Purpose :
2687 // Special Notes :
2688 // Scope : public
2689 // Creator :
2690 // Creation Date :
2691 //-----------------------------------------------------------------------------
2692 Teuchos::RefCountPtr<N_NLS_LOCA::Group> Interface::getSolutionGroup ()
2693 {
2694  return groupPtr_;
2695 }
2696 
2697 //-----------------------------------------------------------------------------
2698 // Function : N_NLS_NOX::Interface::getLoader
2699 //
2700 // Purpose : LOCA needs access to loader to set parameters
2701 //
2702 // Special Notes :
2703 // Scope : public
2704 // Creator :
2705 // Creation Date :
2706 //-----------------------------------------------------------------------------
2707 N_LOA_Loader& Interface::getLoader() const
2708 {
2710 }
2711 
2712 //-----------------------------------------------------------------------------
2713 // Function : N_NLS_NOX::Interface::resetStepper
2714 // Purpose :
2715 // Special Notes :
2716 // Scope : public
2717 // Creator :
2718 // Creation Date :
2719 //-----------------------------------------------------------------------------
2720 void Interface::resetStepper(const Teuchos::RefCountPtr<LOCA::GlobalData>& gd,
2721  const Teuchos::RefCountPtr<LOCA::MultiContinuation::AbstractGroup>& initialGuess,
2722  const Teuchos::RefCountPtr<NOX::StatusTest::Generic>& test,
2723  const Teuchos::RefCountPtr<Teuchos::ParameterList>& p)
2724 {
2725  stepperPtr_ =
2726  Teuchos::rcp(new LOCA::Stepper(gd, initialGuess, test, p));
2727 }
2728 
2729 //-----------------------------------------------------------------------------
2730 // Function : N_NLS_NOX::Interface::getLocaFlag
2731 // Purpose :
2732 // Special Notes :
2733 // Scope : public
2734 // Creator :
2735 // Creation Date :
2736 //-----------------------------------------------------------------------------
2738 {
2739  // Pick the parameter set to use.
2740  const ParameterSet* paramsPtr;
2741  bool retCode;
2742 
2744  {
2745  firstSolveComplete_ = false;
2746  paramsPtr = &transientParams_;
2747  int solverType = paramsPtr->getNoxSolverType();
2748  retCode = false;
2749  if (solverType != 0) retCode = true;
2750  }
2751  else
2752  {
2753  if ((usemode_) && (mode_ == Xyce::Nonlinear::HB_MODE))
2754  {
2755  paramsPtr = &hbParams_;
2756  }
2757  else
2758  {
2759  paramsPtr = &dcParams_;
2760  }
2761 
2762  if (DCOPused_)
2763  {
2764  retCode = firstSolveComplete_;
2765  }
2766  else
2767  {
2768  int solverType = paramsPtr->getNoxSolverType();
2769  retCode=false;
2770  if (solverType != 0) retCode = true;
2771  }
2772  }
2773 
2774  return retCode;
2775 }
2776 
2777 } // namespace N_NLS_NOX