Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_TIA_DataStore.C
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_TIA_DataStore.C,v $
27 //
28 // Purpose : This file creates & initializes the data arrays needed for
29 // the time integration algorithms.
30 //
31 // Special Notes :
32 //
33 // Creator : Buddy Watts
34 //
35 // Creation Date : 6/1/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.145 $
41 //
42 // Revision Date : $Date: 2014/02/24 23:49:27 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 
50 // ---------- Standard Includes ----------
51 #include <iostream>
52 
53 #ifdef HAVE_CMATH
54 #include <cmath>
55 #else
56 #include <math.h>
57 #endif
58 
59 #ifdef HAVE_CSTDIO
60 #include <cstdio>
61 #else
62 #include <stdio.h>
63 #endif
64 
65 #include <N_UTL_Misc.h>
66 #include <N_UTL_fwd.h>
67 
68 // ---------- Xyce Includes ----------
69 
70 #include <N_TIA_DataStore.h>
71 #include <N_TIA_TIAParams.h>
72 
73 #include <N_LAS_MultiVector.h>
74 #include <N_LAS_Vector.h>
75 #include <N_LAS_Matrix.h>
76 #include <N_LAS_System.h>
77 #include <N_LAS_Builder.h>
78 
79 #include <N_ERH_ErrorMgr.h>
80 #include <Teuchos_Utils.hpp>
81 
82 // ---------- Forward Declarations ----------
83 
84 // ---------- Static Initializations ----------
85 
86 //-----------------------------------------------------------------------------
87 // Function : N_TIA_DataStore::N_TIA_DataStore
88 // Purpose : constructor
89 // Special Notes :
90 // Scope : public
91 // Creator : Buddy Watts, SNL
92 // Creation Date : 6/01/00
93 //-----------------------------------------------------------------------------
94 
95 N_TIA_DataStore::N_TIA_DataStore(N_TIA_TIAParams * tiaPtr, N_LAS_System * lsPtr)
96  :
97  limiterFlag(false),
98  lasSysPtr(lsPtr),
99  solutionSize(tiaPtr->solutionSize),
100  stateSize(tiaPtr->stateSize),
101  tiaParamsPtr_(tiaPtr),
102  nextSolPtrSwitched(false),
103  tmpSolVectorPtr(0),
104  tmpStaVectorPtr(0),
105  tmpStaDerivPtr(0),
106  tmpStaDivDiffPtr(0),
107  tmpStoVectorPtr(0),
108  xn0Ptr (0),
109  currSolutionPtr(0),
110  lastSolutionPtr(0),
111  oldeSolutionPtr(0),
112  nextSolutionPtr(0),
113  flagSolutionPtr(0),
114  savedNextSolutionPtr(0),
115  currStatePtr(0),
116  lastStatePtr(0),
117  oldeStatePtr(0),
118  nextStatePtr(0),
119  currStorePtr(0),
120  lastStorePtr(0),
121  oldeStorePtr(0),
122  nextStorePtr(0),
123  currStoreLeadCurrQCompPtr(0),
124  lastStoreLeadCurrQCompPtr(0),
125  oldStoreLeadCurrQCompPtr(0),
126  nextStoreLeadCurrQCompPtr(0),
127  currStoreLeadCurrQCompDerivPtr(0),
128  lastStoreLeadCurrQCompDerivPtr(0),
129  oldStoreLeadCurrQCompDerivPtr(0),
130  nextStoreLeadCurrQCompDerivPtr(0),
131  currSolutionDerivPtr(0),
132  lastSolutionDerivPtr(0),
133  oldeSolutionDerivPtr(0),
134  nextSolutionDerivPtr(0),
135  currStateDerivPtr(0),
136  lastStateDerivPtr(0),
137  oldeStateDerivPtr(0),
138  nextStateDerivPtr(0),
139  currSolutionDivDiffPtr(0),
140  lastSolutionDivDiffPtr(0),
141  oldeSolutionDivDiffPtr(0),
142  nextSolutionDivDiffPtr(0),
143  currStateDivDiffPtr(0),
144  lastStateDivDiffPtr(0),
145  oldeStateDivDiffPtr(0),
146  nextStateDivDiffPtr(0),
147  errWtVecPtr(0),
148  absErrTolPtr(0),
149  relErrTolPtr(0),
150  JMatrixPtr(0),
151  RHSVectorPtr(0),
152 #ifdef Xyce_DEBUG_DEVICE
153  JdxpVectorPtr(0),
154 #endif
155  newtonCorrectionPtr(0),
156  deviceMaskPtr(0),
157  indexVecsInitialized(false),
158 
159  qErrWtVecPtr(0),
160  daeQVectorPtr(0),
161  daeFVectorPtr(0),
162  dQdxMatrixPtr(0),
163  dFdxMatrixPtr(0),
164  dQdxVecVectorPtr(0),
165  dFdxVecVectorPtr(0),
166  dFdxdVpVectorPtr(0),
167  dQdxdVpVectorPtr(0),
168  qn0Ptr(0),
169  qpn0Ptr(0),
170  sn0Ptr(0),
171  spn0Ptr(0),
172  ston0Ptr(0),
173  stopn0Ptr(0),
174  qNewtonCorrectionPtr(0),
175  sNewtonCorrectionPtr(0),
176  stoNewtonCorrectionPtr(0),
177  stoLeadCurrQCompNewtonCorrectionPtr(0),
178  delta_x(0),
179  delta_q(0),
180  tmpXn0APtr(0),
181  tmpXn0BPtr(0)
182 {
183  // temporary vectors:
184  tmpSolVectorPtr = lasSysPtr->builder().createVector();
185  tmpStaVectorPtr = lasSysPtr->builder().createStateVector();
186  tmpStaDerivPtr = lasSysPtr->builder().createStateVector();
187  tmpStaDivDiffPtr = lasSysPtr->builder().createStateVector();
188  tmpStoVectorPtr = lasSysPtr->builder().createStoreVector();
189 
190  xn0Ptr = lasSysPtr->builder().createVector();
191 
192  // solution vectors:
193  currSolutionPtr = lasSysPtr->builder().createVector();
194  lastSolutionPtr = lasSysPtr->builder().createVector();
195  nextSolutionPtr = lasSysPtr->builder().createVector();
196  flagSolutionPtr = lasSysPtr->builder().createVector();
197 
198  // state vectors:
199  currStatePtr = lasSysPtr->builder().createStateVector();
200  lastStatePtr = lasSysPtr->builder().createStateVector();
201  nextStatePtr = lasSysPtr->builder().createStateVector();
202 
203  // store vectors:
204  currStorePtr = lasSysPtr->builder().createStoreVector();
205  lastStorePtr = lasSysPtr->builder().createStoreVector();
206  nextStorePtr = lasSysPtr->builder().createStoreVector();
207  currStoreLeadCurrQCompPtr = lasSysPtr->builder().createStoreVector();
208  lastStoreLeadCurrQCompPtr = lasSysPtr->builder().createStoreVector();
209  //oldStoreLeadCurrQCompPtr = lasSysPtr->builder().createStoreVector();
210  nextStoreLeadCurrQCompPtr = lasSysPtr->builder().createStoreVector();
211 
212  // solution derivative vectors:
213  currSolutionDerivPtr = lasSysPtr->builder().createVector();
214  lastSolutionDerivPtr = lasSysPtr->builder().createVector();
215  nextSolutionDerivPtr = lasSysPtr->builder().createVector();
216 
217  // state derivative vectors:
218  currStateDerivPtr = lasSysPtr->builder().createStateVector();
219  lastStateDerivPtr = lasSysPtr->builder().createStateVector();
220  nextStateDerivPtr = lasSysPtr->builder().createStateVector();
221 
222  // store derivative vec for lead currents.
223  currStoreLeadCurrQCompDerivPtr = lasSysPtr->builder().createStoreVector();
224  lastStoreLeadCurrQCompDerivPtr = lasSysPtr->builder().createStoreVector();
225  //oldStoreLeadCurrQCompDerivPtr = lasSysPtr->builder().createStoreVector();
226  nextStoreLeadCurrQCompDerivPtr = lasSysPtr->builder().createStoreVector();
227 
228  // solution scaled divided differences:
229  currSolutionDivDiffPtr = lasSysPtr->builder().createVector();
230  lastSolutionDivDiffPtr = lasSysPtr->builder().createVector();
231  nextSolutionDivDiffPtr = lasSysPtr->builder().createVector();
232 
233  // state scaled divided differences:
234  currStateDivDiffPtr = lasSysPtr->builder().createStateVector();
235  lastStateDivDiffPtr = lasSysPtr->builder().createStateVector();
236  nextStateDivDiffPtr = lasSysPtr->builder().createStateVector();
237 
238  // error vectors:
239  errWtVecPtr = lasSysPtr->builder().createVector();
240  absErrTolPtr = lasSysPtr->builder().createVector();
241  relErrTolPtr = lasSysPtr->builder().createVector();
242 
243  errWtVecPtr->putScalar(1.0);
244 
245  deviceMaskPtr = lasSysPtr->builder().createVector();
246  deviceMaskPtr->putScalar(1.0);
247 
250 
251  // nonlinear solution vectors:
252  newtonCorrectionPtr = lasSysPtr->builder().createVector();
253 
254  // new-DAE stuff:
255  // Error Vectors
256  qErrWtVecPtr = lasSysPtr->builder().createVector();
257 
258  // DAE formulation vectors
259  daeQVectorPtr = lasSysPtr->builder().createVector();
260  daeFVectorPtr = lasSysPtr->builder().createVector();
261 
262  // DAE formulation matrices
263  dQdxMatrixPtr = lasSysPtr->builder().createMatrix();
264  dFdxMatrixPtr = lasSysPtr->builder().createMatrix();
265 
266  dQdxVecVectorPtr = lasSysPtr->builder().createVector();
267  dFdxVecVectorPtr = lasSysPtr->builder().createVector();
268 
269  // History arrays
270 
271 // if tiaParamsPtr_->method == 7
272  int sizeOfHistory = tiaParamsPtr_->maxOrder+1;
273 // else
274 // int sizeOfHistory = 3;
275 
276  for (int i=0;i<sizeOfHistory;++i)
277  {
278  xHistory.push_back(lasSysPtr->builder().createVector());
279  qHistory.push_back(lasSysPtr->builder().createVector());
280  sHistory.push_back(lasSysPtr->builder().createStateVector());
281  stoHistory.push_back(lasSysPtr->builder().createStoreVector());
282  stoLeadCurrQCompHistory.push_back(lasSysPtr->builder().createStoreVector());
283  }
284 // N_LAS_Vector * tmpVectorPtr = lasSysPtr->builder().createVector();
285 // xHistory.resize(sizeOfHistory,*tmpVectorPtr);
286 // qHistory.resize(sizeOfHistory,*tmpVectorPtr);
287 // N_LAS_Vector * tmpStaVectorPtr = lasSysPtr->builder().createStateVector();
288 // sHistory.resize(sizeOfHistory,*tmpStaVectorPtr);
289 // delete tmpVectorPtr;
290 // delete tmpStaVectorPtr;
291 
292  // Predictors
293  qn0Ptr = lasSysPtr->builder().createVector();
294  qpn0Ptr = lasSysPtr->builder().createVector();
295  sn0Ptr = lasSysPtr->builder().createStateVector();
296  spn0Ptr = lasSysPtr->builder().createStateVector();
297  ston0Ptr = lasSysPtr->builder().createStoreVector();
298  stopn0Ptr = lasSysPtr->builder().createStoreVector();
299  stoQCn0Ptr = lasSysPtr->builder().createStoreVector();
300  stoQCpn0Ptr = lasSysPtr->builder().createStoreVector();
301 
302  // Nonlinear solution vector:
303  qNewtonCorrectionPtr = lasSysPtr->builder().createVector();
304  sNewtonCorrectionPtr = lasSysPtr->builder().createStateVector();
305  stoNewtonCorrectionPtr = lasSysPtr->builder().createStoreVector();
306  stoLeadCurrQCompNewtonCorrectionPtr = lasSysPtr->builder().createStoreVector();
307 
308  // Step-size selection temporary vectors
309  delta_x = lasSysPtr->builder().createVector();
310  delta_q = lasSysPtr->builder().createVector();
311 
312  // Temporary vector for MPDE & WaMPDE interpolation
313  tmpXn0APtr = lasSysPtr->builder().createVector();
314  tmpXn0BPtr = lasSysPtr->builder().createVector();
315 
316  return;
317 }
318 
319 //-----------------------------------------------------------------------------
320 // Function : N_TIA_DataStore::N_TIA_DataStore
321 // Purpose : destructor
322 // Special Notes :
323 // Scope : public
324 // Creator : Buddy Watts, SNL
325 // Creation Date : 6/01/00
326 //-----------------------------------------------------------------------------
327 
329 
330 {
333  if (tmpStaDerivPtr) { delete tmpStaDerivPtr; tmpStaDerivPtr=0;}
336  if (xn0Ptr) { delete xn0Ptr; xn0Ptr=0;}
337 
340 
343 
344  if (currStatePtr) { delete currStatePtr; currStatePtr=0;}
345  if (lastStatePtr) { delete lastStatePtr; lastStatePtr=0;}
346 
347  if (nextStatePtr) { delete nextStatePtr; nextStatePtr=0;}
348 
349  if (currStorePtr) { delete currStorePtr; currStorePtr=0;}
350  if (lastStorePtr) { delete lastStorePtr; lastStorePtr=0;}
351  if (nextStorePtr) { delete nextStorePtr; nextStorePtr=0;}
354  //if (oldStoreLeadCurrQCompPtr) { delete oldStoreLeadCurrQCompPtr; oldStoreLeadCurrQCompPtr=0;}
358  //if (oldStoreLeadCurrQCompDerivPtr) { delete oldStoreLeadCurrQCompDerivPtr; oldStoreLeadCurrQCompDerivPtr=0;}
360 
363 
365 
368 
370 
373 
375 
378 
380 
381  if (errWtVecPtr) { delete errWtVecPtr; errWtVecPtr=0;}
382  if (absErrTolPtr) { delete absErrTolPtr; absErrTolPtr=0;}
383  if (relErrTolPtr) { delete relErrTolPtr; relErrTolPtr=0;}
384 
385  if (deviceMaskPtr) { delete deviceMaskPtr; deviceMaskPtr=0;}
386 
388 
389  //new-DAE:
390  // Error Vectors
391  if (qErrWtVecPtr) { delete qErrWtVecPtr; qErrWtVecPtr=0; }
392 
393  // DAE formulation vectors
394  if (daeQVectorPtr) { delete daeQVectorPtr; daeQVectorPtr=0; }
395  if (daeFVectorPtr) { delete daeFVectorPtr; daeFVectorPtr=0; }
396 
397  // DAE formulation matrices
398  if (dQdxMatrixPtr) { delete dQdxMatrixPtr; dQdxMatrixPtr=0; }
399  if (dFdxMatrixPtr) { delete dFdxMatrixPtr; dFdxMatrixPtr=0; }
400 
401  // HB temporary vectors
404 
405  // History arrays are STL containers of N_LAS_Vector
406  // so they'll take care of themselves. NO! they're containers of
407  // N_LAS_Vector *pointers*, so they need to be deleted by hand.
408  if (xHistory.size() != 0)
409  {
410  int sizeOfHistory=xHistory.size();
411  for (int i=0;i<sizeOfHistory;++i)
412  {
413  if (xHistory[i]) {delete xHistory[i]; }
414  if (qHistory[i]) {delete qHistory[i]; }
415  if (sHistory[i]) {delete sHistory[i]; }
416  if (stoHistory[i]) {delete stoHistory[i]; }
418  }
419  xHistory.clear();
420  qHistory.clear();
421  sHistory.clear();
422  stoHistory.clear();
423  stoLeadCurrQCompHistory.clear();
424  }
425 
426  if (qn0Ptr) { delete qn0Ptr; qn0Ptr=0; }
427  if (qn0Ptr) { delete qn0Ptr; qn0Ptr=0; }
428  if (qpn0Ptr) { delete qpn0Ptr; qpn0Ptr=0; }
429  if (sn0Ptr) { delete sn0Ptr; sn0Ptr=0; }
430  if (spn0Ptr) { delete spn0Ptr; spn0Ptr=0; }
431  if (ston0Ptr) { delete ston0Ptr; ston0Ptr=0; }
432  if (stopn0Ptr) { delete stopn0Ptr; stopn0Ptr=0; }
433  if (stoQCn0Ptr) { delete stoQCn0Ptr; stoQCn0Ptr=0; }
434  if (stoQCpn0Ptr) { delete stoQCpn0Ptr; stoQCpn0Ptr=0; }
435 
436  // Nonlinear solution vector:
441 
442  // Step-size selection temporary vectors
443  if (delta_x) { delete delta_x; delta_x=0; }
444  if (delta_q) { delete delta_q; delta_q=0; }
445 
446  // Temporary vector for WaMPDE interpolation
447  if (tmpXn0APtr) { delete tmpXn0APtr; tmpXn0APtr=0; }
448  if (tmpXn0BPtr) { delete tmpXn0BPtr; tmpXn0BPtr=0; }
449 
450  // Delete data in the fast time storage for HB and MPDE
452 
453  return ;
454 }
455 
456 // ----------------------------------------------------------------------------
457 // ----------------------- DataStore Class Functions -------------------------
458 // ----------------------------------------------------------------------------
459 
460 //-----------------------------------------------------------------------------
461 // Function : N_TIA_DataStore::printOutPointers
462 // Purpose :
463 // Special Notes :
464 // Scope : public
465 // Creator : Eric Keiter, SNL
466 // Creation Date : 6/23/00
467 //-----------------------------------------------------------------------------
468 
470 {
471  Xyce::dout() << "olde ptr = " << oldeSolutionPtr << std::endl;
472  Xyce::dout() << "last ptr = " << lastSolutionPtr << std::endl;
473  Xyce::dout() << "curr ptr = " << currSolutionPtr << std::endl;
474  Xyce::dout() << "next ptr = " << nextSolutionPtr << std::endl;
475 }
476 
477 //-----------------------------------------------------------------------------
478 // Function : N_TIA_DataStore::setConstantHistory
479 // Purpose : This function is called after the operating point
480 // calculation has been called. Once the operating point
481 // solution has been obtained, the code should regard that
482 // solution as having been the existing constant solution since
483 // the dawn of time.
484 // Special Notes : The most recent solution, etc., are in the "next" vectors.
485 // Scope : public
486 // Creator : Eric Keiter, SNL
487 // Creation Date : 6/23/00
488 //-----------------------------------------------------------------------------
490 {
491 #ifdef Xyce_DEBUG_TIME
492  Xyce::dout() << "\nN_TIA_DataStore::setConstantHistory" << std::endl;
493 #endif
494 
495  // Solutions:
498 
499  // Derivative of Solutions:
502 
503  // Scaled Divided Differences of solutions:
506 
507  // States:
508  *(lastStatePtr) = *(nextStatePtr);
509  *(currStatePtr) = *(nextStatePtr);
510 
511  // Stores:
512  *(lastStorePtr) = *(nextStorePtr);
513  *(currStorePtr) = *(nextStorePtr);
514 
517 
518  // Derivative of States:
521 
522  // lead current derivative info in store
525 
526  // Scaled Divided Differences of states:
529 
530 }
531 
532 //-----------------------------------------------------------------------------
533 // Function : N_TIA_DataStore::resetAll
534 //
535 // Purpose : This function resets everything so that a transient loop
536 // can be started from the beginning.
537 //
538 // Special Notes : This function was needed for HB.
539 //
540 // Scope : public
541 // Creator : T. Mei, SNL
542 // Creation Date : 02/26/09
543 //-----------------------------------------------------------------------------
545 {
548 
549  return true;
550 }
551 
552 //-----------------------------------------------------------------------------
553 // Function : N_TIA_DataStore::resetFastTimeData
554 //
555 // Purpose : This function deletes the information from all the vectors
556 // that store fast time data for HB and MPDE
557 //
558 // Special Notes : This function was needed for HB.
559 //
560 // Scope : public
561 // Creator : Heidi Thornquist, SNL
562 // Creation Date : 06/05/13
563 //-----------------------------------------------------------------------------
565 {
566  // Clear the time step vectors
567  timeSteps.clear();
568  timeStepsBreakpointFlag.clear();
569 
570  // Delete any stored up any solution or state info
571  std::vector<N_LAS_Vector *>::iterator currVecPtr = fastTimeSolutionVec.begin();
572  std::vector<N_LAS_Vector *>::iterator endVecPtr = fastTimeSolutionVec.end();
573  while( currVecPtr != endVecPtr )
574  {
575  delete *currVecPtr;
576  currVecPtr++;
577  }
578  fastTimeSolutionVec.clear();
579 
580  currVecPtr = fastTimeStateVec.begin();
581  endVecPtr = fastTimeStateVec.end();
582  while( currVecPtr != endVecPtr )
583  {
584  delete *currVecPtr;
585  currVecPtr++;
586  }
587  fastTimeStateVec.clear();
588 
589  currVecPtr = fastTimeQVec.begin();
590  endVecPtr = fastTimeQVec.end();
591  while( currVecPtr != endVecPtr )
592  {
593  delete *currVecPtr;
594  currVecPtr++;
595  }
596  fastTimeQVec.clear();
597 
598  currVecPtr = fastTimeStoreVec.begin();
599  endVecPtr = fastTimeStoreVec.end();
600  while( currVecPtr != endVecPtr )
601  {
602  delete *currVecPtr;
603  currVecPtr++;
604  }
605  fastTimeStoreVec.clear();
606 
607  return true;
608 }
609 
610 
611 
612 //-----------------------------------------------------------------------------
613 // Function : N_TIA_DataStore::updateSolDataArrays
614 // Purpose : Update the necessary integration data arrays for
615 // preparation of the next integration step. This is done after
616 // a successful step has been taken.
617 // Special Notes :
618 // Scope : public
619 // Creator : Buddy Watts, SNL
620 // Creation Date : 6/01/00
621 //-----------------------------------------------------------------------------
623 {
624 #ifdef Xyce_DEBUG_TIME
625  if (tiaParamsPtr_->debugLevel > 1)
626  {
627  Xyce::dout() << "\nN_TIA_DataStore::updateSolDataArrays " << std::endl;
628  }
629 #endif
630 
631  // if the next solution has been switched out (probably because of NOX),
632  // then reset it
634 
635  // Solutions:
640 
641  // Derivative of Solutions:
646 
647  // Scaled Divided Differences of solutions:
652 
653  // States:
658 
659  // Stores:
668 
669  // Derivative of States:
674 
675  // lead curent component of store
680 
681  // Scaled Divided Differences of states:
686 
687  // copy contents of "curr" into "next". This is to insure
688  // that at a minimum, the initial guess for the Newton solve
689  // will at least be the results of the previous Newton solve.
691  *(nextStatePtr) = *(currStatePtr);
692  *(nextStorePtr) = *(currStorePtr);
693 
694  return;
695 }
696 
697 //-----------------------------------------------------------------------------
698 // Function : N_TIA_DataStore::updateStateDataArrays
699 //
700 //
701 // Purpose : Same as updateSolDataArrays, but this function only
702 // advances the state vector, and leaves the
703 // solution alone.
704 //
705 // Special Notes : The main usage of this function is LOCA.
706 // After each continuation step, LOCA needs to call
707 // this function. LOCA keeps track of solution vectors
708 // on its own, which is why updateSolDataArrays
709 // is inappropriate for LOCA.
710 //
711 // This is necessary for voltage limiting to be
712 // consistent with LOCA.
713 //
714 // Scope : public
715 // Creator : Eric R. Keiter, SNL, 9233.
716 // Creation Date : 3/06/05
717 //-----------------------------------------------------------------------------
718 
720 {
721 #ifdef Xyce_DEBUG_TIME
722  Xyce::dout() << "\nN_TIA_DataStore::updateStateDataArrays " << std::endl;
723 #endif
724  // States:
729 
730  // Stores:
735 
736  // q component of lead current
741 
742  // Derivative of States:
747 
748  // Scaled Divided Differences of states:
753 
754 
755  // Now, make the "next" stuff the same as the "curr" stuff.
756  // This is done because at the end of the tranop, but before
757  // the transient phase starts, the function setConstantHistory
758  // will be called. When it is called, the most recent values
759  // for state variables need to be in the "next" vectors.
760  //
761  // As long as LOCA solves are never used for transient, and only
762  // for DC and tranop solves, this is OK. This is, of course,
763  // a bit of a kludge.
764  *(nextStatePtr) = *(currStatePtr);
765  *(nextStorePtr) = *(currStorePtr);
766 
767  return true;
768 }
769 
770 #ifndef OLD_PLOT
771 //-----------------------------------------------------------------------------
772 // Function : N_TIA_DataStore::outputSolDataArrays
773 // Purpose :
774 // Special Notes :
775 // Scope : public
776 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
777 // Creation Date : 6/29/00
778 //-----------------------------------------------------------------------------
779 
781 {
782  char tmp[256];
783  os << std::endl
784  << Xyce::section_divider << std::endl
785  << std::endl
786  << " Solution Vectors:\n Current Last Olde Error" << std::endl;
787 
788  for (unsigned int k = 0; k < solutionSize; ++k)
789  {
790  os << (*(currSolutionPtr))[k] << (*(lastSolutionPtr))[k] << (*(oldeSolutionPtr))[k] << (*(newtonCorrectionPtr))[k] << std::endl;
791  }
792 
793  os << Xyce::section_divider << std::endl;
794 }
795 
796 #else
797 
798 //-----------------------------------------------------------------------------
799 // Function : N_TIA_DataStore::outputSolDataArrays
800 // Purpose :
801 // Special Notes :
802 // Scope : public
803 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
804 // Creation Date : 6/29/00
805 //-----------------------------------------------------------------------------
806 
807 void N_TIA_DataStore::outputSolDataArrays(std::ostream &os)
808 {
809  for (unsigned int k = 0; k < solutionSize; ++k)
810  {
811  os << "\t" << (*(currSolutionPtr))[0][k] << std::endl;
812  }
813  os << std::endl;
814 }
815 
816 #endif
817 
818 //-----------------------------------------------------------------------------
819 // Function : N_TIA_DataStore::enableOrderOneStart
820 // Purpose : Initialize arrays for "re-starting" integration at order 1.
821 // Special Notes :
822 // Scope : public
823 // Creator : Buddy Watts, SNL
824 // Creation Date : 6/01/00
825 //-----------------------------------------------------------------------------
826 
828 {
829  // solution vectors:
832 
833  nextSolutionDerivPtr->putScalar(0.0);
834  currSolutionDerivPtr->putScalar(0.0);
835  currSolutionDivDiffPtr->putScalar(0.0);
836 
837  // state vectors:
838  *(lastStatePtr) = *(currStatePtr);
839  *(oldeStatePtr) = *(currStatePtr);
840 
841  nextStateDerivPtr->putScalar(0.0);
842  currStateDerivPtr->putScalar(0.0);
843  currStateDivDiffPtr->putScalar(0.0);
844 
845  // store vectors:
846  *(lastStorePtr) = *(currStorePtr);
847  *(oldeStorePtr) = *(currStorePtr);
850  nextStoreLeadCurrQCompDerivPtr->putScalar(0.0);
851  currStoreLeadCurrQCompDerivPtr->putScalar(0.0);
852 
853  return;
854 }
855 
856 //-----------------------------------------------------------------------------
857 // Function : N_TIA_DataStore::outputPredictedSolution
858 // Purpose : Set ErrorEstimate array values to zero.
859 // Special Notes :
860 // Scope : public
861 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
862 // Creation Date : 6/27/00
863 //-----------------------------------------------------------------------------
865 {
866  os << Xyce::subsection_divider << std::endl;
867 
868  os << " Predicted Solution:" << std::endl;
869 
870  for (unsigned int k = 0; k< solutionSize; ++k)
871  {
872  os << (*(nextSolutionPtr))[k] << std::endl;
873  }
874 
875  os << Xyce::subsection_divider << std::endl;
876 }
877 
878 //-----------------------------------------------------------------------------
879 // Function : N_TIA_DataStore::outputPredictedDerivative
880 // Purpose : Set ErrorEstimate array values to zero.
881 // Special Notes :
882 // Scope : public
883 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
884 // Creation Date : 6/27/00
885 //-----------------------------------------------------------------------------
887 {
888  os << Xyce::subsection_divider << std::endl;
889 
890  os << " Predicted Derivative:" << std::endl;
891 
892  for (unsigned int k = 0; k < solutionSize; ++k)
893  {
894  os << (*(nextSolutionDerivPtr))[k] << std::endl;
895  }
896 
897  os << Xyce::subsection_divider << std::endl;
898 }
899 
900 //-----------------------------------------------------------------------------
901 // Function : N_TIA_DataStore::partialErrorNormSum
902 // Purpose : Needed by 2-level solves.
903 //
904 // Special Notes : A weighted RMS norm is this:
905 //
906 // norm = sqrt ( 1/n * sum (x/w)^2 )
907 //
908 // What this function returns is: sum (x/w)^2
909 //
910 // It will later be summed with other patial sums
911 // to get the complete WRMS value.
912 //
913 // Scope : public
914 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
915 // Creation Date : 03/15/06
916 //-----------------------------------------------------------------------------
918 {
919  double errorNorm = 0.0;
920  newtonCorrectionPtr->wRMSNorm(*errWtVecPtr, &errorNorm);
921  double sum = errorNorm*errorNorm;
922  double length = newtonCorrectionPtr->globalLength();
923 
924  sum *= length;
925 
926  return sum;
927 }
928 
929 //-----------------------------------------------------------------------------
930 // Function : N_TIA_DataStore::globalLength
931 // Purpose : Needed by 2-level solves.
932 // Special Notes :
933 // Scope : public
934 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
935 // Creation Date : 03/15/06
936 //-----------------------------------------------------------------------------
938 {
939  return newtonCorrectionPtr->globalLength();
940 }
941 
942 //-----------------------------------------------------------------------------
943 // Function : N_TIA_DataStore::computeDividedDifferences
944 // Purpose : Compute the scaled (by current stepsize) divided difference
945 // approximation to the derivative.
946 // Special Notes :
947 // Scope : public
948 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
949 // Creation Date : 6/27/00
950 //-----------------------------------------------------------------------------
952 {
953  // First do the solution divided difference:
954  nextSolutionDivDiffPtr->linearCombo(1.0, *(nextSolutionPtr), -1.0, *(currSolutionPtr));
955 
956  // Now do the state divided difference:
957  nextStateDivDiffPtr->linearCombo(1.0, *(nextStatePtr), -1.0, *(currStatePtr));
958 
959  return;
960 }
961 
962 //-----------------------------------------------------------------------------
963 // Function : N_TIA_DataStore::computeDivDiffsBlock
964 // Purpose : Compute the scaled (by current stepsize) divided difference
965 // approximation to the derivative. This is the same as
966 // the function "computeDividedDifferences", except that
967 // the operation is only performed on a sub-block of the
968 // vectors.
969 //
970 // Special Notes : Not done yet...
971 // Scope : public
972 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
973 // Creation Date : 01/10/01
974 //-----------------------------------------------------------------------------
976  const std::list<index_pair> & solGIDList,
977  const std::list<index_pair> & staGIDList)
978 {
979 
980 #if 0
982 #endif
983 
984  return;
985 }
986 
987 //-----------------------------------------------------------------------------
988 // Function : N_TIA_DataStore::equateTmpVectors
989 // Purpose : This function equates the 6 temporary vectors with
990 // their "next" vector equivalents. This function
991 // is neccessary for the nonlinear solver damping loop.
992 // Special Notes :
993 // Scope : public
994 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
995 // Creation Date : 01/24/02
996 //-----------------------------------------------------------------------------
998 {
999  // next solution vector:
1001 
1002  // next state vector:
1003  *(tmpStaVectorPtr) = *(nextStatePtr);
1004 
1005  // next store vector:
1006  *(tmpStoVectorPtr) = *(nextStorePtr);
1007 
1008  // next state divided difference vector:
1010 
1011  // next state derivative vector:
1013 
1014  return true;
1015 }
1016 
1017 //-----------------------------------------------------------------------------
1018 // Function : N_TIA_DataStore::usePreviousSolAsPredictor
1019 // Purpose :
1020 // Special Notes :
1021 // Scope : public
1022 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1023 // Creation Date : 6/28/01
1024 //-----------------------------------------------------------------------------
1026 {
1027  bool bsuccess = true;
1028 
1030  *(nextStatePtr) = *(currStatePtr);
1031  *(nextStorePtr) = *(currStorePtr);
1032 
1033  return bsuccess;
1034 }
1035 
1036 //-----------------------------------------------------------------------------
1037 // Function : N_TIA_DataStore::setNextSolVectorPtr
1038 // Purpose :
1039 // Special Notes : Only needed for NOX, and other solvers that prefer to
1040 // own the solution vector.
1041 //
1042 // Scope : public
1043 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1044 // Creation Date : 4/22/03
1045 //-----------------------------------------------------------------------------
1046 bool N_TIA_DataStore::setNextSolVectorPtr (N_LAS_Vector * solVecPtr)
1047 {
1048  // only save the old pointer if it hasn't been switched yet.
1049  if (!nextSolPtrSwitched)
1050  {
1052  nextSolPtrSwitched = true;
1053  }
1054  nextSolutionPtr = solVecPtr;
1055  return true;
1056 }
1057 
1058 //-----------------------------------------------------------------------------
1059 // Function : N_TIA_DataStore::unsetNextSolVectorPtr
1060 // Purpose :
1061 // Special Notes : This also copies over the solution, in addition to the
1062 // pointer.
1063 //
1064 // This is only called when it is time to rotate the
1065 // pointers for the next time step. If we have been
1066 // running with NOX, or with some other solver that prefers
1067 // to own the solution vector, this is neccessary, and the
1068 // switch flag should be set. Otherwise, not.
1069 //
1070 // Basically, if we've been running with NOX, then the next
1071 // solution vector ptr has probably been switched out at least
1072 // once. We need to maintain the history, so we make a
1073 // copy of this switched solution vector, and the
1074 // restore the old pointer.
1075 //
1076 // This is kludgy, but will have to do for now.
1077 //
1078 // Scope : public
1079 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1080 // Creation Date : 4/22/03
1081 //-----------------------------------------------------------------------------
1083 {
1084  if (nextSolPtrSwitched)
1085  {
1088  nextSolPtrSwitched = false;
1089  }
1090  return true;
1091 }
1092 
1093 // new-DAE data store functions:
1094 
1095 
1096 //-----------------------------------------------------------------------------
1097 // Function : N_TIA_DataStore::setZeroHistory
1098 // Purpose : Sets everything to zero.
1099 // Special Notes :
1100 // Scope : public
1101 // Creator : Eric Keiter, SNL
1102 // Creation Date : 1/24/07
1103 //-----------------------------------------------------------------------------
1105 {
1106 #ifdef Xyce_DEBUG_TIME
1107  Xyce::dout() << "\nN_TIA_DataStore::setZeroHistory" << std::endl;
1108 #endif
1109  // Solutions:
1110  nextSolutionPtr->putScalar(0.0);
1111  nextSolutionDerivPtr->putScalar(0.0);
1112  nextSolutionDivDiffPtr->putScalar(0.0);
1113 
1114  // States:
1115  nextStatePtr->putScalar(0.0);
1116  nextStateDerivPtr->putScalar(0.0);
1117  nextStateDivDiffPtr->putScalar(0.0);
1118  nextStorePtr->putScalar(0.0);
1119  nextStoreLeadCurrQCompPtr->putScalar(0.0);
1120 
1121  qErrWtVecPtr->putScalar(0.0);
1122 
1123  // DAE formulation vectors
1124  daeQVectorPtr->putScalar(0.0);
1125  daeFVectorPtr->putScalar(0.0);
1126 
1127  // Predictors
1128  xn0Ptr->putScalar(0.0);
1129  qn0Ptr->putScalar(0.0);
1130  qpn0Ptr->putScalar(0.0);
1131  sn0Ptr->putScalar(0.0);
1132  spn0Ptr->putScalar(0.0);
1133  stoQCn0Ptr->putScalar(0.0);
1134  stoQCpn0Ptr->putScalar(0.0);
1135 
1136  // Nonlinear solution vector:
1137  qNewtonCorrectionPtr->putScalar(0.0);
1138  sNewtonCorrectionPtr->putScalar(0.0);
1139  stoNewtonCorrectionPtr->putScalar(0.0);
1140  stoLeadCurrQCompNewtonCorrectionPtr->putScalar(0.0);
1141 
1142  // Step-size selection temporary vectors
1143  delta_x->putScalar(0.0);
1144  delta_q->putScalar(0.0);
1145 
1146  // Temporary vector for WaMPDE interpolation
1147  tmpXn0APtr->putScalar(0.0);
1148  tmpXn0BPtr->putScalar(0.0);
1149 
1150  // This just sets the "oldDAE" history vectors to zero.
1151  setConstantHistory ();
1152 
1153  // new-DAE history:
1154  int sizeOfHistory = xHistory.size();
1155  for (int i=0;i<sizeOfHistory;++i)
1156  {
1157  (xHistory[i])->putScalar(0.0);
1158  (qHistory[i])->putScalar(0.0);
1159  (sHistory[i])->putScalar(0.0);
1160  (stoHistory[i])->putScalar(0.0);
1161  (stoLeadCurrQCompHistory[i])->putScalar(0.0);
1162  }
1163 }
1164 
1165 //-----------------------------------------------------------------------------
1166 // Function : N_TIA_DataStore::setErrorWtVector_
1167 // Purpose : Set the Error Weight Vector (defined in terms of the
1168 // solution approximation and error tolerances).
1169 // Special Notes :
1170 // Scope : public
1171 // Creator : Eric Keiter, SNL,Parallel Computational Sciences
1172 // Creation Date : 5/25/05
1173 //-----------------------------------------------------------------------------
1175 {
1176  // to avoid several conditionals within a loop we traverse many times, we'll
1177  // presort the variables into types so we can loop without also making conditional
1178  // checks
1179  if( ! indexVecsInitialized )
1180  {
1181  // figure out which unknowns are V's, I's or masked.
1182  numVVars = 0;
1183  numIVars = 0;
1184  numMaskedVars = 0;
1185 
1186  bool nTDMF=lasSysPtr->getNonTrivialDeviceMaskFlag();
1187 
1188  // first count how many of each type we have
1189  for (int k = 0; k < solutionSize; ++k)
1190  {
1191  if (nTDMF && (*(deviceMaskPtr))[k] == 0.0)
1192  {
1193  numMaskedVars++;
1194  }
1195  else if( (tiaParamsPtr_->fastTests == true) && (varTypeVec[k] == 'I') )
1196  {
1197  // we only count I vars if we're doing fast tests, otherwise we treat them as v vars
1198  numIVars++;
1199  }
1200  else
1201  {
1202  numVVars++;
1203  }
1204  }
1205 
1206  // set up our storage
1207  indexVVars.resize(numVVars);
1208  indexIVars.resize(numIVars);
1210 
1211  // now fill the index arrays
1212  for (int k = 0, currI = 0, currV = 0, currM = 0 ; k < solutionSize; ++k)
1213  {
1214  if (nTDMF && (*(deviceMaskPtr))[k] == 0.0)
1215  {
1216  indexMaskedVars[currM] = k;
1217  currM++;
1218  }
1219  else if( (tiaParamsPtr_->fastTests == true) && (varTypeVec[k] == 'I') )
1220  {
1221  indexIVars[currI] = k;
1222  currI++;
1223  }
1224  else
1225  {
1226  indexVVars[currV] = k;
1227  currV++;
1228  }
1229  }
1230 
1231  indexVecsInitialized = true;
1232  }
1233 
1234 #ifdef Xyce_DEBUG_TIME
1235  char tmp[256];
1236 
1237  if (tiaParamsPtr_->debugLevel > 1)
1238  {
1239  Xyce::dout() << Xyce::section_divider << std::endl
1240  << "N_TIA_DataStore::setErrorWtVector" << std::endl << std::endl
1241  << " errorWtVector currSolution relErrorTol absErrorTol" << std::endl
1242  << " -------------- -------------- -------------- --------------" << std::endl;
1243  }
1244 #endif
1245 
1246  if (tiaParamsPtr_->newLte == true)
1247 // if (tiaParamsPtr_->integrationMethod == 7 && tiaParamsPtr_->newLte == true)
1248  {
1249  double currMaxValue = 0.0;
1250  currSolutionPtr->infNorm(&currMaxValue);
1251 
1252  errWtVecPtr->putScalar(currMaxValue);
1253 
1254 #ifdef Xyce_DEBUG_TIME
1255  if (tiaParamsPtr_->debugLevel > 0)
1256  {
1257  std::vector<int> index(1, -1);
1258  currSolutionPtr->infNormIndex( &index[0] );
1259  Xyce::dout() << "currMaxValue = " << currMaxValue << ", currMaxValueIndex = " << index[0] << std::endl;
1260  }
1261 #endif // Xyce_DEBUG_TIME
1262  }
1263  else
1264  {
1265  errWtVecPtr->absValue(*currSolutionPtr);
1266 
1267 #ifdef Xyce_DEBUG_TIME
1268  if (tiaParamsPtr_->debugLevel > 0)
1269  {
1270  double currMaxValue = 0.0;
1271  currSolutionPtr->infNorm(&currMaxValue);
1272  std::vector<int> index(1, -1);
1273  currSolutionPtr->infNormIndex( &index[0] );
1274  Xyce::dout() << "currMaxValueoldLte = " << currMaxValue << ", currMaxValueIndex = " << index[0] << std::endl;
1275  }
1276 #endif
1277  }
1278 
1279  qErrWtVecPtr->absValue(*daeQVectorPtr);
1280 
1281  if( tiaParamsPtr_->fastTests == true )
1282  {
1283  // Voltage variables
1284  for (int k = 0; k < numVVars; ++k)
1285  {
1286 // errWtVecPtr->putScalar(currMaxValue);
1288  {
1289  (*(errWtVecPtr))[indexVVars[k]] = N_UTL_MachineDependentParams::MachineBig();
1290  (*(qErrWtVecPtr))[indexVVars[k]] = N_UTL_MachineDependentParams::MachineBig();
1291  }
1292  else
1293  {
1294  (*(errWtVecPtr))[indexVVars[k]] = (*(relErrTolPtr))[indexVVars[k]] * (*(errWtVecPtr))[indexVVars[k]] + (*(absErrTolPtr))[indexVVars[k]];
1296  }
1297  }
1298 
1299 
1300  // Current variables
1301  for (int k = 0; k < numIVars; ++k)
1302  {
1303 // errWtVecPtr->absValue(*currSolutionPtr);
1305  {
1306  (*(errWtVecPtr))[indexIVars[k]] = N_UTL_MachineDependentParams::MachineBig();
1307  (*(qErrWtVecPtr))[indexIVars[k]] = N_UTL_MachineDependentParams::MachineBig();
1308  }
1309  else
1310  {
1311  (*(errWtVecPtr))[indexIVars[k]] = (*(errWtVecPtr))[indexIVars[k]] + (*(absErrTolPtr))[indexIVars[k]];
1312  (*(qErrWtVecPtr))[indexIVars[k]] = (*(qErrWtVecPtr))[indexIVars[k]] + (*(absErrTolPtr))[indexIVars[k]];
1313  }
1314  }
1315 
1316  // Masked variables
1317  for (int k = 0; k < numMaskedVars; ++k)
1318  {
1319  (*(errWtVecPtr))[indexMaskedVars[k]] = (*(qErrWtVecPtr))[indexMaskedVars[k]] = N_UTL_MachineDependentParams::MachineBig();
1320  }
1321  }
1322  else
1323  {
1324  // Voltage variables
1325  for (int k = 0; k < numVVars; ++k)
1326  {
1327 // errWtVecPtr->putScalar(currMaxValue);
1328  (*(errWtVecPtr))[indexVVars[k]] = (*(relErrTolPtr))[indexVVars[k]] * (*(errWtVecPtr))[indexVVars[k]] + (*(absErrTolPtr))[indexVVars[k]];
1330  }
1331 
1332  // Current variables
1333  // if fastTests == false, then I vars are treated with V vars above.
1334 
1335  // Masked variables
1336  for (int k = 0; k < numMaskedVars; ++k)
1337  {
1338  (*(errWtVecPtr))[indexMaskedVars[k]] = (*(qErrWtVecPtr))[indexMaskedVars[k]] = N_UTL_MachineDependentParams::MachineBig();
1339  }
1340 
1341  }
1342 
1343 #ifdef Xyce_DEBUG_TIME
1344  for (int k = 0; k < solutionSize; ++k)
1345  {
1346  if (tiaParamsPtr_->debugLevel > 1)
1347  {
1348  sprintf(tmp,"%16.6e%16.6e%16.6e%16.6e",
1349  (*(errWtVecPtr)) [k],
1350  (*(currSolutionPtr)) [k],
1351  (*(relErrTolPtr)) [k],
1352  (*(absErrTolPtr)) [k]);
1353 
1354  Xyce::dout() << tmp << std::endl;
1355  }
1356  }
1357 #endif
1358 
1359 #ifdef Xyce_DEBUG_TIME
1360  if (tiaParamsPtr_->debugLevel > 1)
1361  {
1362  Xyce::dout() << "" << std::endl
1363  << Xyce::section_divider << std::endl;
1364  }
1365 #endif
1366  return;
1367 }
1368 
1369 //-----------------------------------------------------------------------------
1370 // Function : N_TIA_DataStore::WRMS_errorNorm
1371 // Purpose :
1372 // Special Notes :
1373 // Scope : public
1374 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1375 // Creation Date : 5/25/05
1376 //-----------------------------------------------------------------------------
1378 {
1379  double errorNorm = 0.0, qErrorNorm = 0.0;
1380  newtonCorrectionPtr->wRMSNorm(*errWtVecPtr, &errorNorm);
1381  qNewtonCorrectionPtr->wRMSNorm(*qErrWtVecPtr, &qErrorNorm);
1382 
1383 #ifdef Xyce_EXTDEV
1384 #ifdef Xyce_DEBUG_TIME
1385  if (tiaParamsPtr_->debugLevel > 1)
1386  {
1387  Xyce::dout() << "N_TIA_DataStore::errorNorm = " << errorNorm << std::endl;
1388  Xyce::dout() << "N_TIA_DataStore::qErrorNorm = " << qErrorNorm << std::endl;
1389  }
1390 #endif
1391 
1392  // This is for handling the total errorNorm for 2-level solves.
1393  //
1394  // Note: This version of the function assumes that the error norm
1395  // and q-error norm are the same size. (they have to be...)
1396  if ( !(innerErrorInfoVec.empty()) )
1397  {
1398  double upperSize = newtonCorrectionPtr->globalLength();
1399  int sumSize = innerErrorInfoVec.size();
1400 
1401  double totalSize = upperSize;
1402  double totalSum = errorNorm*errorNorm*upperSize;
1403  double totalQSum = qErrorNorm*qErrorNorm*upperSize;
1404 
1405  for (int i=0;i<sumSize;++i)
1406  {
1407  double innerSum = innerErrorInfoVec[i].xErrorSum;
1408  double innerQSum = innerErrorInfoVec[i].qErrorSum;
1409  double innerSize = innerErrorInfoVec[i].innerSize;
1410 
1411 #ifdef Xyce_DEBUG_TIME
1412  Xyce::dout() << "DSdae:innerSum["<<i<<"] = " << innerSum <<std::endl;
1413  Xyce::dout() << "DSdae:innerQSum["<<i<<"] = " << innerQSum <<std::endl;
1414  Xyce::dout() << "DSdae:innerSize["<<i<<"] = " << innerSize <<std::endl;
1415 #endif
1416 
1417  totalSize += innerSize;
1418  totalSum += innerSum;
1419  totalQSum += innerQSum;
1420  }
1421 
1422  double recip = 1.0/totalSize;
1423  errorNorm = sqrt(recip*totalSum);
1424  qErrorNorm = sqrt(recip*totalQSum);
1425 
1426 #ifdef Xyce_DEBUG_TIME
1427  Xyce::dout() << "DSdae:upperSize = " << upperSize << std::endl;
1428  Xyce::dout() << "DSdae:totalSum = " << totalSum << std::endl;
1429  Xyce::dout() << "DSdae:totalQSum = " << totalQSum << std::endl;
1430  Xyce::dout() << "DSdae:totalSize = " << totalSize << std::endl;
1431  Xyce::dout() << "DSdae:2-level errorNorm = " << errorNorm << std::endl;
1432  Xyce::dout() << "DSdae:2-level qErrorNorm = " << qErrorNorm << std::endl;
1433 #endif
1434  }
1435 #endif
1436 
1437 #ifndef Xyce_USE_Q_NORM
1438  //errorNorm = errorNorm;
1439 #else
1440  errorNorm = sqrt(0.5*errorNorm*errorNorm+0.5*qErrorNorm*qErrorNorm);
1441 #endif
1442  return errorNorm;
1443 }
1444 
1445 //-----------------------------------------------------------------------------
1446 // Function : N_TIA_DataStore::partialQErrorNormSum
1447 // Purpose : Needed by 2-level solves. This is the Q-vector version
1448 // of this function.
1449 //
1450 // Special Notes : A weighted RMS norm is this:
1451 //
1452 // norm = sqrt ( 1/n * sum (x/w)^2 )
1453 //
1454 // What this function returns is: sum (x/w)^2
1455 //
1456 // It will later be summed with other patial sums
1457 // to get the complete WRMS value.
1458 //
1459 // Scope : public
1460 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1461 // Creation Date : 03/15/06
1462 //-----------------------------------------------------------------------------
1464 {
1465  double qErrorNorm = 0.0;
1466  qNewtonCorrectionPtr->wRMSNorm(*qErrWtVecPtr, &qErrorNorm);
1467  double sum = qErrorNorm*qErrorNorm;
1468  double length = qNewtonCorrectionPtr->globalLength();
1469  sum *= length;
1470 
1471  return sum;
1472 }
1473 
1474 //-----------------------------------------------------------------------------
1475 // Function : N_TIA_DataStore::partialSum_m1
1476 // Purpose : Needed by 2-level solves.
1477 //
1478 // Special Notes : A weighted RMS norm is this:
1479 //
1480 // norm = sqrt ( 1/n * sum (x/w)^2 )
1481 //
1482 // What this function returns is: sum (x/w)^2
1483 //
1484 // It will later be summed with other patial sums
1485 // to get the complete WRMS value.
1486 //
1487 // Scope : public
1488 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1489 // Creation Date : 03/15/07
1490 //-----------------------------------------------------------------------------
1491 double N_TIA_DataStore::partialSum_m1 (int currentOrder)
1492 {
1493  double sum = 0.0;
1494 
1495  if (currentOrder>1)
1496  {
1497  delta_x->linearCombo(1.0,*(xHistory[currentOrder]),1.0,*newtonCorrectionPtr);
1498  double norm = 0.0;
1499  delta_x->wRMSNorm(*errWtVecPtr, &norm);
1500  sum = norm*norm;
1501  double length = newtonCorrectionPtr->globalLength();
1502  sum *= length;
1503  }
1504 
1505  return sum;
1506 }
1507 
1508 //-----------------------------------------------------------------------------
1509 // Function : N_TIA_DataStore::partialSum_m2
1510 // Purpose : Needed by 2-level solves.
1511 //
1512 // Special Notes : A weighted RMS norm is this:
1513 //
1514 // norm = sqrt ( 1/n * sum (x/w)^2 )
1515 //
1516 // What this function returns is: sum (x/w)^2
1517 //
1518 // It will later be summed with other patial sums
1519 // to get the complete WRMS value.
1520 //
1521 // Scope : public
1522 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1523 // Creation Date : 03/15/07
1524 //-----------------------------------------------------------------------------
1525 double N_TIA_DataStore::partialSum_m2 (int currentOrder)
1526 {
1527  double sum = 0.0;
1528 
1529  if (currentOrder>2)
1530  {
1531  delta_x->linearCombo(1.0,*(xHistory[currentOrder]),1.0,*newtonCorrectionPtr);
1532  delta_x->linearCombo(1.0,*(xHistory[currentOrder-1]),1.0,*delta_x);
1533  double norm = 0.0;
1534  delta_x->wRMSNorm(*errWtVecPtr, &norm);
1535  sum = norm*norm;
1536  double length = newtonCorrectionPtr->globalLength();
1537  sum *= length;
1538  }
1539 
1540  return sum;
1541 }
1542 
1543 //-----------------------------------------------------------------------------
1544 // Function : N_TIA_DataStore::partialSum_p1
1545 // Purpose : Needed by 2-level solves.
1546 //
1547 // Special Notes : A weighted RMS norm is this:
1548 //
1549 // norm = sqrt ( 1/n * sum (x/w)^2 )
1550 //
1551 // What this function returns is: sum (x/w)^2
1552 //
1553 // It will later be summed with other patial sums
1554 // to get the complete WRMS value.
1555 //
1556 // Scope : public
1557 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1558 // Creation Date : 03/15/07
1559 //-----------------------------------------------------------------------------
1560 double N_TIA_DataStore::partialSum_p1 (int currentOrder, int maxOrder)
1561 {
1562  double sum = 0.0;
1563 
1564  if (currentOrder<maxOrder)
1565  {
1566  delta_x->linearCombo(1.0,*newtonCorrectionPtr,-1.0,*(xHistory[currentOrder+1]));
1567  double norm = 0.0;
1568  delta_x->wRMSNorm(*errWtVecPtr, &norm);
1569  sum = norm*norm;
1570  double length = newtonCorrectionPtr->globalLength();
1571  sum *= length;
1572  }
1573 
1574  return sum;
1575 }
1576 
1577 //-----------------------------------------------------------------------------
1578 // Function : N_TIA_DataStore::partialSum_q1
1579 // Purpose : Needed by 2-level solves.
1580 //
1581 // Special Notes : A weighted RMS norm is this:
1582 //
1583 // norm = sqrt ( 1/n * sum (x/w)^2 )
1584 //
1585 // What this function returns is: sum (x/w)^2
1586 //
1587 // It will later be summed with other patial sums
1588 // to get the complete WRMS value.
1589 //
1590 // Scope : public
1591 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1592 // Creation Date : 03/15/07
1593 //-----------------------------------------------------------------------------
1595 {
1596  double sum = 0.0;
1597 
1598  double norm = 0.0;
1599  (qHistory[1])->wRMSNorm(*qErrWtVecPtr, &norm);
1600 
1601  sum = norm*norm;
1602  double length = qNewtonCorrectionPtr->globalLength();
1603  sum *= length;
1604 
1605  return sum;
1606 }
1607 
1608 //-----------------------------------------------------------------------------
1609 // Function : N_TIA_DataStore::delta_x_errorNorm_m1
1610 // Purpose :
1611 // Special Notes :
1612 // Scope : public
1613 // Creator : Eric Keiter
1614 // Creation Date : 03/15/07
1615 //-----------------------------------------------------------------------------
1617 {
1618  double errorNorm = 0.0;
1619  delta_x->wRMSNorm(*errWtVecPtr, &errorNorm);
1620 
1621 #ifdef Xyce_EXTDEV
1622  // This is for handling the total errorNorm for 2-level solves.
1623  // It really should get a separate overloaded function.
1624  if ( !(innerErrorInfoVec.empty()) )
1625  {
1626  double upperSize = newtonCorrectionPtr->globalLength();
1627  int sumSize = innerErrorInfoVec.size();
1628 
1629  double totalSize = upperSize;
1630  double totalSum = errorNorm*errorNorm*upperSize;
1631 
1632  for (int i=0;i<sumSize;++i)
1633  {
1634  double innerSum = innerErrorInfoVec[i].xErrorSum_m1;
1635  double innerSize = innerErrorInfoVec[i].innerSize;
1636 
1637  totalSize += innerSize;
1638  totalSum += innerSum;
1639  }
1640 
1641  double recip = 1.0/totalSize;
1642  errorNorm = sqrt(recip*totalSum);
1643  }
1644 #endif
1645 
1646  return errorNorm;
1647 }
1648 
1649 //-----------------------------------------------------------------------------
1650 // Function : N_TIA_DataStore::delta_x_errorNorm_m2
1651 // Purpose :
1652 // Special Notes :
1653 // Scope : public
1654 // Creator : Eric Keiter
1655 // Creation Date : 03/15/07
1656 //-----------------------------------------------------------------------------
1658 {
1659  double errorNorm = 0.0;
1660  delta_x->wRMSNorm(*errWtVecPtr, &errorNorm);
1661 
1662 #ifdef Xyce_EXTDEV
1663  // This is for handling the total errorNorm for 2-level solves.
1664  // It really should get a separate overloaded function.
1665  if ( !(innerErrorInfoVec.empty()) )
1666  {
1667  double upperSize = newtonCorrectionPtr->globalLength();
1668  int sumSize = innerErrorInfoVec.size();
1669 
1670  double totalSize = upperSize;
1671  double totalSum = errorNorm*errorNorm*upperSize;
1672 
1673  for (int i=0;i<sumSize;++i)
1674  {
1675  double innerSum = innerErrorInfoVec[i].xErrorSum_m2;
1676  double innerSize = innerErrorInfoVec[i].innerSize;
1677 
1678  totalSize += innerSize;
1679  totalSum += innerSum;
1680  }
1681 
1682  double recip = 1.0/totalSize;
1683  errorNorm = sqrt(recip*totalSum);
1684  }
1685 #endif
1686 
1687  return errorNorm;
1688 }
1689 
1690 //-----------------------------------------------------------------------------
1691 // Function : N_TIA_DataStore::delta_x_errorNorm_p1
1692 // Purpose :
1693 // Special Notes :
1694 // Scope : public
1695 // Creator : Eric Keiter
1696 // Creation Date : 03/15/07
1697 //-----------------------------------------------------------------------------
1699 {
1700  double errorNorm = 0.0;
1701  delta_x->wRMSNorm(*errWtVecPtr, &errorNorm);
1702 
1703 #ifdef Xyce_EXTDEV
1704  // This is for handling the total errorNorm for 2-level solves.
1705  // It really should get a separate overloaded function.
1706  if ( !(innerErrorInfoVec.empty()) )
1707  {
1708  double upperSize = newtonCorrectionPtr->globalLength();
1709  int sumSize = innerErrorInfoVec.size();
1710 
1711  double totalSize = upperSize;
1712  double totalSum = errorNorm*errorNorm*upperSize;
1713 
1714  for (int i=0;i<sumSize;++i)
1715  {
1716  double innerSum = innerErrorInfoVec[i].xErrorSum_p1;
1717  double innerSize = innerErrorInfoVec[i].innerSize;
1718 
1719  totalSize += innerSize;
1720  totalSum += innerSum;
1721  }
1722 
1723  double recip = 1.0/totalSize;
1724  errorNorm = sqrt(recip*totalSum);
1725  }
1726 #endif
1727 
1728  return errorNorm;
1729 }
1730 
1731 //-----------------------------------------------------------------------------
1732 // Function : N_TIA_DataStore::delta_x_errorNorm_q1
1733 // Purpose :
1734 // Special Notes :
1735 // Scope : public
1736 // Creator : Eric Keiter
1737 // Creation Date : 03/15/07
1738 //-----------------------------------------------------------------------------
1740 {
1741  double errorNorm = 0.0;
1742  (qHistory[1])->wRMSNorm(*qErrWtVecPtr, &errorNorm);
1743 
1744 #ifdef Xyce_EXTDEV
1745 
1746  // This is for handling the total errorNorm for 2-level solves.
1747  // It really should get a separate overloaded function.
1748  if ( !(innerErrorInfoVec.empty()) )
1749  {
1750  double upperSize = newtonCorrectionPtr->globalLength();
1751  int sumSize = innerErrorInfoVec.size();
1752 
1753  double totalSize = upperSize;
1754  double totalSum = errorNorm*errorNorm*upperSize;
1755 
1756  for (int i=0;i<sumSize;++i)
1757  {
1758  double innerSum = innerErrorInfoVec[i].q1HistorySum;
1759  double innerSize = innerErrorInfoVec[i].innerSize;
1760 
1761  totalSize += innerSize;
1762  totalSum += innerSum;
1763  }
1764 
1765  double recip = 1.0/totalSize;
1766  errorNorm = sqrt(recip*totalSum);
1767  }
1768 
1769 #endif
1770 
1771  return errorNorm;
1772 }
1773 
1774 //-----------------------------------------------------------------------------
1775 // Function : N_TIA_DataStore::stepLinearCombo
1776 // Purpose : setup the newtonCorrection vectors.
1777 // Special Notes :
1778 // Scope : public
1779 // Creator : Eric Keiter
1780 // Creation Date : 02/20/07
1781 //-----------------------------------------------------------------------------
1783 {
1784  // 03/16/04 tscoffe: update the newton correction. Note: this should be
1785  // available from NOX, but for now I'm going to do the difference anyway.
1786  newtonCorrectionPtr->linearCombo (1.0,*nextSolutionPtr,-1.0,*xn0Ptr);
1787 
1788  // We need to compute the correction in Q here
1789  // I'm assuming dsDaePtr_->daeQVectorPtr will be fresh from the end of the
1790  // nonlinear solve.
1791  qNewtonCorrectionPtr->linearCombo (1.0,*daeQVectorPtr,-1.0,*qn0Ptr);
1792 
1793  // We also need a State correction between the time steps
1794  sNewtonCorrectionPtr->linearCombo (1.0,*nextStatePtr,-1.0,*sn0Ptr);
1795 
1796  // We also need a Store correction between the time steps
1797  stoNewtonCorrectionPtr->linearCombo (1.0,*nextStorePtr,-1.0,*ston0Ptr);
1799 
1800 #ifdef Xyce_DEBUG_TIME
1801  if (tiaParamsPtr_->debugLevel > 1)
1802  {
1803  Xyce::dout() << "\n newtonCorrection: \n" << std::endl;
1804  newtonCorrectionPtr->printPetraObject(Xyce::dout());
1805  Xyce::dout() << std::endl;
1806  Xyce::dout() << "\n qNewtonCorrection: \n" << std::endl;
1807  qNewtonCorrectionPtr->printPetraObject(Xyce::dout());
1808  Xyce::dout() << "\n sNewtonCorrection: \n" << std::endl;
1809  sNewtonCorrectionPtr->printPetraObject(Xyce::dout());
1810  Xyce::dout() << std::endl;
1811  }
1812 #endif // Xyce_DEBUG_TIME
1813 
1814  return;
1815 }
1816 
1817 //-----------------------------------------------------------------------------
1818 // Function : N_TIA_DataStore::getSolnVarData
1819 // Purpose :
1820 // Special Notes :
1821 // Scope : public
1822 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1823 // Creation Date : 7/27/06
1824 //-----------------------------------------------------------------------------
1825 bool N_TIA_DataStore::getSolnVarData( const int & gid,
1826  std::vector<double> & varData )
1827 {
1828  varData.resize(22);
1829  int i=0;
1830  varData[i++] = tmpSolVectorPtr->getElementByGlobalIndex( gid );
1831  varData[i++] = currSolutionPtr->getElementByGlobalIndex( gid );
1832  varData[i++] = lastSolutionPtr->getElementByGlobalIndex( gid );
1833  varData[i++] = nextSolutionPtr->getElementByGlobalIndex( gid );
1834  varData[i++] = currSolutionDerivPtr->getElementByGlobalIndex( gid );
1835  varData[i++] = lastSolutionDerivPtr->getElementByGlobalIndex( gid );
1836  varData[i++] = nextSolutionDerivPtr->getElementByGlobalIndex( gid );
1837  varData[i++] = currSolutionDivDiffPtr->getElementByGlobalIndex( gid );
1838  varData[i++] = lastSolutionDivDiffPtr->getElementByGlobalIndex( gid );
1839  varData[i++] = nextSolutionDivDiffPtr->getElementByGlobalIndex( gid );
1840  varData[i++] = errWtVecPtr->getElementByGlobalIndex( gid );
1841  varData[i++] = absErrTolPtr->getElementByGlobalIndex( gid );
1842  varData[i++] = relErrTolPtr->getElementByGlobalIndex( gid );
1843  varData[i++] = newtonCorrectionPtr->getElementByGlobalIndex( gid );
1844  varData[i++] = qErrWtVecPtr->getElementByGlobalIndex ( gid );
1845  varData[i++] = daeQVectorPtr->getElementByGlobalIndex ( gid );
1846  varData[i++] = daeFVectorPtr->getElementByGlobalIndex ( gid );
1847  varData[i++] = xn0Ptr->getElementByGlobalIndex ( gid );
1848  varData[i++] = qn0Ptr->getElementByGlobalIndex ( gid );
1849  varData[i++] = qpn0Ptr->getElementByGlobalIndex ( gid );
1850  varData[i++] = dFdxdVpVectorPtr->getElementByGlobalIndex ( gid );
1851  varData[i++] = dQdxdVpVectorPtr->getElementByGlobalIndex ( gid );
1852  return true;
1853 }
1854 
1855 //-----------------------------------------------------------------------------
1856 // Function : N_TIA_DataStore::getStateVarData
1857 // Purpose :
1858 // Special Notes :
1859 // Scope : public
1860 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1861 // Creation Date : 7/27/06
1862 //-----------------------------------------------------------------------------
1863 bool N_TIA_DataStore::getStateVarData( const int & gid,
1864  std::vector<double> & varData )
1865 {
1866  int i=0;
1867  varData.resize( 14 );
1868  varData[i++] = tmpStaVectorPtr->getElementByGlobalIndex( gid );
1869  varData[i++] = tmpStaDerivPtr->getElementByGlobalIndex( gid );
1870  varData[i++] = tmpStaDivDiffPtr->getElementByGlobalIndex( gid );
1871  varData[i++] = currStatePtr->getElementByGlobalIndex( gid );
1872  varData[i++] = lastStatePtr->getElementByGlobalIndex( gid );
1873  varData[i++] = nextStatePtr->getElementByGlobalIndex( gid );
1874  varData[i++] = currStateDerivPtr->getElementByGlobalIndex( gid );
1875  varData[i++] = lastStateDerivPtr->getElementByGlobalIndex( gid );
1876  varData[i++] = nextStateDerivPtr->getElementByGlobalIndex( gid );
1877  varData[i++] = currStateDivDiffPtr->getElementByGlobalIndex( gid );
1878  varData[i++] = lastStateDivDiffPtr->getElementByGlobalIndex( gid );
1879  varData[i++] = nextStateDivDiffPtr->getElementByGlobalIndex( gid );
1880  varData[i++] = sn0Ptr->getElementByGlobalIndex( gid );
1881  varData[i++] = spn0Ptr->getElementByGlobalIndex( gid );
1882  return true;
1883 }
1884 
1885 
1886 //-----------------------------------------------------------------------------
1887 // Function : N_TIA_DataStore::getStoreVarData
1888 // Purpose :
1889 // Special Notes :
1890 // Scope : public
1891 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1892 // Creation Date :
1893 //-----------------------------------------------------------------------------
1894 bool N_TIA_DataStore::getStoreVarData( const int & gid,
1895  std::vector<double> & varData )
1896 {
1897  int i=0;
1898  varData.resize( 6 );
1899  varData[i++] = tmpStoVectorPtr->getElementByGlobalIndex( gid );
1900  varData[i++] = currStorePtr->getElementByGlobalIndex( gid );
1901  varData[i++] = lastStorePtr->getElementByGlobalIndex( gid );
1902  varData[i++] = nextStorePtr->getElementByGlobalIndex( gid );
1903  varData[i++] = ston0Ptr->getElementByGlobalIndex( gid );
1904  varData[i++] = stopn0Ptr->getElementByGlobalIndex( gid );
1905  return true;
1906 }
1907 
1908 //-----------------------------------------------------------------------------
1909 // Function : N_TIA_DataStore::setSolnVarData
1910 // Purpose :
1911 // Special Notes :
1912 // Scope : public
1913 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1914 // Creation Date : 7/27/06
1915 //-----------------------------------------------------------------------------
1916 bool N_TIA_DataStore::setSolnVarData( const int & gid,
1917  const std::vector<double> & varData )
1918 {
1919  int i=0;
1920  tmpSolVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1921  currSolutionPtr->setElementByGlobalIndex ( gid, varData[i++] );
1922  lastSolutionPtr->setElementByGlobalIndex ( gid, varData[i++] );
1923  nextSolutionPtr->setElementByGlobalIndex ( gid, varData[i++] );
1924  currSolutionDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1925  lastSolutionDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1926  nextSolutionDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1927  currSolutionDivDiffPtr->setElementByGlobalIndex( gid, varData[i++] );
1928  lastSolutionDivDiffPtr->setElementByGlobalIndex( gid, varData[i++] );
1929  nextSolutionDivDiffPtr->setElementByGlobalIndex( gid, varData[i++] );
1930  errWtVecPtr->setElementByGlobalIndex ( gid, varData[i++] );
1931  absErrTolPtr->setElementByGlobalIndex ( gid, varData[i++] );
1932  relErrTolPtr->setElementByGlobalIndex ( gid, varData[i++] );
1933  newtonCorrectionPtr->setElementByGlobalIndex ( gid, varData[i++] );
1934  qErrWtVecPtr->setElementByGlobalIndex ( gid, varData[i++] );
1935  daeQVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1936  daeFVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1937  xn0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1938  qn0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1939  qpn0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1940  dFdxdVpVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1941  dQdxdVpVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1942  return true;
1943 }
1944 
1945 //-----------------------------------------------------------------------------
1946 // Function : N_TIA_DataStore::setStateVarData
1947 // Purpose :
1948 // Special Notes :
1949 // Scope : public
1950 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1951 // Creation Date : 7/27/06
1952 //-----------------------------------------------------------------------------
1953 bool N_TIA_DataStore::setStateVarData( const int & gid,
1954  const std::vector<double> & varData )
1955 {
1956  int i=0;
1957  tmpStaVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1958  tmpStaDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1959  tmpStaDivDiffPtr->setElementByGlobalIndex ( gid, varData[i++] );
1960  currStatePtr->setElementByGlobalIndex ( gid, varData[i++] );
1961  lastStatePtr->setElementByGlobalIndex ( gid, varData[i++] );
1962  nextStatePtr->setElementByGlobalIndex ( gid, varData[i++] );
1963  currStateDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1964  lastStateDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1965  nextStateDerivPtr->setElementByGlobalIndex ( gid, varData[i++] );
1966  currStateDivDiffPtr->setElementByGlobalIndex( gid, varData[i++] );
1967  lastStateDivDiffPtr->setElementByGlobalIndex( gid, varData[i++] );
1968  nextStateDivDiffPtr->setElementByGlobalIndex( gid, varData[i++] );
1969 
1970  sn0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1971  spn0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1972  return true;
1973 }
1974 
1975 //-----------------------------------------------------------------------------
1976 // Function : N_TIA_DataStore::setStoreVarData
1977 // Purpose :
1978 // Special Notes :
1979 // Scope : public
1980 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
1981 // Creation Date : 7/27/06
1982 //-----------------------------------------------------------------------------
1983 bool N_TIA_DataStore::setStoreVarData( const int & gid,
1984  const std::vector<double> & varData )
1985 {
1986  int i=0;
1987  tmpStoVectorPtr->setElementByGlobalIndex ( gid, varData[i++] );
1988  currStorePtr->setElementByGlobalIndex ( gid, varData[i++] );
1989  lastStorePtr->setElementByGlobalIndex ( gid, varData[i++] );
1990  nextStorePtr->setElementByGlobalIndex ( gid, varData[i++] );
1991  ston0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1992  stopn0Ptr->setElementByGlobalIndex ( gid, varData[i++] );
1993  return true;
1994 }
1995