Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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.23 $
41 //
42 // Revision Date : $Date: 2014/02/24 23:49:24 $
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 #include <Teuchos_RefCountPtr.hpp>
51 using Teuchos::RefCountPtr;
52 using Teuchos::rcp;
53 
54 // ---------- Xyce Includes ----------
55 #include <N_NLS_ReturnCodes.h>
56 
57 // ---------- NOX Includes ----------
58 
59 #include "NOX_StatusTest_Generic.H" // base class
60 #include "NOX_StatusTest_FiniteValue.H"
61 
62 // ---------- Forward Declarations ----------
63 
64 class N_LAS_Vector;
65 class N_LAS_System;
66 class N_LOA_Loader;
67 
68 // ---------- Namespace Declarations ----------
69 
70 // N_NLS namespace is for the Xyce Nonlinear Solver Package
71 namespace N_NLS_NOX {
72 
73 //-----------------------------------------------------------------------------
74 // Class : N_NLS_NOX::XyceTests
75 //
76 // Purpose :
77 //
78 // NOX Vector Interface for Xyce vectors.
79 //
80 // Creator : Tammy Kolda, SNL, 8950
81 //
82 // Creation Date : 2/1/02
83 //-----------------------------------------------------------------------------
84 
85 class XyceTests : public NOX::StatusTest::Generic {
86 
87 public:
88 
89  //---------------------------------------------------------------------------
90  // Function : XyceTests (constructor)
91  //
92  // Purpose : Constructs a NOX-compatiable status test based
93  // the weighted norm of the update.
94  //
95  //---------------------------------------------------------------------------
96  XyceTests(bool isTransient,
97  double normF,
98  double machPrec,
99  N_LAS_Vector** currSolVectorPtrPtr,
100  double epsilon_a,
101  double epsilon_r,
102  double tol,
103  int maxIters,
104  double convRate,
105  double relConvRate,
106  double maxConvRate,
107  double stagnationTol,
108  int maxBadSteps,
109  int checkDeviceConvergence,
110  double smallUpdateTol,
111  N_LOA_Loader* loader
112 #ifdef Xyce_NLS_MASKED_WRMS_NORMS
113  , bool nonTrivialDeviceMaskFlag,
114  N_LAS_Vector * maskVectorPtr
115 #endif
116  );
117 
118  //---------------------------------------------------------------------------
119  // Function : Destructor
120  //---------------------------------------------------------------------------
121  ~XyceTests();
122 
123  //---------------------------------------------------------------------------
124  // Purpose : Test stopping criterion given the current
125  // nonlinear problem
126  //---------------------------------------------------------------------------
127  NOX::StatusTest::StatusType
128  checkStatus(const NOX::Solver::Generic& problem,
129  NOX::StatusTest::CheckType checkType);
130 
131  //---------------------------------------------------------------------------
132  // Purpose : Test stopping criterion given the current
133  // nonlinear problem
134  //---------------------------------------------------------------------------
135  NOX::StatusTest::StatusType getStatus() const { return status_; };
136 
137  //---------------------------------------------------------------------------
138  // Purpose : Get the return code to send to the time stepper.
139  //
140  //---------------------------------------------------------------------------
141  int getXyceReturnCode() const;
142 
143  //---------------------------------------------------------------------------
144  // Purpose : Output formatted description of stopping test to
145  // output stream.
146  //---------------------------------------------------------------------------
147  std::ostream& print(std::ostream& stream, int indent = 0) const;
148 
149  //---------------------------------------------------------------------------
150  // Purpose : Set a specific set of return codes to be used.
151  //---------------------------------------------------------------------------
152  void setReturnCodes (const N_NLS_ReturnCodes & retCodesTmp);
153 
154  double getMaxNormF() const;
155 
156  int getMaxNormFindex () const;
157 
158 protected:
159 
160  NOX::StatusTest::StatusType status_;
163  int niters_;
164 
166 
167  //Test #0
168  //****************************************
169  NOX::StatusTest::FiniteValue finiteTest_;
170 
171  //Test #1
172  //****************************************
174  double maxNormF_;
177 
178  // Test #2
179  //****************************************
180  N_LAS_Vector** oldTimeStepVectorPtrPtr_;
181  N_LAS_Vector* weightsVectorPtr_;
182  N_LAS_Vector* updateVectorPtr_;
183  N_LAS_Vector* tmpVectorPtr_;
184  const double epsilon_a_;
185  const double epsilon_r_;
186  const double tol_;
188 
189  // Test #3
190  //****************************************
191  // Maximum number of nonlinear iterations allowed
193 
194  // ||F(x_current)|| / ||F(x_previous)||
195  const double requestedConvRate_;
197 
198  // ||F(x)|| / ||F(x_init)||
201 
202  // Initial norm of the RHS used to calculate ratio
204 
205  // test #4
207 
208  // Test #6
209  const double maxConvRate_;
210 
211  // Test #7
214  const int maxBadSteps_;
215  double minConvRate_;
216  const double stagnationTol_;
217 
218  // Xyce return Code
220 
221  // For Device Specific Convergence cirteria
223  N_LOA_Loader* loaderPtr_;
224 #ifdef Xyce_NLS_MASKED_WRMS_NORMS
225  bool deviceMaskFlag_;
226  N_LAS_Vector* weightMaskVectorPtr_;
227 #endif
230 
231 }; // class SharedSystem
232 
233 inline void XyceTests::setReturnCodes
234  (const N_NLS_ReturnCodes & retCodesTmp)
235 {
236  retCodes_ = retCodesTmp;
237 }
238 
239 
240 } // namespace N_NLS_NOX
241 
242 #endif // Xyce_N_NLS_NOX_SharedSystem_h
243