Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIATest.C
Go to the documentation of this file.
1 //-------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright (c) 2000, Sandia Corporation, Albuquerque, NM.
5 //-------------------------------------------------------------------------
6 
7 //-------------------------------------------------------------------------
8 // Filename : $RCSfile: TIATest.C,v $
9 //
10 // Purpose : This is the test program for the time integration
11 // pacakge.
12 //
13 // Special Notes :
14 //
15 // Creator : Buddy Watts
16 //
17 // Creation Date : 5/26/00
18 //
19 // Revision Information:
20 // ---------------------
21 //
22 // Revision Number: $Revision: 1.3 $
23 //
24 // Revision Date : $Date: 2002/01/24 00:52:11 $
25 //
26 // Current Owner : $Author: tgkolda $
27 //-------------------------------------------------------------------------
28 
29 // ---------- Xyce Includes ----------
30 #include <N_UTL_Misc.h>
31 #include <TIATest.h>
32 
33 #ifdef TESTLA
34  #include <N_LAS_Dummy.h>
35 #else
36  #include <N_LAS_LAFactory.h>
37  #include <N_LAS_System.h>
38  #include <N_LAS_MultiVector.h>
39  #include <N_LAS_Matrix.h>
40 #endif
41 
42 #include <N_NLS_Manager.h>
43 #include <N_NLS_NonLinearSolver.h>
44 
45 #include <N_DEV_DeviceMgr.h>
46 
47 #include <N_LOA_LoaderMgr.h>
48 #include <N_LOA_Loader.h>
49 
50 //-----------------------------------------------------------------------------
51 // Function : TIATestor::setTiaParams
52 // Purpose :
53 // Special Notes :
54 // Scope : public
55 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
56 // Creation Date : 6/09/00
57 //-----------------------------------------------------------------------------
59 {
60  tiaParams_.RestartingIntegrationFromSSS = 0;
61  tiaParams_.InitialTime = 1.0;
62  tiaParams_.FinalTime = 5.0;
63  tiaParams_.IntegrationMethod = 2;
64  tiaParams_.StartingTimeStep = 0.5;
65  tiaParams_.ConstantStepSize = 1;
68 
69  //tiaParams_.xxx = 1.2; // Initial_Solution_(1)
70  //tiaParams_.xxx = 3.4; // Initial_Solution_(2)
71  //tiaParams_.xxx = 5.6; // Initial_Solution_(3)
72 
73  tiaParams_.ScalarTolerances = 1;
74  tiaParams_.IntegRelErrorTol = 1.0e-4;
75  tiaParams_.IntegAbsErrorThreshold = 1.0e-8;
76  tiaParams_.NumDiscontinuityPts = 1;
77 
78  //tiaParams_.xxx = 3.5; // PtOfDiscontinuity
79 
80  return STATUS_SUCCESS;
81 }
82 
83 //-----------------------------------------------------------------------------
84 // Function : TIATestor::setNLParams
85 // Purpose :
86 // Special Notes :
87 // Scope : public
88 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
89 // Creation Date : 6/09/00
90 //-----------------------------------------------------------------------------
92 {
93  nlParamsPtr_->deltaxTol = 1.0e-8;
94  nlParamsPtr_->normRHS = 0.0;
95  nlParamsPtr_->absTol = 1.0e-8;
96  nlParamsPtr_->relTol = 1.0e-8;
97  nlParamsPtr_->dampFactor = 1.0;
98  nlParamsPtr_->maxChange = 0.0;
99  nlParamsPtr_->newtonStep = 0;
100  nlParamsPtr_->maxNewtonStep = 15;
101  nlParamsPtr_->dampStep = 0;
102  nlParamsPtr_->maxDampStep = 7;
103  nlParamsPtr_->normLevel = 2;
104 
105  return STATUS_SUCCESS;
106 }
107 
108 
109 
110 //-----------------------------------------------------------------------------
111 // Function : TIATestor::doAllocations
112 // Purpose :
113 // Special Notes :
114 // Scope : public
115 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
116 // Creation Date : 9/06/00
117 //-----------------------------------------------------------------------------
119 {
120  bool bsuccess = STATUS_SUCCESS;
121 
122  lasSysPtr_ = new N_LAS_System ();
123  nlsMgrPtr_ = new N_NLS_Manager ();
124  nlsMgrPtr_->createNLS();
125  nlsPtr_ = nlsMgrPtr_->getNonLinearSolver ();
126 
127  nlParamsPtr_ = new N_NLS_NLParams ();
128 
129  bsuccess = bsuccess && (lasSysPtr_ != NULL);
130  bsuccess = bsuccess && (nlsMgrPtr_ != NULL);
131  bsuccess = bsuccess && (nlsPtr_ != NULL);
132 
133  // do the loader:
134  loaderMgrPtr_ = new N_LOA_LoaderMgr ();
135  loaderPtr_ = loaderMgrPtr_->createLoader (_CKTLOADER);
136 
137  bsuccess = bsuccess && (loaderMgrPtr_ != NULL);
138  bsuccess = bsuccess && (loaderPtr_ != NULL);
139 
140  // device manager:
142 
143  return bsuccess;
144 }
145 
146 //-----------------------------------------------------------------------------
147 // Function : TIATestor::doRegistrations
148 // Purpose :
149 // Special Notes :
150 // Scope : public
151 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
152 // Creation Date : 9/06/00
153 //-----------------------------------------------------------------------------
155 {
156  bool bsuccess = STATUS_SUCCESS;
157 
158  // time integration registrations:
159  bsuccess = bsuccess && tia_.registerTIAParams (tiaParams_);
160  bsuccess = bsuccess && tia_.registerLinearSystem (lasSysPtr_);
161  bsuccess = bsuccess && tia_.registerNLSolver (nlsPtr_);
162  bsuccess = bsuccess && tia_.registerLoader (loaderPtr_);
163 
164  // nonlinear solver registrations:
165  bsuccess = bsuccess && nlsMgrPtr_->registerNLParams (*nlParamsPtr_);
166  bsuccess = bsuccess && nlsMgrPtr_->registerLoader (loaderPtr_);
167  bsuccess = bsuccess && nlsMgrPtr_->registerLinearSystem (lasSysPtr_);
168  bsuccess = bsuccess && nlsMgrPtr_->registerTimeIntegrator (&tia_);
169 
170  // loader registrations:
171  bsuccess = bsuccess && loaderMgrPtr_->registerDeviceManager (devPtr_);
172 
173  // device registrations:
174  bsuccess = bsuccess && devPtr_->registerLinearSystem (lasSysPtr_);
175  bsuccess = bsuccess && devPtr_->registerTimeIntegrator (&tia_);
176 
177  return bsuccess;
178 }
179 
180 //-----------------------------------------------------------------------------
181 // Function : TIATestor::doMatrixCreation
182 // Purpose :
183 // Special Notes :
184 // Scope : public
185 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
186 // Creation Date : 6/12/00
187 //-----------------------------------------------------------------------------
189 {
190  bool bsuccess = STATUS_SUCCESS;
191 
192  // jacobian matrix was already created in the dummy version of the
193  // N_LAS_System constructor.
194 
195  return bsuccess;
196 }
197 
198 //-----------------------------------------------------------------------------
199 // Function : TIATestor::doInitializations
200 // Purpose :
201 // Special Notes :
202 // Scope : public
203 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
204 // Creation Date : 6/12/00
205 //-----------------------------------------------------------------------------
207 {
208  bool bsuccess = STATUS_SUCCESS;
209 
210  bsuccess = bsuccess && tia_.initializeAll ();
211  bsuccess = bsuccess && devPtr_->initializeAll ();
212  bsuccess = bsuccess && nlsMgrPtr_->initializeAll ();
213 
214  return bsuccess;
215 }
216 
217 //-----------------------------------------------------------------------------
218 // Function : TIATestor::doDeAllocations
219 // Purpose :
220 // Special Notes :
221 // Scope : public
222 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
223 // Creation Date : 6/12/00
224 //-----------------------------------------------------------------------------
226 {
227  bool bsuccess = STATUS_SUCCESS;
228 
229  if (lasSysPtr_ != NULL) delete lasSysPtr_;
230  if (nlsMgrPtr_ != NULL) delete nlsMgrPtr_;
231  if (loaderMgrPtr_ != NULL) delete loaderMgrPtr_;
232  if (loaderPtr_ != NULL) delete loaderPtr_;
233  if (devPtr_ != NULL) delete devPtr_;
234  if (nlParamsPtr_ != NULL) delete nlParamsPtr_;
235 
236  return bsuccess;
237 }
238 
239 //-----------------------------------------------------------------------------
240 // Function : TIATestor::runTests
241 // Purpose :
242 // Special Notes :
243 // Scope : public
244 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
245 // Creation Date : 6/06/00
246 //-----------------------------------------------------------------------------
247 bool TIATestor::runTests(int iargs, char *cargs[])
248 {
249  bool bsuccess;
250 
251  bsuccess = doAllocations ();
252 
253  setTiaParams ();
254  setNLParams ();
255 
256  bsuccess = bsuccess && doRegistrations ();
257 
258  bsuccess = bsuccess && doMatrixCreation ();
259 
260  bsuccess = bsuccess && doInitializations ();
261 
262  bsuccess = bsuccess && tia_.runIntegrator ();
263 
264  bsuccess = bsuccess && doDeAllocations ();
265 
266  return bsuccess;
267 }
268 
269 //-----------------------------------------------------------------------------
270 // Function : main
271 // Purpose :
272 // Special Notes :
273 // Scope : public
274 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
275 // Creation Date : 6/06/00
276 //-----------------------------------------------------------------------------
277 int main(int iargs, char *cargs[])
278 {
279  TIATestor * TIAT_ptr = new TIATestor ();
280  bool bsuccess = TIAT_ptr->runTests(iargs, cargs);
281  delete TIAT_ptr;
282  return 0;
283 }