Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_ANP_AnalysisBase.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-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_ANP_AnalysisBase.h,v $
27 //
28 // Purpose : Base class for Analysis types
29 //
30 // Special Notes : Specify any "hidden" or subtle details of the class here.
31 // Portability details, error handling information, etc.
32 //
33 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
34 //
35 // Creation Date : 01/24/08
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.21 $
41 //
42 // Revision Date : $Date: 2014/02/24 23:49:11 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_ANP_AnalysisBase_h
48 #define Xyce_N_ANP_AnalysisBase_h
49 
50 #include <Teuchos_RefCountPtr.hpp>
51 using Teuchos::RefCountPtr;
52 using Teuchos::rcp;
53 
54 #include <N_ANP_fwd.h>
55 
56 #include <N_UTL_OptionBlock.h>
57 #include <N_TIA_TIAParams.h>
58 
59 class N_TIA_Assembler;
60 class N_LAS_System;
61 class N_LOA_Loader;
62 class N_NLS_Manager;
65 
66 namespace Xyce {
67 namespace Analysis {
68 
69 //-------------------------------------------------------------------------
70 // Class : AnalysisBase
71 // Purpose : Base class for common analysis functions
72 // Special Notes :
73 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
74 // Creation Date : 01/24/08
75 //-------------------------------------------------------------------------
77 {
78  public:
79 
80  AnalysisBase( AnalysisManager * anaManagerPtr );
81  virtual ~AnalysisBase();
82 
83  virtual bool setAnalysisParams(const N_UTL_OptionBlock & paramsBlock) {return true;};
84  virtual bool outputFailureStats () {return true;};
85 
86  virtual void setParamsWithOutputMgrAdapter
87  (RefCountPtr< OutputMgrAdapter > & outputMgrAdapterRCPtr) {};
88 
89  virtual int getStepIter () { return 0; }
90  virtual int getStepNumber () { return stepNumber; }
91  virtual void setStepNumber (int step) { stepNumber=step; }
92 
93  virtual void setTranStepNumber (int step) { tranStepNumber=step; }
94  virtual int getTranStepNumber () { return tranStepNumber; }
95  virtual void setSensFlag() {sensFlag_=true;}
96 
97  virtual bool run() = 0;
98  virtual bool init() = 0;
99  virtual bool loopProcess() = 0;
100  virtual bool processSuccessfulStep() = 0;
101  virtual bool processFailedStep() = 0;
102  virtual bool finish() = 0;
103  virtual bool handlePredictor() = 0;
104 
105  virtual void printStepHeader(std::ostream &os);
106  virtual void printProgress(std::ostream &os);
107 
108  // mixed-signal
109  virtual void preStepDetails(double maxTimeStepFromHabanero)
110  {}
111 
112  virtual bool mixedSignalStep() {
113  return true;
114  }
115 
116  virtual bool finalizeStep () {
117  return true;
118  }
119 
120  // Two Level specific
121  virtual bool twoLevelStep() {
122  return true;
123  }
124 
125  virtual bool resetForStepAnalysis();
126 
127  // utility functions common to more than one analysis
128  int setupSweepLoop_( std::vector<SweepParam> & sweepParamVec );
129  bool updateSweepParams_ (int loopIter, std::vector<SweepParam> & sweepParamVec);
130 
131  // Utility function for AnalysisManager to determine if a complex analysis type (like HB)
132  // is performing another type of analysis under the hood. This is necessary for populating
133  // the N_TIA_TimeIntInfo struct. For straightforward analysis types, this method is not
134  // needed because the AnalysisManager already knows which analysis is being performed.
135  virtual bool isAnalysis( int analysis_type ) { return false; }
136 
137  void resetAll();
138  int saveLoopInfo ();
139  virtual bool printLoopInfo(int start, int finish);
140 
141  virtual void setBeginningIntegrationFlag(bool bif) {beginningIntegration = bif;}
143 
144  virtual void setIntegrationMethod (int im) {integrationMethod_= im;}
145  virtual unsigned int getIntegrationMethod () {return integrationMethod_;}
146 
147  virtual bool getInputOPFlag(){return inputOPFlag_;}
148 
149  // step statistic functions
150  void gatherStepStatistics_ ();
151  double getTotalLinearSolutionTime() const;
152  double getTotalResidualLoadTime() const;
153  double getTotalJacobianLoadTime() const;
154  bool getDoubleDCOPEnabled ();
155  int getDoubleDCOPStep();
156  bool firstDoubleDCOPStep_ ();
157 
158  public:
159  RefCountPtr< AnalysisManager > anaManagerRCPtr_;
160  RefCountPtr< N_TIA_Assembler > assemblerRCPtr_;
161  RefCountPtr< N_LAS_System > lasSystemRCPtr_;
162  RefCountPtr< N_LOA_Loader > loaderRCPtr_;
163  RefCountPtr< N_NLS_Manager > nlsMgrRCPtr_;
164  RefCountPtr< OutputMgrAdapter > outputMgrAdapterRCPtr_;
165  RefCountPtr< N_TIA_StepErrorControl > secRCPtr_;
166  RefCountPtr< N_TIA_WorkingIntegrationMethod > wimRCPtr_;
167 
169 
170  //protected:
172 
173  // Current time-integration method flag.
174  unsigned int integrationMethod_;
175 
176  // Time-integration step number counter.
177  unsigned int stepNumber;
178  // NOTE: For now tranStepNumber is the same as stepNumber, but later I will
179  // change it. stepNumber will later include both dcop and tran steps.
180  // I haven't changed it yet b/c I need to check what devices call
181  // getStepNumber, and what they expect to get.
182  unsigned int tranStepNumber;
183 
184  // Counters used in Monitoring the Cost of the Process:
185 
186  // Number of consecutive successful time-integration steps.
189 
190  // Total number of failed time-integration steps.
192 
200 
204 
205  bool doubleDCOPFlag_; // true if doing a double-DCOP is possible.
206  int doubleDCOPStep_; // current step in the DCOP loop.
207 
208  bool sensFlag_;
209  bool inputOPFlag_; // true if starting from an initial condition.
210 
211 
212  std::vector<std::vector<int> > saveTimeI;
213  std::vector<std::vector<double> > saveTimeD;
214 
215  protected:
216  // command line object
217  const N_IO_CmdParse & commandLine_;
218 
219  private:
220 
221 };
222 
223 //-----------------------------------------------------------------------------
225 {
227 }
228 
229 //-----------------------------------------------------------------------------
231 {
232  return totalResidualLoadTime_;
233 }
234 
235 //-----------------------------------------------------------------------------
237 {
238  return totalJacobianLoadTime_;
239 }
240 
241 //-----------------------------------------------------------------------------
243 {
244  return doubleDCOPFlag_;
245 }
246 
247 //-----------------------------------------------------------------------------
249 {
250  return doubleDCOPStep_ ;
251 }
252 
253 //-----------------------------------------------------------------------------
254 // Function : AnalysisBase::firstDoubleDCOPStep_
255 // Purpose : If the current step is the first step of
256 // a "doubleDCOP", then return "true".
257 //
258 // Explanation:
259 //
260 // If there are PDE semiconductor devices as part of this problem,
261 // there may need to be a "double-pass"
262 //
263 // first pass = nonlinear poisson solution
264 // second pass = drift diffusion solution
265 //
266 // Special Notes : Only PDE problems can ever return true.
267 // Scope :
268 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
269 // Creation Date : 11/21/04
270 //-----------------------------------------------------------------------------
272 {
274 }
275 
276 } // namespace Analysis
277 } // namespace Xyce
278 
280 
281 #endif
282