Xyce  6.1
N_ANP_MOR.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_ANP_MOR.h,v $
27 //
28 // Purpose : MOR 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 : Ting Mei
34 //
35 // Creation Date : 01/11
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.47 $
41 // Revision Date : $Date: 2015/10/27 19:24:39 $
42 // Current Owner : $Author: tvrusso $
43 //-----------------------------------------------------------------------------
44 
45 #ifndef Xyce_N_ANP_MOR_h
46 #define Xyce_N_ANP_MOR_h
47 
48 #include <Teuchos_RCP.hpp>
49 using Teuchos::RCP;
50 using Teuchos::rcp;
51 #include <Teuchos_SerialDenseMatrix.hpp>
52 
53 // ---------- Xyce Includes ----------
54 #include <N_ANP_fwd.h>
55 #include <N_UTL_fwd.h>
56 #include <N_LAS_fwd.h>
57 #include <N_TOP_fwd.h>
58 
59 #include <N_ANP_AnalysisBase.h>
60 #include <N_ANP_RegisterAnalysis.h>
61 #include <N_IO_OutputMOR.h>
62 #include <N_UTL_FixedQueue.h>
63 #include <N_UTL_OptionBlock.h>
64 
65 // ---------- Forward Declarations ----------
66 class Amesos_BaseSolver;
67 class Epetra_LinearProblem;
68 class Epetra_Map;
69 
70 namespace Xyce {
71 namespace Analysis {
72 
73 //-------------------------------------------------------------------------
74 // Class : MOR
75 // Purpose : MOR analysis class
76 // Special Notes :
77 // Creator : Ting Mei
78 // Creation Date : 05/24/11
79 //-------------------------------------------------------------------------
80 class MOR: public AnalysisBase
81 {
82 public:
83  MOR(
84  AnalysisManager & analysis_manager,
85  Nonlinear::Manager & nonlinear_manager,
86  Loader::Loader & loader,
87  Topo::Topology & topology,
88  IO::InitialConditionsManager & initial_conditions_manager);
89 
90  ~MOR();
91 
93  {
94  return tiaParams_;
95  }
96 
98  {
99  return tiaParams_;
100  }
101 
102  // Method to set MOR options
103  bool setMOROptions(const Util::OptionBlock & option_block);
104 
105  bool setAnalysisParams(const Util::OptionBlock & paramsBlock);
106 
107  bool reduceSystem();
110 
111  bool processSuccessfulStep(bool origSys);
112 
113 protected:
114  bool doRun();
115  bool doInit();
116  virtual bool doProcessSuccessfulStep() { return true; }
117  virtual bool doLoopProcess() { return true; }
118  virtual bool doProcessFailedStep();
119  virtual bool doFinish();
120  virtual bool doHandlePredictor();
121 
122 public:
123  bool getDCOPFlag() const
124  {
125  return true;
126  }
127 
128 private:
129  Parallel::Machine comm_;
130 
134  Topo::Topology & topology_;
135  IO::InitialConditionsManager & initialConditionsManager_;
137  IO::OutputMOR outputMOR_;
138 
140 
141  int ROMsize_;
142  std::string morMethod_;
146  std::string morCompType_;
151  double morMaxFreq_;
152 
154  double morExpPoint_;
160  std::vector<std::string> subcircuitNames_;
161 
162  bool isPaused;
165 
166  std::list < int > morEvalFailures_;
167 
169  std::vector<std::string> portList_;
170 
171  double stepMult_;
172  double fStep_;
173  double currentFreq_;
174  double s0_;
175 
176  int setupSweepParam_();
177 
178  bool updateCurrentFreq_(int stepNumber);
179 
181  bool createRedLinearSystem_();
182 
185 
186  bool solveOrigLinearSystem_();
187  bool solveRedLinearSystem_();
188 
189  bool sparsifyRedSystem_();
190 
191  // Original system
192  RCP<Linear::Matrix> CPtr_;
193  RCP<Linear::Matrix> GPtr_;
194  RCP<Linear::Matrix> sCpG_MatrixPtr_;
195  RCP<Linear::MultiVector> RPtr_, BPtr_, VPtr_;
197 
198  // Original system, real-equivalent form
199  RCP<Linear::BlockMatrix> sCpG_REFMatrixPtr_;
200  RCP<Linear::BlockVector> REFBPtr_;
201  RCP<Linear::BlockVector> REFXPtr_; // Store solution from Amesos here.
202 
203  // Reduced system (dense)
204  Teuchos::SerialDenseMatrix<int, double> redC_;
205  Teuchos::SerialDenseMatrix<int, double> redG_;
206  Teuchos::SerialDenseMatrix<int, double> redB_;
207  Teuchos::SerialDenseMatrix<int, double> redL_; // redL_ != redB_
208 
209  // Reduced system (sparse)
210  RCP<Linear::Matrix> redCPtr_, redGPtr_;
211  RCP<Epetra_Map> redMapPtr_;
212 
213  // Reduced system, real-equivalent form (dense)
214  Teuchos::SerialDenseMatrix<int, double> sCpG_redMatrix_, sCpG_tmpMatrix_;
215  Teuchos::SerialDenseMatrix<int, double> ref_redB_;
216 
217  // Reduced system, real-equivalent form (sparse)
218  RCP<Linear::BlockMatrix> sCpG_ref_redMatrixPtr_;
219  RCP<Linear::BlockVector> ref_redBPtr_;
220  RCP<Linear::BlockVector> ref_redXPtr_; // Store solution from Amesos here.
221 
222  // Transfer functions
223  Teuchos::SerialDenseMatrix<int, std::complex<double> > origH_;
224  Teuchos::SerialDenseMatrix<int, std::complex<double> > redH_;
225 
226  // Original system solver objects
227  RCP<Amesos_BaseSolver> blockSolver_, origSolver_;
228  RCP<Epetra_LinearProblem> blockProblem_, origProblem_;
229 
230  // Reduced system solver objects (sparse)
231  RCP<Amesos_BaseSolver> blockRedSolver_;
232  RCP<Epetra_LinearProblem> blockRedProblem_;
233 };
234 
235 bool registerMORFactory(FactoryBlock &factory_block);
236 
237 } // namespace Analysis
238 } // namespace Xyce
239 
240 #endif // Xyce_N_ANP_MOR_h
RCP< Linear::MultiVector > RPtr_
Definition: N_ANP_MOR.h:195
bool getDCOPFlag() const
Definition: N_ANP_MOR.h:123
Topo::Topology & topology_
Definition: N_ANP_MOR.h:134
double morScaleFactor_
Definition: N_ANP_MOR.h:155
Teuchos::SerialDenseMatrix< int, double > redB_
Definition: N_ANP_MOR.h:206
RCP< Epetra_LinearProblem > origProblem_
Definition: N_ANP_MOR.h:228
RCP< Epetra_LinearProblem > blockRedProblem_
Definition: N_ANP_MOR.h:232
RCP< Linear::BlockVector > ref_redBPtr_
Definition: N_ANP_MOR.h:219
virtual bool doProcessSuccessfulStep()
Definition: N_ANP_MOR.h:116
bool evalOrigTransferFunction()
Definition: N_ANP_MOR.C:1058
Pure virtual class to augment a linear system.
RCP< Linear::MultiVector > BPtr_
Definition: N_ANP_MOR.h:195
RCP< Linear::BlockMatrix > sCpG_REFMatrixPtr_
Definition: N_ANP_MOR.h:199
RCP< Linear::MultiVector > VPtr_
Definition: N_ANP_MOR.h:195
MOR(AnalysisManager &analysis_manager, Nonlinear::Manager &nonlinear_manager, Loader::Loader &loader, Topo::Topology &topology, IO::InitialConditionsManager &initial_conditions_manager)
Definition: N_ANP_MOR.C:134
unsigned int stepNumber
Time-integration step number counter.
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_MOR.h:133
const TimeIntg::TIAParams & getTIAParams() const
Definition: N_ANP_MOR.h:92
bool registerMORFactory(FactoryBlock &factory_block)
Definition: N_ANP_MOR.C:2292
std::vector< std::string > portList_
Definition: N_ANP_MOR.h:169
bool createOrigLinearSystem_()
Definition: N_ANP_MOR.C:1153
Teuchos::SerialDenseMatrix< int, std::complex< double > > origH_
Definition: N_ANP_MOR.h:223
RCP< Linear::BlockMatrix > sCpG_ref_redMatrixPtr_
Definition: N_ANP_MOR.h:218
RCP< Epetra_LinearProblem > blockProblem_
Definition: N_ANP_MOR.h:228
RCP< Amesos_BaseSolver > blockSolver_
Definition: N_ANP_MOR.h:227
Teuchos::SerialDenseMatrix< int, double > sCpG_redMatrix_
Definition: N_ANP_MOR.h:214
bool updateOrigLinearSystemFreq_()
Definition: N_ANP_MOR.C:1324
bool setAnalysisParams(const Util::OptionBlock &paramsBlock)
Definition: N_ANP_MOR.C:195
std::string morMethod_
Definition: N_ANP_MOR.h:142
RCP< Linear::BlockVector > REFXPtr_
Definition: N_ANP_MOR.h:201
AnalysisManager & analysisManager_
Definition: N_ANP_MOR.h:131
Teuchos::SerialDenseMatrix< int, double > sCpG_tmpMatrix_
Definition: N_ANP_MOR.h:214
RCP< Amesos_BaseSolver > origSolver_
Definition: N_ANP_MOR.h:227
Teuchos::SerialDenseMatrix< int, double > redG_
Definition: N_ANP_MOR.h:205
std::string morCompType_
Definition: N_ANP_MOR.h:146
std::vector< int > bMatEntriesVec_
Definition: N_ANP_MOR.h:196
RCP< Amesos_BaseSolver > blockRedSolver_
Definition: N_ANP_MOR.h:231
Teuchos::SerialDenseMatrix< int, std::complex< double > > redH_
Definition: N_ANP_MOR.h:224
TimeIntg::TIAParams & getTIAParams()
Definition: N_ANP_MOR.h:97
Teuchos::SerialDenseMatrix< int, double > redL_
Definition: N_ANP_MOR.h:207
The FactoryBlock contains parameters needed by the analysis creation functions.
Parallel::Machine comm_
Definition: N_ANP_MOR.h:129
bool sparsifyRedSystem_()
Definition: N_ANP_MOR.C:1545
bool solveRedLinearSystem_()
Definition: N_ANP_MOR.C:1440
IO::OutputMOR outputMOR_
Definition: N_ANP_MOR.h:137
RCP< Linear::Matrix > redCPtr_
Definition: N_ANP_MOR.h:210
Teuchos::SerialDenseMatrix< int, double > redC_
Definition: N_ANP_MOR.h:204
Loader::Loader & loader_
Definition: N_ANP_MOR.h:132
RCP< Epetra_Map > redMapPtr_
Definition: N_ANP_MOR.h:211
virtual bool doLoopProcess()
Definition: N_ANP_MOR.h:117
RCP< Linear::BlockVector > REFBPtr_
Definition: N_ANP_MOR.h:200
RCP< Linear::BlockVector > ref_redXPtr_
Definition: N_ANP_MOR.h:220
bool createRedLinearSystem_()
Definition: N_ANP_MOR.C:1225
std::vector< int > bMatPosEntriesVec_
Definition: N_ANP_MOR.h:196
virtual bool doProcessFailedStep()
Definition: N_ANP_MOR.C:1897
bool setMOROptions(const Util::OptionBlock &option_block)
Definition: N_ANP_MOR.C:225
RCP< Linear::Matrix > redGPtr_
Definition: N_ANP_MOR.h:210
std::list< int > morEvalFailures_
Definition: N_ANP_MOR.h:166
RCP< Linear::Matrix > GPtr_
Definition: N_ANP_MOR.h:193
double morScaleFactor1_
Definition: N_ANP_MOR.h:157
std::vector< std::string > subcircuitNames_
Definition: N_ANP_MOR.h:160
bool evalRedTransferFunction()
Definition: N_ANP_MOR.C:1106
RCP< Linear::Matrix > sCpG_MatrixPtr_
Definition: N_ANP_MOR.h:194
bool updateCurrentFreq_(int stepNumber)
Definition: N_ANP_MOR.C:1967
Teuchos::SerialDenseMatrix< int, double > ref_redB_
Definition: N_ANP_MOR.h:215
RCP< Linear::Matrix > CPtr_
Definition: N_ANP_MOR.h:192
TimeIntg::TIAParams tiaParams_
Definition: N_ANP_MOR.h:139
IO::InitialConditionsManager & initialConditionsManager_
Definition: N_ANP_MOR.h:135
OutputMgrAdapter & outputManagerAdapter_
Definition: N_ANP_MOR.h:136
bool solveOrigLinearSystem_()
Definition: N_ANP_MOR.C:1391
virtual bool doHandlePredictor()
Definition: N_ANP_MOR.C:1941
bool updateRedLinearSystemFreq_()
Definition: N_ANP_MOR.C:1348
virtual bool doFinish()
Definition: N_ANP_MOR.C:1917