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.16 $
40 //
41 // Revision Date : $Date: 2014/08/07 23:08:54 $
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 namespace Xyce {
62 namespace Nonlinear {
63 
64 //-----------------------------------------------------------------------------
65 // Function : ParamMgr::ParamMgr
66 // Purpose : constructor
67 // Special Notes :
68 // Scope : public
69 // Creator : Eric R. Keiter, SNL, Computational Sciences
70 // Creation Date : 10/26/02
71 //-----------------------------------------------------------------------------
72 ParamMgr::ParamMgr (N_IO_CmdParse & cp)
73  : modeToggled_(true),
74  gcp_calledBefore_(false),
75  paramsChanged_(false),
76  currentMode_(DC_OP)
77 {
78  paramVector_.resize(NUM_MODES, NLParams(DC_OP, cp));
80 
82 }
83 
84 //-----------------------------------------------------------------------------
85 // Function : ParamMgr::~ParamMgr
86 // Purpose : destructor
87 // Special Notes :
88 // Scope : public
89 // Creator : Eric R. Keiter, SNL, Computational Sciences
90 // Creation Date : 10/26/02
91 //-----------------------------------------------------------------------------
93 {
94 
95 }
96 
97 //-----------------------------------------------------------------------------
98 // Function : ParamMgr::addParameterSet
99 // Purpose :
100 // Special Notes :
101 // Scope : public
102 // Creator : Eric R. Keiter, SNL, Computational Sciences
103 // Creation Date : 10/26/02
104 //-----------------------------------------------------------------------------
106 {
107  // add a check to make see if this parameter name has already been used.
108  paramVector_[mode] = nlp;
109 
110  return true;
111 }
112 
113 //-----------------------------------------------------------------------------
114 // Function : ParamMgr::getParams
115 // Purpose :
116 // Special Notes : might not need this one...
117 // Scope : public
118 // Creator : Eric R. Keiter, SNL, Computational Sciences
119 // Creation Date : 10/26/02
120 //-----------------------------------------------------------------------------
122 {
123  nlp = paramVector_[mode];
124  return true;
125 }
126 
127 //-----------------------------------------------------------------------------
128 // Function : ParamMgr::getCurrentparams
129 // Purpose : copies the official set of current parameters into the
130 // passed reference.
131 //
132 // Special Notes :
133 //
134 // If the toggle flag isn't set, then don't change the parameters.
135 // Leave them as-is.
136 //
137 // The modeToggled flag is connected to the "resetTranNLS" setting
138 // from time integration. If true, it means "use different params"
139 // for transient than for dcop. In general, if resetTranNLS=0 in
140 // the netlist, then the code will only use the first (DCOP) set of
141 // parameters and will never use any others.
142 //
143 // It is kind of an obsolete option. When it was first put in the code,
144 // it was not possible to specify a separate set of options for transient.
145 // You could only specify one set, and that was it. Initially, to get
146 // around this limitation, a set of options for transient was hardwired
147 // into the code. This hardwired set became the default for transient.
148 // If you didn't want to use this default, you had to invoke the
149 // resetTranNLS option, and the code would just use the DCOP options.
150 //
151 // Now, however, you can easily specify a separate set for transient,
152 // so this feature probably isn't necessary. ERK.
153 //
154 // Scope : public
155 // Creator : Eric R. Keiter, SNL, Computational Sciences
156 // Creation Date : 10/26/02
157 //-----------------------------------------------------------------------------
159 {
160  // copy over a new copy of the params if one of the following is true:
161  // 1) parameters have changed, and resetTranNLS is true.
162  // 2) this function has never been called before.
163  bool updateFlag = ((paramsChanged_ && modeToggled_) || !gcp_calledBefore_);
164 
165  if ( updateFlag )
166  {
167  nlp = paramVector_[currentMode_];
168  paramsChanged_ = false;
169  gcp_calledBefore_ = true;
170  }
171 
172 #ifdef Xyce_VERBOSE_NONLINEAR
173  // if this has never been called before, or if the parameters have
174  // been changed recently, then print them out.
175  if ( updateFlag )
176  {
177  nlp.printParams (Xyce::lout());
178  }
179 #endif
180 
181  return true;
182 }
183 
184 } // namespace Nonlinear
185 } // namespace Xyce