Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_TIA_Gear12.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_TIA_Gear12.h,v $
27 //
28 // Purpose : This file defines the classes for the backward
29 // differentiation, order 1-2 method.
30 //
31 // Special Notes :
32 //
33 // Creator : Ting Mei
34 //
35 // Creation Date : 10/31/07
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.9 $
41 //
42 // Revision Date : $Date: 2014/02/24 23:49:26 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_TIA_GEAR12_H
48 #define Xyce_N_TIA_GEAR12_H
49 
50 
51 // ---------- Standard Includes ----------
52 #ifdef HAVE_CMATH
53 #include <cmath>
54 #else
55 #include <math.h>
56 #endif
57 
58 #include <Teuchos_RefCountPtr.hpp>
59 using Teuchos::RefCountPtr;
60 using Teuchos::rcp;
61 
62 // ---------- Xyce Includes ----------
63 #include <N_TIA_DataStore.h>
64 #include <N_TIA_StepErrorControl.h>
66 #include <N_PDS_ParMap.h>
67 
68 //-----------------------------------------------------------------------------
69 // Class : N_TIA_Gear12
70 // Purpose : Gear12 Formula Integration Class
71 // (derived from N_TIA_TimeIntegrationMethod)
72 // Special Notes :
73 // Creator : Ting Mei, SNL
74 // Creation Date : 10/31/07
75 //-----------------------------------------------------------------------------
77 {
78 public:
79 
80  // Destructor
82 
83  // Predict solution at next time point.
84  virtual void obtainPredictor();
85 
86  // Evaluate the predictor derivative formula.
87  virtual void obtainPredictorDeriv() {return;}
88 
89  // Evaluate the corrector derivative formula.
90  virtual void obtainCorrectorDeriv() {return;}
91 
92  // Compute an estimate of the error in the integration step.
93  virtual void updateDerivsBlock(const std::list< index_pair > & solGIDList,
94  const std::list< index_pair > & staGIDList) {return;}
95 
96  // Compute an estimate of the error in the integration step.
97  virtual double computeErrorEstimate() { return sec.ck_*ds.WRMS_errorNorm(); }
98 
99  // Interpolate solution approximation at prescribed time point.
100  virtual bool interpolateSolution(double timepoint,
101  N_LAS_Vector * tmpSolVectorPtr, std::vector<N_LAS_Vector*> & historyVec);
102 
103  // Interpolate MPDE solution approximation at prescribed time point.
104  virtual bool interpolateMPDESolution(std::vector<double>& timepoint,
105  N_LAS_Vector * tmpSolVectorPtr);
106 
107  // Print transient output from MPDE simulation
108  virtual bool printMPDEOutputSolution(
109  RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
110  const double time,
111  N_LAS_Vector * solnVecPtr,
112  const std::vector<double> & fastTimes );
113 
114  // Print transient output from WaMPDE simulation
115  virtual bool printWaMPDEOutputSolution(
116  RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
117  const double time,
118  N_LAS_Vector * solnVecPtr,
119  const std::vector<double> & fastTimes,
120  const int phiGID );
121 
122  // Print output using interpolation when order is high
123  virtual bool printOutputSolution(
124  RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
125  const double time,
126  N_LAS_Vector * solnVecPtr,
127  const bool doNotInterpolate,
128  const std::vector<double> & outputInterpolationTimes,
129  bool skipPrintLineOutput);
130 
131  // .SAVE output using interpolation when order is high
132  virtual bool saveOutputSolution(
133  RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
134  N_LAS_Vector * solnVecPtr,
135  const double saveTime,
136  const bool doNotInterpolate);
137 
138  // Computes the step adjustment.
139  virtual double computeExpoStepAdjust(double stepadjust);
140 
141  // Gets the time-integration order.
142  virtual int getOrder() {return sec.currentOrder_;}
143  virtual int getUsedOrder() {return sec.usedOrder_;}
144  virtual int getNumberOfSteps () { return sec.numberOfSteps_; }
145  virtual int getNscsco () { return sec.nscsco_; }
146 
147  virtual void getInitialQnorm (N_TIA_TwoLevelError & tle);
148  virtual void setupTwoLevelError(N_TIA_TwoLevelError & tle);
149 
150  // 2/16/04 tscoffe: This is just for testing, we'll need a dynamic fcn later
151 
152  // Time-integration factory.
154  (N_TIA_TIAParams & tiaP,
155  N_TIA_StepErrorControl & secTmp ,
156  N_TIA_DataStore & dsTmp);
157 
158  // 03/08/04 tscoffe: New functions necessary for Gear12
159  // Evaluate corrector residual for nonlinear solver
160  virtual void obtainResidual();
161 
162  // Evaluate corrector Jacobian for nonlinear solver
163  virtual void obtainJacobian();
164 
165  // Update history array after a successful step
166  virtual void updateHistory();
167 
168  // Restore history array after a failed step
169  virtual void restoreHistory();
170 
171  // Return max order of method (this should obey user option maxorder)
172  virtual int getMaxOrder(){ return sec.maxOrder_;}
173 
174  // Update method coefficients
175  virtual void updateCoeffs();
176 
177  // Initialize method with initial solution & step-size
178  virtual void initialize();
179 
180  // setup 2-level data.
181  virtual void setTwoLevelTimeInfo(const N_TIA_TimeIntInfo & tiInfo);
182 
183  // Reject a step (this turns back history and chooses new order & step-size)
184  virtual void rejectStep();
185 
186  // Reject a step, but only restore the history, as the new step will be
187  // imposed by an outside program.
188  virtual void rejectStepForHabanero ();
189 
190  // Complete a step (this updates history and chooses new order & step-size)
191  virtual void completeStep();
192 
193  virtual void updateStateDeriv ();
194 
195  // calculates dQ/dt component of store vector and adds it to store vector
196  virtual void updateLeadCurrent ();
197 
198 private:
199 
200  // Constructor (private).
202  N_TIA_StepErrorControl & secTmp,
203  N_TIA_DataStore & dsTmp);
204 
205  // Check whether to reduce order independent of local error test
206  virtual void checkReduceOrder();
207 
209 
210  // Used to keep track of last interpolation point in printMPDEOutputSolution
211  double timept_;
212 
213 };
214 
215  // Computes the step addjustment.
216  // 2/16/04 tscoffe: I'm not exactly sure what this routine is for...
218  double stepadjust)
219 {
220  return pow(stepadjust, 1.0 / 3.0);
221 }
222 
223 //-----------------------------------------------------------------------------
224 // Function : N_TIA_Gear12::factory
225 // Purpose :
226 // Special Notes :
227 // Scope : public
228 // Creator : Ting Mei, SNL
229 // Creation Date : 10/31/07
230 //-----------------------------------------------------------------------------
232  (N_TIA_TIAParams & tiaP,
233  N_TIA_StepErrorControl & secTmp ,
234  N_TIA_DataStore & dsTmp)
235 {
236  N_TIA_TimeIntegrationMethod * timPtr =
237  new N_TIA_Gear12(tiaP,secTmp,dsTmp);
238  return timPtr;
239 }
240 
241 #endif //Xyce_N_TIA_GEAR12_H
242