Xyce  6.1
N_NLS_NOX_XyceTests.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_NOX_XyceTests.h,v $
27 //
28 // Purpose : Particular Status Test Based on the Weighed Norm of the
29 // Update
30 //
31 // Special Notes :
32 //
33 // Creator : Tammy Kolda, NLS, 8950
34 //
35 // Creation Date : 01/31/02
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.35 $
41 //
42 // Revision Date : $Date: 2015/08/03 21:12:39 $
43 //
44 // Current Owner : $Author: erkeite $
45 //-------------------------------------------------------------------------
46 #ifndef Xyce_N_NLS_NOX_XyceTests_h
47 #define Xyce_N_NLS_NOX_XyceTests_h
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 #include <N_LAS_fwd.h>
53 #include <N_LOA_fwd.h>
54 #include <N_PDS_fwd.h>
55 #include <N_NLS_ReturnCodes.h>
56 #include <N_UTL_FeatureTest.h>
57 
58 // ---------- NOX Includes ----------
59 
60 #include "NOX_StatusTest_Generic.H" // base class
61 #include "NOX_StatusTest_FiniteValue.H"
62 
63 // ---------- Namespace Declarations ----------
64 
65 // N_NLS namespace is for the Xyce Nonlinear Solver Package
66 namespace Xyce {
67 namespace Nonlinear {
68 namespace N_NLS_NOX {
69 
70 //-----------------------------------------------------------------------------
71 // Class : N_NLS_NOX::XyceTests
72 //
73 // Purpose :
74 //
75 // NOX Vector Interface for Xyce vectors.
76 //
77 // Creator : Tammy Kolda, SNL, 8950
78 //
79 // Creation Date : 2/1/02
80 //-----------------------------------------------------------------------------
81 
82 class XyceTests : public NOX::StatusTest::Generic {
83 
84 public:
85 
86  //---------------------------------------------------------------------------
87  // Function : XyceTests (constructor)
88  //
89  // Purpose : Constructs a NOX-compatiable status test based
90  // the weighted norm of the update.
91  //
92  //---------------------------------------------------------------------------
93  XyceTests(
94  Parallel::Machine comm,
95  bool isTransient,
96  double normF,
97  double machPrec,
98  Xyce::Linear::Vector** currSolVectorPtrPtr,
99  double epsilon_a,
100  double epsilon_r,
101  double tol,
102  int maxIters,
103  double convRate,
104  double relConvRate,
105  double maxConvRate,
106  double stagnationTol,
107  int maxBadSteps,
108  int checkDeviceConvergence,
109  double smallUpdateTol,
111  bool maskingFlag,
112  Xyce::Linear::Vector * maskVectorPtr);
113 
114  //---------------------------------------------------------------------------
115  // Function : Destructor
116  //---------------------------------------------------------------------------
117  ~XyceTests();
118 
119  //---------------------------------------------------------------------------
120  // Purpose : Test stopping criterion given the current
121  // nonlinear problem
122  //---------------------------------------------------------------------------
123  NOX::StatusTest::StatusType checkStatus(
124  const NOX::Solver::Generic& problem,
125  NOX::StatusTest::CheckType checkType);
126 
127  //---------------------------------------------------------------------------
128  // Purpose : Test stopping criterion given the current
129  // nonlinear problem
130  //---------------------------------------------------------------------------
131  NOX::StatusTest::StatusType getStatus() const { return status_; };
132 
133  //---------------------------------------------------------------------------
134  // Purpose : Get the return code to send to the time stepper.
135  //
136  //---------------------------------------------------------------------------
137  int getXyceReturnCode() const;
138 
139  //---------------------------------------------------------------------------
140  // Purpose : Output formatted description of stopping test to
141  // output stream.
142  //---------------------------------------------------------------------------
143  std::ostream& print(std::ostream& stream, int indent = 0) const;
144 
145  //---------------------------------------------------------------------------
146  // Purpose : Set a specific set of return codes to be used.
147  //---------------------------------------------------------------------------
148  void setReturnCodes (const Xyce::Nonlinear::ReturnCodes & retCodesTmp);
149 
150  double getMaxNormF() const;
151 
152  int getMaxNormFindex () const;
153 
154 protected:
155  Parallel::Machine comm_;
156  NOX::StatusTest::StatusType status_;
159  int niters_;
160 
162 
163  //Test #0
164  //****************************************
165  NOX::StatusTest::FiniteValue finiteTest_;
166 
167  //Test #1
168  //****************************************
170  double maxNormF_;
173 
174  // Test #2
175  //****************************************
176  Xyce::Linear::Vector** oldTimeStepVectorPtrPtr_;
177  Xyce::Linear::Vector* weightsVectorPtr_;
178  Xyce::Linear::Vector* updateVectorPtr_;
179  Xyce::Linear::Vector* tmpVectorPtr_;
180  const double epsilon_a_;
181  const double epsilon_r_;
182  const double tol_;
184 
185  // Test #3
186  //****************************************
187  // Maximum number of nonlinear iterations allowed
189 
190  // ||F(x_current)|| / ||F(x_previous)||
191  const double requestedConvRate_;
193 
194  // ||F(x)|| / ||F(x_init)||
197 
198  // Initial norm of the RHS used to calculate ratio
200 
201  // test #4
203 
204  // Test #6
205  const double maxConvRate_;
206 
207  // Test #7
210  const int maxBadSteps_;
211  double minConvRate_;
212  const double stagnationTol_;
213 
214  // Xyce return Code
216 
217  // For Device Specific Convergence cirteria
220 
221 // Only used if NLS_MASKED_WRMS_NORMS
224  Xyce::Linear::Vector* weightMaskVectorPtr_;
225 
228 
229 }; // class SharedSystem
230 
231 inline void XyceTests::setReturnCodes
232  (const Xyce::Nonlinear::ReturnCodes & retCodesTmp)
233 {
234  retCodes_ = retCodesTmp;
235 }
236 
237 
238 }}} // namespace N_NLS_NOX
239 
240 #endif // Xyce_N_NLS_NOX_SharedSystem_h
241 
Pure virtual class to augment a linear system.
void setReturnCodes(const Xyce::Nonlinear::ReturnCodes &retCodesTmp)
Xyce::Loader::NonlinearEquationLoader * loaderPtr_
NOX::StatusTest::FiniteValue finiteTest_
Xyce::Linear::Vector ** oldTimeStepVectorPtrPtr_
Xyce::Nonlinear::ReturnCodes retCodes_
NOX::StatusTest::StatusType getStatus() const
XyceTests(Parallel::Machine comm, bool isTransient, double normF, double machPrec, Xyce::Linear::Vector **currSolVectorPtrPtr, double epsilon_a, double epsilon_r, double tol, int maxIters, double convRate, double relConvRate, double maxConvRate, double stagnationTol, int maxBadSteps, int checkDeviceConvergence, double smallUpdateTol, Xyce::Loader::NonlinearEquationLoader *loader, bool maskingFlag, Xyce::Linear::Vector *maskVectorPtr)
std::ostream & print(std::ostream &stream, int indent=0) const
NOX::StatusTest::StatusType checkStatus(const NOX::Solver::Generic &problem, NOX::StatusTest::CheckType checkType)