Xyce  6.1
NLSTest.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // File : NLSTest.C
3 //
4 // Purpose : This function is the test driver for the nonlinear solver
5 // package.
6 //
7 // Special Notes :
8 //
9 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
10 //
11 // Creation Date : 5/01/00
12 //-----------------------------------------------------------------------------
13 
14 // ---------- Standard Includes ----------
15 #include <iostream>
16 #include <vector>
17 #include <list>
18 #include <string>
19 
20 // ---------- Xyce Includes ----------
21 #include <NLSTest.h>
22 #include <N_LOA_LoaderMgr.h>
23 #include <N_LOA_Loader.h>
24 
25 #ifdef TESTLA
26 #include <N_LAS_Dummy.h>
27 #else
28 #include <N_LAS_LAFactory.h>
29 #endif
30 
31 #ifdef TESTTI
32 #include <N_TIA_Dummy.h>
33 #else
34 #include <N_TIA_TimeIntegrationAlgorithm.h>
35 #endif
36 
37 //-----------------------------------------------------------------------------
38 // Function : NLSTestor::NLSTestor
39 // Purpose : constructor
40 // Special Notes :
41 // Scope : public
42 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
43 // Creation Date : 5/01/00
44 //-----------------------------------------------------------------------------
46 {
47 
48 }
49 
50 //-----------------------------------------------------------------------------
51 // Function : NLSTestor::~NLSTestor
52 // Purpose : destructor
53 // Special Notes :
54 // Scope : public
55 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
56 // Creation Date : 5/01/00
57 //-----------------------------------------------------------------------------
59 {
60 
61 }
62 
63 //-----------------------------------------------------------------------------
64 // Function : NLSTestor::doAllocations
65 // Purpose :
66 // Special Notes :
67 // Scope : private
68 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
69 // Creation Date : 5/01/00
70 //-----------------------------------------------------------------------------
72 {
73  int bsuccess = STATUS_SUCCESS;
74 
75  cout << endl;
76  cout << "Performing allocations" << endl;
77 
78  LAS_SolverPtr_ = new N_LAS_IterativeSolver(); // Allocate LAS class
79  LAS_MatrixPtr_ = new N_LAS_Matrix(); // Allocate LAS matrix class
80  LAS_RHSVecPtr_ = new N_LAS_MultiVector(); // Allocate LAS vector class
81  LAS_SolVecPtr_ = new N_LAS_MultiVector(); // Allocate LAS vector class
82  LOA_LoaderMgrPtr_ = new N_LOA_LoaderMgr(); // Allocate loader manager.
83 
84  // Allocate Loader
85  LOA_LoaderPtr_ = LOA_LoaderMgrPtr_->createLoader(_CKTLOADER);
86 
87  // Allocate Time Integration:
89 
90  ERH_Ptr_ = new N_ERH_ErrorMgr(); // Allocate Error handler
91  NLS_Ptr_ = new N_NLS_Manager(); // Allocate Nonlinear Solver
92  DEV_Ptr_ = N_DEV_DeviceMgr::factory(); // Allocate device manager
93 
94  bsuccess = bsuccess && (LAS_SolverPtr_ != NULL);
95  bsuccess = bsuccess && (LAS_MatrixPtr_ != NULL);
96  bsuccess = bsuccess && (LAS_RHSVecPtr_ != NULL);
97  bsuccess = bsuccess && (LAS_SolVecPtr_ != NULL);
98  bsuccess = bsuccess && (LOA_LoaderMgrPtr_ != NULL);
99  bsuccess = bsuccess && (LOA_LoaderPtr_ != NULL);
100  bsuccess = bsuccess && (TIA_Ptr_ != NULL);
101  bsuccess = bsuccess && (ERH_Ptr_ != NULL);
102  bsuccess = bsuccess && (DEV_Ptr_ != NULL);
103 
104  cout << "Done with allocations";
105  cout << endl;
106 
107  return bsuccess;
108 }
109 
110 //-----------------------------------------------------------------------------
111 // Function : NLSTestor::doRegistrations
112 // Purpose :
113 // Special Notes :
114 // Scope : private
115 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
116 // Creation Date : 5/01/00
117 //-----------------------------------------------------------------------------
119 
120 {
121  bool bsuccess = STATUS_SUCCESS;
122 
123  cout << endl;
124  cout << "Performing registrations";
125  cout << endl;
126 
127  bsuccess = bsuccess && NLS_Ptr_->registerLinearSolver(LAS_SolverPtr_);
128  bsuccess = bsuccess && NLS_Ptr_->registerLinearSystem(LAS_MatrixPtr_,
131 
132  bsuccess = bsuccess && NLS_Ptr_->registerLoader(LOA_LoaderPtr_);
133 
134  bsuccess = bsuccess && NLS_Ptr_->registerTimeIntegrator(TIA_Ptr_);
135 
136  bsuccess = bsuccess && LOA_LoaderMgrPtr_->registerDeviceManager(DEV_Ptr_);
137 
138  cout << "Done with registrations";
139  cout << endl;
140 
141  return bsuccess;
142 }
143 
144 //-----------------------------------------------------------------------------
145 // Function : NLSTestor::doDeAllocations
146 // Purpose :
147 // Special Notes :
148 // Scope : private
149 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
150 // Creation Date : 5/01/00
151 //-----------------------------------------------------------------------------
153 {
154  bool bsuccess = STATUS_SUCCESS;
155 
156  cout << endl;
157  cout << "Performing de-allocations";
158  cout << endl;
159 
160  delete LAS_SolverPtr_;
161  delete LAS_MatrixPtr_;
162  delete LAS_RHSVecPtr_;
163  delete LAS_SolVecPtr_;
164  delete LOA_LoaderMgrPtr_;
165  delete LOA_LoaderPtr_;
166  delete TIA_Ptr_;
167  delete ERH_Ptr_;
168  delete NLS_Ptr_;
169  delete DEV_Ptr_;
170 
171  cout << "Done with de-allocations";
172  cout << endl;
173 
174  return bsuccess;
175 }
176 
177 //-----------------------------------------------------------------------------
178 // Function : NLTestor::doInitialization
179 // Purpose : Tells the nonlinear solver to allocate one of the various
180 // nonlinear solvers.
181 // Special Notes :
182 // Scope : private
183 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
184 // Creation Date : 5/01/00
185 //-----------------------------------------------------------------------------
187 {
188  int isolver;
189  N_NLS_NLParams nlParams;
190 
191  cout << "Performing initializations" << endl;
192 
193  // Which solver is allocated depends upon the command line args.
194 
195  bool bsuccess = NLS_Ptr_->createNLS();
196  bool btmp = NLS_Ptr_->initNLS(nlParams);
197 
198  cout << "Done Initializations" << endl;
199  cout << endl;
200 
201  return bsuccess;
202 }
203 
204 //-----------------------------------------------------------------------------
205 // Function : NLSTestor::doSolve
206 // Purpose :
207 // Special Notes :
208 // Scope : private
209 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
210 // Creation Date : 5/01/00
211 //-----------------------------------------------------------------------------
213 {
214  cout << "Performing solve" << endl;
215 
216  bool bsuccess = NLS_Ptr_->solve();
217 
218  cout << "Done with doSolve" << endl;
219  cout << endl;
220 
221  return bsuccess;
222 }
223 
224 //-----------------------------------------------------------------------------
225 // Function : NLSTestor::runTests
226 // Purpose :
227 // Special Notes :
228 // Scope : public
229 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
230 // Creation Date : 5/01/00
231 //-----------------------------------------------------------------------------
232 bool NLSTestor::runTests(int iargs_tmp, char *cargs_tmp[])
233 {
234  bool bsuccess;
235  bool btmp;
236 
237  iargs = iargs_tmp; cargs = cargs_tmp;
238 
239  cout << endl;
240  cout << "Welcome to the Nonlinear solver testing program";
241  cout << endl;
242 
243  bsuccess = doAllocations();
244  btmp = doRegistrations(); bsuccess = bsuccess && btmp;
245  btmp = doInitialization(); bsuccess = bsuccess && btmp;
246  btmp = doSolve(); bsuccess = bsuccess && btmp;
247  btmp = doDeAllocations(); bsuccess = bsuccess && btmp;
248 
249  cout << endl;
250  cout << "Done testing the Nonlinear solver";
251  cout << endl;
252  cout << endl;
253 
254  return bsuccess;
255 }
256 
257 //-----------------------------------------------------------------------------
258 // Function : main
259 // Purpose :
260 // Special Notes :
261 // Scope : public
262 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
263 // Creation Date : 5/01/00
264 //-----------------------------------------------------------------------------
265 int main(int iargs, char *cargs[])
266 {
267  NLSTestor *NLSPtr = new NLSTestor();
268 
269  bool bsuccess = NLSPtr->runTests(iargs, cargs);
270 
271  delete NLSPtr;
272 
273  return 0;
274 }
275 
char ** cargs
Definition: NLSTest.h:85
bool runTests(int iargs, char *cargs[])
Definition: NLSTest.C:232
N_LAS_IterativeSolver * LAS_SolverPtr_
Definition: NLSTest.h:74
bool doInitialization()
Definition: NLSTest.C:186
bool doRegistrations()
Definition: NLSTest.C:118
bool doDeAllocations()
Definition: NLSTest.C:152
N_LAS_Matrix * LAS_MatrixPtr_
Definition: NLSTest.h:75
~NLSTestor()
Definition: NLSTest.C:58
N_LAS_MultiVector * LAS_SolVecPtr_
Definition: NLSTest.h:77
NLSTestor()
Definition: NLSTest.C:45
bool doSolve()
Definition: NLSTest.C:212
int iargs
Definition: NLSTest.h:84
int main(int iargs, char *cargs[])
Definition: NLSTest.C:265
N_LOA_Loader * LOA_LoaderPtr_
Definition: NLSTest.h:79
Xyce::Nonlinear::Manager N_NLS_Manager
Definition: N_NLS_fwd.h:134
N_NLS_Manager * NLS_Ptr_
Definition: NLSTest.h:73
N_DEV_DeviceMgr * DEV_Ptr_
Definition: NLSTest.h:82
N_ERH_ErrorMgr * ERH_Ptr_
Definition: NLSTest.h:81
N_LOA_LoaderMgr * LOA_LoaderMgrPtr_
Definition: NLSTest.h:78
N_LAS_MultiVector * LAS_RHSVecPtr_
Definition: NLSTest.h:76
bool doAllocations()
Definition: NLSTest.C:71
N_TIA_TimeIntegrationAlgorithm * TIA_Ptr_
Definition: NLSTest.h:80