Xyce  6.1
N_TIA_BackwardDifferentiation15.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_BackwardDifferentiation15.h,v $
27 //
28 // Purpose : This file defines the classes for the backward
29 // differentiation, order 1-5 method.
30 //
31 // Special Notes :
32 //
33 // Creator : Todd Coffey
34 //
35 // Creation Date : 2/16/04
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.68.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_BackwardDifferentiation15_h
48 #define Xyce_N_TIA_BackwardDifferentiation15_h
49 
50 // ---------- Standard Includes ----------
51 #include <N_ANP_fwd.h>
52 #include <N_TIA_fwd.h>
53 
54 #include <N_PDS_ParMap.h>
55 #include <N_TIA_DataStore.h>
56 #include <N_TIA_StepErrorControl.h>
58 
59 #include <N_UTL_Math.h>
60 #include <N_UTL_IndexPair.h>
61 
62 namespace Xyce {
63 namespace TimeIntg {
64 
65 //-----------------------------------------------------------------------------
66 // Class : BackwardDifferentiation15
67 // Purpose : Backward Differentiation Formula(of order 1-5)
68 // Integration Class
69 // (derived from TimeIntegrationMethod)
70 // Special Notes :
71 // Creator : Todd Coffey, SNL
72 // Creation Date : 2/16/04
73 //-----------------------------------------------------------------------------
75 {
76 public:
77  static const int type = 6;
78  static const char *name;
79 
81  const TIAParams & tia_params,
82  StepErrorControl & step_error_control,
83  DataStore & data_store);
84 
86  const TIAParams & tia_params,
87  StepErrorControl & step_error_control,
88  DataStore & data_store);
89 
91  {}
92 
93  const char *getName() const /* override */
94  {
95  return "Backward Differentiation 15";
96  }
97 
98  // Predict solution at next time point(BDF1-5) /* override */.
99  void obtainPredictor() /* override */;
100 
101  // Evaluate the predictor derivative formula(BDF1-5) /* override */.
102  void obtainPredictorDeriv() /* override */
103  {}
104 
105  // Evaluate the corrector derivative formula(BDF1-5) /* override */.
106  void obtainCorrectorDeriv() /* override */
107  {}
108 
109  // Compute an estimate of the error in the integration step(BDF1-5) /* override */.
111  const std::list< IndexPair > & solGIDList,
112  const std::list< IndexPair > & staGIDList) /* override */
113  {}
114 
115  // Compute an estimate of the error in the integration step(BDF1-5) /* override */.
116  double computeErrorEstimate() /* override */ const
117  {
118  return sec.ck_*ds.WRMS_errorNorm() /* override */;
119  }
120 
121  // Interpolate solution approximation at prescribed time point(BDF1-5) /* override */.
122  bool interpolateSolution(
123  double timepoint,
124  Linear::Vector * tmpSolVectorPtr, std::vector<Linear::Vector*> & historyVec) /* override */;
125 
126  // Print output using interpolation when order is high
127  bool printOutputSolution(
128  Analysis::OutputMgrAdapter & outputManagerAdapter,
129  const TIAParams & tia_params,
130  const double time,
131  Linear::Vector * solnVecPtr,
132  const bool doNotInterpolate,
133  const std::vector<double> & outputInterpolationTimes,
134  bool skipPrintLineOutput) /* override */;
135 
136  // Print transient output from MPDE simulation
138  Analysis::OutputMgrAdapter & outputManagerAdapter,
139  const double time,
140  Linear::Vector * solnVecPtr,
141  const std::vector<double> & fastTimes ) /* override */;
142 
143  // Print transient output from WaMPDE simulation
145  Analysis::OutputMgrAdapter & outputManagerAdapter,
146  const double time,
147  Linear::Vector * solnVecPtr,
148  const std::vector<double> & fastTimes,
149  const int phiGID ) /* override */;
150 
151  // .SAVE output using interpolation when order is high
152  bool saveOutputSolution(
153  Analysis::OutputMgrAdapter & outputManagerAdapter,
154  const TIAParams & tia_params,
155  Linear::Vector * solnVecPtr,
156  const double saveTime,
157  const bool doNotInterpolate) /* override */;
158 
159  // Computes the step adjustment(BDF1-5) /* override */.
160  double computeExpoStepAdjust(double stepadjust) /* override */;
161 
162  // Gets the time-integration order(BDF1-5) /* override */.
163  int getOrder() const /* override */
164  {
165  return sec.currentOrder_;
166  }
167 
168  int getNumberOfSteps() const /* override */
169  {
170  return sec.numberOfSteps_;
171  }
172 
173  int getUsedOrder() const /* override */
174  {
175  return sec.usedOrder_;
176  }
177 
178  int getNscsco() const /* override */
179  {
180  return sec.nscsco_;
181  }
182 
183  int getMaxOrder() const /* override */
184  {
185  return sec.maxOrder_;
186  }
187 
188  void getInitialQnorm(TwoLevelError & tle) const /* override */;
189  void getTwoLevelError(TwoLevelError & tle) const /* override */;
190 
191  // This is for new-DAE.
192  void updateStateDeriv() /* override */;
193 
194  // calculates dQ/dt component of store vector and adds it to store vector
195  void updateLeadCurrent() /* override */;
196 
197  // calculates dQ/dt component of the lead current Q vector and adds it to lead current vector
198  void updateLeadCurrentVec() /* override */;
199 
200 
201  // Returns the current partial time derivative for either the solution or
202  // state vector.
203  double partialTimeDeriv() /* override */ const;
204 
205  // Gets the leading coefficient for the specified time-integration method.
206  double getLeadingCoeff() const /* override */
207  {
208  return leadingCoeff;
209  }
210 
211  // sets the leading coefficient for the specified time-integration method.
212  void setLeadingCoeff(double & LC) /* override */
213  {
214  leadingCoeff = LC;
215  }
216 
217  // 03/08/04 tscoffe: New functions necessary for BackwardDifferentiation15
218  // Evaluate corrector residual for nonlinear solver
219  void obtainResidual() /* override */;
220 
221  // obtain residuals for transient sensitivity analysis
222  void obtainSensitivityResiduals() /* override */;
223 
224  // obtain final derivatives w.r.t. time for transient sensitivity analysis
225  void loadFinalSensitivityDerivatives() /* override */
226  {}
227 
228  // Evaluate corrector Jacobian for nonlinear solver
229  void obtainJacobian() /* override */;
230 
231  // Update history array after a successful step
232  void updateHistory() /* override */;
233 
234  // Restore history array after a failed step
235  void restoreHistory() /* override */;
236 
237  // Update method coefficients
238  void updateCoeffs() /* override */;
239 
240  // Initialize method with initial solution & step-size
241  void initialize(const TIAParams &tia_params) /* override */;
242 
243  // setup 2-level data.
244  void setTwoLevelTimeInfo(const TimeIntInfo & tiInfo) /* override */;
245 
246  // Reject a step(this turns back history and chooses new order & step-size) /* override */
247  void rejectStep(const TIAParams &tia_params) /* override */;
248 
249  // Reject a step, but only restore the history, as the new step will be
250  // imposed by an outside program.
251  void rejectStepForHabanero() /* override */;
252 
253  // Complete a step(this updates history and chooses new order & step-size) /* override */
254  void completeStep(const TIAParams &tia_params) /* override */;
255 
256 private:
257  // Return min order of method(this should obey user option minorder) /* override */
259  {
260  return sec.minOrder_;
261  }
262 
263  // Interpolate MPDE solution approximation at prescribed time point(BDF1-5).
265  std::vector<double>& timepoint,
266  Linear::Vector * tmpSolVectorPtr);
267 
268  // Check whether to reduce order independent of local error test
269  void checkReduceOrder();
270 
271  double timept_; ///< Keep track of last interpolation point in printMPDEOutputSolution
272  DataStore & ds; ///< Reference to the TIA data-store object.
273  StepErrorControl & sec; ///< Reference to step-error control object
274  double leadingCoeff; ///< Time-integration method leading coefficient value.
275 };
276 
277 } // namespace TimeIntg
278 } // namespace Xyce
279 
280 #endif // Xyce_N_TIA_BackwardDifferentiation15_h
BackwardDifferentiation15(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Pure virtual class to augment a linear system.
StepErrorControl & sec
Reference to step-error control object.
bool interpolateSolution(double timepoint, Linear::Vector *tmpSolVectorPtr, std::vector< Linear::Vector * > &historyVec)
bool printWaMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes, const int phiGID)
double leadingCoeff
Time-integration method leading coefficient value.
bool saveOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const TIAParams &tia_params, Linear::Vector *solnVecPtr, const double saveTime, const bool doNotInterpolate)
static TimeIntegrationMethod * factory(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
bool printMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes)
int getMaxOrder() const
Return max order of method (this should obey user option maxorder)
bool interpolateMPDESolution(std::vector< double > &timepoint, Linear::Vector *tmpSolVectorPtr)
double timept_
Keep track of last interpolation point in printMPDEOutputSolution.
void updateDerivsBlock(const std::list< IndexPair > &solGIDList, const std::list< IndexPair > &staGIDList)
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)
DataStore & ds
Reference to the TIA data-store object.