Xyce  6.1
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-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_NLS_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.21 $
40 //
41 // Revision Date : $Date: 2015/04/08 19:18:29 $
42 //
43 // Current Owner : $Author $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 #include <N_ERH_ErrorMgr.h>
53 #include <N_IO_CmdParse.h>
54 #include <N_NLS_NLParams.h>
55 #include <N_NLS_ParamMgr.h>
56 #include <N_UTL_FeatureTest.h>
57 
58 // ---------- Forward Declarations ----------
59 
60 // ---------- Static Initializations ----------
61 
62 namespace Xyce {
63 namespace Nonlinear {
64 
65 //-----------------------------------------------------------------------------
66 // Function : ParamMgr::ParamMgr
67 // Purpose : constructor
68 // Special Notes :
69 // Scope : public
70 // Creator : Eric R. Keiter, SNL, Computational Sciences
71 // Creation Date : 10/26/02
72 //-----------------------------------------------------------------------------
73 ParamMgr::ParamMgr (const IO::CmdParse & cp)
74  : modeToggled_(true),
75  gcp_calledBefore_(false),
76  paramsChanged_(false),
77  currentMode_(DC_OP)
78 {
79  paramVector_.resize(NUM_MODES, NLParams(DC_OP, cp));
81 
83 }
84 
85 //-----------------------------------------------------------------------------
86 // Function : ParamMgr::~ParamMgr
87 // Purpose : destructor
88 // Special Notes :
89 // Scope : public
90 // Creator : Eric R. Keiter, SNL, Computational Sciences
91 // Creation Date : 10/26/02
92 //-----------------------------------------------------------------------------
94 {
95 
96 }
97 
98 //-----------------------------------------------------------------------------
99 // Function : ParamMgr::addParameterSet
100 // Purpose :
101 // Special Notes :
102 // Scope : public
103 // Creator : Eric R. Keiter, SNL, Computational Sciences
104 // Creation Date : 10/26/02
105 //-----------------------------------------------------------------------------
107 {
108  // add a check to make see if this parameter name has already been used.
109  paramVector_[mode] = nlp;
110 
111  return true;
112 }
113 
114 //-----------------------------------------------------------------------------
115 // Function : ParamMgr::getParams
116 // Purpose :
117 // Special Notes : might not need this one...
118 // Scope : public
119 // Creator : Eric R. Keiter, SNL, Computational Sciences
120 // Creation Date : 10/26/02
121 //-----------------------------------------------------------------------------
123 {
124  nlp = paramVector_[mode];
125  return true;
126 }
127 
128 //-----------------------------------------------------------------------------
129 // Function : ParamMgr::getCurrentparams
130 // Purpose : copies the official set of current parameters into the
131 // passed reference.
132 //
133 // Special Notes :
134 //
135 // If the toggle flag isn't set, then don't change the parameters.
136 // Leave them as-is.
137 //
138 // The modeToggled flag is connected to the "resetTranNLS" setting
139 // from time integration. If true, it means "use different params"
140 // for transient than for dcop. In general, if resetTranNLS=0 in
141 // the netlist, then the code will only use the first (DCOP) set of
142 // parameters and will never use any others.
143 //
144 // It is kind of an obsolete option. When it was first put in the code,
145 // it was not possible to specify a separate set of options for transient.
146 // You could only specify one set, and that was it. Initially, to get
147 // around this limitation, a set of options for transient was hardwired
148 // into the code. This hardwired set became the default for transient.
149 // If you didn't want to use this default, you had to invoke the
150 // resetTranNLS option, and the code would just use the DCOP options.
151 //
152 // Now, however, you can easily specify a separate set for transient,
153 // so this feature probably isn't necessary. ERK.
154 //
155 // Scope : public
156 // Creator : Eric R. Keiter, SNL, Computational Sciences
157 // Creation Date : 10/26/02
158 //-----------------------------------------------------------------------------
160 {
161  // copy over a new copy of the params if one of the following is true:
162  // 1) parameters have changed, and resetTranNLS is true.
163  // 2) this function has never been called before.
164  bool updateFlag = ((paramsChanged_ && modeToggled_) || !gcp_calledBefore_);
165 
166  if ( updateFlag )
167  {
168  nlp = paramVector_[currentMode_];
169  paramsChanged_ = false;
170  gcp_calledBefore_ = true;
171  }
172 
173  // if this has never been called before, or if the parameters have
174  // been changed recently, then print them out.
175  if (VERBOSE_NONLINEAR && updateFlag )
176  nlp.printParams (lout());
177 
178  return true;
179 }
180 
181 } // namespace Nonlinear
182 } // namespace Xyce
Pure virtual class to augment a linear system.
bool getCurrentParams(NLParams &nlp)
std::vector< NLParams > paramVector_
bool addParameterSet(AnalysisMode mode, NLParams &nlp)
ParamMgr(const IO::CmdParse &cp)
void printParams(std::ostream &os)
bool getParams(AnalysisMode mode, NLParams &nlp)