Xyce  6.1
N_TIA_TimeIntegrationMethods.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_TimeIntegrationMethods.h,v $
27 //
28 // Purpose : This file defines the classes for the time integration
29 // methods --- the "interface base class" along with the
30 // accompanying integration methods classes which can be
31 // used in the time integration algorithm.
32 //
33 // Special Notes :
34 //
35 // Creator : Buddy Watts
36 //
37 // Creation Date : 6/1/00
38 //
39 // Revision Information:
40 // ---------------------
41 //
42 // Revision Number: $Revision: 1.77 $
43 //
44 // Revision Date : $Date: 2015/06/05 20:49:43 $
45 //
46 // Current Owner : $Author: dgbaur $
47 //-----------------------------------------------------------------------------
48 
49 #ifndef Xyce_N_TIA_TimeIntegrationMethods_h
50 #define Xyce_N_TIA_TimeIntegrationMethods_h
51 
52 // ---------- Standard Includes ----------
53 #include <list>
54 
55 // ---------- Xyce Includes ----------
56 #include <N_ANP_fwd.h>
57 #include <N_IO_fwd.h>
58 #include <N_LAS_fwd.h>
59 #include <N_PDS_fwd.h>
60 #include <N_TIA_fwd.h>
61 #include <N_UTL_fwd.h>
62 
63 #include <N_UTL_IndexPair.h>
64 
65 namespace Xyce {
66 namespace TimeIntg {
67 
68 //-----------------------------------------------------------------------------
69 // Class : TimeIntegrationMethod
70 //
71 // Purpose : This is the integration methods interface class, from which
72 // specific integration methods (such as BDF15, trap, etc) are
73 // derrived.
74 //
75 // Special Notes :
76 // Creator : Buddy Watts, SNL
77 // Creation Date : 6/01/00
78 //-----------------------------------------------------------------------------
80 {
81 protected:
83  {}
84 
85 public:
87  {}
88 
89  virtual const char *getName() const = 0;
90 
91  // Predict solution at next time point.
92  virtual void obtainPredictor() = 0;
93 
94  // Evaluate the predictor derivative formula.
95  virtual void obtainPredictorDeriv() = 0;
96 
97  // Evaluate the corrector derivative formula.
98  virtual void obtainCorrectorDeriv() = 0;
99 
100  // Compute an estimate of the error in the integration step.
101  virtual void updateDerivsBlock(
102  const std::list<IndexPair> & solGIDList,
103  const std::list<IndexPair> & staGIDList) = 0;
104 
105  // Compute an estimate of the error in the integration step.
106  virtual double computeErrorEstimate() const = 0;
107 
108  // Interpolate solution, state or store approximation at prescribed time point.
109  virtual bool interpolateSolution(double timepoint, Linear::Vector * tmpSolVectorPtr, std::vector<Linear::Vector*> & historyVec) = 0;
110 
111  // Print output using interpolation when order is high
112  virtual bool printOutputSolution(
113  Analysis::OutputMgrAdapter & outputManagerAdapter,
114  const TIAParams & tia_params,
115  const double time,
116  Linear::Vector * solnVecPtr,
117  const bool doNotInterpolate,
118  const std::vector<double> & outputInterpolationTimes,
119  bool skipPrintLineOutput) = 0;
120 
121  // Print MPDE output using local interpolation methods
123  Analysis::OutputMgrAdapter & outputManagerAdapter,
124  const double time,
125  Linear::Vector * solnVecPtr,
126  const std::vector<double> & fastTimes)
127  {
128  return false;
129  }
130 
131  // Print WaMPDE output using local interpolation methods
133  Analysis::OutputMgrAdapter & outputManagerAdapter,
134  const double time,
135  Linear::Vector * solnVecPtr,
136  const std::vector<double> & fastTimes,
137  const int phiGID)
138  {
139  return false;
140  }
141 
142  // .SAVE output using interpolation when order is high
143  virtual bool saveOutputSolution(
144  Parallel::Machine comm,
145  IO::InitialConditionsManager & initial_conditions_manager,
146  const NodeNameMap & node_name_map,
147  const TIAParams & tia_params,
148  Linear::Vector * solnVecPtr,
149  const double saveTime,
150  const bool doNotInterpolate) = 0;
151 
152  // Computes the step adjustment.
153  virtual double computeExpoStepAdjust(double stepadjust) = 0;
154 
155  // Gets the time-integration order.
156  virtual int getOrder() const = 0;
157  virtual int getNumberOfSteps() const = 0;
158  virtual int getUsedOrder() const = 0;
159  virtual int getNscsco() const = 0;
160  virtual int getMaxOrder() const = 0; ///< Return max order of method (this should obey user option maxorder)
161 
162  virtual void getInitialQnorm(TwoLevelError & tle) const = 0;
163  virtual void getTwoLevelError(TwoLevelError & tle) const = 0;
164 
165  // This is for new-DAE.
166  virtual void updateStateDeriv ()
167  {}
168 
169  // calculates dQ/dt component of store vector and adds it to store vector
170  virtual void updateLeadCurrent ()
171  {}
172 
173  // calculates dQ/dt component of lead current vector and adds it to the lead current vector
174  virtual void updateLeadCurrentVec ()
175  {}
176 
177 
178  // Returns the current partial time derivative for either the solution or
179  // state vector.
180  virtual double partialTimeDeriv() const = 0;
181 
182  // Gets the leading coefficient for the specified time-integration method.
183  virtual double getLeadingCoeff() const = 0;
184 
185  // sets the leading coefficient for the specified time-integration method.
186  virtual void setLeadingCoeff(double & LC) = 0;
187 
188  // Evaluate residual for nonlinear solver
189  virtual void obtainResidual() = 0;
190 
191  // obtain residuals for transient sensitivity analysis
192  virtual void obtainSensitivityResiduals() = 0;
193 
194  // obtain final derivatives w.r.t. time for transient sensitivity analysis
195  virtual void loadFinalSensitivityDerivatives() = 0;
196 
197  // Evaluate Jacobian for nonlinear solver
198  virtual void obtainJacobian()
199  {}
200 
201  // Apply Jacobian for nonlinear solver
202  virtual void applyJacobian(const Linear::Vector& input, Linear::Vector& result)
203  {}
204 
205  // Update history array after a successful step
206  virtual void updateHistory()
207  {}
208 
209  // Restore history array after a failed step
210  virtual void restoreHistory()
211  {}
212 
213  // Update method coefficients
214  virtual void updateCoeffs()
215  {}
216 
217  // Initialize method with initial solution & step-size
218  virtual void initialize(const TIAParams &tia_params) = 0;
219 
220  // setup 2-level data.
221  virtual void setTwoLevelTimeInfo() = 0;
222 
223  // Reject a step (this turns back history and chooses new order & step-size)
224  virtual void rejectStep(const TIAParams &tia_params) = 0;
225 
226  // Reject a step, but only restore the history, as the new step will be
227  // imposed by an outside program.
228  virtual void rejectStepForHabanero()
229  {}
230 
231  // Complete a step (this updates history and chooses new order & step-size)
232  virtual void completeStep(const TIAParams &tia_params) = 0;
233 };
234 
235 } // namespace TimeIntg
236 } // namespace Xyce
237 
238 #endif // Xyce_N_TIA_TimeIntegrationMethods_h
virtual void getInitialQnorm(TwoLevelError &tle) const =0
virtual void updateDerivsBlock(const std::list< IndexPair > &solGIDList, const std::list< IndexPair > &staGIDList)=0
virtual double getLeadingCoeff() const =0
virtual 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)=0
virtual bool printMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes)
virtual const char * getName() const =0
Pure virtual class to augment a linear system.
virtual bool interpolateSolution(double timepoint, Linear::Vector *tmpSolVectorPtr, std::vector< Linear::Vector * > &historyVec)=0
virtual void initialize(const TIAParams &tia_params)=0
virtual void getTwoLevelError(TwoLevelError &tle) const =0
virtual bool printWaMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes, const int phiGID)
virtual void completeStep(const TIAParams &tia_params)=0
virtual int getUsedOrder() const =0
virtual double partialTimeDeriv() const =0
virtual void applyJacobian(const Linear::Vector &input, Linear::Vector &result)
virtual void setLeadingCoeff(double &LC)=0
virtual 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)=0
virtual int getMaxOrder() const =0
Return max order of method (this should obey user option maxorder)
virtual int getNscsco() const =0
virtual double computeExpoStepAdjust(double stepadjust)=0
virtual double computeErrorEstimate() const =0
virtual void loadFinalSensitivityDerivatives()=0
virtual int getNumberOfSteps() const =0
virtual void rejectStep(const TIAParams &tia_params)=0