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.71 $
41 //
42 // Revision Date : $Date: 2015/06/05 20:49:43 $
43 //
44 // Current Owner : $Author: dgbaur $
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  Parallel::Machine comm,
154  IO::InitialConditionsManager & initial_conditions_manager,
155  const NodeNameMap & node_name_map,
156  const TIAParams & tia_params,
157  Linear::Vector * solnVecPtr,
158  const double saveTime,
159  const bool doNotInterpolate) /* override */;
160 
161  // Computes the step adjustment(BDF1-5) /* override */.
162  double computeExpoStepAdjust(double stepadjust) /* override */;
163 
164  // Gets the time-integration order(BDF1-5) /* override */.
165  int getOrder() const /* override */
166  {
167  return sec.currentOrder_;
168  }
169 
170  int getNumberOfSteps() const /* override */
171  {
172  return sec.numberOfSteps_;
173  }
174 
175  int getUsedOrder() const /* override */
176  {
177  return sec.usedOrder_;
178  }
179 
180  int getNscsco() const /* override */
181  {
182  return sec.nscsco_;
183  }
184 
185  int getMaxOrder() const /* override */
186  {
187  return sec.maxOrder_;
188  }
189 
190  void getInitialQnorm(TwoLevelError & tle) const /* override */;
191  void getTwoLevelError(TwoLevelError & tle) const /* override */;
192 
193  // This is for new-DAE.
194  void updateStateDeriv() /* override */;
195 
196  // calculates dQ/dt component of store vector and adds it to store vector
197  void updateLeadCurrent() /* override */;
198 
199  // calculates dQ/dt component of the lead current Q vector and adds it to lead current vector
200  void updateLeadCurrentVec() /* override */;
201 
202 
203  // Returns the current partial time derivative for either the solution or
204  // state vector.
205  double partialTimeDeriv() /* override */ const;
206 
207  // Gets the leading coefficient for the specified time-integration method.
208  double getLeadingCoeff() const /* override */
209  {
210  return leadingCoeff;
211  }
212 
213  // sets the leading coefficient for the specified time-integration method.
214  void setLeadingCoeff(double & LC) /* override */
215  {
216  leadingCoeff = LC;
217  }
218 
219  // 03/08/04 tscoffe: New functions necessary for BackwardDifferentiation15
220  // Evaluate corrector residual for nonlinear solver
221  void obtainResidual() /* override */;
222 
223  // obtain residuals for transient sensitivity analysis
224  void obtainSensitivityResiduals() /* override */;
225 
226  // obtain final derivatives w.r.t. time for transient sensitivity analysis
227  void loadFinalSensitivityDerivatives() /* override */
228  {}
229 
230  // Evaluate corrector Jacobian for nonlinear solver
231  void obtainJacobian() /* override */;
232 
233  // Update history array after a successful step
234  void updateHistory() /* override */;
235 
236  // Restore history array after a failed step
237  void restoreHistory() /* override */;
238 
239  // Update method coefficients
240  void updateCoeffs() /* override */;
241 
242  // Initialize method with initial solution & step-size
243  void initialize(const TIAParams &tia_params) /* override */;
244 
245  // setup 2-level data.
246  void setTwoLevelTimeInfo() /* override */;
247 
248  // Reject a step(this turns back history and chooses new order & step-size) /* override */
249  void rejectStep(const TIAParams &tia_params) /* override */;
250 
251  // Reject a step, but only restore the history, as the new step will be
252  // imposed by an outside program.
253  void rejectStepForHabanero() /* override */;
254 
255  // Complete a step(this updates history and chooses new order & step-size) /* override */
256  void completeStep(const TIAParams &tia_params) /* override */;
257 
258 private:
259  // Return min order of method(this should obey user option minorder) /* override */
261  {
262  return sec.minOrder_;
263  }
264 
265  // Interpolate MPDE solution approximation at prescribed time point(BDF1-5).
267  std::vector<double>& timepoint,
268  Linear::Vector * tmpSolVectorPtr);
269 
270  // Check whether to reduce order independent of local error test
271  void checkReduceOrder();
272 
273  double timept_; ///< Keep track of last interpolation point in printMPDEOutputSolution
274  DataStore & ds; ///< Reference to the TIA data-store object.
275  StepErrorControl & sec; ///< Reference to step-error control object
276  double leadingCoeff; ///< Time-integration method leading coefficient value.
277 };
278 
279 } // namespace TimeIntg
280 } // namespace Xyce
281 
282 #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.
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)
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)
DataStore & ds
Reference to the TIA data-store object.