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.33.2.1 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:20:17 $
43 //
44 // Current Owner : $Author: tvrusso $
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(const NOX::Solver::Generic& problem, NOX::StatusTest::CheckType checkType);
124 
125  //---------------------------------------------------------------------------
126  // Purpose : Test stopping criterion given the current
127  // nonlinear problem
128  //---------------------------------------------------------------------------
129  NOX::StatusTest::StatusType getStatus() const { return status_; };
130 
131  //---------------------------------------------------------------------------
132  // Purpose : Get the return code to send to the time stepper.
133  //
134  //---------------------------------------------------------------------------
135  int getXyceReturnCode() const;
136 
137  //---------------------------------------------------------------------------
138  // Purpose : Output formatted description of stopping test to
139  // output stream.
140  //---------------------------------------------------------------------------
141  std::ostream& print(std::ostream& stream, int indent = 0) const;
142 
143  //---------------------------------------------------------------------------
144  // Purpose : Set a specific set of return codes to be used.
145  //---------------------------------------------------------------------------
146  void setReturnCodes (const Xyce::Nonlinear::ReturnCodes & retCodesTmp);
147 
148  double getMaxNormF() const;
149 
150  int getMaxNormFindex () const;
151 
152 protected:
153  Parallel::Machine comm_;
154  NOX::StatusTest::StatusType status_;
157  int niters_;
158 
160 
161  //Test #0
162  //****************************************
163  NOX::StatusTest::FiniteValue finiteTest_;
164 
165  //Test #1
166  //****************************************
168  double maxNormF_;
171 
172  // Test #2
173  //****************************************
174  Xyce::Linear::Vector** oldTimeStepVectorPtrPtr_;
175  Xyce::Linear::Vector* weightsVectorPtr_;
176  Xyce::Linear::Vector* updateVectorPtr_;
177  Xyce::Linear::Vector* tmpVectorPtr_;
178  const double epsilon_a_;
179  const double epsilon_r_;
180  const double tol_;
182 
183  // Test #3
184  //****************************************
185  // Maximum number of nonlinear iterations allowed
187 
188  // ||F(x_current)|| / ||F(x_previous)||
189  const double requestedConvRate_;
191 
192  // ||F(x)|| / ||F(x_init)||
195 
196  // Initial norm of the RHS used to calculate ratio
198 
199  // test #4
201 
202  // Test #6
203  const double maxConvRate_;
204 
205  // Test #7
208  const int maxBadSteps_;
209  double minConvRate_;
210  const double stagnationTol_;
211 
212  // Xyce return Code
214 
215  // For Device Specific Convergence cirteria
218 
219 // Only used if NLS_MASKED_WRMS_NORMS
222  Xyce::Linear::Vector* weightMaskVectorPtr_;
223 
226 
227 }; // class SharedSystem
228 
229 inline void XyceTests::setReturnCodes
230  (const Xyce::Nonlinear::ReturnCodes & retCodesTmp)
231 {
232  retCodes_ = retCodesTmp;
233 }
234 
235 
236 }}} // namespace N_NLS_NOX
237 
238 #endif // Xyce_N_NLS_NOX_SharedSystem_h
239 
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)