Xyce  6.1
N_LOA_Loader.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-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_LOA_Loader.h,v $
27 //
28 // Purpose : This file contains class definitions for the base
29 // loader class.
30 //
31 // Special Notes : This is a potentially confusing set of classes. As of
32 // this writing(2/11/2007), loaders are used in 2 different
33 // interface layers:
34 //
35 // 1) between the nonlinear solver and time integrator:
36 // Nonlinear Equation loader.
37 //
38 // 2) between the time integrator and the device package:
39 // Ckt loader, MPDE, and SawTooth loaders
40 //
41 // This gets confusing, because 2 different purposes are being
42 // served.
43 //
44 // The Nonlinear Equation loader exists to insulate the nonlinear
45 // solver from having to know what kind of problem(in a math
46 // sense) this is. For DCOP, the rhs consists of F(x) and B(t),
47 // but for transient F(x,t) , dQdt(x,t) and B(t). The Nonlinear Equation
48 // loader hides this decision from the nonlinear solver.
49 //
50 // The other layer(Ckt, MPDE and sawtooth) does 2 things.
51 // (1) it insulates the solvers from the specific physics.
52 // ie, the solvers(theoretically) don't know this is a
53 // circuit code.(2) We can hide MPDE details behind this
54 // interface, so the rest of the code can mostly be unaware
55 // if we are running an MPDE simulation or not.
56 //
57 // This structure is not perfect, and because it serves several
58 // different purposes, confusing.
59 //
60 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
61 //
62 // Creation Date : 05/26/00
63 //
64 // Revision Information:
65 // ---------------------
66 //
67 // Revision Number: $Revision: 1.122 $
68 //
69 // Revision Date : $Date: 2015/07/11 23:40:29 $
70 //
71 // Current Owner : $Author: erkeite $
72 //-----------------------------------------------------------------------------
73 
74 #ifndef Xyce_LOA_Loader_H
75 #define Xyce_LOA_Loader_H
76 
77 // ---------- Standard Includes ----------
78 #include <vector>
79 
80 // ---------- Xyce Includes ----------
81 
82 #include <N_ANP_fwd.h>
83 #include <N_DEV_fwd.h>
84 #include <N_LAS_fwd.h>
85 #include <N_PDS_fwd.h>
86 #include <N_TIA_fwd.h>
87 #include <N_UTL_fwd.h>
88 
89 namespace Xyce {
90 namespace Loader {
91 
92 //-----------------------------------------------------------------------------
93 // Class : Loader
94 // Purpose :
95 // Special Notes :
96 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
97 // Creation Date : 5/03/00
98 //-----------------------------------------------------------------------------
99 class Loader
100 {
101 public:
103  {}
104 
105  virtual ~Loader()
106  {}
107 
108  // return value indicates whether mask is nontrivial
109  // Virtual nonlinear new-DAE Matrices load method.
110  virtual bool loadDAEMatrices(
111  Linear::Vector * tmpSolVectorPtr,
112  Linear::Vector * tmpStaVectorPtr,
113  Linear::Vector * tmpStaDerivVectorPtr,
114  Linear::Vector * tmpStoVectorPtr,
115  Linear::Matrix * tmpdQdxMatrixPtr,
116  Linear::Matrix * tmpdFdxMatrixPtr)
117  {
118  return false;
119  }
120 
121  // Virtual nonlinear new-DAE vectors load method.
122  virtual bool loadDAEVectors(
123  Linear::Vector * nextSolVectorPtr,
124  Linear::Vector * currSolVectorPtr,
125  Linear::Vector * lastSolVectorPtr,
126  Linear::Vector * nextStaVectorPtr,
127  Linear::Vector * currStaVectorPtr,
128  Linear::Vector * lastStaVectorPtr,
129  Linear::Vector * StaDerivVectorPtr,
130  Linear::Vector * nextStoVectorPtr,
131  Linear::Vector * currStoVectorPtr,
132  Linear::Vector * lastStoVectorPtr,
133  Linear::Vector * stoLeadCurrQVectorPtr,
134  Linear::Vector * nextLeadFVectorPtr,
135  Linear::Vector * currLeadFVectorPtr,
136  Linear::Vector * lastLeadFVectorPtr,
137  Linear::Vector * nextLeadQVectorPtr,
138  Linear::Vector * nextJunctionVVectorPtr,
139  Linear::Vector * currJunctionVVectorPtr,
140  Linear::Vector * lastJunctionVVectorPtr,
141  Linear::Vector * QVectorPtr,
142  Linear::Vector * FVectorPtr,
143  Linear::Vector * BVectorPtr,
144  Linear::Vector * dFdxdVpVectorPtr,
145  Linear::Vector * dQdxdVpVectorPtr)
146  {
147  return false;
148  }
149 
150  // base class method does nothing.
151  virtual bool loadDeviceErrorWeightMask(Linear::Vector * deviceMask) const
152  {
153  return false;
154  }
155 
156  // Virtual method which initializes the nonlinear problem.
157  virtual bool initializeProblem(
158  Linear::Vector * nextSolVectorPtr,
159  Linear::Vector * currSolVectorPtr,
160  Linear::Vector * lastSolVectorPtr,
161  Linear::Vector * nextStaVectorPtr,
162  Linear::Vector * currStaVectorPtr,
163  Linear::Vector * lastStaVectorPtr,
164  Linear::Vector * StateDerivVectorPtr,
165  Linear::Vector * nextStoVectorPtr,
166  Linear::Vector * currStoVectorPtr,
167  Linear::Vector * lastStoVectorPtr,
168  Linear::Vector * QVectorPtr,
169  Linear::Vector * FVectorPtr,
170  Linear::Vector * BVectorPtr,
171  Linear::Vector * dFdxdVpVectorPtr,
172  Linear::Vector * dQdxdVpVectorPtr) const = 0;
173 
174  // Virtual nonlinear new-DAE Matrices apply method.
175  // tmpdQdxVecVector = tmpdQdxMatrix * tmpVecVector
176  // tmpdFdxVecVector = tmpdFdxMatrix * tmpVecVector
177  virtual bool applyDAEMatrices(
178  Linear::Vector * tmpSolVectorPtr,
179  Linear::Vector * tmpStaVectorPtr,
180  Linear::Vector * tmpStaDerivVectorPtr,
181  Linear::Vector * tmpStoVectorPtr,
182  const Linear::Vector & tmpVecVectorPtr,
183  Linear::Vector * tmpdQdxVecVectorPtr,
184  Linear::Vector * tmpdFdxVecVectorPtr)
185  {
186  return false;
187  }
188 
189  virtual bool updateState(
190  Linear::Vector * nextSolVectorPtr,
191  Linear::Vector * currSolVectorPtr,
192  Linear::Vector * lastSolVectorPtr,
193  Linear::Vector * nextStaVectorPtr,
194  Linear::Vector * currStaVectorPtr,
195  Linear::Vector * lastStaVectorPtr,
196  Linear::Vector * nextStoVectorPtr,
197  Linear::Vector * currStoVectorPtr,
198  Linear::Vector * lastStoVectorPtr)
199  {
200  return false;
201  }
202 
203  virtual bool loadBVectorsforAC(
204  Linear::Vector * bVecRealPtr,
205  Linear::Vector * bVecImagPtr)
206  {
207  return false;
208  }
209 
210  virtual int getNumNoiseSources()
211  {
212  return 0;
213  }
214 
215  virtual int getNumNoiseDevices()
216  {
217  return 0;
218  }
219 
220  virtual void setupNoiseSources(std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec)
221  {}
222 
223  virtual void getNoiseSources(std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec)
224  {}
225 
226  virtual bool getBMatrixEntriesforMOR(std::vector<int>& bMatEntriesVec, std::vector<int>& bMatPosEntriesVec)
227  {
228  return false;
229  }
230 
231  // Virtual function for setting the initial guess.
232  virtual bool setInitialGuess(Linear::Vector * solVectorPtr)
233  {
234  return false;
235  }
236 
237  // Virtual function for setting a single parameter value.
238  virtual bool setParam(std::string & name, double val, bool overrideOriginal = false) = 0;
239 
240  // Virtual function for getting a single parameter value.
241  virtual double getParamAndReduce(Parallel::Machine comm, const std::string & name) const = 0;
242 
243  // Virtual method which is called to update the sources.
244  virtual bool updateSources()
245  {
246  return false;
247  }
248  // This is somewhat circuit-specific, unfortunately.
249  virtual bool getLimiterFlag()
250  {
251  return false;
252  }
253 
254  // Virtual method which gets the double DC Operating Point flag - used for
255  // PDE devices.
256  virtual bool isPDESystem() const
257  {
258  return false;
259  }
260 
261  virtual bool outputPlotFiles() const
262  {
263  return false;
264  }
265 
266  virtual bool finishOutput() const
267  {
268  return false;
269  }
270 
271  // Virtual method which gets the time integration required breakpoint times
272  //(in a vector).
273  virtual bool getBreakPoints(std::vector< Util::BreakPoint > & breakPointTimes) const
274  {
275  return false;
276  }
277 
278  // Virtual accessor which returns the maximum time step size(in seconds).
279  virtual double getMaxTimeStepSize()
280  {
281  return 0.0;
282  }
283 
284  virtual void stepSuccess(Analysis::TwoLevelMode analysis)
285  {}
286 
287  virtual void stepFailure(Analysis::TwoLevelMode analysis)
288  {}
289 
290  //TVR: Method to be called when time integrator accepts a step, before any
291  // tinkering with times or vectors
292  virtual void acceptStep()
293  {}
294 
295  virtual bool getInitialQnorm(std::vector<TimeIntg::TwoLevelError> & tleVec )
296  {
297  return false;
298  }
299 
300  virtual bool getInnerLoopErrorSums(std::vector<TimeIntg::TwoLevelError> & tleVec ) const
301  {
302  return false;
303  }
304 
305  virtual bool startTimeStep(
306  bool beginIntegrationFlag,
307  double nextTimeStep,
308  double nextTime,
309  int currentOrder)
310  {
311  return true;
312  }
313 
314  virtual void setExternalSolverState(bool external_initJctFlag)
315  {}
316 
317  // voltage limiter toggle functions
318  virtual bool getVoltageLimiterStatus() = 0;
319  virtual void setVoltageLimiterStatus(bool voltageLimterStatus) = 0;
320 
321 };
322 
323 } // namespace Loader
324 } // namespace Xyce
325 
326 #endif
virtual bool setInitialGuess(Linear::Vector *solVectorPtr)
Definition: N_LOA_Loader.h:232
virtual bool getBMatrixEntriesforMOR(std::vector< int > &bMatEntriesVec, std::vector< int > &bMatPosEntriesVec)
Definition: N_LOA_Loader.h:226
Pure virtual class to augment a linear system.
virtual void stepFailure(Analysis::TwoLevelMode analysis)
Definition: N_LOA_Loader.h:287
virtual bool loadDAEVectors(Linear::Vector *nextSolVectorPtr, Linear::Vector *currSolVectorPtr, Linear::Vector *lastSolVectorPtr, Linear::Vector *nextStaVectorPtr, Linear::Vector *currStaVectorPtr, Linear::Vector *lastStaVectorPtr, Linear::Vector *StaDerivVectorPtr, Linear::Vector *nextStoVectorPtr, Linear::Vector *currStoVectorPtr, Linear::Vector *lastStoVectorPtr, Linear::Vector *stoLeadCurrQVectorPtr, Linear::Vector *nextLeadFVectorPtr, Linear::Vector *currLeadFVectorPtr, Linear::Vector *lastLeadFVectorPtr, Linear::Vector *nextLeadQVectorPtr, Linear::Vector *nextJunctionVVectorPtr, Linear::Vector *currJunctionVVectorPtr, Linear::Vector *lastJunctionVVectorPtr, Linear::Vector *QVectorPtr, Linear::Vector *FVectorPtr, Linear::Vector *BVectorPtr, Linear::Vector *dFdxdVpVectorPtr, Linear::Vector *dQdxdVpVectorPtr)
Definition: N_LOA_Loader.h:122
virtual bool outputPlotFiles() const
Definition: N_LOA_Loader.h:261
virtual int getNumNoiseDevices()
Definition: N_LOA_Loader.h:215
virtual bool loadBVectorsforAC(Linear::Vector *bVecRealPtr, Linear::Vector *bVecImagPtr)
Definition: N_LOA_Loader.h:203
virtual bool applyDAEMatrices(Linear::Vector *tmpSolVectorPtr, Linear::Vector *tmpStaVectorPtr, Linear::Vector *tmpStaDerivVectorPtr, Linear::Vector *tmpStoVectorPtr, const Linear::Vector &tmpVecVectorPtr, Linear::Vector *tmpdQdxVecVectorPtr, Linear::Vector *tmpdFdxVecVectorPtr)
Definition: N_LOA_Loader.h:177
virtual bool getVoltageLimiterStatus()=0
virtual int getNumNoiseSources()
Definition: N_LOA_Loader.h:210
virtual bool initializeProblem(Linear::Vector *nextSolVectorPtr, Linear::Vector *currSolVectorPtr, Linear::Vector *lastSolVectorPtr, Linear::Vector *nextStaVectorPtr, Linear::Vector *currStaVectorPtr, Linear::Vector *lastStaVectorPtr, Linear::Vector *StateDerivVectorPtr, Linear::Vector *nextStoVectorPtr, Linear::Vector *currStoVectorPtr, Linear::Vector *lastStoVectorPtr, Linear::Vector *QVectorPtr, Linear::Vector *FVectorPtr, Linear::Vector *BVectorPtr, Linear::Vector *dFdxdVpVectorPtr, Linear::Vector *dQdxdVpVectorPtr) const =0
virtual bool startTimeStep(bool beginIntegrationFlag, double nextTimeStep, double nextTime, int currentOrder)
Definition: N_LOA_Loader.h:305
virtual bool isPDESystem() const
Definition: N_LOA_Loader.h:256
virtual double getMaxTimeStepSize()
Definition: N_LOA_Loader.h:279
virtual void acceptStep()
Definition: N_LOA_Loader.h:292
virtual void setVoltageLimiterStatus(bool voltageLimterStatus)=0
virtual bool setParam(std::string &name, double val, bool overrideOriginal=false)=0
virtual bool updateSources()
Definition: N_LOA_Loader.h:244
virtual bool loadDeviceErrorWeightMask(Linear::Vector *deviceMask) const
Definition: N_LOA_Loader.h:151
virtual bool updateState(Linear::Vector *nextSolVectorPtr, Linear::Vector *currSolVectorPtr, Linear::Vector *lastSolVectorPtr, Linear::Vector *nextStaVectorPtr, Linear::Vector *currStaVectorPtr, Linear::Vector *lastStaVectorPtr, Linear::Vector *nextStoVectorPtr, Linear::Vector *currStoVectorPtr, Linear::Vector *lastStoVectorPtr)
Definition: N_LOA_Loader.h:189
virtual bool loadDAEMatrices(Linear::Vector *tmpSolVectorPtr, Linear::Vector *tmpStaVectorPtr, Linear::Vector *tmpStaDerivVectorPtr, Linear::Vector *tmpStoVectorPtr, Linear::Matrix *tmpdQdxMatrixPtr, Linear::Matrix *tmpdFdxMatrixPtr)
Definition: N_LOA_Loader.h:110
virtual void getNoiseSources(std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec)
Definition: N_LOA_Loader.h:223
virtual void setupNoiseSources(std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec)
Definition: N_LOA_Loader.h:220
virtual bool getLimiterFlag()
Definition: N_LOA_Loader.h:249
virtual bool getInnerLoopErrorSums(std::vector< TimeIntg::TwoLevelError > &tleVec) const
Definition: N_LOA_Loader.h:300
virtual void setExternalSolverState(bool external_initJctFlag)
Definition: N_LOA_Loader.h:314
virtual void stepSuccess(Analysis::TwoLevelMode analysis)
Definition: N_LOA_Loader.h:284
virtual bool finishOutput() const
Definition: N_LOA_Loader.h:266
virtual bool getInitialQnorm(std::vector< TimeIntg::TwoLevelError > &tleVec)
Definition: N_LOA_Loader.h:295
virtual bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes) const
Definition: N_LOA_Loader.h:273
virtual double getParamAndReduce(Parallel::Machine comm, const std::string &name) const =0