Xyce  6.1
N_NLS_Manager.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_NLS_Manager.h,v $
27 //
28 // Purpose : Defines Manager class.
29 //
30 // Special Notes :
31 //
32 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 04/28/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.144 $
40 //
41 // Revision Date : $Date: 2015/05/21 16:43:51 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_NLS_Manager_h
47 #define Xyce_N_NLS_Manager_h
48 
49 // ---------- Standard Includes ----------
50 #include <map>
51 #include <vector>
52 
53 #include <N_ANP_fwd.h>
54 #include <N_IO_fwd.h>
55 #include <N_LAS_fwd.h>
56 #include <N_LOA_fwd.h>
57 #include <N_NLS_fwd.h>
58 #include <N_PDS_fwd.h>
59 #include <N_TIA_fwd.h>
60 #include <N_TOP_fwd.h>
61 
62 #include <N_UTL_OptionBlock.h>
63 #include <N_UTL_Stats.h>
64 #include <N_NLS_ReturnCodes.h>
65 #include <N_NLS_NonLinearSolver.h>
66 
67 namespace Xyce {
68 namespace Nonlinear {
69 
70 //-----------------------------------------------------------------------------
71 // Class : Manager
72 // Purpose : Interface to the nonlinear solvers (NLS). All communication
73 // between Xyce and the nonlinear solver should be via this
74 // interface.
75 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
76 // Creation Date : 5/01/00
77 //-----------------------------------------------------------------------------
78 
79 class Manager
80 {
81 public:
82  typedef unordered_map<int, Util::OptionBlock> OptionBlockMap;
83 
84  Manager(const IO::CmdParse & command_line);
85  ~Manager();
86 
87 
88  bool setOptions(const Util::OptionBlock& option_block );
89  bool setTranOptions(const Util::OptionBlock& option_block );
90  bool setHBOptions(const Util::OptionBlock& option_block );
91  bool setNLPOptions(const Util::OptionBlock& option_block );
92  bool setTwoLevelOptions (const Util::OptionBlock & option_block);
93  bool setTwoLevelTranOptions (const Util::OptionBlock & option_block);
94  bool setSensOptions (const Util::OptionBlock & option_block);
95  bool setSensitivityOptions (const Util::OptionBlock & option_block);
96  bool setLinSolOptions(const Util::OptionBlock& option_block );
97  bool setLocaOptions(const Util::OptionBlock& option_block );
98  bool setTwoLevelLocaOptions(const Util::OptionBlock& option_block );
99  bool setDCOPRestartOptions (const Util::OptionBlock& option_block );
100  bool setICOptions (const Util::OptionBlock& option_block );
101  bool setNodeSetOptions (const Util::OptionBlock& option_block );
102  bool setReturnCodeOption(const Util::Param &param);
103 
104  Util::OptionBlock& getHBOptions();
105 
106  bool registerPrecondFactory(const Linear::PrecondFactory *preconditioner_factory)
107  {
108  lasPrecPtr_ = preconditioner_factory;
109  return lasPrecPtr_;
110  }
111 
112  void setReturnCodes (const ReturnCodes & retCodeTmp);
113 
115  return *nonlinearSolver_;
116  }
117 
119  return *conductanceExtractorPtr_;
120  }
121 
122  const ReturnCodes &getReturnCodes() const;
123 
124  bool initializeAll(
125  Analysis::AnalysisManager & analysis_manager,
126  Loader::NonlinearEquationLoader & nonlinear_equation_loader,
127  Linear::System & linear_system,
128  TimeIntg::DataStore & data_store,
129  Parallel::Manager & parallel_manager,
130  IO::InitialConditionsManager & initial_conditions_manager,
131  IO::OutputMgr & output_manager,
132  Topo::Topology & topology);
133 
134  int solve();
135 
136  void setAnalysisMode(AnalysisMode mode);
137 
138  // This is a more extensive version of setAnalysisMode.
139  // It makes it like we are starting over.
140  void resetAll(AnalysisMode mode);
141 
142  NonLinInfo getNonLinInfo() const;
143 
144  bool enableSensitivity(TimeIntg::DataStore & data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology);
145  bool icSensitivity(
146  std::vector<double> & objectiveVec,
147  std::vector<double> & dOdpVec, std::vector<double> & dOdpAdjVec,
148  std::vector<double> & scaled_dOdpVec, std::vector<double> & scaled_dOdpAdjVec);
149  bool calcSensitivity(
150  std::vector<double> & objectiveVec,
151  std::vector<double> & dOdpVec, std::vector<double> & dOdpAdjVec,
152  std::vector<double> & scaled_dOdpVec, std::vector<double> & scaled_dOdpAdjVec);
153 
154  void setMatrixFreeFlag(bool matrixFreeFlag)
155  {
156  matrixFreeFlag_ = matrixFreeFlag;
157  }
158 
159  void allocateTranSolver(
160  Analysis::AnalysisManager & analysis_manager,
161  Loader::NonlinearEquationLoader & nonlinear_equation_loader,
162  Linear::System & linear_system,
163  TimeIntg::DataStore & data_store,
164  Parallel::Manager & parallel_manager,
165  IO::OutputMgr & output_manager,
166  Topo::Topology & topology);
167 
168 private:
169  bool allocateSolver(
170  Analysis::AnalysisManager & analysis_manager,
171  Loader::NonlinearEquationLoader & nonlinear_equation_loader,
172  Linear::System & linear_system,
173  TimeIntg::DataStore & data_store,
174  Parallel::Manager & parallel_manager,
175  IO::InitialConditionsManager & initial_conditions_manager,
176  IO::OutputMgr & output_manager);
177 
178  void usingNox();
179  bool setupSensitivity(TimeIntg::DataStore & data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology);
180 
181 private:
182  const IO::CmdParse & commandLine_;
186  const Linear::PrecondFactory * lasPrecPtr_;
187 
189  bool twoLevelNewtonFlag_; /// Flag to determine if we are doing 2-level newton or not.
190  bool noxFlag_; /// Flag to determine if NOX is the solver in use.
191  bool noxFlagInner_; /// For 2-level newton, option for inner loop to use nox.
192  bool noxFlagTransient_; /// Use nox in transient phase of calculation.
193  OptionBlockMap optionBlockMap_; /// netlist option blocks until we know which
195  ReturnCodes retCodes_; /// Return Codes.
196  Util::Expression * exprPtr_;
197 };
198 
199 bool registerPkgOptionsMgr(Manager &manager, IO::PkgOptionsMgr &options_manager);
200 
201 } // namespace Nonlinear
202 } // namespace Xyce
203 
204 #endif // Xyce_N_NLS_Manager_h
bool setTranOptions(const Util::OptionBlock &option_block)
bool enableSensitivity(TimeIntg::DataStore &data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology)
bool noxFlagTransient_
For 2-level newton, option for inner loop to use nox.
NonLinInfo getNonLinInfo() const
bool icSensitivity(std::vector< double > &objectiveVec, std::vector< double > &dOdpVec, std::vector< double > &dOdpAdjVec, std::vector< double > &scaled_dOdpVec, std::vector< double > &scaled_dOdpAdjVec)
bool setSensOptions(const Util::OptionBlock &option_block)
bool setTwoLevelTranOptions(const Util::OptionBlock &option_block)
bool calcSensitivity(std::vector< double > &objectiveVec, std::vector< double > &dOdpVec, std::vector< double > &dOdpAdjVec, std::vector< double > &scaled_dOdpVec, std::vector< double > &scaled_dOdpAdjVec)
Pure virtual class to augment a linear system.
OptionBlockMap optionBlockMap_
Use nox in transient phase of calculation.
bool registerPkgOptionsMgr(Manager &manager, IO::PkgOptionsMgr &options_manager)
bool setTwoLevelLocaOptions(const Util::OptionBlock &option_block)
ConductanceExtractor & getConductanceExtractor()
bool setLocaOptions(const Util::OptionBlock &option_block)
void setAnalysisMode(AnalysisMode mode)
ConductanceExtractor * conductanceExtractorPtr_
bool allocateSolver(Analysis::AnalysisManager &analysis_manager, Loader::NonlinearEquationLoader &nonlinear_equation_loader, Linear::System &linear_system, TimeIntg::DataStore &data_store, Parallel::Manager &parallel_manager, IO::InitialConditionsManager &initial_conditions_manager, IO::OutputMgr &output_manager)
NonLinearSolver & getNonlinearSolver()
Manager(const IO::CmdParse &command_line)
Definition: N_NLS_Manager.C:98
bool setNodeSetOptions(const Util::OptionBlock &option_block)
bool setLinSolOptions(const Util::OptionBlock &option_block)
void resetAll(AnalysisMode mode)
bool setSensitivityOptions(const Util::OptionBlock &option_block)
const ReturnCodes & getReturnCodes() const
void setReturnCodes(const ReturnCodes &retCodeTmp)
bool noxFlagInner_
Flag to determine if NOX is the solver in use.
bool initializeAll(Analysis::AnalysisManager &analysis_manager, Loader::NonlinearEquationLoader &nonlinear_equation_loader, Linear::System &linear_system, TimeIntg::DataStore &data_store, Parallel::Manager &parallel_manager, IO::InitialConditionsManager &initial_conditions_manager, IO::OutputMgr &output_manager, Topo::Topology &topology)
bool noxFlag_
Flag to determine if we are doing 2-level newton or not.
Util::OptionBlock & getHBOptions()
const IO::CmdParse & commandLine_
bool setICOptions(const Util::OptionBlock &option_block)
bool setHBOptions(const Util::OptionBlock &option_block)
bool setOptions(const Util::OptionBlock &option_block)
bool setupSensitivity(TimeIntg::DataStore &data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology)
NonLinearSolver * nonlinearSolver_
unordered_map< int, Util::OptionBlock > OptionBlockMap
Definition: N_NLS_Manager.h:82
bool setTwoLevelOptions(const Util::OptionBlock &option_block)
const Linear::PrecondFactory * lasPrecPtr_
Util::Expression * exprPtr_
Return Codes.
bool setNLPOptions(const Util::OptionBlock &option_block)
void allocateTranSolver(Analysis::AnalysisManager &analysis_manager, Loader::NonlinearEquationLoader &nonlinear_equation_loader, Linear::System &linear_system, TimeIntg::DataStore &data_store, Parallel::Manager &parallel_manager, IO::OutputMgr &output_manager, Topo::Topology &topology)
Sensitivity * nlsSensitivityPtr_
bool initializeAllFlag_
netlist option blocks until we know which
void setMatrixFreeFlag(bool matrixFreeFlag)
bool setDCOPRestartOptions(const Util::OptionBlock &option_block)
bool setReturnCodeOption(const Util::Param &param)
bool registerPrecondFactory(const Linear::PrecondFactory *preconditioner_factory)