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.138.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:17 $
42 //
43 // Current Owner : $Author: tvrusso $
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 std::map<std::string, Util::OptionBlock> OptionBlockMap;
83 
84  Manager(const IO::CmdParse & command_line);
85  ~Manager();
86 
87  bool setOptions(const Util::OptionBlock& option_block );
88  bool setTranOptions(const Util::OptionBlock& option_block );
89  bool setHBOptions(const Util::OptionBlock& option_block );
90  bool setTwoLevelOptions (const Util::OptionBlock & option_block);
91  bool setTwoLevelTranOptions (const Util::OptionBlock & option_block);
92  bool setSensOptions (const Util::OptionBlock & option_block);
93  bool setSensitivityOptions (const Util::OptionBlock & option_block);
94  bool setLinSolOptions(const Util::OptionBlock& option_block );
95  bool setLocaOptions(const Util::OptionBlock& option_block );
96  bool setTwoLevelLocaOptions(const Util::OptionBlock& option_block );
97  bool setDCOPRestartOptions (const Util::OptionBlock& option_block );
98  bool setICOptions (const Util::OptionBlock& option_block );
99  bool setNodeSetOptions (const Util::OptionBlock& option_block );
100  bool setReturnCodeOption(const Util::Param &param);
101 
102  Util::OptionBlock& getHBOptions();
103 
104  bool registerPrecondFactory(const Linear::PrecondFactory *preconditioner_factory)
105  {
106  lasPrecPtr_ = preconditioner_factory;
107  return lasPrecPtr_;
108  }
109 
110  void setReturnCodes (const ReturnCodes & retCodeTmp);
111 
113  return *nonlinearSolver_;
114  }
115 
117  return *conductanceExtractorPtr_;
118  }
119 
120  const ReturnCodes &getReturnCodes() const;
121 
122  bool initializeAll(
123  Analysis::AnalysisManager & analysis_manager,
124  Loader::NonlinearEquationLoader & nonlinear_equation_loader,
125  Linear::System & linear_system,
126  TimeIntg::DataStore & data_store,
127  Parallel::Manager & parallel_manager,
128  IO::InitialConditionsManager & initial_conditions_manager,
129  IO::OutputMgr & output_manager,
130  Topo::Topology & topology);
131 
132  int solve();
133 
134  void setAnalysisMode(AnalysisMode mode);
135 
136  // This is a more extensive version of setAnalysisMode.
137  // It makes it like we are starting over.
138  void resetAll(AnalysisMode mode);
139 
140  NonLinInfo getNonLinInfo() const;
141 
142  bool enableSensitivity(TimeIntg::DataStore & data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology);
143  bool icSensitivity(
144  std::vector<double> & objectiveVec,
145  std::vector<double> & dOdpVec, std::vector<double> & dOdpAdjVec,
146  std::vector<double> & scaled_dOdpVec, std::vector<double> & scaled_dOdpAdjVec);
147  bool calcSensitivity(
148  std::vector<double> & objectiveVec,
149  std::vector<double> & dOdpVec, std::vector<double> & dOdpAdjVec,
150  std::vector<double> & scaled_dOdpVec, std::vector<double> & scaled_dOdpAdjVec);
151 
152  void setMatrixFreeFlag(bool matrixFreeFlag)
153  {
154  matrixFreeFlag_ = matrixFreeFlag;
155  }
156 
157  void allocateTranSolver(
158  Analysis::AnalysisManager & analysis_manager,
159  Loader::NonlinearEquationLoader & nonlinear_equation_loader,
160  Linear::System & linear_system,
161  TimeIntg::DataStore & data_store,
162  Parallel::Manager & parallel_manager,
163  IO::OutputMgr & output_manager,
164  Topo::Topology & topology);
165 
166 private:
167  bool allocateSolver(
168  Analysis::AnalysisManager & analysis_manager,
169  Loader::NonlinearEquationLoader & nonlinear_equation_loader,
170  Linear::System & linear_system,
171  TimeIntg::DataStore & data_store,
172  Parallel::Manager & parallel_manager,
173  IO::InitialConditionsManager & initial_conditions_manager,
174  IO::OutputMgr & output_manager);
175 
176  void usingNox();
177  bool setupSensitivity(TimeIntg::DataStore & data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology);
178 
179 private:
180  const IO::CmdParse & commandLine_;
184  const Linear::PrecondFactory * lasPrecPtr_;
185 
187  bool twoLevelNewtonFlag_; /// Flag to determine if we are doing 2-level newton or not.
188  bool noxFlag_; /// Flag to determine if NOX is the solver in use.
189  bool noxFlagInner_; /// For 2-level newton, option for inner loop to use nox.
190  bool noxFlagTransient_; /// Use nox in transient phase of calculation.
191  OptionBlockMap optionBlockMap_; /// netlist option blocks until we know which
193  ReturnCodes retCodes_; /// Return Codes.
194  Util::Expression * exprPtr_;
195 };
196 
197 bool registerPkgOptionsMgr(Manager &manager, const std::string netlist_filename, IO::PkgOptionsMgr &options_manager);
198 
199 } // namespace Nonlinear
200 } // namespace Xyce
201 
202 #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 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)
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 registerPkgOptionsMgr(Manager &manager, const std::string netlist_filename, IO::PkgOptionsMgr &options_manager)
std::map< std::string, Util::OptionBlock > OptionBlockMap
Definition: N_NLS_Manager.h:82
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_
bool setTwoLevelOptions(const Util::OptionBlock &option_block)
const Linear::PrecondFactory * lasPrecPtr_
Util::Expression * exprPtr_
Return Codes.
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)