Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_ANP_HB.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-2014 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_HB.h,v $
27 //
28 // Purpose : HB analysis class
29 //
30 // Special Notes : Specify any "hidden" or subtle details of the class here.
31 // Portability details, error handling information, etc.
32 //
33 // Creator : Todd Coffey, 1414, Ting Mei 1437
34 //
35 // Creation Date : 07/23/08
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.23 $
41 // Revision Date : $Date: 2014/02/24 23:49:12 $
42 // Current Owner : $Author: tvrusso $
43 //-----------------------------------------------------------------------------
44 
45 #ifndef Xyce_N_ANP_HB_h
46 #define Xyce_N_ANP_HB_h
47 
48 #include <vector>
49 
50 // ---------- Xyce Includes ----------
51 #include <N_ANP_fwd.h>
52 
53 #include <N_ANP_AnalysisBase.h>
54 #include <N_MPDE_State.h>
55 
56 // ---------- Forward Declarations ----------
57 class N_LAS_PrecondFactory;
58 class N_LAS_System;
59 
60 class N_MPDE_Discretization;
61 
62 class N_LOA_HBLoader;
63 class N_LAS_HBBuilder;
64 
65 namespace Xyce {
66 namespace Analysis {
67 
68 //-------------------------------------------------------------------------
69 // Class : HB
70 // Purpose : HB analysis class
71 // Special Notes :
72 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
73 // Creation Date : 01/24/08
74 //-------------------------------------------------------------------------
75 class HB : public AnalysisBase
76 {
77 public:
78  HB( AnalysisManager * anaManagerPtr );
79  virtual ~HB() {};
80 
81  // Method to set HB options
82  bool setHBOptions(const N_UTL_OptionBlock & OB);
83 
84  // Method to set HB linear solver / preconditioning options
85  bool setHBLinSol(const N_UTL_OptionBlock & OB);
86 
87  // Method to set non-HB linear solver / preconditioning options (needed for .STEP)
88  bool setLinSol(const N_UTL_OptionBlock & OB);
89 
90  // Override these methods using the current analysisObject_.
91  int getStepNumber ();
92  void setStepNumber (int step);
93  void setBeginningIntegrationFlag(bool bif);
95  void setIntegrationMethod (int im);
96  unsigned int getIntegrationMethod ();
97 
98  virtual bool run(); /* override */
99  virtual bool init(); /* override */
100  virtual bool loopProcess(); /* override */
101  virtual bool processSuccessfulDCOP(); /* override */
102  virtual bool processFailedDCOP(); /* override */
103  virtual bool processSuccessfulStep(); /* override */
104  virtual bool processFailedStep(); /* override */
105  virtual bool finish(); /* override */
106  virtual bool handlePredictor(); /* override */
107 
108  virtual bool resetForStepAnalysis();
109 
110  bool finalVerboseOutput();
111 
112  // Utility function for AnalysisManager to determine if a complex analysis type (like HB)
113  // is performing another type of analysis under the hood. This is necessary for populating
114  // the N_TIA_TimeIntInfo struct. For straightforward analysis types, this method is not
115  // needed because the AnalysisManager already knows which analysis is being performed.
116  bool isAnalysis( int analysis_type );
117 
118  // Transform the current solution vector for time domain and frequency domain output
119  void prepareHBOutput(N_LAS_Vector & solnVecPtr,
120  std::vector<double> & timePoints,
121  std::vector<double> & freqPoints,
122  Teuchos::RCP<N_LAS_BlockVector> & timeDomainSolnVec,
123  Teuchos::RCP<N_LAS_BlockVector> & freqDomainSolnVecReal,
124  Teuchos::RCP<N_LAS_BlockVector> & freqDomainSolnVecImaginary,
125  Teuchos::RCP<N_LAS_BlockVector> & timeDomainStoreVec,
126  Teuchos::RCP<N_LAS_BlockVector> & freqDomainStoreVecReal,
127  Teuchos::RCP<N_LAS_BlockVector> & freqDomainStoreVecImaginary) const;
128 
130 
131 private:
132 
133  // Add in solver info and timing info from current analysisObject_
134  void accumulateStatistics_();
135 
136  bool runTol_();
137  bool runStartupPeriods_();
138  bool runTransientIC_();
139  bool interpolateIC_();
140 
141  // Flag to indicate of the simulation is paused
142  bool isPaused;
143 
144  // Timing/loop count info
145  double startDCOPtime, endTRANtime; // startTRANtime
146 
147  Teuchos::RCP<N_DEV_DeviceInterface> devInterfacePtr_;
148  Teuchos::RCP<N_TOP_Topology> topoMgrPtr_;
149  Teuchos::RCP<N_LOA_NonlinearEquationLoader> nonlinearEquationLoaderPtr_;
150  Teuchos::RCP<N_LAS_Builder> appBuilderPtr_;
151  Teuchos::RCP<N_PDS_Manager> pdsMgrPtr_;
152  Teuchos::RCP<AnalysisBase> analysisObject_;
153 
154  // Current analysis state flags.
156 
157  //Testing Flag
158  bool test_;
159 
160  // Problem Size
161  int size_;
162 
163  // Periodicity Information
164  double period_;
165 
166  // Number of fast time periods to integrate over and IGNORE before
167  // getting initial conditions for HB. Default is zero.
170 
173 
174  // Stored copy of transient TIAParams
176 
177  // Transient assisted HB.
178  int taHB_;
179 
181  // HB loader, builder, and system
182  Teuchos::RCP<N_LOA_HBLoader> hbLoaderPtr_;
183  Teuchos::RCP<N_LAS_HBBuilder> hbBuilderPtr_;
184  Teuchos::RCP<N_LAS_System> lasHBSysPtr_;
185 
186  // Time discretization
189  std::vector<double> fastTimes_;
190  std::vector<double> timeSteps_;
191  std::vector<double> freqPoints_;
192  Teuchos::RCP<N_MPDE_Discretization> mpdeDiscPtr_;
193  N_MPDE_State mpdeState_;
194 
195  // Linear solver and nonlinear solver options
196  N_UTL_OptionBlock saved_lsHBOB_;
197  N_UTL_OptionBlock saved_lsOB_;
198  N_UTL_OptionBlock saved_nlHBOB_;
199 
200  // An analysis-dependent preconditioner factory.
201  Teuchos::RCP<N_LAS_PrecondFactory> precFactory_;
202 
203  // Local storage vectors
204  Teuchos::RCP<N_LAS_Vector> dcOpSolVecPtr_;
205  Teuchos::RCP<N_LAS_Vector> dcOpStateVecPtr_;
206  Teuchos::RCP<N_LAS_Vector> dcOpQVecPtr_;
207  Teuchos::RCP<N_LAS_Vector> dcOpStoreVecPtr_;
208 
209  std::vector<double> goodTimePoints_;
210  std::vector<Teuchos::RCP<N_LAS_Vector> > goodSolutionVec_;
211  std::vector<Teuchos::RCP<N_LAS_Vector> > goodStateVec_;
212  std::vector<Teuchos::RCP<N_LAS_Vector> > goodQVec_;
213  std::vector<Teuchos::RCP<N_LAS_Vector> > goodStoreVec_;
214 
215  // HB initial condition
216  Teuchos::RCP<N_LAS_BlockVector> HBICVectorPtr_;
217  Teuchos::RCP<N_LAS_BlockVector> HBICVectorFreqPtr_;
218 
219  // HB initial state condition
220  Teuchos::RCP<N_LAS_BlockVector> HBICStateVectorPtr_;
221 // Teuchos::RCP<N_LAS_BlockVector> HBICStateVectorFreqPtr_;
222 
223  // HB initial Q condition
224  Teuchos::RCP<N_LAS_BlockVector> HBICQVectorPtr_;
225  // Teuchos::RCP<N_LAS_BlockVector> HBICQVectorFreqPtr_;
226 
227  // HB initial store condition
228  Teuchos::RCP<N_LAS_BlockVector> HBICStoreVectorPtr_;
229 
230  // HB statistics
243 
245 };
246 
247 } // namespace Analysis
248 } // namespace Xyce
249 
251 
252 #endif // Xyce_N_ANP_HB_h
253