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.114.2.1 $
68 //
69 // Revision Date : $Date: 2015/04/02 18:20:15 $
70 //
71 // Current Owner : $Author: tvrusso $
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_TIA_fwd.h>
86 #include <N_UTL_fwd.h>
87 
88 namespace Xyce {
89 namespace Loader {
90 
91 //-----------------------------------------------------------------------------
92 // Class : Loader
93 // Purpose :
94 // Special Notes :
95 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
96 // Creation Date : 5/03/00
97 //-----------------------------------------------------------------------------
98 class Loader
99 {
100 public:
102  {}
103 
104  virtual ~Loader()
105  {}
106 
107  // return value indicates whether mask is nontrivial
108  // Virtual nonlinear new-DAE Matrices load method.
109  virtual bool loadDAEMatrices(
110  Linear::Vector * tmpSolVectorPtr,
111  Linear::Vector * tmpStaVectorPtr,
112  Linear::Vector * tmpStaDerivVectorPtr,
113  Linear::Vector * tmpStoVectorPtr,
114  Linear::Matrix * tmpdQdxMatrixPtr,
115  Linear::Matrix * tmpdFdxMatrixPtr)
116  {
117  return false;
118  }
119 
120  // Virtual nonlinear new-DAE vectors load method.
121  virtual bool loadDAEVectors(
122  Linear::Vector * nextSolVectorPtr,
123  Linear::Vector * currSolVectorPtr,
124  Linear::Vector * lastSolVectorPtr,
125  Linear::Vector * nextStaVectorPtr,
126  Linear::Vector * currStaVectorPtr,
127  Linear::Vector * lastStaVectorPtr,
128  Linear::Vector * StaDerivVectorPtr,
129  Linear::Vector * nextStoVectorPtr,
130  Linear::Vector * currStoVectorPtr,
131  Linear::Vector * lastStoVectorPtr,
132  Linear::Vector * stoLeadCurrQVectorPtr,
133  Linear::Vector * nextLeadFVectorPtr,
134  Linear::Vector * currLeadFVectorPtr,
135  Linear::Vector * lastLeadFVectorPtr,
136  Linear::Vector * nextLeadQVectorPtr,
137  Linear::Vector * nextJunctionVVectorPtr,
138  Linear::Vector * currJunctionVVectorPtr,
139  Linear::Vector * lastJunctionVVectorPtr,
140  Linear::Vector * QVectorPtr,
141  Linear::Vector * FVectorPtr,
142  Linear::Vector * BVectorPtr,
143  Linear::Vector * dFdxdVpVectorPtr,
144  Linear::Vector * dQdxdVpVectorPtr)
145  {
146  return false;
147  }
148 
149  // base class method does nothing.
150  virtual bool loadDeviceErrorWeightMask(Linear::Vector * deviceMask) const
151  {
152  return false;
153  }
154 
155  // Virtual method which initializes the nonlinear problem.
156  virtual bool initializeProblem(
157  Linear::Vector * nextSolVectorPtr,
158  Linear::Vector * currSolVectorPtr,
159  Linear::Vector * lastSolVectorPtr,
160  Linear::Vector * nextStaVectorPtr,
161  Linear::Vector * currStaVectorPtr,
162  Linear::Vector * lastStaVectorPtr,
163  Linear::Vector * StateDerivVectorPtr,
164  Linear::Vector * nextStoVectorPtr,
165  Linear::Vector * currStoVectorPtr,
166  Linear::Vector * lastStoVectorPtr,
167  Linear::Vector * QVectorPtr,
168  Linear::Vector * FVectorPtr,
169  Linear::Vector * BVectorPtr,
170  Linear::Vector * dFdxdVpVectorPtr,
171  Linear::Vector * dQdxdVpVectorPtr) const = 0;
172 
173  // Virtual nonlinear new-DAE Matrices apply method.
174  // tmpdQdxVecVector = tmpdQdxMatrix * tmpVecVector
175  // tmpdFdxVecVector = tmpdFdxMatrix * tmpVecVector
176  virtual bool applyDAEMatrices(
177  Linear::Vector * tmpSolVectorPtr,
178  Linear::Vector * tmpStaVectorPtr,
179  Linear::Vector * tmpStaDerivVectorPtr,
180  Linear::Vector * tmpStoVectorPtr,
181  const Linear::Vector & tmpVecVectorPtr,
182  Linear::Vector * tmpdQdxVecVectorPtr,
183  Linear::Vector * tmpdFdxVecVectorPtr)
184  {
185  return false;
186  }
187 
188  virtual bool updateState(
189  Linear::Vector * nextSolVectorPtr,
190  Linear::Vector * currSolVectorPtr,
191  Linear::Vector * lastSolVectorPtr,
192  Linear::Vector * nextStaVectorPtr,
193  Linear::Vector * currStaVectorPtr,
194  Linear::Vector * lastStaVectorPtr,
195  Linear::Vector * nextStoVectorPtr,
196  Linear::Vector * currStoVectorPtr,
197  Linear::Vector * lastStoVectorPtr)
198  {
199  return false;
200  }
201 
202  virtual bool loadBVectorsforAC(
203  Linear::Vector * bVecRealPtr,
204  Linear::Vector * bVecImagPtr)
205  {
206  return false;
207  }
208 
209  virtual int getNumNoiseSources()
210  {
211  return 0;
212  }
213 
214  virtual int getNumNoiseDevices()
215  {
216  return 0;
217  }
218 
219  virtual void setupNoiseSources(std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec)
220  {}
221 
222  virtual void getNoiseSources(std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec)
223  {}
224 
225  virtual bool getBMatrixEntriesforMOR(std::vector<int>& bMatEntriesVec, std::vector<int>& bMatPosEntriesVec)
226  {
227  return false;
228  }
229 
230  // Virtual function for setting the initial guess.
231  virtual bool setInitialGuess(Linear::Vector * solVectorPtr)
232  {
233  return false;
234  }
235 
236  // Virtual function for setting a single parameter value.
237  virtual bool setParam(std::string & name, double val, bool overrideOriginal = false) = 0;
238 
239  // Virtual function for getting a single parameter value.
240  virtual double getParamAndReduce(const std::string & name) const = 0;
241 
242  // Virtual method which is called to update the sources.
243  virtual bool updateSources()
244  {
245  return false;
246  }
247  // This is somewhat circuit-specific, unfortunately.
248  virtual bool getLimiterFlag()
249  {
250  return false;
251  }
252 
253  // Virtual method which gets the double DC Operating Point flag - used for
254  // PDE devices.
255  virtual bool getDoubleDCOPFlag() const
256  {
257  return false;
258  }
259 
260  virtual bool output() const
261  {
262  return false;
263  }
264 
265  virtual bool finishOutput() const
266  {
267  return false;
268  }
269 
270  // Virtual method which gets the time integration required breakpoint times
271  //(in a vector).
272  virtual bool getBreakPoints(std::vector< Util::BreakPoint > & breakPointTimes) const
273  {
274  return false;
275  }
276 
277  // Virtual accessor which returns the maximum time step size(in seconds).
278  virtual double getMaxTimeStepSize()
279  {
280  return 0.0;
281  }
282 
283  virtual void stepSuccess(Analysis::TwoLevelMode analysis)
284  {}
285 
286  virtual void stepFailure(Analysis::TwoLevelMode analysis)
287  {}
288 
289  //TVR: Method to be called when time integrator accepts a step, before any
290  // tinkering with times or vectors
291  virtual void acceptStep()
292  {}
293 
294  virtual bool getInitialQnorm(std::vector<TimeIntg::TwoLevelError> & tleVec )
295  {
296  return false;
297  }
298 
299  virtual bool getInnerLoopErrorSums(std::vector<TimeIntg::TwoLevelError> & tleVec )
300  {
301  return false;
302  }
303 
304  virtual bool startTimeStep()
305  {
306  return true;
307  }
308 
310  {}
311 };
312 
313 } // namespace Loader
314 } // namespace Xyce
315 
316 #endif
virtual bool getInnerLoopErrorSums(std::vector< TimeIntg::TwoLevelError > &tleVec)
Definition: N_LOA_Loader.h:299
virtual bool setInitialGuess(Linear::Vector *solVectorPtr)
Definition: N_LOA_Loader.h:231
virtual bool getBMatrixEntriesforMOR(std::vector< int > &bMatEntriesVec, std::vector< int > &bMatPosEntriesVec)
Definition: N_LOA_Loader.h:225
Pure virtual class to augment a linear system.
virtual void stepFailure(Analysis::TwoLevelMode analysis)
Definition: N_LOA_Loader.h:286
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:121
virtual int getNumNoiseDevices()
Definition: N_LOA_Loader.h:214
virtual bool loadBVectorsforAC(Linear::Vector *bVecRealPtr, Linear::Vector *bVecImagPtr)
Definition: N_LOA_Loader.h:202
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:176
virtual int getNumNoiseSources()
Definition: N_LOA_Loader.h:209
virtual bool startTimeStep()
Definition: N_LOA_Loader.h:304
virtual double getMaxTimeStepSize()
Definition: N_LOA_Loader.h:278
virtual void acceptStep()
Definition: N_LOA_Loader.h:291
virtual bool setParam(std::string &name, double val, bool overrideOriginal=false)=0
virtual bool updateSources()
Definition: N_LOA_Loader.h:243
virtual bool loadDeviceErrorWeightMask(Linear::Vector *deviceMask) const
Definition: N_LOA_Loader.h:150
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:188
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:109
virtual void getNoiseSources(std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec)
Definition: N_LOA_Loader.h:222
virtual bool getDoubleDCOPFlag() const
Definition: N_LOA_Loader.h:255
virtual void setupNoiseSources(std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec)
Definition: N_LOA_Loader.h:219
virtual bool getLimiterFlag()
Definition: N_LOA_Loader.h:248
virtual double getParamAndReduce(const std::string &name) const =0
virtual void stepSuccess(Analysis::TwoLevelMode analysis)
Definition: N_LOA_Loader.h:283
virtual bool finishOutput() const
Definition: N_LOA_Loader.h:265
virtual void setExternalSolverState(const Device::SolverState &ss)
Definition: N_LOA_Loader.h:309
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 getInitialQnorm(std::vector< TimeIntg::TwoLevelError > &tleVec)
Definition: N_LOA_Loader.h:294
virtual bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes) const
Definition: N_LOA_Loader.h:272
virtual bool output() const
Definition: N_LOA_Loader.h:260