Xyce  6.1
N_ANP_MPDE.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_ANP_MPDE.C,v $
27 // Purpose : MPDE analysis functions.
28 // Special Notes :
29 // Creator : Todd Coffey, 1414, Ting Mei, 1437
30 // Creation Date : 07/23/08
31 //
32 // Revision Information:
33 // ---------------------
34 // Revision Number: $Revision: 1.45.2.1 $
35 // Revision Date : $Date: 2015/04/02 18:20:07 $
36 // Current Owner : $Author: tvrusso $
37 //-----------------------------------------------------------------------------
38 #include <Xyce_config.h>
39 
40 #include <N_ANP_AnalysisManager.h>
41 #include <N_ANP_OutputMgrAdapter.h>
42 #include <N_ANP_MPDE.h>
43 #include <N_DEV_DeviceMgr.h>
44 #include <N_IO_CmdParse.h>
45 #include <N_IO_OutputMgr.h>
46 #include <N_IO_PkgOptionsMgr.h>
47 #include <N_LOA_Loader.h>
48 #include <N_MPDE_Manager.h>
49 #include <N_TIA_DataStore.h>
50 #include <N_TIA_StepErrorControl.h>
52 
53 namespace Xyce {
54 namespace Analysis {
55 
56 //-----------------------------------------------------------------------------
57 // Function : MPDE::MPDE( AnalysisManager * )
58 // Purpose :
59 // Special Notes :
60 // Scope : public
61 // Creator : Rich Schiek, SNL
62 // Creation Date : 3/11/06
63 //-----------------------------------------------------------------------------
65  AnalysisManager & analysis_manager,
66  Linear::System & linear_system,
67  Nonlinear::Manager & nonlinear_manager,
68  Device::DeviceMgr & device_manager,
69  Linear::Builder & builder,
70  Topo::Topology & topology)
71  : AnalysisBase(analysis_manager, "MPDE"),
72  StepEventListener(&analysis_manager),
73  analysisManager_(analysis_manager),
74  loader_(analysis_manager.getLoader()),
75  linearSystem_(linear_system),
76  nonlinearManager_(nonlinear_manager),
77  topology_(topology),
78  mpdeManager_(new N_MPDE_Manager(analysisManager_, device_manager, builder, topology, analysisManager_.getCommandLine()))
79 {}
80 
81 void MPDE::notify(const StepEvent &event)
82 {
83  if (event.state_ == StepEvent::STEP_STARTED)
84  {
86  }
87 }
88 
89 //-----------------------------------------------------------------------------
90 // Function : MPDE::~MPDE
91 // Purpose :
92 // Special Notes :
93 // Scope : public
94 // Creator :
95 // Creation Date :
96 //-----------------------------------------------------------------------------
98 {
99  delete mpdeManager_;
100 }
101 
102 const TimeIntg::TIAParams &
104 {
105  return mpdeManager_->getTIAParams();
106 }
107 
110 {
111  return mpdeManager_->getTIAParams();
112 }
113 
114 //-----------------------------------------------------------------------------
115 // Function : MPDE::getDCOPFlag()
116 // Purpose :
117 // Special Notes :
118 // Scope : public
119 // Creator : Eric Keiter, SNL
120 // Creation Date : 3/24/2014
121 //-----------------------------------------------------------------------------
122 bool MPDE::getDCOPFlag() const
123 {
125 }
126 
127 //-----------------------------------------------------------------------------
128 // Function : MPDE::run()
129 // Purpose :
130 // Special Notes :
131 // Scope : public
132 // Creator : Rich Schiek, SNL
133 // Creation Date : 3/11/06
134 //-----------------------------------------------------------------------------
136 {
137  mpdeManager_->registerApplicationLoader(&loader_);
139 
140  return true;
141 }
142 
143 //-----------------------------------------------------------------------------
144 // Function : MPDE::init()
145 // Purpose :
146 // Special Notes :
147 // Scope : public
148 // Creator : Rich Schiek, SNL
149 // Creation Date : 3/11/06
150 //-----------------------------------------------------------------------------
152 {
153 // analysisManager_.getMPDEManager()->initializeAll();
154 
155  return false;
156 }
157 
158 //-----------------------------------------------------------------------------
159 // Function : MPDE::loopProcess()
160 // Purpose : Conduct the time stepping loop.
161 // Special Notes :
162 // Scope : public
163 // Creator : Rich Schiek, SNL
164 // Creation Date : 3/11/06
165 //-----------------------------------------------------------------------------
167 {
168  return false;
169 }
170 
171 //-----------------------------------------------------------------------------
172 // Function : MPDE::processSuccessfulDCOP()
173 // Purpose :
174 // Special Notes :
175 // Scope : public
176 // Creator : Rich Schiek, SNL
177 // Creation Date : 3/11/06
178 //-----------------------------------------------------------------------------
180 {
181  return false;
182 }
183 
184 //-----------------------------------------------------------------------------
185 // Function : MPDE::processSuccessfulStep()
186 // Purpose :
187 // Special Notes :
188 // Scope : public
189 // Creator : Rich Schiek, SNL
190 // Creation Date : 3/11/06
191 //-----------------------------------------------------------------------------
193 {
194  return false;
195 }
196 
197 //-----------------------------------------------------------------------------
198 // Function : MPDE::processFailedStep
199 // Purpose :
200 // Special Notes :
201 // Scope : public
202 // Creator : Rich Schiek, SNL
203 // Creation Date : 3/11/06
204 //-----------------------------------------------------------------------------
206 {
207  return false;
208 }
209 
210 //-----------------------------------------------------------------------------
211 // Function : MPDE::processFailedDCOP
212 // Purpose :
213 // Special Notes :
214 // Scope : public
215 // Creator : Rich Schiek, SNL
216 // Creation Date : 3/11/06
217 //-----------------------------------------------------------------------------
219 {
220  return false;
221 }
222 
223 //-----------------------------------------------------------------------------
224 // Function : MPDE::finish
225 // Purpose :
226 // Special Notes :
227 // Scope : public
228 // Creator : Rich Schiek, SNL
229 // Creation Date : 3/11/06
230 //-----------------------------------------------------------------------------
232 {
233  return false;
234 }
235 
237 {
238  return true;
239 }
240 
241 //-----------------------------------------------------------------------------
242 // Function : MPDE::finalVerboseOutput
243 // Purpose :
244 // Special Notes :
245 // Scope : public
246 // Creator : Rich Schiek, SNL
247 // Creation Date : 3/11/06
248 //-----------------------------------------------------------------------------
250 {
251  return false;
252 }
253 
254 namespace {
255 
256 //-----------------------------------------------------------------------------
257 // Class : MPDEFactory
258 // Purpose :
259 // Special Notes :
260 // Scope : public
261 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
262 // Creation Date : Thu Jan 29 12:53:02 2015
263 //-----------------------------------------------------------------------------
264 ///
265 /// Factory for parsing MPDE parameters from the netlist and creating MPDE analysis.
266 ///
267 class MPDEFactory : public Factory<MPDE>
268 {
269 public:
270  //-----------------------------------------------------------------------------
271  // Function : MPDEFactory
272  // Purpose :
273  // Special Notes :
274  // Scope : public
275  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
276  // Creation Date : Thu Jan 29 12:54:09 2015
277  //-----------------------------------------------------------------------------
278  ///
279  /// Constructs the MPDE analysis factory
280  ///
281  /// @invariant Stores the results of parsing, so if more than one of the analysis and
282  /// associated lines are parsed, the second options simply overwrite the previously parsed
283  /// values.
284  ///
285  /// @invariant The existence of the parameters specified in the constructor cannot
286  /// change.
287  ///
288  /// @param analysis_manager
289  /// @param linear_system
290  /// @param nonlinear_manager
291  /// @param device_manager
292  /// @param builder
293  /// @param topology
294  ///
295  MPDEFactory(
296  Analysis::AnalysisManager & analysis_manager,
297  Linear::System & linear_system,
298  Nonlinear::Manager & nonlinear_manager,
299  Device::DeviceMgr & device_manager,
300  Linear::Builder & builder,
301  Topo::Topology & topology)
302  : Factory<MPDE>(),
303  analysisManager_(analysis_manager),
304  linearSystem_(linear_system),
305  nonlinearManager_(nonlinear_manager),
306  deviceManager_(device_manager),
307  builder_(builder),
308  topology_(topology)
309  {}
310 
311  virtual ~MPDEFactory()
312  {}
313 
314  //-----------------------------------------------------------------------------
315  // Function : create
316  // Purpose :
317  // Special Notes :
318  // Scope : public
319  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
320  // Creation Date : Thu Jan 29 12:59:00 2015
321  //-----------------------------------------------------------------------------
322  ///
323  /// Create a new MPDE analysis and applies the analysis and time integrator option blocks.
324  ///
325  /// @return new MPDE analysis object
326  ///
327  MPDE *create() const
328  {
329  analysisManager_.setAnalysisMode(ANP_MODE_MPDE);
330 
332 
333  mpde->getMPDEManager().setMPDEAnalysisParams(mpdeAnalysisOptionBlock_);
334  mpde->getMPDEManager().setMPDEOptions(mpdeIntOptionBlock_);
335  mpde->getMPDEManager().setTransientOptions(mpdeTimeIntegratorOptionBlock_);
336 
337  return mpde;
338  }
339 
340  //-----------------------------------------------------------------------------
341  // Function : setMPDEAnalysisOptionBlock
342  // Purpose :
343  // Special Notes :
344  // Scope : public
345  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
346  // Creation Date : Thu Jan 29 13:00:14 2015
347  //-----------------------------------------------------------------------------
348  ///
349  /// Saves the analysis parsed options block in the factory.
350  ///
351  /// @invariant Overwrites any previously specified analysis option block.
352  ///
353  /// @param option_block parsed option block
354  ///
355  void setMPDEAnalysisOptionBlock(const Util::OptionBlock &option_block)
356  {
357  mpdeAnalysisOptionBlock_ = option_block;
358  }
359 
360  //-----------------------------------------------------------------------------
361  // Function : setMPDETimeIntegratorOptionBlock
362  // Purpose :
363  // Special Notes :
364  // Scope : public
365  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
366  // Creation Date : Thu Jan 29 13:01:27 2015
367  //-----------------------------------------------------------------------------
368  ///
369  /// Saves the time integrator parsed option block.
370  ///
371  /// @invariant Overwrites any previously specified time integrator option block.
372  ///
373  /// @param option_block parsed option block
374  ///
375  void setMPDETimeIntegratorOptionBlock(const Util::OptionBlock &option_block)
376  {
377  mpdeTimeIntegratorOptionBlock_ = option_block;
378  }
379 
380  //-----------------------------------------------------------------------------
381  // Function : setMPDEIntOptionBlock
382  // Purpose :
383  // Special Notes :
384  // Scope : public
385  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
386  // Creation Date : Thu Jan 29 13:01:27 2015
387  //-----------------------------------------------------------------------------
388  ///
389  /// Saves the MPDEINT parsed option block.
390  ///
391  /// @invariant Overwrites any previously specified time integrator option block.
392  ///
393  /// @param option_block parsed option block
394  ///
395  void setMPDEIntOptionBlock(const Util::OptionBlock &option_block)
396  {
397  mpdeIntOptionBlock_ = option_block;
398  }
399 
400 public:
401  AnalysisManager & analysisManager_;
402  Linear::System & linearSystem_;
403  Nonlinear::Manager & nonlinearManager_;
404  Device::DeviceMgr & deviceManager_;
405  Linear::Builder & builder_;
406  Topo::Topology & topology_;
407 
408 private:
409  Util::OptionBlock mpdeAnalysisOptionBlock_;
410  Util::OptionBlock mpdeIntOptionBlock_;
412  Util::OptionBlock timeIntegratorOptionBlock_;
413 };
414 
415 // .options MPDEINT
416 struct MPDEIntOptionsReg : public IO::PkgOptionsReg
417 {
418  MPDEIntOptionsReg(
419  MPDEFactory & factory )
420  : factory_(factory)
421  {}
422 
423  bool operator()(const Util::OptionBlock &option_block)
424  {
425  factory_.setMPDEIntOptionBlock(option_block);
426 
427  return true;
428  }
429 
430  MPDEFactory & factory_;
431 };
432 
433 // .options TIMEINT-MPDE
434 struct MPDETimeIntegratorOptionsReg : public IO::PkgOptionsReg
435 {
436  MPDETimeIntegratorOptionsReg(
437  MPDEFactory & factory )
438  : factory_(factory)
439  {}
440 
441  bool operator()(const Util::OptionBlock &option_block)
442  {
443  factory_.setMPDETimeIntegratorOptionBlock(option_block);
444 
445  return true;
446  }
447 
448  MPDEFactory & factory_;
449 };
450 
451 // .MPDE
452 struct MPDEAnalysisReg : public IO::PkgOptionsReg
453 {
454  MPDEAnalysisReg(
455  MPDEFactory & factory )
456  : factory_(factory)
457  {}
458 
459  bool operator()(const Util::OptionBlock &option_block)
460  {
461  factory_.setMPDEAnalysisOptionBlock(option_block);
462  factory_.deviceManager_.setBlockAnalysisFlag(true);
463 
464  factory_.analysisManager_.addAnalysis(&factory_);
465 
466  return true;
467  }
468 
469  MPDEFactory & factory_;
470 };
471 
472 } // namespace <unnamed>
473 
474 
475 bool
477  const std::string & netlist_filename,
478  IO::PkgOptionsMgr & options_manager,
479  AnalysisManager & analysis_manager,
480  Linear::System & linear_system,
481  Nonlinear::Manager & nonlinear_manager,
482  Device::DeviceMgr & device_manager,
483  Linear::Builder & builder,
484  Topo::Topology & topology)
485 {
486  MPDEFactory *factory = new MPDEFactory(analysis_manager, linear_system, nonlinear_manager, device_manager, builder, topology);
487 
488  analysis_manager.addAnalysisFactory(factory);
489 
490  options_manager.submitRegistration("MPDE", netlist_filename, new MPDEAnalysisReg(*factory));
491  options_manager.submitRegistration("MPDEINT", netlist_filename, new MPDEIntOptionsReg(*factory));
492  options_manager.submitRegistration("TIMEINT-MPDE", netlist_filename, new MPDETimeIntegratorOptionsReg(*factory));
493 
494 
495  return true;
496 }
497 
498 } // namespace Analysis
499 } // namespace Xyce
Loader::Loader & loader_
Definition: N_ANP_MPDE.h:111
bool doProcessSuccessfulStep()
Definition: N_ANP_MPDE.C:192
Pure virtual class to augment a linear system.
MPDE(AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Device::DeviceMgr &device_manager, Linear::Builder &builder, Topo::Topology &topology)
Definition: N_ANP_MPDE.C:64
bool registerMPDEFactory(const std::string &netlist_filename, IO::PkgOptionsMgr &options_manager, AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Device::DeviceMgr &device_manager, Linear::Builder &builder, Topo::Topology &topology)
Definition: N_ANP_MPDE.C:476
MPDEFactory & factory_
Definition: N_ANP_MPDE.C:430
Device::DeviceMgr & deviceManager_
Definition: N_ANP_MPDE.C:404
Util::ListenerAutoSubscribe< StepEvent > StepEventListener
void notify(const StepEvent &event)
Definition: N_ANP_MPDE.C:81
Topo::Topology & topology_
Definition: N_ANP_MPDE.C:406
Util::OptionBlock mpdeIntOptionBlock_
Definition: N_ANP_MPDE.C:410
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_MPDE.h:113
Linear::System & linearSystem_
Definition: N_ANP_MPDE.h:112
Topo::Topology & topology_
Definition: N_ANP_MPDE.h:114
Util::OptionBlock mpdeTimeIntegratorOptionBlock_
Definition: N_ANP_MPDE.C:411
Linear::System & linearSystem_
Definition: N_ANP_MPDE.C:402
Util::OptionBlock timeIntegratorOptionBlock_
Definition: N_ANP_MPDE.C:412
Linear::Builder & builder_
Definition: N_ANP_MPDE.C:405
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_MPDE.C:403
void addAnalysisFactory(Factory< void > *factory)
const TimeIntg::TIAParams & getTIAParams() const
Definition: N_ANP_MPDE.C:103
The analysis factory template defines an interface for analysis type testing and analysis creation...
Definition: N_ANP_Factory.h:65
bool processSuccessfulDCOP()
Definition: N_ANP_MPDE.C:179
AnalysisManager & analysisManager_
Definition: N_ANP_MPDE.C:401
Util::OptionBlock mpdeAnalysisOptionBlock_
Definition: N_ANP_MPDE.C:409
N_MPDE_Manager * mpdeManager_
Definition: N_ANP_MPDE.h:115
bool doProcessFailedStep()
Definition: N_ANP_MPDE.C:205
bool getDCOPFlag() const
Definition: N_ANP_MPDE.C:122