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.28 $
41 //
42 // Revision Date : $Date: 2015/06/05 20:49:43 $
43 //
44 // Current Owner : $Author: dgbaur $
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  Parallel::Machine comm,
143  IO::InitialConditionsManager & initial_conditions_manager,
144  const NodeNameMap & node_name_map,
145  const TIAParams & tia_params,
146  Linear::Vector * solnVecPtr,
147  const double saveTime,
148  const bool doNotInterpolate) /* override */;
149 
150  // Computes the step adjustment.
151  double computeExpoStepAdjust(double stepadjust) /* override */;
152 
153  // Gets the time-integration order.
154  int getOrder() const /* override */
155  {
156  return sec.currentOrder_;
157  }
158 
159  int getUsedOrder() const /* override */
160  {
161  return sec.usedOrder_;
162  }
163 
164  int getNumberOfSteps() const /* override */
165  {
166  return sec.numberOfSteps_;
167  }
168 
169  int getNscsco() const /* override */
170  {
171  return sec.nscsco_;
172  }
173 
174  int getMaxOrder() const /* override */
175  {
176  return sec.maxOrder_;
177  }
178 
179  void getInitialQnorm(TwoLevelError & tle) const /* override */;
180 
181  void getTwoLevelError(TwoLevelError & tle) const /* override */;
182 
183  void updateStateDeriv() /* override */;
184 
185  // calculates dQ/dt component of store vector and adds it to store vector
186  void updateLeadCurrent() /* override */;
187 
188  // calculates dQ/dt component of lead current Q vector and adds it to the lead current vector
189  void updateLeadCurrentVec() /* override */;
190 
191  // Returns the current partial time derivative for either the solution or
192  // state vector.
193  double partialTimeDeriv() const /* override */;
194 
195  // Gets the leading coefficient for the specified time-integration method.
196  double getLeadingCoeff() const { return leadingCoeff; /* override */}
197 
198  // sets the leading coefficient for the specified time-integration method.
199  void setLeadingCoeff(double & LC) { leadingCoeff = LC; /* override */}
200 
201  // Evaluate corrector residual for nonlinear solver
202  void obtainResidual() /* override */;
203 
204  // obtain residuals for transient sensitivity analysis
205  void obtainSensitivityResiduals() /* override */;
206 
207  // obtain final derivatives w.r.t. time for transient sensitivity analysis
208  void loadFinalSensitivityDerivatives() /* override */
209  {}
210 
211  // Evaluate corrector Jacobian for nonlinear solver
212  void obtainJacobian() /* override */;
213 
214  // Update history array after a successful step
215  void updateHistory() /* override */;
216 
217  // Restore history array after a failed step
218  void restoreHistory() /* override */;
219 
220  // Update method coefficients
221  void updateCoeffs() /* override */;
222 
223  // Initialize method with initial solution & step-size
224  void initialize(const TIAParams &tia_params) /* override */;
225 
226  // setup 2-level data.
227  void setTwoLevelTimeInfo() /* override */;
228 
229  // Reject a step(this turns back history and chooses new order & step-size)
230  void rejectStep(const TIAParams &tia_params) /* override */;
231 
232  // Reject a step, but only restore the history, as the new step will be
233  // imposed by an outside program.
234  void rejectStepForHabanero() /* override */;
235 
236  // Complete a step(this updates history and chooses new order & step-size)
237  void completeStep(const TIAParams &tia_params) /* override */;
238 
239 private:
240  // Interpolate MPDE solution approximation at prescribed time point.
241  bool interpolateMPDESolution(std::vector<double>& timepoint, Linear::Vector * tmpSolVectorPtr) /* override */;
242 
243  // Initialize arrays related to sensitivities
245 
246  // Predict solution at next time point.
248 
249  // Update sensitivity history arrays after a successful step
251 
252  // Check whether to reduce order independent of local error test
253  void checkReduceOrder();
254 
255  double timept_; ///< Keep track of last interpolation point in printMPDEOutputSolution
256  DataStore & ds; ///< Reference to the TIA data-store object.
257  StepErrorControl & sec; ///< Reference to step-error control object
258  double leadingCoeff; ///< Time-integration method leading coefficient value.
259 };
260 
261 } // namespace TimeIntg
262 } // namespace Xyce
263 
264 #endif //Xyce_N_TIA_GEAR12_H
265 
bool saveOutputSolution(Parallel::Machine comm, IO::InitialConditionsManager &initial_conditions_manager, const NodeNameMap &node_name_map, const TIAParams &tia_params, Linear::Vector *solnVecPtr, const double saveTime, const bool doNotInterpolate)
Definition: N_TIA_Gear12.C:653
const char * getName() const
Definition: N_TIA_Gear12.h:87
bool interpolateMPDESolution(std::vector< double > &timepoint, Linear::Vector *tmpSolVectorPtr)
Definition: N_TIA_Gear12.C:450
void rejectStep(const TIAParams &tia_params)
Gear12(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Definition: N_TIA_Gear12.C:104
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:407
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:569
void setLeadingCoeff(double &LC)
Definition: N_TIA_Gear12.h:199
static TimeIntegrationMethod * factory(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Definition: N_TIA_Gear12.C:88
int getNscsco() const
Definition: N_TIA_Gear12.h:169
void initialize(const TIAParams &tia_params)
Definition: N_TIA_Gear12.C:970
double leadingCoeff
Time-integration method leading coefficient value.
Definition: N_TIA_Gear12.h:258
void loadFinalSensitivityDerivatives()
Definition: N_TIA_Gear12.h:208
DataStore & ds
Reference to the TIA data-store object.
Definition: N_TIA_Gear12.h:256
double computeExpoStepAdjust(double stepadjust)
Definition: N_TIA_Gear12.C:217
bool printWaMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes, const int phiGID)
Definition: N_TIA_Gear12.C:549
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:531
int getNumberOfSteps() const
Definition: N_TIA_Gear12.h:164
int getUsedOrder() const
Definition: N_TIA_Gear12.h:159
int getMaxOrder() const
Return max order of method (this should obey user option maxorder)
Definition: N_TIA_Gear12.h:174
double getLeadingCoeff() const
Definition: N_TIA_Gear12.h:196
double partialTimeDeriv() const
StepErrorControl & sec
Reference to step-error control object.
Definition: N_TIA_Gear12.h:257
void obtainSensitivityPredictors()
Definition: N_TIA_Gear12.C:211
double computeErrorEstimate() const
Definition: N_TIA_Gear12.h:107
double timept_
Keep track of last interpolation point in printMPDEOutputSolution.
Definition: N_TIA_Gear12.h:255