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