Xyce  6.1
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-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_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.25.2.1 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:20:18 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_TIA_GEAR12_H
48 #define Xyce_N_TIA_GEAR12_H
49 
50 // ---------- Standard Includes ----------
51 
52 // ---------- Xyce Includes ----------
53 #include <N_TIA_DataStore.h>
54 #include <N_TIA_StepErrorControl.h>
56 #include <N_PDS_ParMap.h>
57 #include <N_UTL_Math.h>
58 #include <N_UTL_IndexPair.h>
59 
60 namespace Xyce {
61 namespace TimeIntg {
62 
63 //-----------------------------------------------------------------------------
64 // Class : Gear12
65 // Purpose : Gear12 Formula Integration Class
66 // (derived from TimeIntegrationMethod)
67 // Special Notes :
68 // Creator : Ting Mei, SNL
69 // Creation Date : 10/31/07
70 //-----------------------------------------------------------------------------
72 {
73 public:
74  static const int type = 8;
75  static const char *name;
76 
77  static TimeIntegrationMethod *factory(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store);
78 
79  Gear12(
80  const TIAParams & tia_params,
81  StepErrorControl & step_error_control,
82  DataStore & data_store);
83 
85  {}
86 
87  const char *getName() const /* override */ {
88  return "Gear 12";
89  }
90 
91  // Predict solution at next time point.
92  void obtainPredictor() /* override */;
93 
94  // Evaluate the predictor derivative formula.
95  void obtainPredictorDeriv() /* override */
96  {}
97 
98  // Evaluate the corrector derivative formula.
99  void obtainCorrectorDeriv() /* override */
100  {}
101 
102  // Compute an estimate of the error in the integration step.
103  void updateDerivsBlock(const std::list< IndexPair > & solGIDList, const std::list< IndexPair > & staGIDList) /* override */
104  {}
105 
106  // Compute an estimate of the error in the integration step.
107  double computeErrorEstimate() const /* override */
108  {
109  return sec.ck_*ds.WRMS_errorNorm();
110  }
111 
112  // Interpolate solution approximation at prescribed time point.
113  bool interpolateSolution(double timepoint, Linear::Vector * tmpSolVectorPtr, std::vector<Linear::Vector*> & historyVec) /* override */;
114 
115  // Print output using interpolation when order is high
116  bool printOutputSolution(
117  Analysis::OutputMgrAdapter & outputManagerAdapter,
118  const TIAParams & tia_params,
119  const double time,
120  Linear::Vector * solnVecPtr,
121  const bool doNotInterpolate,
122  const std::vector<double> & outputInterpolationTimes,
123  bool skipPrintLineOutput) /* override */;
124 
125  // Print transient output from MPDE simulation
127  Analysis::OutputMgrAdapter & outputManagerAdapter,
128  const double time,
129  Linear::Vector * solnVecPtr,
130  const std::vector<double> & fastTimes ); /* override */
131 
132  // Print transient output from WaMPDE simulation
134  Analysis::OutputMgrAdapter & outputManagerAdapter,
135  const double time,
136  Linear::Vector * solnVecPtr,
137  const std::vector<double> & fastTimes,
138  const int phiGID) /* override */;
139 
140  // .SAVE output using interpolation when order is high
141  bool saveOutputSolution(
142  Analysis::OutputMgrAdapter & outputManagerAdapter,
143  const TIAParams & tia_params,
144  Linear::Vector * solnVecPtr,
145  const double saveTime,
146  const bool doNotInterpolate) /* override */;
147 
148  // Computes the step adjustment.
149  double computeExpoStepAdjust(double stepadjust) /* override */;
150 
151  // Gets the time-integration order.
152  int getOrder() const /* override */
153  {
154  return sec.currentOrder_;
155  }
156 
157  int getUsedOrder() const /* override */
158  {
159  return sec.usedOrder_;
160  }
161 
162  int getNumberOfSteps() const /* override */
163  {
164  return sec.numberOfSteps_;
165  }
166 
167  int getNscsco() const /* override */
168  {
169  return sec.nscsco_;
170  }
171 
172  int getMaxOrder() const /* override */
173  {
174  return sec.maxOrder_;
175  }
176 
177  void getInitialQnorm(TwoLevelError & tle) const /* override */;
178 
179  void getTwoLevelError(TwoLevelError & tle) const /* override */;
180 
181  void updateStateDeriv() /* override */;
182 
183  // calculates dQ/dt component of store vector and adds it to store vector
184  void updateLeadCurrent() /* override */;
185 
186  // calculates dQ/dt component of lead current Q vector and adds it to the lead current vector
187  void updateLeadCurrentVec() /* override */;
188 
189  // Returns the current partial time derivative for either the solution or
190  // state vector.
191  double partialTimeDeriv() const /* override */;
192 
193  // Gets the leading coefficient for the specified time-integration method.
194  double getLeadingCoeff() const { return leadingCoeff; /* override */}
195 
196  // sets the leading coefficient for the specified time-integration method.
197  void setLeadingCoeff(double & LC) { leadingCoeff = LC; /* override */}
198 
199  // Evaluate corrector residual for nonlinear solver
200  void obtainResidual() /* override */;
201 
202  // obtain residuals for transient sensitivity analysis
203  void obtainSensitivityResiduals() /* override */;
204 
205  // obtain final derivatives w.r.t. time for transient sensitivity analysis
206  void loadFinalSensitivityDerivatives() /* override */
207  {}
208 
209  // Evaluate corrector Jacobian for nonlinear solver
210  void obtainJacobian() /* override */;
211 
212  // Update history array after a successful step
213  void updateHistory() /* override */;
214 
215  // Restore history array after a failed step
216  void restoreHistory() /* override */;
217 
218  // Update method coefficients
219  void updateCoeffs() /* override */;
220 
221  // Initialize method with initial solution & step-size
222  void initialize(const TIAParams &tia_params) /* override */;
223 
224  // setup 2-level data.
225  void setTwoLevelTimeInfo(const TimeIntInfo & tiInfo) /* override */;
226 
227  // Reject a step(this turns back history and chooses new order & step-size)
228  void rejectStep(const TIAParams &tia_params) /* override */;
229 
230  // Reject a step, but only restore the history, as the new step will be
231  // imposed by an outside program.
232  void rejectStepForHabanero() /* override */;
233 
234  // Complete a step(this updates history and chooses new order & step-size)
235  void completeStep(const TIAParams &tia_params) /* override */;
236 
237 private:
238  // Interpolate MPDE solution approximation at prescribed time point.
239  bool interpolateMPDESolution(std::vector<double>& timepoint, Linear::Vector * tmpSolVectorPtr) /* override */;
240 
241  // Initialize arrays related to sensitivities
243 
244  // Predict solution at next time point.
246 
247  // Update sensitivity history arrays after a successful step
249 
250  // Check whether to reduce order independent of local error test
251  void checkReduceOrder();
252 
253  double timept_; ///< Keep track of last interpolation point in printMPDEOutputSolution
254  DataStore & ds; ///< Reference to the TIA data-store object.
255  StepErrorControl & sec; ///< Reference to step-error control object
256  double leadingCoeff; ///< Time-integration method leading coefficient value.
257 };
258 
259 } // namespace TimeIntg
260 } // namespace Xyce
261 
262 #endif //Xyce_N_TIA_GEAR12_H
263 
const char * getName() const
Definition: N_TIA_Gear12.h:87
bool interpolateMPDESolution(std::vector< double > &timepoint, Linear::Vector *tmpSolVectorPtr)
Definition: N_TIA_Gear12.C:449
void rejectStep(const TIAParams &tia_params)
Gear12(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Definition: N_TIA_Gear12.C:103
static const int type
Definition: N_TIA_Gear12.h:74
static const char * name
Definition: N_TIA_Gear12.h:75
Pure virtual class to augment a linear system.
void getInitialQnorm(TwoLevelError &tle) const
bool interpolateSolution(double timepoint, Linear::Vector *tmpSolVectorPtr, std::vector< Linear::Vector * > &historyVec)
Definition: N_TIA_Gear12.C:406
void updateDerivsBlock(const std::list< IndexPair > &solGIDList, const std::list< IndexPair > &staGIDList)
Definition: N_TIA_Gear12.h:103
void completeStep(const TIAParams &tia_params)
bool printOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const TIAParams &tia_params, const double time, Linear::Vector *solnVecPtr, const bool doNotInterpolate, const std::vector< double > &outputInterpolationTimes, bool skipPrintLineOutput)
Definition: N_TIA_Gear12.C:568
void setLeadingCoeff(double &LC)
Definition: N_TIA_Gear12.h:197
static TimeIntegrationMethod * factory(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Definition: N_TIA_Gear12.C:87
int getNscsco() const
Definition: N_TIA_Gear12.h:167
void initialize(const TIAParams &tia_params)
Definition: N_TIA_Gear12.C:965
double leadingCoeff
Time-integration method leading coefficient value.
Definition: N_TIA_Gear12.h:256
void loadFinalSensitivityDerivatives()
Definition: N_TIA_Gear12.h:206
DataStore & ds
Reference to the TIA data-store object.
Definition: N_TIA_Gear12.h:254
double computeExpoStepAdjust(double stepadjust)
Definition: N_TIA_Gear12.C:216
bool printWaMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes, const int phiGID)
Definition: N_TIA_Gear12.C:548
void getTwoLevelError(TwoLevelError &tle) const
bool printMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes)
Definition: N_TIA_Gear12.C:530
bool saveOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const TIAParams &tia_params, Linear::Vector *solnVecPtr, const double saveTime, const bool doNotInterpolate)
Definition: N_TIA_Gear12.C:651
int getNumberOfSteps() const
Definition: N_TIA_Gear12.h:162
int getUsedOrder() const
Definition: N_TIA_Gear12.h:157
int getMaxOrder() const
Return max order of method (this should obey user option maxorder)
Definition: N_TIA_Gear12.h:172
double getLeadingCoeff() const
Definition: N_TIA_Gear12.h:194
double partialTimeDeriv() const
StepErrorControl & sec
Reference to step-error control object.
Definition: N_TIA_Gear12.h:255
void obtainSensitivityPredictors()
Definition: N_TIA_Gear12.C:210
double computeErrorEstimate() const
Definition: N_TIA_Gear12.h:107
void setTwoLevelTimeInfo(const TimeIntInfo &tiInfo)
double timept_
Keep track of last interpolation point in printMPDEOutputSolution.
Definition: N_TIA_Gear12.h:253