Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_ParamMgr.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_ParamMgr.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 10/26/02
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.15 $
40 //
41 // Revision Date : $Date: 2014/02/24 23:49:25 $
42 //
43 // Current Owner : $Author $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 #include <N_NLS_ParamMgr.h>
53 #include <N_NLS_NLParams.h>
54 #include <N_ERH_ErrorMgr.h>
55 #include <N_IO_CmdParse.h>
56 
57 // ---------- Forward Declarations ----------
58 
59 // ---------- Static Initializations ----------
60 
61 //-----------------------------------------------------------------------------
62 // Function : N_NLS_ParamMgr::N_NLS_ParamMgr
63 // Purpose : constructor
64 // Special Notes :
65 // Scope : public
66 // Creator : Eric R. Keiter, SNL, Computational Sciences
67 // Creation Date : 10/26/02
68 //-----------------------------------------------------------------------------
69 N_NLS_ParamMgr::N_NLS_ParamMgr (N_IO_CmdParse & cp)
70  : modeToggled_(true),
71  gcp_calledBefore_(false),
72  paramsChanged_(false),
73  currentMode_(DC_OP)
74 {
77 
79 }
80 
81 //-----------------------------------------------------------------------------
82 // Function : N_NLS_ParamMgr::~N_NLS_ParamMgr
83 // Purpose : destructor
84 // Special Notes :
85 // Scope : public
86 // Creator : Eric R. Keiter, SNL, Computational Sciences
87 // Creation Date : 10/26/02
88 //-----------------------------------------------------------------------------
90 {
91 
92 }
93 
94 //-----------------------------------------------------------------------------
95 // Function : N_NLS_ParamMgr::addParameterSet
96 // Purpose :
97 // Special Notes :
98 // Scope : public
99 // Creator : Eric R. Keiter, SNL, Computational Sciences
100 // Creation Date : 10/26/02
101 //-----------------------------------------------------------------------------
103 {
104  // add a check to make see if this parameter name has already been used.
105  paramVector_[mode] = nlp;
106 
107  return true;
108 }
109 
110 //-----------------------------------------------------------------------------
111 // Function : N_NLS_ParamMgr::getParams
112 // Purpose :
113 // Special Notes : might not need this one...
114 // Scope : public
115 // Creator : Eric R. Keiter, SNL, Computational Sciences
116 // Creation Date : 10/26/02
117 //-----------------------------------------------------------------------------
119 {
120  nlp = paramVector_[mode];
121  return true;
122 }
123 
124 //-----------------------------------------------------------------------------
125 // Function : N_NLS_ParamMgr::getCurrentparams
126 // Purpose : copies the official set of current parameters into the
127 // passed reference.
128 //
129 // Special Notes :
130 //
131 // If the toggle flag isn't set, then don't change the parameters.
132 // Leave them as-is.
133 //
134 // The modeToggled flag is connected to the "resetTranNLS" setting
135 // from time integration. If true, it means "use different params"
136 // for transient than for dcop. In general, if resetTranNLS=0 in
137 // the netlist, then the code will only use the first (DCOP) set of
138 // parameters and will never use any others.
139 //
140 // It is kind of an obsolete option. When it was first put in the code,
141 // it was not possible to specify a separate set of options for transient.
142 // You could only specify one set, and that was it. Initially, to get
143 // around this limitation, a set of options for transient was hardwired
144 // into the code. This hardwired set became the default for transient.
145 // If you didn't want to use this default, you had to invoke the
146 // resetTranNLS option, and the code would just use the DCOP options.
147 //
148 // Now, however, you can easily specify a separate set for transient,
149 // so this feature probably isn't necessary. ERK.
150 //
151 // Scope : public
152 // Creator : Eric R. Keiter, SNL, Computational Sciences
153 // Creation Date : 10/26/02
154 //-----------------------------------------------------------------------------
156 {
157  // copy over a new copy of the params if one of the following is true:
158  // 1) parameters have changed, and resetTranNLS is true.
159  // 2) this function has never been called before.
160  bool updateFlag = ((paramsChanged_ && modeToggled_) || !gcp_calledBefore_);
161 
162  if ( updateFlag )
163  {
164  nlp = paramVector_[currentMode_];
165  paramsChanged_ = false;
166  gcp_calledBefore_ = true;
167  }
168 
169 #ifdef Xyce_VERBOSE_NONLINEAR
170  // if this has never been called before, or if the parameters have
171  // been changed recently, then print them out.
172  if ( updateFlag )
173  {
174  nlp.printParams (Xyce::lout());
175  }
176 #endif
177 
178  return true;
179 }
180