Xyce  6.1
N_TIA_WorkingIntegrationMethod.C
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_WorkingIntegrationMethod.C,v $
27 //
28 // Purpose : This file contains the functions which define the
29 // time integration methods classes.
30 //
31 // Special Notes :
32 //
33 // Creator : Buddy Watts
34 //
35 // Creation Date : 6/1/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.8.2.1 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:20:18 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 #include <N_ERH_ErrorMgr.h>
50 #include <N_TIA_StepErrorControl.h>
51 #include <N_TIA_TIAParams.h>
54 #include <N_UTL_FeatureTest.h>
55 
56 namespace Xyce {
57 namespace TimeIntg {
58 
59 namespace {
60 
61 typedef std::map<int, std::pair<const char *, Factory> > Registry;
62 
63 Registry &
64 getRegistry()
65 {
66  static Registry s_registry;
67 
68  return s_registry;
69 }
70 
71 } // namespace <unnamed>
72 
73 void
74 registerFactory(int type, const char *name, Factory factory)
75 {
76  std::pair<Registry::iterator, bool> result = getRegistry().insert(Registry::value_type(type, std::pair<const char *, Factory>(name, factory)));
77  if (!result.second && name != (*result.first).second.first)
78  Report::DevelFatal0() << "Time integration factory " << type << " named " << name << " already registered with name " << (*result.first).second.first;
79 }
80 
81 TimeIntegrationMethod *
83  int type,
84  const TIAParams & tia_params,
85  StepErrorControl & step_error_control,
86  DataStore & data_store)
87 {
88  Registry::const_iterator it = getRegistry().find(type);
89  if (it == getRegistry().end())
90  return 0;
91 
92  return (*(*it).second.second)(tia_params, step_error_control, data_store);
93 }
94 
95 const char *
97 {
98  Registry::const_iterator it = getRegistry().find(type);
99  if (it == getRegistry().end())
100  return "<none>";
101 
102  return (*it).second.first;
103 }
104 
105 //-----------------------------------------------------------------------------
106 // Function : WorkingIntegrationMethod::WorkingIntegrationMethod
107 // Purpose : constructor
108 // Special Notes :
109 // Scope : public
110 // Creator : Buddy Watts, SNL
111 // Creation Date : 6/01/00
112 //-----------------------------------------------------------------------------
114  : timeIntegrationMethod_(0),
115  jacLimitFlag(false),
116  jacLimit(1.0e+17),
117  timeIntegratorStat_("Time integrator", parent_stat),
118  predictorStat_("Predictor", timeIntegratorStat_),
119  completeStepStat_("Successful Step", timeIntegratorStat_),
120  rejectStepStat_("Failed Step", timeIntegratorStat_),
121  updateCoefStat_("Update Coef", timeIntegratorStat_),
122  residualStat_("Load Residual", timeIntegratorStat_),
123  jacobianStat_("Load Jacobian", timeIntegratorStat_),
124  initializeStat_("Initialize", timeIntegratorStat_),
125  updateLeadStat_("Lead Currents", timeIntegratorStat_)
126 {}
127 
128 //-----------------------------------------------------------------------------
129 // Function : WorkingIntegrationMethod::~WorkingIntegrationMethod()
130 // Purpose : destructor
131 // Special Notes :
132 // Scope : public
133 // Creator : Buddy Watts, SNL
134 // Creation Date : 6/01/00
135 //-----------------------------------------------------------------------------
137 {
138  delete timeIntegrationMethod_;
139 }
140 
141 //-----------------------------------------------------------------------------
142 // Function : WorkingIntegrationMethod::createTimeIntegMethod
143 // Purpose : Creates the time integration method class --- assigning a
144 // pointer and the Leading Coefficient value of the method.
145 // Special Notes :
146 // Scope : public
147 // Creator : Buddy Watts, SNL
148 // Creation Date : 6/01/00
149 //-----------------------------------------------------------------------------
151  int type,
152  const TIAParams & tia_params,
153  StepErrorControl & step_error_control,
154  DataStore & data_store)
155 {
156  jacLimitFlag = tia_params.jacLimitFlag;
157  jacLimit = tia_params.jacLimit;
158 
159  delete timeIntegrationMethod_;
160  timeIntegrationMethod_ = createTimeIntegrationMethod(type, tia_params, step_error_control, data_store);
161 
163  Report::DevelFatal0().in("WorkingIntegrationMethod::createTimeIntegMethod") << "Invalid integration method " << type << " specified";
164 
165  if (VERBOSE_TIME)
166  Xyce::lout() << " Integration method = " << timeIntegrationMethod_->getName() << std::endl;
167 }
168 
170 {
171  return timeIntegrationMethod_ != 0;
172 }
173 
175 {
177  if (jacLimitFlag && pdt > jacLimit)
178  pdt = jacLimit;
179 
180  return pdt;
181 }
182 
184 {
185  Stats::TimeBlock x(predictorStat_);
186 
188 }
189 
191 {
192  Stats::TimeBlock x(predictorStat_);
194 }
195 
197 {
199 }
200 
201 void WorkingIntegrationMethod::updateDerivsBlock ( const std::list<IndexPair> & solGIDList, const std::list<IndexPair> & staGIDList)
202 {
203  timeIntegrationMethod_->updateDerivsBlock (solGIDList, staGIDList);
204 }
205 
207 {
209 }
210 
212 {
214 }
215 
217 {
219 }
220 
222 {
224 }
225 
227 {
229 }
230 
232 {
234 }
235 
237 {
239 }
240 
242 {
243 
244  Stats::TimeBlock x(updateCoefStat_);
246 }
247 
249 {
251 }
252 
254 {
255  Stats::TimeBlock x( initializeStat_ );
256  return timeIntegrationMethod_->initialize(tia_params);
257 }
258 
260 {
261 
262  Stats::TimeBlock x(completeStepStat_);
263 
264  return timeIntegrationMethod_->completeStep(tia_params);
265 }
266 
268 {
269  Stats::TimeBlock x(rejectStepStat_);
270  return timeIntegrationMethod_->rejectStep(tia_params);
271 }
272 
274 {
275 // Stats::TimeBlock x(ErrorStat_);
277 }
278 
280 {
282 }
283 
285 {
286 
287 
288  Stats::TimeBlock x( updateLeadStat_);
291 }
292 
294 {
295  Stats::TimeBlock x(residualStat_);
297 }
298 
300 {
302 }
303 
305 {
307 }
308 
310 {
311 
312  Stats::TimeBlock x(jacobianStat_);
314 }
315 
316 void WorkingIntegrationMethod::applyJacobian(const Linear::Vector& input, Linear::Vector& result)
317 {
318  Stats::TimeBlock x(jacobianStat_);
319  return timeIntegrationMethod_->applyJacobian(input, result);
320 }
321 
323  Analysis::OutputMgrAdapter & outputManagerAdapter,
324  const double time,
325  Linear::Vector * solnVecPtr,
326  const std::vector<double> & fastTimes )
327 {
329  outputManagerAdapter, time, solnVecPtr, fastTimes );
330 }
331 
333  Analysis::OutputMgrAdapter & outputManagerAdapter,
334  const double time,
335  Linear::Vector * solnVecPtr,
336  const std::vector<double> & fastTimes,
337  const int phiGID )
338 {
340  outputManagerAdapter, time, solnVecPtr, fastTimes, phiGID );
341 }
342 
344  Analysis::OutputMgrAdapter & outputManagerAdapter,
345  const TIAParams & tia_params,
346  const double time,
347  Linear::Vector * solnVecPtr,
348  const bool doNotInterpolate,
349  const std::vector<double> & outputInterpolationTimes,
350  bool skipPrintLineOutput )
351 {
352 // Stats::TimeBlock x( othersStat_);
354  outputManagerAdapter, tia_params, time, solnVecPtr, doNotInterpolate, outputInterpolationTimes, skipPrintLineOutput) ;
355 }
356 
358  Analysis::OutputMgrAdapter & outputManagerAdapter,
359  const TIAParams & tia_params,
360  Linear::Vector * solnVecPtr,
361  const double saveTime,
362  const bool doNotInterpolate)
363 {
365  outputManagerAdapter, tia_params, solnVecPtr, saveTime, doNotInterpolate);
366 }
367 
368 } // namespace TimeIntg
369 } // namespace Xyce
virtual void updateDerivsBlock(const std::list< IndexPair > &solGIDList, const std::list< IndexPair > &staGIDList)=0
virtual const char * getName() const =0
virtual bool printMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes)
Pure virtual class to augment a linear system.
virtual void getTwoLevelError(TwoLevelError &tle) const =0
virtual int getNumberOfSteps() const =0
void updateDerivsBlock(const std::list< IndexPair > &solGIDList, const std::list< IndexPair > &staGIDList)
virtual void initialize(const TIAParams &tia_params)=0
TimeIntegrationMethod * timeIntegrationMethod_
Pointer to the integration method.
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
const char * getTimeIntegrationName(int type)
TimeIntegrationMethod * createTimeIntegrationMethod(int type, const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
bool saveOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const TIAParams &tia_params, Linear::Vector *solnVecPtr, const double saveTime, const bool doNotInterpolate)
void registerFactory(int type, const char *name, Factory factory)
virtual int getUsedOrder() const =0
virtual double computeErrorEstimate() const =0
virtual void applyJacobian(const Linear::Vector &input, Linear::Vector &result)
bool printMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes)
virtual double partialTimeDeriv() const =0
virtual void getInitialQnorm(TwoLevelError &tle) const =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
TimeIntegrationMethod *(* Factory)(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
void createTimeIntegMethod(int type, const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
virtual void setTwoLevelTimeInfo(const TimeIntInfo &tiInfo)=0
virtual int getNscsco() const =0
void applyJacobian(const Linear::Vector &input, Linear::Vector &result)
virtual void loadFinalSensitivityDerivatives()=0
bool printWaMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes, const int phiGID)
virtual bool saveOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const TIAParams &tia_params, Linear::Vector *solnVecPtr, const double saveTime, const bool doNotInterpolate)=0
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)
std::vector< Factory< void > * > Registry
Registry of factories.
virtual void rejectStep(const TIAParams &tia_params)=0