Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_NLParams.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_NLS_NLParams.h,v $
27 //
28 // Purpose : Basic user-specifid parameters data structure.
29 //
30 // Special Notes :
31 //
32 // Creator : Scott A. Hutchinson, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 04/28/00
35 //
36 // Revision Information:
37 // ----------------------
38 //
39 // Revision Number: $Revision: 1.83 $
40 //
41 // Revision Date : $Date: 2014/08/07 23:08:54 $
42 //
43 // Current Owner : $Author $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_NLS_NLParams_h
47 #define Xyce_N_NLS_NLParams_h
48 
49 // ---------- Standard Includes ----------
50 
51 #include <N_UTL_Misc.h>
52 
53 #ifdef HAVE_CMATH
54 #include <cmath>
55 #else
56 #include <math.h>
57 #endif
58 
59 #include <assert.h>
60 
61 #ifdef HAVE_CLIMITS
62 #include <climits>
63 #else
64 #include <limits.h>
65 #endif
66 
67 #include <N_UTL_Xyce.h>
68 #include <N_IO_fwd.h>
69 #include <N_NLS_Manager.h>
70 #include <N_ERH_ErrorMgr.h>
71 
72 namespace Xyce {
73 namespace Nonlinear {
74 
75 // ---------- Enumerated Types ----------
76 
77 // Support line-search methods.
79  FULL, // Newton's Method, undamped.
80  DIVIDE, // Reduce step-size by successively halving the previous
81  // step.
82  BACKTRACK, // Backtrack using interpolation (ala Dennis & Schnabel).
83  BANK_ROSE, // Bank and Rose algorithm - see method notes.
84  DESCENT, // More'-Thuente line search
85  SIMPLE_BACKTRACK // Simple backtracking method
86 };
87 
88 // Search directions.
89 enum Direction {
90  NEWTON_DIR, // Newton's direction
91  GRADIENT_DIR, // Steepest descent direction
92  MOD_NEWTON_DIR // Modified Newton direction
93 };
94 
95 // Nonlinear solution "strategies".
96 enum NLStrategy {
97  NEWTON, // Pure Newton's method
98  GRADIENT, // Pure gradient method
99  NEWTON_GRADIENT, // Combined Newton/gradient method
100  MOD_NEWTON, // Pure modified Newton's method
101  MOD_NEWTON_GRADIENT // Combined modified-Newton/gradient method
102 };
103 
104 //-----------------------------------------------------------------------------
105 // Class : NLParams
106 // Purpose : Stores nonlinear solver user settings.
107 // Special Notes :
108 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
109 // Creation Date : 5/01/00
110 //-----------------------------------------------------------------------------
111 class NLParams
112 {
113 public:
114  //NLParams(AnalysisMode mode=DC_OP);
115  NLParams(AnalysisMode mode, N_IO_CmdParse & cp);
116  NLParams(const NLParams & right);
117 
118  ~NLParams();
119 
120  NLParams & operator=(const NLParams & right);
121 
122  // ***** Accessor functions *****
123 
124  void setPrintParamsFlag();
125  void clearPrintParamsFlag();
126  bool getPrintParamsFlag() const;
127 
128  bool setOptions(const N_UTL_OptionBlock & OB);
129  bool setCmdLineOptions ();
130 
131  inline void setNLStrategy(NLStrategy strategy);
132  inline void setNLStrategy(int strategy);
133  inline void resetNLStrategy();
134  inline NLStrategy getNLStrategy() const;
135 
136  inline void setSearchMethod(LineSearchMethod method);
137  inline void setSearchMethod(int method);
138  inline void resetSearchMethod();
139  inline LineSearchMethod getSearchMethod() const;
140 
141  inline void setDirection(Direction value);
142  inline void resetDirection();
143  inline Direction getDirection() const;
144 
145  inline void setDeltaXTol(double Tolerance);
146  inline void resetDeltaXTol();
147  inline double getDeltaXTol() const;
148 
149  inline void setSmallUpdateTol (double Tolerance);
150  inline void resetSmallUpdateTol ();
151  inline double getSmallUpdateTol () const;
152 
153  inline void setEnforceDeviceConvFlag (bool flag);
154  inline void resetEnforceDeviceConvFlag ();
155  inline bool getEnforceDeviceConvFlag () const;
156 
157  inline void setRHSTol(double Tolerance);
158  inline void resetRHSTol();
159  inline double getRHSTol() const;
160 
161  inline void setAbsTol(double Tolerance);
162  inline void resetAbsTol();
163  inline double getAbsTol() const;
164 
165  inline void setRelTol(double Tolerance);
166  inline void resetRelTol();
167  inline double getRelTol() const;
168 
169  inline void setMaxNewtonStep(unsigned maxNewtonStep);
170  inline void resetMaxNewtonStep();
171  inline unsigned getMaxNewtonStep() const;
172 
173  inline void setMaxSearchStep(unsigned maxSearchStep);
174  inline void resetMaxSearchStep();
175  inline unsigned getMaxSearchStep() const;
176 
177  inline void setForcingFlag(bool flag);
178  inline void resetForcingFlag();
179  inline bool getForcingFlag() const;
180 
181  inline void setForcingTerm(double value);
182  inline void resetForcingTerm();
183  inline double getForcingTerm() const;
184 
185  inline void setNormLevel(int level);
186  inline void resetNormLevel();
187  inline int getNormLevel() const;
188 
189  inline void setLinearOpt(bool flag);
190  inline void resetLinearOpt();
191  inline bool getLinearOpt() const;
192 
193  inline void setConstraintBT(bool flag);
194  inline void resetConstraintBT();
195  inline bool getConstraintBT() const;
196 
197  inline void setGlobalBTMax(double value);
198  inline void resetGlobalBTMax();
199  inline double getGlobalBTMax() const;
200 
201  inline void setGlobalBTMin(double value);
202  inline void resetGlobalBTMin();
203  inline double getGlobalBTMin() const;
204 
205  inline void setGlobalBTChange(double value);
206  inline void resetGlobalBTChange();
207  inline double getGlobalBTChange() const;
208 
209  void printParams(std::ostream &os);
210 
211  inline void setDebugLevel(int value);
212  inline void resetDebugLevel();
213  inline int getDebugLevel() const;
214 
215  inline void setDebugMinTimeStep(int value);
216  inline void resetDebugMinTimeStep();
217  inline int getDebugMinTimeStep() const;
218 
219  inline void setDebugMaxTimeStep(int value);
220  inline void resetDebugMaxTimeStep();
221  inline int getDebugMaxTimeStep() const;
222 
223  inline void setDebugMinTime(double value);
224  inline void resetDebugMinTime();
225  inline double getDebugMinTime() const;
226 
227  inline void setDebugMaxTime(double value);
228  inline void resetDebugMaxTime();
229  inline double getDebugMaxTime() const;
230 
231  inline void setScreenOutputFlag (bool bval);
232  inline void resetScreenOutputFlag ();
233  inline bool getScreenOutputFlag () const;
234 
235  inline void setMMFormat(bool value);
236  inline void resetMMFormat();
237  inline bool getMMFormat() const;
238 
239 protected:
240 private:
241 
242 public:
243 
244 protected:
245  // Print control flag
247 
248  // command line parser
249  N_IO_CmdParse * commandLine_;
250 
251  // Calling solution method (e.g., DC Operation Point, Transient, etc.)
254 
255  // Nonlinear solution strategy
257 
258  // Damping method (e.g., Bank and Rose)
260 
261  // Direction flag - dictates which direction to take in advancing the
262  // nonlinear solver.
264 
265  // Absolute convergence tolerance for the norm of the residual.
266  double absTol_;
267 
268  // Relative convergence tolerance.
269  double relTol_;
270 
271  // Weighted deltaX (update) norm tolerance (Petzold)
272  double deltaXTol_;
273 
274  // Special deltaX (update) norm tolerance, used for the
275  // "small update" test.
277 
278  // Weighted RHS (residual) norm tolerance
279  double RHSTol_;
280 
281  // Maximum number of solution steps to attempt.
282  unsigned maxNewtonStep_;
283 
284  // maximum number of damping steps:
285  unsigned maxSearchStep_;
286 
287  // inexact-Newton forcing flag:
289 
290  // check device convergence flag:
292 
293  // inexact-Newton forcing term:
294  double eta_;
295 
296  // norm level:
298 
299  // linear optimization flag
301 
302  // Constraint backtracking flag
304 
305  // Backtracking constraint scalar values. Note that these are used to set
306  // vectors of values to these defaults but, in general, the constraints can
307  // be individually applied to all solution variables (see
308  // ConstraintBT.h).
309  double globalBTMax_;
310  double globalBTMin_;
312 
313  // Debug output options:
321 };
322 
323 //-----------------------------------------------------------------------------
324 // Function : NLParams::setPrintParamsFlag
325 // Purpose : Sets the flag which controls the printing of the nonlinear
326 // solver parameters list. This flag should be set anytime one
327 // of the parameters is modified as the code runs.
328 // Special Notes :
329 // Scope : public
330 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
331 // Creation Date : 01/16/01
332 //-----------------------------------------------------------------------------
334 {
335  printParamsFlag_ = true;
336 }
337 
338 //-----------------------------------------------------------------------------
339 // Function : NLParams::clearPrintParamsFlag
340 // Purpose : Clears the flag which controls the printing of the nonlinear
341 // solver parameters list. This flag is cleared once the
342 // output is printed.
343 // Special Notes :
344 // Scope : public
345 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
346 // Creation Date : 01/16/01
347 //-----------------------------------------------------------------------------
349 {
350  printParamsFlag_ = 0;
351 }
352 
353 //-----------------------------------------------------------------------------
354 // Function : NLParams::getPrintParamsFlag
355 // Purpose : Returns the flag value
356 // Special Notes :
357 // Scope : public
358 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
359 // Creation Date : 01/16/01
360 //-----------------------------------------------------------------------------
361 inline bool NLParams::getPrintParamsFlag() const
362 {
363  return printParamsFlag_;
364 }
365 
366 //-----------------------------------------------------------------------------
367 // Function : NLParams::setNLStrategy
368 // Purpose : Accessor method to set the nonlinear solver strategy.
369 // Special Notes :
370 // Scope : public
371 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
372 // Creation Date : 02/26/01
373 //-----------------------------------------------------------------------------
374 inline void NLParams::setNLStrategy(NLStrategy strategy)
375 {
376  nlStrategy_ = strategy;
377 
378  // Make sure the method selected is supported, otherwise revert to the
379  // default.
380  if (nlStrategy_ != NEWTON &&
381  nlStrategy_ != GRADIENT &&
383  nlStrategy_ != MOD_NEWTON &&
385  resetNLStrategy();
386 }
387 
388 //-----------------------------------------------------------------------------
389 // Function : NLParams::setNLStrategy
390 // Purpose : Accessor method to set the nonlinear solver strategy.
391 // Special Notes : Takes an integer argument
392 // Scope : public
393 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
394 // Creation Date : 02/26/01
395 //-----------------------------------------------------------------------------
396 inline void NLParams::setNLStrategy(int strategy)
397 {
398  nlStrategy_ = static_cast<NLStrategy> (strategy);
399 
400  // Make sure the method selected is supported, otherwise revert to the
401  // default.
402  if (nlStrategy_ != NEWTON &&
403  nlStrategy_ != GRADIENT &&
405  nlStrategy_ != MOD_NEWTON &&
407  resetNLStrategy();
408 }
409 
410 //-----------------------------------------------------------------------------
411 // Function : NLParams::resetNLStrategy
412 // Purpose : Accessor method to reset the nonlinear solver strategy to
413 // its default.
414 // Special Notes :
415 // Scope : public
416 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
417 // Creation Date : 02/26/01
418 //-----------------------------------------------------------------------------
420 {
422 }
423 
424 //-----------------------------------------------------------------------------
425 // Function : NLParams::getNLStrategy
426 // Purpose : Accessor method to return the nonlinear solver strategy.
427 // Special Notes :
428 // Scope : public
429 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
430 // Creation Date : 02/26/01
431 //-----------------------------------------------------------------------------
433 {
434  return nlStrategy_;
435 }
436 
437 //-----------------------------------------------------------------------------
438 // Function : NLParams::setSearchMethod
439 // Purpose : Accessor method to set the line-search method
440 // Special Notes :
441 // Scope : public
442 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
443 // Creation Date : 01/13/01
444 //-----------------------------------------------------------------------------
446 {
447  searchMethod_ = method;
448 
449  // Revert to the default if the method selected is not supported
450  if (searchMethod_ != FULL &&
451  searchMethod_ != DIVIDE &&
457 }
458 
459 //-----------------------------------------------------------------------------
460 // Function : NLParams::setSearchMethod
461 // Purpose : Accessor method to set the line-search method
462 // Special Notes : Takes and integer argument
463 // Scope : public
464 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
465 // Creation Date : 01/13/01
466 //-----------------------------------------------------------------------------
467 inline void NLParams::setSearchMethod(int method)
468 {
469  searchMethod_ = static_cast<LineSearchMethod> (method);
470 
471  // Revert to the default if the method selected is not supported
472  if (searchMethod_ != FULL &&
473  searchMethod_ != DIVIDE &&
479 }
480 
481 //-----------------------------------------------------------------------------
482 // Function : NLParams::resetSearchMethod
483 // Purpose : Accessor method to reset the default line-search method
484 // Special Notes :
485 // Scope : public
486 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
487 // Creation Date : 01/24/01
488 //-----------------------------------------------------------------------------
490 {
492 }
493 
494 //-----------------------------------------------------------------------------
495 // Function : NLParams::getSearchMethod
496 // Purpose : Accessor method to return the line-search method
497 // Special Notes :
498 // Scope : public
499 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
500 // Creation Date : 01/13/01
501 //-----------------------------------------------------------------------------
503 {
504  return searchMethod_;
505 }
506 
507 //-----------------------------------------------------------------------------
508 // Function : NLParams::setDirection
509 // Purpose : Accessor method to set the nonlinear direction flag.
510 // Special Notes :
511 // Scope : public
512 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
513 // Creation Date : 02/19/01
514 //-----------------------------------------------------------------------------
516 {
517 
518  // Make sure we have a valid value here.
519  assert(value >= 0);
520  direction_ = value;
521 }
522 
523 //-----------------------------------------------------------------------------
524 // Function : NLParams::resetDirection
525 // Purpose : Accessor method to reset the default nonlinear direction
526 // flag.
527 // Special Notes :
528 // Scope : public
529 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
530 // Creation Date : 02/19/01
531 //-----------------------------------------------------------------------------
533 {
535 }
536 
537 //-----------------------------------------------------------------------------
538 // Function : NLParams::getDirection
539 // Purpose : Accessor method to return the nonlinear diection flag.
540 // Special Notes :
541 // Scope : public
542 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
543 // Creation Date : 02/19/01
544 //-----------------------------------------------------------------------------
546 {
547  return direction_;
548 }
549 
550 //-----------------------------------------------------------------------------
551 // Function : NLParams::setDeltaXTol
552 // Purpose : Accessor method to set the deltaX (update) tolerance.
553 // Special Notes : This is used in combination with a WRMS norm.
554 // Scope : public
555 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
556 // Creation Date : 01/20/01
557 //-----------------------------------------------------------------------------
558 inline void NLParams::setDeltaXTol(double value)
559 {
560  deltaXTol_ = value;
561 }
562 
563 //-----------------------------------------------------------------------------
564 // Function : NLParams::resetDeltaXTol
565 // Purpose : Accessor method to reset the deltaX (update) tolerance to
566 // the default value.
567 // Special Notes : This is used in combination with a WRMS norm.
568 // Scope : public
569 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
570 // Creation Date : 01/20/01
571 //-----------------------------------------------------------------------------
573 {
574  deltaXTol_ = 1.0;
575 }
576 
577 //-----------------------------------------------------------------------------
578 // Function : NLParams::getDeltaXTol
579 // Purpose : Accessor method to return the deltaX (update) tolerance
580 // Special Notes : This is used in combination with a WRMS norm.
581 // Scope : public
582 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
583 // Creation Date : 01/20/01
584 //-----------------------------------------------------------------------------
585 inline double NLParams::getDeltaXTol() const
586 {
587  return deltaXTol_;
588 }
589 
590 //-----------------------------------------------------------------------------
591 // Function : NLParams::setSmallUpdateTol
592 // Purpose :
593 // Special Notes :
594 // Scope : public
595 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
596 // Creation Date : 07/02/03
597 //-----------------------------------------------------------------------------
598 inline void NLParams::setSmallUpdateTol (double value)
599 {
601 }
602 
603 //-----------------------------------------------------------------------------
604 // Function : NLParams::resetSmallUpdateTol
605 // Purpose :
606 // Special Notes :
607 // Scope : public
608 // Creator : Eric R. Keiter, SNL, Computational Sciences
609 // Creation Date : 07/02/03
610 //-----------------------------------------------------------------------------
612 {
613  smallUpdateTol_ = 1.0e-6;
614 }
615 
616 //-----------------------------------------------------------------------------
617 // Function : NLParams::getSmallUpdateTol
618 // Purpose :
619 // Special Notes :
620 // Scope : public
621 // Creator : Eric R. Keiter, SNL, Computational Sciences
622 // Creation Date : 07/02/03
623 //-----------------------------------------------------------------------------
624 inline double NLParams::getSmallUpdateTol () const
625 {
626  return smallUpdateTol_;
627 }
628 
629 //-----------------------------------------------------------------------------
630 // Function : NLParams::setRHSTol
631 // Purpose : Accessor method to set the RHS (residual) tolerance.
632 // Special Notes : This is used in combination with a WRMS norm.
633 // Scope : public
634 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
635 // Creation Date : 01/24/01
636 //-----------------------------------------------------------------------------
637 inline void NLParams::setRHSTol(double value)
638 {
639  RHSTol_ = value;
640 }
641 
642 //-----------------------------------------------------------------------------
643 // Function : NLParams::resetRHSTol
644 // Purpose : Accessor method to reset the RHS (residual) tolerance to
645 // the default value.
646 // Special Notes : This is used in combination with a WRMS norm.
647 // Scope : public
648 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
649 // Creation Date : 01/24/01
650 //-----------------------------------------------------------------------------
652 {
653  RHSTol_ = 1.0e-06;
654 }
655 
656 //-----------------------------------------------------------------------------
657 // Function : NLParams::getRHSTol
658 // Purpose : Accessor method to return the RHS (residual) tolerance
659 // Special Notes : This is used in combination with a WRMS norm.
660 // Scope : public
661 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
662 // Creation Date : 01/24/01
663 //-----------------------------------------------------------------------------
664 inline double NLParams::getRHSTol() const
665 {
666  return RHSTol_;
667 }
668 
669 //-----------------------------------------------------------------------------
670 // Function : NLParams::setAbsTol
671 // Purpose : Accessor method to set the absTol tolerance.
672 // Special Notes :
673 // Scope : public
674 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
675 // Creation Date : 01/22/01
676 //-----------------------------------------------------------------------------
677 inline void NLParams::setAbsTol(double value)
678 {
679  absTol_ = value;
680 }
681 
682 //-----------------------------------------------------------------------------
683 // Function : NLParams::resetAbsTol
684 // Purpose : Accessor method to reset the absTol tolerance to
685 // the default value.
686 // Special Notes :
687 // Scope : public
688 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
689 // Creation Date : 01/21/01
690 //-----------------------------------------------------------------------------
692 {
693  absTol_ = 1.0e-12;
694 }
695 
696 //-----------------------------------------------------------------------------
697 // Function : NLParams::getAbsTol
698 // Purpose : Accessor method to return the absTol tolerance
699 // Special Notes :
700 // Scope : public
701 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
702 // Creation Date : 01/21/01
703 //-----------------------------------------------------------------------------
704 inline double NLParams::getAbsTol() const
705 {
706  return absTol_;
707 }
708 
709 //-----------------------------------------------------------------------------
710 // Function : NLParams::setRelTol
711 // Purpose : Accessor method to set the relTol tolerance.
712 // Special Notes :
713 // Scope : public
714 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
715 // Creation Date : 01/22/01
716 //-----------------------------------------------------------------------------
717 inline void NLParams::setRelTol(double value)
718 {
719  relTol_ = value;
720 }
721 
722 //-----------------------------------------------------------------------------
723 // Function : NLParams::resetRelTol
724 // Purpose : Accessor method to reset the relTol tolerance to
725 // the default value.
726 // Special Notes :
727 // Scope : public
728 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
729 // Creation Date : 01/21/01
730 //-----------------------------------------------------------------------------
732 {
733  relTol_ = 1.0e-03;
734 }
735 
736 //-----------------------------------------------------------------------------
737 // Function : NLParams::getRelTol
738 // Purpose : Accessor method to return the relTol tolerance
739 // Special Notes :
740 // Scope : public
741 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
742 // Creation Date : 01/21/01
743 //-----------------------------------------------------------------------------
744 inline double NLParams::getRelTol() const
745 {
746  return relTol_;
747 }
748 
749 //-----------------------------------------------------------------------------
750 // Function : NLParams::setMaxNewtonStep
751 // Purpose : Accessor method to set the maximum number of Newton steps.
752 // Special Notes :
753 // Scope : public
754 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
755 // Creation Date : 01/24/01
756 //-----------------------------------------------------------------------------
757 inline void NLParams::setMaxNewtonStep(unsigned value)
758 {
760 }
761 
762 //-----------------------------------------------------------------------------
763 // Function : NLParams::resetMaxNewtonStep
764 // Purpose : Accessor method to reset the maximum number of Newton steps
765 // to the default.
766 // Special Notes :
767 // Scope : public
768 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
769 // Creation Date : 01/24/01
770 //-----------------------------------------------------------------------------
772 {
773  maxNewtonStep_ = 200;
774 }
775 
776 //-----------------------------------------------------------------------------
777 // Function : NLParams::getMaxNewtonStep
778 // Purpose : Accessor method to get the maximum number of Newton steps.
779 // Special Notes :
780 // Scope : public
781 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
782 // Creation Date : 01/24/01
783 //-----------------------------------------------------------------------------
784 inline unsigned NLParams::getMaxNewtonStep() const
785 {
786  return maxNewtonStep_;
787 }
788 
789 //-----------------------------------------------------------------------------
790 // Function : NLParams::setMaxSearchStep
791 // Purpose : Accessor method to set the maximum number of line-search
792 // steps.
793 // Special Notes :
794 // Scope : public
795 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
796 // Creation Date : 01/24/01
797 //-----------------------------------------------------------------------------
798 inline void NLParams::setMaxSearchStep(unsigned value)
799 {
801 }
802 
803 //-----------------------------------------------------------------------------
804 // Function : NLParams::resetMaxSearchStep
805 // Purpose : Accessor method to reset the maximum number of line-search
806 // steps to the default.
807 // Special Notes :
808 // Scope : public
809 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
810 // Creation Date : 01/24/01
811 //-----------------------------------------------------------------------------
813 {
814  maxSearchStep_ = 9;
815 }
816 
817 //-----------------------------------------------------------------------------
818 // Function : NLParams::getMaxSearchStep
819 // Purpose : Accessor method to get the maximum number of line-search
820 // steps.
821 // Special Notes :
822 // Scope : public
823 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
824 // Creation Date : 01/24/01
825 //-----------------------------------------------------------------------------
826 inline unsigned NLParams::getMaxSearchStep() const
827 {
828  return maxSearchStep_;
829 }
830 
831 //-----------------------------------------------------------------------------
832 // Function : NLParams::setForcingFlag
833 // Purpose : Accessor method to set the inexact-Newton forcing flag.
834 // Special Notes :
835 // Scope : public
836 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
837 // Creation Date : 05/04/01
838 //-----------------------------------------------------------------------------
840 {
841 
842  // Reset the linear solver tolerance if we're switching forcing off
843  // NOTE: I couldn't get this to work because we're instantiating several
844  // NLParams objects and the one for which the lasSolverPtr is getting set
845  // isn't the one needed. I've found a work-around for now but we'll need to
846  // fix this - SAH, 6/25/01
847 // if (INForcingFlag_ && !value)
848 // lasSolverPtr_->resetTolerance();
849 
851 }
852 
853 //-----------------------------------------------------------------------------
854 // Function : NLParams::resetForcingFlag
855 // Purpose : Accessor method to reset the default inexact-Newton forcing
856 // flag.
857 // Special Notes :
858 // Scope : public
859 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
860 // Creation Date : 05/04/01
861 //-----------------------------------------------------------------------------
863 {
864  INForcingFlag_ = false;
865 }
866 
867 //-----------------------------------------------------------------------------
868 // Function : NLParams::getForcingFlag
869 // Purpose : Accessor method to get the inexact-Newton forcing flag.
870 // Special Notes :
871 // Scope : public
872 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
873 // Creation Date : 05/04/01
874 //-----------------------------------------------------------------------------
875 inline bool NLParams::getForcingFlag() const
876 {
877  return INForcingFlag_;
878 }
879 
880 //-----------------------------------------------------------------------------
881 // Function : NLParams::setEnforceDeviceConvFlag
882 // Purpose : Accessor method to set the inexact-Newton forcing term.
883 // Special Notes :
884 // Scope : public
885 // Creator : Eric R. Keiter, SNL, Computational Sciences
886 // Creation Date : 06/30/05
887 //-----------------------------------------------------------------------------
888 inline void NLParams::setEnforceDeviceConvFlag (bool flag)
889 {
890  enforceDeviceConvFlag_ = flag;
891 }
892 
893 //-----------------------------------------------------------------------------
894 // Function : NLParams::resetEnforceDeviceConvFlag
895 // Purpose : Accessor method to reset the default inexact-Newton forcing
896 // value.
897 // Special Notes :
898 // Scope : public
899 // Creator : Eric R. Keiter, SNL, Computational Sciences
900 // Creation Date : 06/30/05
901 //-----------------------------------------------------------------------------
903 {
904  enforceDeviceConvFlag_ = true;
905 }
906 
907 //-----------------------------------------------------------------------------
908 // Function : NLParams::getEnforceDeviceConvFlag
909 // Purpose : Accessor method to get the inexact-Newton forcing term.
910 // Special Notes :
911 // Scope : public
912 // Creator : Eric R. Keiter, SNL, Computational Sciences
913 // Creation Date : 06/30/05
914 //-----------------------------------------------------------------------------
916 {
917  return enforceDeviceConvFlag_;
918 }
919 
920 //-----------------------------------------------------------------------------
921 // Function : NLParams::setForcingTerm
922 // Purpose : Accessor method to set the inexact-Newton forcing term.
923 // Special Notes :
924 // Scope : public
925 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
926 // Creation Date : 07/29/01
927 //-----------------------------------------------------------------------------
928 inline void NLParams::setForcingTerm(double value)
929 {
930  eta_ = value;
931 }
932 
933 //-----------------------------------------------------------------------------
934 // Function : NLParams::resetForcingTerm
935 // Purpose : Accessor method to reset the default inexact-Newton forcing
936 // value.
937 // Special Notes :
938 // Scope : public
939 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
940 // Creation Date : 07/29/01
941 //-----------------------------------------------------------------------------
943 {
944  eta_ = 1.0e-01;
945 }
946 
947 //-----------------------------------------------------------------------------
948 // Function : NLParams::getForcingTerm
949 // Purpose : Accessor method to get the inexact-Newton forcing term.
950 // Special Notes :
951 // Scope : public
952 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
953 // Creation Date : 06/29/01
954 //-----------------------------------------------------------------------------
955 inline double NLParams::getForcingTerm() const
956 {
957  return eta_;
958 }
959 
960 //-----------------------------------------------------------------------------
961 // Function : NLParams::setNormLevel
962 // Purpose : Accessor method to set the lp norm level (p).
963 // Special Notes :
964 // Scope : public
965 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
966 // Creation Date : 01/24/01
967 //-----------------------------------------------------------------------------
969 {
970  normLevel_ = value;
971 }
972 
973 //-----------------------------------------------------------------------------
974 // Function : NLParams::resetNormLevel
975 // Purpose : Accessor method to reset the lp norm level (p) to the
976 // default value.
977 // Special Notes :
978 // Scope : public
979 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
980 // Creation Date : 01/24/01
981 //-----------------------------------------------------------------------------
983 {
984  normLevel_ = 2;
985 }
986 
987 //-----------------------------------------------------------------------------
988 // Function : NLParams::getNormLevel
989 // Purpose : Accessor method to return the lp norm level (p).
990 // Special Notes :
991 // Scope : public
992 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
993 // Creation Date : 01/24/01
994 //-----------------------------------------------------------------------------
995 inline int NLParams::getNormLevel() const
996 {
997  return normLevel_;
998 }
999 
1000 //-----------------------------------------------------------------------------
1001 // Function : NLParams::setLinearOpt
1002 // Purpose : Accessor method to set the linear optimization flag.
1003 // Special Notes :
1004 // Scope : public
1005 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1006 // Creation Date : 01/24/01
1007 //-----------------------------------------------------------------------------
1008 inline void NLParams::setLinearOpt(bool flag)
1009 {
1010  linearOptimization_ = flag;
1011 }
1012 
1013 //-----------------------------------------------------------------------------
1014 // Function : NLParams::resetLinearOpt
1015 // Purpose : Accessor method to reset the default linear optimization
1016 // flag.
1017 // Special Notes :
1018 // Scope : public
1019 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1020 // Creation Date : 01/24/01
1021 //-----------------------------------------------------------------------------
1023 {
1024  linearOptimization_ = 0;
1025 }
1026 
1027 //-----------------------------------------------------------------------------
1028 // Function : NLParams::getLinearOpt
1029 // Purpose : Accessor method to return the linear optimization flag.
1030 // Special Notes :
1031 // Scope : public
1032 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1033 // Creation Date : 01/24/01
1034 //-----------------------------------------------------------------------------
1035 inline bool NLParams::getLinearOpt() const
1036 {
1037  return linearOptimization_;
1038 }
1039 
1040 //-----------------------------------------------------------------------------
1041 // Function : NLParams::setConstraintBT
1042 // Purpose : Accessor method to set the constraint backtracking flag.
1043 // Special Notes :
1044 // Scope : public
1045 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1046 // Creation Date : 02/06/01
1047 //-----------------------------------------------------------------------------
1048 inline void NLParams::setConstraintBT(bool flag)
1049 {
1050  constraintBT_ = flag;
1051 }
1052 
1053 //-----------------------------------------------------------------------------
1054 // Function : NLParams::resetConstraintBT
1055 // Purpose : Accessor method to reset the default constraint backtracking
1056 // flag.
1057 // Special Notes :
1058 // Scope : public
1059 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1060 // Creation Date : 02/06/01
1061 //-----------------------------------------------------------------------------
1063 {
1064  constraintBT_ = 0;
1065 }
1066 
1067 //-----------------------------------------------------------------------------
1068 // Function : NLParams::getConstraintBT
1069 // Purpose : Accessor method to return the constraint backtracking flag.
1070 // Special Notes :
1071 // Scope : public
1072 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1073 // Creation Date : 02/06/01
1074 //-----------------------------------------------------------------------------
1075 inline bool NLParams::getConstraintBT() const
1076 {
1077  return constraintBT_;
1078 }
1079 
1080 //-----------------------------------------------------------------------------
1081 // Function : NLParams::setGlobalBTMax
1082 // Purpose : Accessor method to set the constraint maximum value.
1083 // Special Notes :
1084 // Scope : public
1085 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1086 // Creation Date : 02/14/01
1087 //-----------------------------------------------------------------------------
1088 inline void NLParams::setGlobalBTMax(double value)
1089 {
1090  globalBTMax_ = value;
1091 }
1092 
1093 //-----------------------------------------------------------------------------
1094 // Function : NLParams::resetGlobalBTMax
1095 // Purpose : Accessor method to set the constraint maximum default value.
1096 // Special Notes :
1097 // Scope : public
1098 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1099 // Creation Date : 02/14/01
1100 //-----------------------------------------------------------------------------
1102 {
1103  globalBTMax_ = N_UTL_MachineDependentParams::DoubleMax();
1104 }
1105 
1106 //-----------------------------------------------------------------------------
1107 // Function : NLParams::getGlobalBTMax
1108 // Purpose : Accessor method to return the constraint maximum value.
1109 // Special Notes :
1110 // Scope : public
1111 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1112 // Creation Date : 02/14/01
1113 //-----------------------------------------------------------------------------
1114 inline double NLParams::getGlobalBTMax() const
1115 {
1116  return globalBTMax_;
1117 }
1118 
1119 //-----------------------------------------------------------------------------
1120 // Function : NLParams::setGlobalBTMin
1121 // Purpose : Accessor method to set the constraint minimum value.
1122 // Special Notes :
1123 // Scope : public
1124 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1125 // Creation Date : 02/14/01
1126 //-----------------------------------------------------------------------------
1127 inline void NLParams::setGlobalBTMin(double value)
1128 {
1129  globalBTMin_ = value;
1130 }
1131 
1132 //-----------------------------------------------------------------------------
1133 // Function : NLParams::resetGlobalBTMin
1134 // Purpose : Accessor method to set the constraint minimum default value.
1135 // Special Notes :
1136 // Scope : public
1137 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1138 // Creation Date : 02/14/01
1139 //-----------------------------------------------------------------------------
1141 {
1142  globalBTMin_ = -N_UTL_MachineDependentParams::DoubleMax();
1143 }
1144 
1145 //-----------------------------------------------------------------------------
1146 // Function : NLParams::getGlobalBTMin
1147 // Purpose : Accessor method to return the constraint minimum value.
1148 // Special Notes :
1149 // Scope : public
1150 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1151 // Creation Date : 02/14/01
1152 //-----------------------------------------------------------------------------
1153 inline double NLParams::getGlobalBTMin() const
1154 {
1155  return globalBTMin_;
1156 }
1157 
1158 //-----------------------------------------------------------------------------
1159 // Function : NLParams::setGlobalBTChange
1160 // Purpose : Accessor method to set the constraint percentage change
1161 // value.
1162 // Special Notes :
1163 // Scope : public
1164 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1165 // Creation Date : 02/14/01
1166 //-----------------------------------------------------------------------------
1168 {
1170 }
1171 
1172 //-----------------------------------------------------------------------------
1173 // Function : NLParams::resetGlobalBTChange
1174 // Purpose : Accessor method to set the constraint percentage change
1175 // default value.
1176 // Special Notes :
1177 // Scope : public
1178 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1179 // Creation Date : 02/14/01
1180 //-----------------------------------------------------------------------------
1182 {
1183  globalBTChange_ = sqrt(N_UTL_MachineDependentParams::DoubleMax());
1184 }
1185 
1186 //-----------------------------------------------------------------------------
1187 // Function : NLParams::getGlobalBTChange
1188 // Purpose : Accessor method to return the constraint percentage change
1189 // value.
1190 // Special Notes :
1191 // Scope : public
1192 // Creator : Scott A. Hutchinson, SNL, Computational Sciences
1193 // Creation Date : 02/14/01
1194 //-----------------------------------------------------------------------------
1195 inline double NLParams::getGlobalBTChange() const
1196 {
1197  return globalBTChange_;
1198 }
1199 
1200 //-----------------------------------------------------------------------------
1201 // Function : NLParams::setDebugLevel
1202 // Purpose :
1203 // Special Notes :
1204 // Scope : public
1205 // Creator : Eric R. Keiter, SNL, Computational Sciences
1206 // Creation Date : 09/23/01
1207 //-----------------------------------------------------------------------------
1209 {
1210  debugLevel_ = value;
1211 }
1212 
1213 //-----------------------------------------------------------------------------
1214 // Function : NLParams::resetDebugLevel
1215 // Purpose :
1216 // Special Notes :
1217 // Scope : public
1218 // Creator : Eric R. Keiter, SNL, Computational Sciences
1219 // Creation Date : 09/23/01
1220 //-----------------------------------------------------------------------------
1222 {
1223  debugLevel_ = 1;
1224 }
1225 
1226 //-----------------------------------------------------------------------------
1227 // Function : NLParams::getDebugLevel
1228 // Purpose :
1229 // Special Notes :
1230 // Scope : public
1231 // Creator : Eric R. Keiter, SNL, Computational Sciences
1232 // Creation Date : 09/23/01
1233 //-----------------------------------------------------------------------------
1234 inline int NLParams::getDebugLevel() const
1235 {
1236  return debugLevel_;
1237 }
1238 
1239 
1240 //-----------------------------------------------------------------------------
1241 // Function : NLParams::setDebugMinTimeStep
1242 // Purpose :
1243 // Special Notes :
1244 // Scope : public
1245 // Creator : Eric R. Keiter, SNL, Computational Sciences
1246 // Creation Date : 09/23/01
1247 //-----------------------------------------------------------------------------
1249 {
1251 }
1252 
1253 //-----------------------------------------------------------------------------
1254 // Function : NLParams::resetDebugMinTimeStep
1255 // Purpose :
1256 // Special Notes :
1257 // Scope : public
1258 // Creator : Eric R. Keiter, SNL, Computational Sciences
1259 // Creation Date : 09/23/01
1260 //-----------------------------------------------------------------------------
1262 {
1263  debugMinTimeStep_ = 0;
1264 }
1265 
1266 //-----------------------------------------------------------------------------
1267 // Function : NLParams::getDebugMinTimeStep
1268 // Purpose :
1269 // Special Notes :
1270 // Scope : public
1271 // Creator : Eric R. Keiter, SNL, Computational Sciences
1272 // Creation Date : 09/23/01
1273 //-----------------------------------------------------------------------------
1275 {
1276  return debugMinTimeStep_;
1277 }
1278 
1279 //-----------------------------------------------------------------------------
1280 // Function : NLParams::setDebugMaxTimeStep
1281 // Purpose :
1282 // Special Notes :
1283 // Scope : public
1284 // Creator : Eric R. Keiter, SNL, Computational Sciences
1285 // Creation Date : 09/23/01
1286 //-----------------------------------------------------------------------------
1288 {
1290 }
1291 
1292 //-----------------------------------------------------------------------------
1293 // Function : NLParams::resetDebugMaxTimeStep
1294 // Purpose :
1295 // Special Notes :
1296 // Scope : public
1297 // Creator : Eric R. Keiter, SNL, Computational Sciences
1298 // Creation Date : 09/23/01
1299 //-----------------------------------------------------------------------------
1301 {
1302  debugMaxTimeStep_ = N_UTL_MachineDependentParams::IntMax();
1303 }
1304 
1305 //-----------------------------------------------------------------------------
1306 // Function : NLParams::getDebugMaxTimeStep
1307 // Purpose :
1308 // Special Notes :
1309 // Scope : public
1310 // Creator : Eric R. Keiter, SNL, Computational Sciences
1311 // Creation Date : 09/23/01
1312 //-----------------------------------------------------------------------------
1314 {
1315  return debugMaxTimeStep_;
1316 }
1317 
1318 //-----------------------------------------------------------------------------
1319 // Function : NLParams::setDebugMinTime
1320 // Purpose :
1321 // Special Notes :
1322 // Scope : public
1323 // Creator : Eric R. Keiter, SNL, Computational Sciences
1324 // Creation Date : 09/23/01
1325 //-----------------------------------------------------------------------------
1327 {
1328  debugMinTime_ = value;
1329 }
1330 
1331 //-----------------------------------------------------------------------------
1332 // Function : NLParams::resetDebugMinTime
1333 // Purpose :
1334 // Special Notes :
1335 // Scope : public
1336 // Creator : Eric R. Keiter, SNL, Computational Sciences
1337 // Creation Date : 09/23/01
1338 //-----------------------------------------------------------------------------
1340 {
1341  debugMinTime_ = 0.0;
1342 }
1343 
1344 //-----------------------------------------------------------------------------
1345 // Function : NLParams::getDebugMinTime
1346 // Purpose :
1347 // Special Notes :
1348 // Scope : public
1349 // Creator : Eric R. Keiter, SNL, Computational Sciences
1350 // Creation Date : 09/23/01
1351 //-----------------------------------------------------------------------------
1352 inline double NLParams::getDebugMinTime() const
1353 {
1354  return debugMinTime_;
1355 }
1356 
1357 //-----------------------------------------------------------------------------
1358 // Function : NLParams::setDebugMaxTime
1359 // Purpose :
1360 // Special Notes :
1361 // Scope : public
1362 // Creator : Eric R. Keiter, SNL, Computational Sciences
1363 // Creation Date : 09/23/01
1364 //-----------------------------------------------------------------------------
1366 {
1367  debugMaxTime_ = value;
1368 }
1369 
1370 //-----------------------------------------------------------------------------
1371 // Function : NLParams::resetDebugMaxTime
1372 // Purpose :
1373 // Special Notes :
1374 // Scope : public
1375 // Creator : Eric R. Keiter, SNL, Computational Sciences
1376 // Creation Date : 09/23/01
1377 //-----------------------------------------------------------------------------
1379 {
1380  debugMaxTime_ = N_UTL_MachineDependentParams::DoubleMax();
1381 }
1382 
1383 //-----------------------------------------------------------------------------
1384 // Function : NLParams::getDebugMaxTime
1385 // Purpose :
1386 // Special Notes :
1387 // Scope : public
1388 // Creator : Eric R. Keiter, SNL, Computational Sciences
1389 // Creation Date : 09/23/01
1390 //-----------------------------------------------------------------------------
1391 inline double NLParams::getDebugMaxTime() const
1392 {
1393  return debugMaxTime_;
1394 }
1395 
1396 //-----------------------------------------------------------------------------
1397 // Function : NLParams::setScreenOutputFlag
1398 // Purpose :
1399 // Special Notes :
1400 // Scope : public
1401 // Creator : Eric R. Keiter, SNL, Computational Sciences
1402 // Creation Date : 04/25/04
1403 //-----------------------------------------------------------------------------
1404 inline void NLParams::setScreenOutputFlag (bool bval)
1405 {
1406  screenOutputFlag_ = bval;
1407 }
1408 
1409 //-----------------------------------------------------------------------------
1410 // Function : NLParams::resetScreenOutputFlag
1411 // Purpose :
1412 // Special Notes :
1413 // Scope : public
1414 // Creator : Eric R. Keiter, SNL, Computational Sciences
1415 // Creation Date : 04/25/04
1416 //-----------------------------------------------------------------------------
1418 {
1419  screenOutputFlag_ = false;
1420 }
1421 
1422 //-----------------------------------------------------------------------------
1423 // Function : NLParams::getScreenOutputFlag
1424 // Purpose :
1425 // Special Notes :
1426 // Scope : public
1427 // Creator : Eric R. Keiter, SNL, Computational Sciences
1428 // Creation Date : 04/25/04
1429 //-----------------------------------------------------------------------------
1430 inline bool NLParams::getScreenOutputFlag () const
1431 {
1432  return screenOutputFlag_;
1433 }
1434 
1435 //-----------------------------------------------------------------------------
1436 // Function : NLParams::setMMFormat
1437 // Purpose :
1438 // Special Notes :
1439 // Scope : public
1440 // Creator : Eric R. Keiter, SNL, Computational Sciences
1441 // Creation Date :
1442 //-----------------------------------------------------------------------------
1443 inline void NLParams::setMMFormat(bool value)
1444 {
1446 }
1447 
1448 //-----------------------------------------------------------------------------
1449 // Function : NLParams::resetMMFormat
1450 // Purpose :
1451 // Special Notes :
1452 // Scope : public
1453 // Creator : Eric R. Keiter, SNL, Computational Sciences
1454 // Creation Date :
1455 //-----------------------------------------------------------------------------
1457 {
1458  matrixMarketFormat_=false;
1459 }
1460 
1461 //-----------------------------------------------------------------------------
1462 // Function : NLParams::getMMFormat
1463 // Purpose :
1464 // Special Notes :
1465 // Scope : public
1466 // Creator : Eric R. Keiter, SNL, Computational Sciences
1467 // Creation Date :
1468 //-----------------------------------------------------------------------------
1469 inline bool NLParams::getMMFormat() const
1470 {
1471  return matrixMarketFormat_;
1472 }
1473 
1474 } // namespace Nonlinear
1475 } // namespace Xyce
1476 
1477 #endif // Xyce_N_NLS_NLParams_h