Xyce  6.1
N_LOA_NonlinearEquationLoader.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_LOA_NonlinearEquationLoader.h,v $
27 //
28 // Purpose : This file contains the interface class that sits between
29 // the nonlinear solver and (ultimately) the time integrator.
30 // For transient calculations only the time integrator knows
31 // what to sum into the Jacobian and Residual vector.
32 //
33 // Special Notes :
34 //
35 // Creator : Todd Coffey, SNL
36 //
37 // Creation Date : 07/29/08
38 //
39 // Revision Information:
40 // ---------------------
41 //
42 // Revision Number: $Revision: 1.51.2.1 $
43 //
44 // Revision Date : $Date: 2015/04/02 18:20:15 $
45 //
46 // Current Owner : $Author: tvrusso $
47 //-----------------------------------------------------------------------------
48 
49 #ifndef Xyce_LOA_NonlinearEquationLoader_H
50 #define Xyce_LOA_NonlinearEquationLoader_H
51 
52 #include <N_DEV_fwd.h>
53 #include <N_LAS_fwd.h>
54 #include <N_LOA_fwd.h>
55 #include <N_PDS_fwd.h>
56 #include <N_TIA_fwd.h>
57 #include <N_UTL_fwd.h>
58 
59 #include <N_UTL_Stats.h>
60 
61 namespace Xyce {
62 namespace Loader {
63 
64 //-----------------------------------------------------------------------------
65 // Class : NonlinearEquationLoader
66 //
67 // Purpose : This class contains the interface class that sits between
68 // the nonlinear solver and (ultimately) the time integrator.
69 // For transient calculations only the time integrator knows
70 // what to sum into the Jacobian and Residual vector.
71 //
72 // Special Notes :
73 // Creator : Todd Coffey, SNL
74 // Creation Date : 07/29/08
75 //-----------------------------------------------------------------------------
77 {
78 public:
79 
80  // Default constructor
83  Loader & loader,
84  Device::DeviceMgr & device_manager,
86  bool daeStateDerivFlag);
87 
88  // Destructor
89  virtual ~NonlinearEquationLoader();
90 
91  // // Method which is called to load the nonlinear Jacobian matrix.
92  bool loadJacobian();
93 
94  // // Method which is called to apply the nonlinear Jacobian matrix.
95  bool applyJacobian (const Linear::Vector& input, Linear::Vector& result);
96 
97  // bool initializeProblem( Linear::Vector * nextSolVectorPtr,
98  // Linear::Vector * currSolVectorPtr,
99  // Linear::Vector * lastSolVectorPtr,
100  // Linear::Vector * nextStaVectorPtr,
101  // Linear::Vector * currStaVectorPtr,
102  // Linear::Vector * lastStaVectorPtr,
103  // Linear::Vector * StateDerivVectorPtr,
104  // Linear::Vector * nextStoVectorPtr,
105  // Linear::Vector * currStoVectorPtr,
106  // Linear::Vector * lastStoVectorPtr,
107  // Linear::Vector * QVectorPtr,
108  // Linear::Vector * FVectorPtr,
109  // Linear::Vector * BVectorPtr,
110  // Linear::Vector * dFdxdVpVectorPtr,
111  // Linear::Vector * dQdxdVpVectorPtr) const;
112 
113  // // Method which is called to load the nonlinear residual (RHS) vector.
114  bool loadRHS();
115 
116  bool loadSensitivityResiduals ();
118 
119  // // Function for setting the initial guess.
120  // bool setInitialGuess(Linear::Vector * solVectorPtr);
121 
122  // // Method which is called to update the sources.
123  // bool updateSources();
124  bool getLinearSystemFlag() const;
125 
126  // // Get the voltage limiter flag:
127  // bool getLimiterFlag ();
128 
129  // // Gets the double DC Operating Point flag - used for PDE devices.
130  // bool getDoubleDCOPFlag() const;
131  // bool output() const;
132  // bool finishOutput() const;
133 
134  // // two-level newton functions:
135  int enablePDEContinuation();
136  bool disablePDEContinuation ();
137 
138  void getNumInterfaceNodes (std::vector<int> & numINodes);
139  bool loadCouplingRHS (int iSubProblem, int iCouple, Linear::Vector * dfdvPtr);
140  bool calcCouplingTerms (int iSubProblem, int iCouple, const Linear::Vector * dxdvPtr);
141 
142  // // Gets the time integration required breakpoint times (in a vector).
143  // bool getBreakPoints(std::vector < Util::BreakPoint > & breakPointTimes) const;
144 
145  // // Accessor which returns the maximum time step size (in seconds).
146  // double getMaxTimeStepSize();
147 
148  // // Accessors for timing information
149 
150  // // Gets the nonlinear residual load time.
151  double getResidualTime() { return residualTime_; }
152 
153  // // Gets the nonlinear Jacobian load time.
154  double getJacobianTime() { return jacobianTime_; }
155 
156  // // Get block size from device options for block gainscale homotopy
157  int getHomotopyBlockSize() const;
158 
159  // // Get convergence info from devices
160  bool allDevicesConverged(Parallel::Machine comm);
161 
162  // // Get convergence info from inner-solves
163  bool innerDevicesConverged(Parallel::Machine comm);
164 
165  // // Function for determining if an analytic sensitivity (df/dp, dq/dp, db/dp) is available.
166  bool analyticSensitivitiesAvailable (std::string & name);
167 
169  std::string & name,
170  std::vector<double> & dfdpVec,
171  std::vector<double> & dqdpVec,
172  std::vector<double> & dbdpVec,
173  std::vector<int> & FindicesVec,
174  std::vector<int> & QindicesVec,
175  std::vector<int> & BindicesVec) const;
176 
177  bool setParam(std::string & name, double val, bool overrideOriginal=false);
178 
179  // double getParamAndReduce(const std::string & name) const;
180 
181  bool getParamAndReduce(const std::string & name, double & val) const;
182 
183  //const Loader::Loader &getLoader() const {
184  const Loader &getLoader() const {
185  return loader_;
186  }
187 
188  // Functions needed by the NEW (power node) 2-level algorithm:
189  void homotopyStepSuccess(const std::vector<std::string> & paramNames, const std::vector<double> & paramVals);
190  void homotopyStepFailure();
191 
192 private:
193  Util::Timer * residualTimerPtr_;
194  Util::Timer * jacobianTimerPtr_;
201  Device::DeviceMgr & deviceManager_; ///< Device manager
202 };
203 
204 } // namespace Loader
205 } // namespace Xyce
206 
207 #endif
208 
bool loadCouplingRHS(int iSubProblem, int iCouple, Linear::Vector *dfdvPtr)
bool getParamAndReduce(const std::string &name, double &val) const
Pure virtual class to augment a linear system.
TimeIntg::WorkingIntegrationMethod & wim_
bool applyJacobian(const Linear::Vector &input, Linear::Vector &result)
bool setParam(std::string &name, double val, bool overrideOriginal=false)
bool calcCouplingTerms(int iSubProblem, int iCouple, const Linear::Vector *dxdvPtr)
NonlinearEquationLoader(TimeIntg::DataStore &ds, Loader &loader, Device::DeviceMgr &device_manager, TimeIntg::WorkingIntegrationMethod &wim, bool daeStateDerivFlag)
void getAnalyticSensitivities(std::string &name, std::vector< double > &dfdpVec, std::vector< double > &dqdpVec, std::vector< double > &dbdpVec, std::vector< int > &FindicesVec, std::vector< int > &QindicesVec, std::vector< int > &BindicesVec) const
void homotopyStepSuccess(const std::vector< std::string > &paramNames, const std::vector< double > &paramVals)
void getNumInterfaceNodes(std::vector< int > &numINodes)
Device::DeviceMgr & deviceManager_
Device manager.