Xyce  6.1
N_DEV_2DPDE_Output.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-2015 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_DEV_2DPDE_Output.C,v $
27 //
28 // Purpose : This file contains just the output functions of the
29 // N_DEV_2DPDE and N_DEV_2DPDEInstance classes.
30 //
31 // Special Notes :
32 //
33 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
34 //
35 // Creation Date : 06/17/03
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.48.2.1 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:20:12 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 // ---------- Standard Includes ----------
50 #include <iostream>
51 #include <N_UTL_Math.h>
52 
53 // ---------- Xyce Includes ----------
54 #include <N_DEV_2DPDE.h>
55 #include <N_DEV_SolverState.h>
56 #include <N_DEV_DeviceOptions.h>
57 #include <N_DEV_Message.h>
58 
59 #include <N_DEV_PDE_2DMesh.h>
60 #include <N_DEV_SGF_Interface.h>
61 
62 #include <N_LAS_Vector.h>
63 #include <N_LAS_System.h>
64 
65 namespace Xyce {
66 namespace Device {
67 namespace TwoDPDE {
68 
69 //-----------------------------------------------------------------------------
70 // Function : Instance::outputPlotFiles
71 // Purpose :
72 // Special Notes :
73 // Scope : public
74 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
75 // Creation Date : 07/22/03
76 //-----------------------------------------------------------------------------
78 {
79  bool bsuccess = true;
80  bool bs1 = true;
81  bool skipOutput = false;
82 
83  // usually, don't bother outputting nonlinear Poisson result.
84  if (equationSet == 0 && !outputNLPoisson) return bsuccess;
85 
86  // If using output interval, check if enough time has passed to do
87  // another output. (only applies for transient - not DCOP).
88  if ( !(getSolverState().dcopFlag) &&
89  !(getSolverState().forceFinalOutput) &&
90  given("OUTPUTINTERVAL") )
91  {
92  double outMult = static_cast<double> (outputIndex);
93  double nextOutputTime = outMult * outputInterval;
94 
95  if (nextOutputTime > getSolverState().currTime)
96  {
97  skipOutput = true;
98  }
99  }
100 
101  // If this is a "forced" final output, make sure that it didn't already output.
102  // This can happen if the output interval is an exact multiple of the
103  // total simulation time.
105 
106  if (skipOutput) return bsuccess;
107  ++outputIndex;
109 
110  if (DEBUG_DEVICE)
111  {
112  Xyce::dout() << std::endl << "Doing an output at time = " << getSolverState().currTime << std::endl;
113  }
114 
115  if (tecplotLevel > 0)
116  {
117  bs1 = outputTecplot ();
118  bsuccess = bsuccess && bs1;
119  }
120 
121  if (tecplotLevel > 2)
122  {
123  bs1 = outputTecplotVectors ();
124  bsuccess = bsuccess && bs1;
125  }
126 
127  if (sgplotLevel > 0)
128  {
129  bs1 = outputSgplot ();
130  bsuccess = bsuccess && bs1;
131  }
132 
133  if (gnuplotLevel > 0)
134  {
135  bs1 = outputGnuplot ();
136  bsuccess = bsuccess && bs1;
137  }
138 
139  if (txtDataLevel > 0)
140  {
141  bs1 = outputTxtData ();
142  bsuccess = bsuccess && bs1;
143  }
144 
145  return bsuccess;
146 }
147 
148 //-----------------------------------------------------------------------------
149 // Function : Instance::tecplotGeomOutput
150 //
151 // Purpose : This function outputs the reactor geometry
152 // information for a tecplot file.
153 // Special Notes :
154 // Scope : public
155 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
156 // Creation Date : 04/25/02
157 //-----------------------------------------------------------------------------
158 
160 {
161  UINT iNodeA,iNodeB;
162 
163  // output the geometries:
164  UINT iE;
165  UINT iNumG = iNumPlotEdges/50 + 1;
166  UINT iNumF = iNumPlotEdges - (iNumG-1)*50;
167 
168  UINT iGnum = 1;
169  fprintf(fp1,"%s","\n GEOMETRY M=GRID, C=BLACK, X= .00, Y= .00,");
170  fprintf(fp1,"%s"," T=LINE, F=POINT, LT=0.8\n");
171 
172  if(iGnum == iNumG) fprintf(fp1,"\t%d\n",iNumF);
173  else fprintf(fp1,"\t%d\n",50);
174 
175  double x1,y1,x2,y2;
176  UINT itmp = 2;
177  UINT icount = 0;
178 
179  for(iE = 0;iE<numMeshEdges;++iE)
180  {
181  if(aiEdge[iE] == 1)
182  {
183  mEdge * edgePtr = meshContainerPtr->getEdge(iE);
184 
185  ++icount;
186  iNodeA = edgePtr->inodeA;
187  iNodeB = edgePtr->inodeB;
188  x1 = xVec[iNodeA];
189  y1 = yVec[iNodeA];
190  x2 = xVec[iNodeB];
191  y2 = yVec[iNodeB];
192 
193  if (variablesScaled)
194  {
195  x1 = x1 * scalingVars.x0;
196  x2 = x2 * scalingVars.x0;
197  y1 = y1 * scalingVars.x0;
198  y2 = y2 * scalingVars.x0;
199  }
200 
201  fprintf(fp1,"%4d\n%11.3e %11.3e\n%11.3e %11.3e\n",
202  itmp,x1,y1,x2,y2);
203  }
204 
205  if(icount >= 50)
206  {
207  icount = 0;
208  ++iGnum;
209  if(iGnum == iNumG)
210  {
211  if(iNumF != 0)
212  {
213  fprintf(fp1,"%s","\n GEOMETRY M=GRID, C=BLACK, X= .00,");
214  fprintf(fp1,"%s"," Y= .00,");
215  fprintf(fp1,"%s"," T=LINE, F=POINT, LT=0.8\n");
216  fprintf(fp1,"\t%d\n",iNumF);}
217  }
218  else
219  {
220  fprintf(fp1,"%s","\n GEOMETRY M=GRID, C=BLACK, X= .00,");
221  fprintf(fp1,"%s"," Y= .00,");
222  fprintf(fp1,"%s"," T=LINE, F=POINT, LT=0.8\n");
223  fprintf(fp1,"\t%d\n",50);
224  }
225  }
226  }
227 
228  fprintf(fp1,"%s","\n");
229 
230  // Now do the "noflux" edges.
231  iNumG = iNumPlotEdges_nf/50 + 1;
232  iNumF = iNumPlotEdges_nf - (iNumG-1)*50;
233 
234  iGnum = 1;
235  fprintf(fp1,"%s","\n GEOMETRY M=GRID, C=RED, X= .00, Y= .00,");
236  fprintf(fp1,"%s"," T=LINE, F=POINT, LT=0.2\n");
237 
238  if(iGnum == iNumG) fprintf(fp1,"\t%d\n",iNumF);
239  else fprintf(fp1,"\t%d\n",50);
240 
241  itmp = 2;
242  icount = 0;
243 
244  for(iE = 0;iE<numMeshEdges;++iE)
245  {
246  if(aiEdge_nf[iE] == 1)
247  {
248  mEdge * edgePtr = meshContainerPtr->getEdge(iE);
249 
250  ++icount;
251  iNodeA = edgePtr->inodeA;
252  iNodeB = edgePtr->inodeB;
253  x1 = xVec[iNodeA];
254  y1 = yVec[iNodeA];
255  x2 = xVec[iNodeB];
256  y2 = yVec[iNodeB];
257 
258  if (variablesScaled)
259  {
260  x1 = x1 * scalingVars.x0;
261  x2 = x2 * scalingVars.x0;
262  y1 = y1 * scalingVars.x0;
263  y2 = y2 * scalingVars.x0;
264  }
265 
266  fprintf(fp1,"%4d\n%11.3e %11.3e\n%11.3e %11.3e\n",
267  itmp,x1,y1,x2,y2);
268  }
269 
270  if(icount >= 50)
271  {
272  icount = 0;
273  ++iGnum;
274  if(iGnum == iNumG)
275  {
276  if(iNumF != 0)
277  {
278  fprintf(fp1,"%s","\n GEOMETRY M=GRID, C=RED, X= .00,");
279  fprintf(fp1,"%s"," Y= .00,");
280  fprintf(fp1,"%s"," T=LINE, F=POINT, LT=0.2\n");
281  fprintf(fp1,"\t%d\n",iNumF);}
282  }
283  else
284  {
285  fprintf(fp1,"%s","\n GEOMETRY M=GRID, C=RED, X= .00,");
286  fprintf(fp1,"%s"," Y= .00,");
287  fprintf(fp1,"%s"," T=LINE, F=POINT, LT=0.2\n");
288  fprintf(fp1,"\t%d\n",50);
289  }
290  }
291  }
292 
293  fprintf(fp1,"%s","\n");
294 
295  return true;
296 }
297 
298 //-----------------------------------------------------------------------------
299 // Function : Instance::outputTecplot
300 // Purpose :
301 // Special Notes : If tecplot level is set to 1, then output each dataset
302 // in a separate file. If not, then append to a single file.
303 // Scope : public
304 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
305 // Creation Date : 11/14/01
306 //-----------------------------------------------------------------------------
308 {
309  bool bsuccess = true;
310  bool bs1 = true;
311 
312  int i;
313  char filename[32]; for(i=0;i<32;++i) filename[i] = static_cast<char>(0);
314 
315  if (tecplotLevel == 1)
316  {
317  sprintf(filename,"%s_%03d.dat",outputName.c_str(),callsOTEC);
318  }
319  else
320  {
321  sprintf(filename,"%s.dat",outputName.c_str());
322  }
323 
324  double time = getSolverState().currTime;
325 
326  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
327  {
328  Xyce::dout() << std::endl;
329  Xyce::dout() << section_divider << std::endl;
330  Xyce::dout() << "In Instance::outputTecplot. filename = ";
331  Xyce::dout() << std::string(filename);
332  Xyce::dout() << std::endl;
333  }
334 
335  FILE *fp1;
336 
337  if (tecplotLevel == 1)
338  {
339  fp1 = fopen(filename,"w");
340  }
341  else
342  {
343  if (callsOTEC <= 0)
344  {
345  fp1 = fopen(filename,"w");
346  }
347  else
348  {
349  fp1 = fopen(filename,"a");
350  }
351  }
352 
353  double Ex, Ey;
354  double V2x, V2y;
355  double V1x, V1y;
356  double V0x, V0y;
357 
358  double dDx_dt, dDy_dt;
359  double D2x, D2y;
360  double D1x, D1y;
361  double D0x, D0y;
362 
363  double xLoc, yLoc;
364  double dx1, dy1;
365 
366  if (tecplotLevel == 1)
367  {
368  if (equationSet == 0)
369  {
370  fprintf(fp1,
371  " TITLE = \"Spatially Dependent data for 2D PDE: %s time = %12.4e seconds. equation set = nonlinear Poisson\",\n",
372  outputName.c_str(),time);
373  }
374  else
375  {
376  fprintf(fp1,
377  " TITLE = \"Spatially Dependent data for 2D PDE: %s time = %12.4e seconds. equation set = drift diffusion\",\n",
378  outputName.c_str(),time);
379  }
380  }
381  else
382  {
383  if (callsOTEC <= 0)
384  {
385  fprintf(fp1,
386  " TITLE = \"Spatially Dependent data for 2D PDE: %s time = %12.4e seconds.\",\n",
387  outputName.c_str(),time);
388  }
389  }
390 
391  if (callsOTEC <= 0 || tecplotLevel == 1)
392  {
393  if (cylGeomFlag)
394  fprintf(fp1,"%s","\tVARIABLES = \"R (cm) \",\"Z (cm)\",\n");
395  else
396  fprintf(fp1,"%s","\tVARIABLES = \"X (cm) \",\"Y (cm)\",\n");
397 
398  fprintf(fp1,"%s","\t \"V \",\n");
399  fprintf(fp1,"%s","\t \"nn (electron dens.) \",\n");
400  fprintf(fp1,"%s","\t \"np (hole dens.) \",\n");
401  fprintf(fp1,"%s","\t \"Dopant dens. \",\n");
402  fprintf(fp1,"%s","\t \"abs(Dopant dens.)\",\n");
403  fprintf(fp1,"%s","\t \"total density\",\n");
404  fprintf(fp1,"%s","\t \"electron lifetime \",\n");
405  fprintf(fp1,"%s","\t \"hole lifetime \",\n");
406  fprintf(fp1,"%s","\t \"electron mobility \",\n");
407  fprintf(fp1,"%s","\t \"hole mobility \",\n");
408 
409  if (tecplotLevel > 1)
410  {
411  fprintf(fp1,"%s","\t \"Ex \",\n");
412  fprintf(fp1,"%s","\t \"Ey \",\n");
413  fprintf(fp1,"%s","\t \"Emag \",\n");
414  fprintf(fp1,"%s","\t \"dDx_dt \",\n");
415  fprintf(fp1,"%s","\t \"dDy_dt \",\n");
416  fprintf(fp1,"%s","\t \"dDmag_dt \",\n");
417  }
418 
419  fprintf(fp1,"%s","\t \"Recombination \",\n");
420  fprintf(fp1,"%s","\t \"photogen \",\n");
421  fprintf(fp1,"%s","\t \"total src \",\n");
422  }
423 
424  fprintf(fp1,"\tZONE F=FEPOINT,ET=QUADRILATERAL,N=%d,E=%d",
426 
427  if (getSolverState().dcopFlag)
428  {
429  fprintf(fp1," T = \"DCOP step = %d\" \n", callsOTEC);
430  }
431  else
432  {
433  fprintf(fp1," T = \"time step = %d\" time = %12.4e seconds\" \n", callsOTEC , time);
434  }
435 
436  if (variablesScaled)
437  {
438  for (i=0;i<numMeshPoints;++i)
439  {
440  xLoc = xVec[i];
441  yLoc = yVec[i];
442 
443  double xLocS = xLoc * scalingVars.x0;
444  double yLocS = yLoc * scalingVars.x0;
445 
446  fprintf(fp1," %12.4e",xLocS);
447  fprintf(fp1," %12.4e",yLocS);
448  fprintf(fp1," %12.4e",VVec[i]*scalingVars.V0);
449  fprintf(fp1," %12.4e",nnVec[i]*scalingVars.C0);
450  fprintf(fp1," %12.4e",npVec[i]*scalingVars.C0);
451  double C = CVec[i]*scalingVars.C0;
452  fprintf(fp1," %12.4e",C);
453  fprintf(fp1," %12.4e",fabs(C));
454  double totCharge = (npVec[i]*scalingVars.C0-nnVec[i]*scalingVars.C0+C);
455  fprintf(fp1," %12.4e",totCharge);
456  fprintf(fp1," %12.4e",tnVec[i]*scalingVars.t0);
457  fprintf(fp1," %12.4e",tpVec[i]*scalingVars.t0);
458  fprintf(fp1," %12.4e",unVec[i]*scalingVars.u0);
459  fprintf(fp1," %12.4e",upVec[i]*scalingVars.u0);
460 
461  if (tecplotLevel > 1)
462  {
463  dx1 = dy1 = 0.5 * minDXVec[i];
464 
466  if (lPtr->uType == TYPE_REGION)
467  {
468  // electric field:
469  V2x = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLocS+dx1, yLocS));
470  V1x = scalingVars.V0*VVec[i];
471  V0x = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLocS-dx1, yLocS));
472  Ex = -0.5 * ( (V2x-V1x)+(V1x-V0x) )/dx1;
473 
474  V2y = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLocS, yLocS+dy1));
475  V1y = scalingVars.V0*VVec[i];
476  V0y = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLocS, yLocS-dy1));
477  Ey = -0.5 * ( (V2y-V1y)+(V1y-V0y) )/dy1;
478 
479 
480  // displacement current:
481  D2x = (meshContainerPtr->interp(&(displPotential[0]),xLocS+dx1, yLocS));
482  D1x = displPotential[i];
483  D0x = (meshContainerPtr->interp(&(displPotential[0]),xLocS-dx1, yLocS));
484 
485  dDx_dt = -0.5 * ( (D2x-D1x)+(D1x-D0x) )/dx1;
486  dDx_dt *= eSi * e0;
487 
488  D2y = (meshContainerPtr->interp(&(displPotential[0]),xLocS, yLocS+dy1));
489  D1y = displPotential[i];
490  D0y = (meshContainerPtr->interp(&(displPotential[0]),xLocS, yLocS-dy1));
491 
492  dDy_dt = -0.5 * ( (D2y-D1y)+(D1y-D0y) )/dy1;
493  dDy_dt *= eSi * e0;
494 
495  }
496  else
497  {
498  Ex = 0.0;
499  Ey = 0.0;
500  dDx_dt = 0.0;
501  dDy_dt = 0.0;
502  }
503 
504  fprintf(fp1," %12.4e",Ex);
505  fprintf(fp1," %12.4e",Ey);
506  fprintf(fp1," %12.4e",sqrt(Ex*Ex + Ey*Ey) );
507 
508  fprintf(fp1," %12.4e",dDx_dt);
509  fprintf(fp1," %12.4e",dDy_dt);
510  fprintf(fp1," %12.4e",sqrt(dDx_dt*dDx_dt + dDy_dt*dDy_dt) );
511  }
512 
513  fprintf(fp1," %12.4e",RVec[i]*scalingVars.R0);
514  fprintf(fp1," %12.4e",SVec[i]*scalingVars.R0);
515  fprintf(fp1," %12.4e",totSrcVec[i]*scalingVars.R0);
516  fprintf(fp1,"%s","\n");
517  }
518  }
519  else
520  {
521  for (i=0;i<numMeshPoints;++i)
522  {
523  xLoc = xVec[i];
524  yLoc = yVec[i];
525 
526  fprintf(fp1," %12.4e",xLoc);
527  fprintf(fp1," %12.4e",yLoc);
528  fprintf(fp1," %12.4e",VVec[i]);
529  fprintf(fp1," %12.4e",nnVec[i]);
530  fprintf(fp1," %12.4e",npVec[i]);
531  double C = CVec[i];
532  fprintf(fp1," %12.4e",C);
533  fprintf(fp1," %12.4e",fabs(C));
534  double totCharge = (npVec[i]-nnVec[i]+C);
535  fprintf(fp1," %12.4e",totCharge);
536  fprintf(fp1," %12.4e",tnVec[i]);
537  fprintf(fp1," %12.4e",tpVec[i]);
538  fprintf(fp1," %12.4e",unVec[i]);
539  fprintf(fp1," %12.4e",upVec[i]);
540 
541  if (tecplotLevel > 1)
542  {
543  dx1 = dy1 = 0.5 * minDXVec[i];
545 
546  if (lPtr->uType == TYPE_REGION)
547  {
548  // electric field:
549  V2x = (meshContainerPtr->interp(&(VVec[0]),xLoc+dx1, yLoc));
550  V1x = VVec[i];
551  V0x = (meshContainerPtr->interp(&(VVec[0]),xLoc-dx1, yLoc));
552  Ex = -0.5 * ( (V2x-V1x)+(V1x-V0x) )/dx1;
553 
554  V2y = (meshContainerPtr->interp(&(VVec[0]),xLoc, yLoc+dy1));
555  V1y = VVec[i];
556  V0y = (meshContainerPtr->interp(&(VVec[0]),xLoc, yLoc-dy1));
557  Ey = -0.5 * ( (V2y-V1y)+(V1y-V0y) )/dy1;
558 
559  // displacement current:
560  D2x = (meshContainerPtr->interp(&(displPotential[0]),xLoc+dx1, yLoc));
561  D1x = displPotential[i];
562  D0x = (meshContainerPtr->interp(&(displPotential[0]),xLoc-dx1, yLoc));
563 
564  dDx_dt = -0.5 * ( (D2x-D1x)+(D1x-D0x) )/dx1;
565  dDx_dt *= eSi * e0;
566 
567  D2y = (meshContainerPtr->interp(&(displPotential[0]),xLoc, yLoc+dy1));
568  D1y = displPotential[i];
569  D0y = (meshContainerPtr->interp(&(displPotential[0]),xLoc, yLoc-dy1));
570 
571  dDy_dt = -0.5 * ( (D2y-D1y)+(D1y-D0y) )/dy1;
572  dDy_dt *= eSi * e0;
573  }
574  else
575  {
576  Ex = 0.0;
577  Ey = 0.0;
578  dDx_dt = 0.0;
579  dDy_dt = 0.0;
580  }
581 
582  fprintf(fp1," %12.4e",Ex);
583  fprintf(fp1," %12.4e",Ey);
584  fprintf(fp1," %12.4e",sqrt(Ex*Ex + Ey*Ey) );
585 
586  fprintf(fp1," %12.4e",dDx_dt);
587  fprintf(fp1," %12.4e",dDy_dt);
588  fprintf(fp1," %12.4e",sqrt(dDx_dt*dDx_dt + dDy_dt*dDy_dt) );
589  }
590 
591  fprintf(fp1," %12.4e",RVec[i]);
592  fprintf(fp1," %12.4e",SVec[i]);
593  fprintf(fp1," %12.4e",totSrcVec[i]);
594  fprintf(fp1,"%s","\n");
595  }
596  }
597 
598  fprintf(fp1,"%s","\n");
599 
600  for(UINT iTri=0; iTri<numMeshCells; ++iTri)
601  {
602  UINT inodeA,inodeB,inodeC,inodeD;
603 
604  mCell * cellPtr = meshContainerPtr->getCell(iTri);
605 
606  inodeA = cellPtr->inodeA;
607  inodeB = cellPtr->inodeB;
608  inodeC = cellPtr->inodeC;
609  inodeD = cellPtr->inodeD;
610 
611  if(inodeD == -1u) inodeD = inodeC;
612 
613  if((inodeA == -1u || inodeB == -1u ||
614  inodeC == -1u || inodeD == -1u) ||
615  (inodeA == inodeB) || (inodeA == inodeC) ||
616  (inodeB == inodeC))
617  {
618  fprintf(stdout,"%s","Error in ::outputTecplot\n");
619  fprintf(stdout,"inodeA = %d\n",inodeA);
620  fprintf(stdout,"inodeB = %d\n",inodeB);
621  fprintf(stdout,"inodeC = %d\n",inodeC);
622  fprintf(stdout,"inodeD = %d\n",inodeD);
623  }
624 
625  // output
626  fprintf(fp1,"%d %d %d %d\n",
627  inodeA+1,
628  inodeB+1,
629  inodeC+1,
630  inodeD+1);
631  }
632 
633  if (tecplotLevel >= 1)
634  {
635  if (callsOTEC<=0)
636  {
637  bs1 = tecplotGeomOutput(fp1);
638  bsuccess = bsuccess && bs1;
639  }
640  }
641 
642  ++callsOTEC;
643  fclose(fp1);
644 
645  return bsuccess;
646 }
647 
648 //-----------------------------------------------------------------------------
649 // Function : Instance::outputTecplotVectors
650 // Purpose : This function outputs a tecplot file which contains vector
651 // data. It does this by performing interpolations on the
652 // unstructured grid. As such, for testing purposed it also
653 // outputs some interpolated scalar data.
654 // Special Notes :
655 // Scope : public
656 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
657 // Creation Date : 11/14/01
658 //-----------------------------------------------------------------------------
660 {
661  bool bsuccess = true;
662 
663  int i, j;
664  char filename[32]; for(i=0;i<32;++i) filename[i] = static_cast<char>(0);
665 
666  sprintf(filename,"%s_%03dVec.dat",outputName.c_str(),callsOTECvec);
667  ++callsOTECvec;
668 
669  double time = getSolverState().currTime;
670 
671  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
672  {
673  Xyce::dout() << std::endl;
674  Xyce::dout() << section_divider << std::endl;
675  Xyce::dout() << "In Instance::outputTecplotVectors. filename = ";
676  Xyce::dout() << std::string(filename);
677  Xyce::dout() << std::endl;
678  }
679 
680  FILE *fp1 = fopen(filename,"w");
681 
682  // set up the cartesian grid with which to perform interpolations:
683  double tmp;
684  double xMax = meshContainerPtr->getXMax ();
685  double xMin = meshContainerPtr->getXMin ();
686  if (xMin > xMax)
687  {
688  tmp = xMax;
689  xMax = xMin;
690  xMin = tmp;
691  }
692 
693  double yMax = meshContainerPtr->getYMax ();
694  double yMin = meshContainerPtr->getYMin ();
695  if (yMin > yMax)
696  {
697  tmp = yMax;
698  yMax = yMin;
699  yMin = tmp;
700  }
701 
702  double DeltaX = xMax - xMin;
703  double DeltaY = yMax - yMin;
704 
705  int inx;
706  int iny;
707 
708  int iNumMeshPoints = interpGridSize;
709 
710  // Have one (the shorter one) of the axes have iNumMeshPoints "mesh" points.
711  if (DeltaX < DeltaY)
712  { inx = iNumMeshPoints; iny = static_cast<int> (iNumMeshPoints * fabs(DeltaY/DeltaX)); }
713  else
714  { iny = iNumMeshPoints; inx = static_cast<int> (iNumMeshPoints * fabs(DeltaX/DeltaY)); }
715 
716  double dx = fabs(DeltaX/static_cast<double>(inx));
717  double dx1 = dx*0.5;
718  double dy = fabs(DeltaY/static_cast<double>(iny));
719  double dy1 = dy*0.5;
720 
721  double Ex, Ey;
722  double V2x, V2y;
723  double V1x, V1y;
724  double V0x, V0y;
725 
726  double dDx_dt, dDy_dt;
727  double D2x, D2y;
728  double D1x, D1y;
729  double D0x, D0y;
730 
731  if (DEBUG_DEVICE)
732  {
733  Xyce::dout() << "outputTecplotVectors:\n";
734  Xyce::dout() << "DeltaX = " << DeltaX << std::endl;
735  Xyce::dout() << "DeltaY = " << DeltaY << std::endl;
736 
737  Xyce::dout() << "xMax = " << xMax << std::endl;
738  Xyce::dout() << "xMin = " << xMin << std::endl;
739  Xyce::dout() << "yMax = " << yMax << std::endl;
740  Xyce::dout() << "yMin = " << yMin << std::endl;
741 
742  Xyce::dout() << "dx = " << dx << std::endl;
743  Xyce::dout() << "dy = " << dy << std::endl;
744 
745  Xyce::dout() << "inx = " << inx << std::endl;
746  Xyce::dout() << "iny = " << iny << std::endl;
747  }
748 
749  if (equationSet == 0)
750  {
751  fprintf(fp1,
752  " TITLE = \"Spatially Dependent vector data for 2D PDE: %s time = %12.4e seconds. equation set = nonlinear Poisson\",\n",
753  outputName.c_str(),time);
754  }
755  else
756  {
757  fprintf(fp1,
758  " TITLE = \"Spatially Dependent vector data for 2D PDE: %s time = %12.4e seconds. equation set = drift diffusion\",\n",
759  outputName.c_str(),time);
760  }
761 
762  if (cylGeomFlag)
763  fprintf(fp1,"%s","\tVARIABLES = \"R (cm) \",\"Z (cm)\",\n");
764  else
765  fprintf(fp1,"%s","\tVARIABLES = \"X (cm) \",\"Y (cm)\",\n");
766 
767  fprintf(fp1,"%s","\t \"V \", \n");
768  fprintf(fp1,"%s","\t \"Ex \", \n");
769  fprintf(fp1,"%s","\t \"Ey \", \n");
770  fprintf(fp1,"%s","\t \"Emag \",\n");
771  fprintf(fp1,"%s","\t \"dDx_dt \", \n");
772  fprintf(fp1,"%s","\t \"dDy_dt \", \n");
773  fprintf(fp1,"%s","\t \"Dmag \",\n");
774 
775  fprintf(fp1,"\tZONE I=%d, J=%d, F=POINT\n", iny+1, inx+1);
776 
777  double xLoc, yLoc;
778 
779  if (variablesScaled)
780  {
781  for (i=0;i<inx+1;++i)
782  {
783  xLoc = xMin + static_cast<double>(i) * dx;
784 
785  for (j=0;j<iny+1;++j)
786  {
787  yLoc = yMin + static_cast<double>(j) * dy;
788 
789  fprintf(fp1," %12.4e",xLoc);
790  fprintf(fp1," %12.4e",yLoc);
791  double Vtmp = meshContainerPtr->interp(&(VVec[0]),xLoc,yLoc);
792  double Dtmp = meshContainerPtr->interp(&(displPotential[0]),xLoc,yLoc);
793  fprintf(fp1," %12.4e",Vtmp*scalingVars.V0);
794 
795  if (i>0 && i<inx)
796  {
797  // electric field
798  V2x = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLoc+dx1, yLoc));
799  V1x = scalingVars.V0*Vtmp;
800  V0x = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLoc-dx1, yLoc));
801  Ex = -0.5 * ( (V2x-V1x)+(V1x-V0x) )/dx1;
802 
803  // displacement current:
804  D2x = (meshContainerPtr->interp(&(displPotential[0]),xLoc+dx1, yLoc));
805  D1x = Dtmp;
806  D0x = (meshContainerPtr->interp(&(displPotential[0]),xLoc-dx1, yLoc));
807 
808  dDx_dt = -0.5 * ( (D2x-D1x)+(D1x-D0x) )/dx1;
809  dDx_dt *= eSi * e0;
810  }
811  else
812  {
813  Ex = 0.0;
814  dDx_dt = 0.0;
815  }
816 
817  if (j>0 && j<iny)
818  {
819  // electric field:
820  V2y = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLoc, yLoc+dy1));
821  V1y = scalingVars.V0*Vtmp;
822  V0y = scalingVars.V0* (meshContainerPtr->interp(&(VVec[0]),xLoc, yLoc-dy1));
823  Ey = -0.5 * ( (V2y-V1y)+(V1y-V0y) )/dy1;
824 
825  // displacement current:
826  D2y = (meshContainerPtr->interp(&(displPotential[0]),xLoc, yLoc+dy1));
827  D1y = Dtmp;
828  D0y = (meshContainerPtr->interp(&(displPotential[0]),xLoc, yLoc-dy1));
829 
830  dDy_dt = -0.5 * ( (D2y-D1y)+(D1y-D0y) )/dy1;
831  dDy_dt *= eSi * e0;
832  }
833  else
834  {
835  Ey = 0.0;
836  dDy_dt = 0.0;
837  }
838 
839  fprintf(fp1," %12.4e",Ex);
840  fprintf(fp1," %12.4e",Ey);
841  fprintf(fp1," %12.4e",sqrt(Ex*Ex + Ey*Ey) );
842 
843  fprintf(fp1," %12.4e",dDx_dt);
844  fprintf(fp1," %12.4e",dDy_dt);
845  fprintf(fp1," %12.4e",sqrt(dDx_dt*dDx_dt + dDy_dt*dDy_dt) );
846  fprintf(fp1,"%s","\n");
847  }
848  }
849  }
850  else
851  {
852  for (i=0;i<inx+1;++i)
853  {
854  xLoc = xMin + static_cast<double>(i) * dx;
855  for (j=0;j<iny+1;++j)
856  {
857  yLoc = yMin + static_cast<double>(j) * dy;
858 
859  fprintf(fp1," %12.4e",xLoc);
860  fprintf(fp1," %12.4e",yLoc);
861  double Vtmp = meshContainerPtr->interp(&(VVec[0]),xLoc,yLoc);
862  double Dtmp = meshContainerPtr->interp(&(displPotential[0]),xLoc,yLoc);
863  fprintf(fp1," %12.4e",Vtmp);
864 
865  if (i>0 && i<inx)
866  {
867  // electric field:
868  V2x = (meshContainerPtr->interp(&(VVec[0]),xLoc+dx1, yLoc));
869  V1x = Vtmp;
870  V0x = (meshContainerPtr->interp(&(VVec[0]),xLoc-dx1, yLoc));
871  Ex = -0.5 * ( (V2x-V1x)+(V1x-V0x) )/dx1;
872 
873  // displacement current:
874  D2x = (meshContainerPtr->interp(&(displPotential[0]),xLoc+dx1, yLoc));
875  D1x = Dtmp;
876  D0x = (meshContainerPtr->interp(&(displPotential[0]),xLoc-dx1, yLoc));
877 
878  dDx_dt = -0.5 * ( (D2x-D1x)+(D1x-D0x) )/dx1;
879  dDx_dt *= eSi * e0;
880  }
881  else
882  {
883  Ex = 0.0;
884  dDx_dt = 0.0;
885  }
886 
887  if (j>0 && j<iny)
888  {
889  // electric field:
890  V2y = (meshContainerPtr->interp(&(VVec[0]),xLoc, yLoc+dy1));
891  V1y = Vtmp;
892  V0y = (meshContainerPtr->interp(&(VVec[0]),xLoc, yLoc-dy1));
893  Ey = -0.5 * ( (V2y-V1y)+(V1y-V0y) )/dy1;
894 
895  // displacement current:
896  D2y = (meshContainerPtr->interp(&(displPotential[0]),xLoc, yLoc+dy1));
897  D1y = Dtmp;
898  D0y = (meshContainerPtr->interp(&(displPotential[0]),xLoc, yLoc-dy1));
899 
900  dDy_dt = -0.5 * ( (D2y-D1y)+(D1y-D0y) )/dy1;
901  dDy_dt *= eSi * e0;
902  }
903  else
904  {
905  Ey = 0.0;
906  dDy_dt = 0.0;
907  }
908 
909  fprintf(fp1," %12.4e",Ex);
910  fprintf(fp1," %12.4e",Ey);
911  fprintf(fp1," %12.4e",sqrt(Ex*Ex + Ey*Ey) );
912 
913  fprintf(fp1," %12.4e",dDx_dt);
914  fprintf(fp1," %12.4e",dDy_dt);
915  fprintf(fp1," %12.4e",sqrt(dDx_dt*dDx_dt + dDy_dt*dDy_dt) );
916  fprintf(fp1,"%s","\n");
917  }
918  }
919  }
920 
921  //bool bs1 = true;
922  //bs1 = tecplotGeomOutput(fp1);
923  //bsuccess = bsuccess && bs1;
924 
925  fclose(fp1);
926 
927  return bsuccess;
928 }
929 
930 //-----------------------------------------------------------------------------
931 // Function : Instance::outputGnuplot
932 //
933 // Purpose : This function outputs very simple column data that can
934 // be read by gnuplot, in the form x,y,V,n,p,C.
935 //
936 // Special Notes : It is somewhat easy to do this if we are running with
937 // the internal mesh, which is cartesian in appearance.
938 // If running without a cartesian mesh, then it is
939 // neccessary to do some interpolations.
940 //
941 // Scope : public
942 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
943 // Creation Date : 04/15/03
944 //-----------------------------------------------------------------------------
946 {
947  bool bsuccess = true;
948 
949  int i, j;
950  char filename[32]; for(i=0;i<32;++i) filename[i] = static_cast<char>(0);
951 
952  sprintf(filename,"%s_%03dGnu.dat",outputName.c_str(),callsOGNU);
953  ++callsOGNU;
954 
955  if (!given("NX") || !given("NY"))
956  {
957  bsuccess = false;
958  UserWarning(*this) << "Gnuplot only works if using the internal mesh.";
959  }
960  else
961  {
962  // get the node index vector from the mesh class:
963  int ** nodeIndex = meshContainerPtr->getNodeIndexVector ();
964 
965  int ixMax = numMeshPointsX;
966  int iyMax = numMeshPointsY;
967 
968  FILE *fp1 = fopen(filename,"w");
969 
970  for (j=0;j<iyMax;++j)
971  {
972  for (i=0;i<ixMax;++i)
973  {
974  int index = nodeIndex[i][j];
975  fprintf(fp1,"%12.4e",xVec[index] * scalingVars.x0);
976  fprintf(fp1,"%12.4e",yVec[index] * scalingVars.x0);
977  fprintf(fp1,"%12.4e",VVec[index] * scalingVars.V0);
978  fprintf(fp1,"%12.4e",nnVec[index] * scalingVars.C0);
979  fprintf(fp1,"%12.4e",npVec[index] * scalingVars.C0);
980  fprintf(fp1,"%12.4e",CVec[index] * scalingVars.C0);
981  fprintf(fp1,"%12.4e",fabs(CVec[index] * scalingVars.C0));
982  fprintf(fp1,"%s","\n");
983  }
984  fprintf(fp1,"%s","\n");
985  }
986 
987  fclose (fp1);
988  }
989 
990 
991  return bsuccess;
992 }
993 
994 //-----------------------------------------------------------------------------
995 // Function : Instance::outputTxtData
996 // Purpose : This function outputs data about each time step, that is
997 // easier to read as a text data, than as plotted data.
998 // Special Notes :
999 // Scope : public
1000 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1001 // Creation Date : 04/15/03
1002 //-----------------------------------------------------------------------------
1004 {
1005  bool bsuccess = true;
1006 
1007  int i;
1008  char filename[32]; for(i=0;i<32;++i) filename[i] = static_cast<char>(0);
1009 
1010  sprintf(filename,"%s_data.txt",outputName.c_str());
1011 
1012  double time = getSolverState().currTime;
1013 
1014  FILE *fp1;
1015  if (callsOTXT<=0)
1016  fp1 = fopen(filename,"w");
1017  else
1018  fp1 = fopen(filename,"a");
1019  ++callsOTXT;
1020 
1021  // get maxs and mins.
1022  double VminOut = 1.0e+99;
1023  double VmaxOut =-1.0e+99;
1024  double NnMinOut = 1.0e+99;
1025  double NnMaxOut =-1.0e+99;
1026  double NpMinOut = 1.0e+99;
1027  double NpMaxOut =-1.0e+99;
1028 
1029  for (i=0;i<numMeshPoints; ++i)
1030  {
1031  if (VminOut > ( VVec[i]*scalingVars.V0)) VminOut = ( VVec[i]*scalingVars.V0);
1032  if (VmaxOut < ( VVec[i]*scalingVars.V0)) VmaxOut = ( VVec[i]*scalingVars.V0);
1033  if (NnMinOut > (nnVec[i]*scalingVars.C0)) NnMinOut = (nnVec[i]*scalingVars.C0);
1034  if (NnMaxOut < (nnVec[i]*scalingVars.C0)) NnMaxOut = (nnVec[i]*scalingVars.C0);
1035  if (NpMinOut > (npVec[i]*scalingVars.C0)) NpMinOut = (npVec[i]*scalingVars.C0);
1036  if (NpMaxOut < (npVec[i]*scalingVars.C0)) NpMaxOut = (npVec[i]*scalingVars.C0);
1037  }
1038 
1039  fprintf(fp1,"%s","\n");
1040  fprintf(fp1,"%s","---------------------------------------------------------\n");
1041  if (getSolverState().dcopFlag)
1042  {
1043  fprintf(fp1,"Global data for DC step %4d:\n", callsOTXT);
1044  }
1045  else
1046  {
1047  fprintf(fp1,"Global data for time step %4d:\n", callsOTXT);
1048  }
1049  fprintf(fp1,"Current Time = %12.4e\n" , time);
1050  fprintf(fp1," Vmin = %12.4e\n", VminOut);
1051  fprintf(fp1," Vmax = %12.4e\n", VmaxOut);
1052  fprintf(fp1," NnMin = %12.4e\n", NnMinOut);
1053  fprintf(fp1," NnMax = %12.4e\n", NnMaxOut);
1054  fprintf(fp1," NpMin = %12.4e\n", NpMinOut);
1055  fprintf(fp1," NpMax = %12.4e\n", NpMaxOut);
1056 
1057  fprintf(fp1,"%s","\n");
1058 
1059  // loop over the device interface nodes, sum the currents going into each one.
1060  std::vector<DeviceInterfaceNode>::iterator firstDI = dIVec.begin ();
1061  std::vector<DeviceInterfaceNode>::iterator lastDI = dIVec.end ();
1062  std::vector<DeviceInterfaceNode>::iterator iterDI;
1063 
1064  for (iterDI=firstDI; iterDI!=lastDI; ++iterDI)
1065  {
1066  // loop over the nodes of this device interface node:
1067 
1068  if ( !( meshContainerPtr->labelEdgeType (iterDI->eName) ) ) continue;
1069 
1070  mLabel * labelPtr = meshContainerPtr->getLabel(iterDI->eName);
1071 
1072  fprintf(fp1, "Information for electrode: %s\n", iterDI->eName.c_str());
1073  fprintf(fp1, "potential: %12.4e\n", scalingVars.V0* VVec[iterDI->firstMeshNodeIndex] );
1074  fprintf(fp1, " current: %12.4e\n", iterDI->currentSum);
1075  fprintf(fp1, " charge: %12.4e\n", iterDI->chargeSum);
1076  fprintf(fp1, " dIdVckt: %12.4e\n", iterDI->dIdVckt);
1077  fprintf(fp1, " dQdVckt: %12.4e\n", iterDI->dQdVckt);
1078  fprintf(fp1, "%s","\n");
1079  }
1080 
1081  if (!calcConductanceFlag)
1082  {
1083  fprintf(fp1, "%s","NOTE: The two-level Newton algorithm was not used.\n");
1084  fprintf(fp1, "%s"," This means that the condutances and capacitances\n");
1085  fprintf(fp1, "%s"," were not calculated.\n\n");
1086  }
1087 
1088  int iE1,iE2;
1089 
1090  fprintf(fp1, "%s","Conductance array: \n");
1091  fprintf(fp1,"%s"," ");
1092  for (iE2 = 0; iE2 < numElectrodes; ++iE2)
1093  {
1094  fprintf(fp1,"\t%14s",dIVec[iE2].eName.c_str());
1095  }
1096  fprintf(fp1,"%s","\n");
1097 
1098  for (iE1 = 0; iE1 < numElectrodes; ++iE1)
1099  {
1100  fprintf(fp1,"%14s",dIVec[iE1].eName.c_str());
1101  for (iE2 = 0; iE2 < numElectrodes; ++iE2)
1102  {
1103  fprintf(fp1,"\t%14.4e",condVec[iE1][iE2]);
1104  }
1105  fprintf(fp1,"%s","\n");
1106  }
1107  fprintf(fp1,"%s","\n");
1108 
1109  fprintf(fp1, "%s","Capacitance array: \n");
1110  fprintf(fp1,"%s"," ");
1111  for (iE2 = 0; iE2 < numElectrodes; ++iE2)
1112  {
1113  fprintf(fp1,"\t%14s",dIVec[iE2].eName.c_str());
1114  }
1115  fprintf(fp1,"%s","\n");
1116 
1117  for (iE1 = 0; iE1 < numElectrodes; ++iE1)
1118  {
1119  fprintf(fp1,"%14s",dIVec[iE1].eName.c_str());
1120  for (iE2 = 0; iE2 < numElectrodes; ++ iE2)
1121  {
1122  fprintf(fp1,"\t%14.4e",capVec[iE1][iE2]);
1123  }
1124  fprintf(fp1,"%s","\n");
1125  }
1126  fprintf(fp1,"%s","\n");
1127 
1128  fclose(fp1);
1129 
1130  return bsuccess;
1131 }
1132 
1133 
1134 //-----------------------------------------------------------------------------
1135 // Function : Instance::outputSgplot
1136 // Purpose : This function outputs a file that can be read by the
1137 // plotting program sgplot.
1138 // Special Notes :
1139 // Scope : public
1140 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1141 // Creation Date : 09/30/02
1142 //-----------------------------------------------------------------------------
1144 {
1145  int i;
1146 
1147  // note: number of elements = N*Narray + Nvars.
1148  // N = number of nodes
1149  // Narray = number of arrays
1150  // Nvars = number of non-array variables
1151  // Nconst = number of constants
1152 
1153  UINT Narray = 6; // x,y,V,nn,np,C
1154  UINT Nconst = 3;
1155 
1156  RESHEAD resheadxyce =
1157  { "SGFramework Result File Version 1.0\n\x1a", // text logo
1158  "@~!_RES" "ULT_!~@", // signature
1159  "", // mesh file name
1160  Nconst, // number of constants
1161  0, // number of variables
1162  Narray, // number of arrays
1163  Narray*numMeshPoints, // number of elements
1164  Narray, // number of 1D arrays
1165  0, // number of 2D arrays
1166  0, // number of 3D arrays
1167  1}; // number of data sets
1168 
1169  RESHEAD *presheadxyce = &resheadxyce;
1170 
1171  // fix this:
1172  if (usingInternalMesh) meshFileName = outputName + ".msh";
1173 
1174  strcpy(presheadxyce->szMeshFile, meshFileName.c_str());
1175 
1176  // set up empty axlatconstxyce:
1177  XLATCONST axlatconstxyce[] =
1178  { { "NODES", TYPE_ICONST, { numMeshPoints } },
1179  { "EDGES", TYPE_ICONST, { numMeshEdges } },
1180  { "TRIANGLES", TYPE_ICONST, { numMeshCells } }
1181  };
1182 
1183  DAXLATARRAY AxlatArray(numMeshPoints); // see the constructor
1184 
1185  XLATARRAY *paxlat = AxlatArray.GetPointer(0);
1186 
1187  char filename[32]; for(i=0;i<32;++i) filename[i] = static_cast<char>(0);
1188  sprintf(filename,"%s_%03d.res",outputName.c_str(),callsOSG);
1189  ++callsOSG;
1190 
1191  FILE *nHandle = fopen(filename, "w");
1192 
1193  UINT cConst = Nconst;
1194  // XLATARRAY union fix makes this unneeded
1195  // for(i = 0; i < Nconst; ++i)
1196  // axlatconstxyce[i].data.n = static_cast<int> (axlatconstxyce[i].data.r);
1197 
1198  fwrite(presheadxyce, sizeof(RESHEAD),1,nHandle);
1199  if (cConst) fwrite(axlatconstxyce, sizeof(XLATCONST), cConst, nHandle);
1200  if (Narray ) fwrite( paxlat, sizeof(XLATARRAY), Narray, nHandle);
1201 
1202  // In Kevin's original setup, these two lines are in place.
1203  // The reason for this is so that he can keep adding data sets
1204  // to the same file. To do so, he has to update the cSset
1205  // attribute of RESHEAD, but nothing else. So he rewrites that,
1206  // then goes back to the end of the file.
1207  // Anyway, it isn't neccessary here. I only put one data set in
1208  // any file.
1209  //presheadxyce->cSet++;
1210  //fwrite(presheadxyce, sizeof(RESHEAD),1,nHandle);
1211  //fseek(nHandle, 0L, SEEK_END);
1212 
1213  // output all the data arrays:
1214  for (i=0;i<numMeshPoints;++i) outputVec[i] = scalingVars.x0 * xVec[i];
1215  fwrite( &(outputVec[0]), sizeof(double), numMeshPoints, nHandle);
1216 
1217  for (i=0;i<numMeshPoints;++i) outputVec[i] = scalingVars.x0 * yVec[i];
1218  fwrite( &(outputVec[0]), sizeof(double), numMeshPoints, nHandle);
1219 
1220  for (i=0;i<numMeshPoints;++i) outputVec[i] = scalingVars.V0 * VVec[i];
1221  fwrite( &(outputVec[0]), sizeof(double), numMeshPoints, nHandle);
1222 
1223  for (i=0;i<numMeshPoints;++i) outputVec[i] = scalingVars.C0 * nnVec[i];
1224  fwrite( &(outputVec[0]), sizeof(double), numMeshPoints, nHandle);
1225 
1226  for (i=0;i<numMeshPoints;++i) outputVec[i] = scalingVars.C0 * npVec[i];
1227  fwrite( &(outputVec[0]), sizeof(double), numMeshPoints, nHandle);
1228 
1229  for (i=0;i<numMeshPoints;++i) outputVec[i] = scalingVars.C0 * CVec[i];
1230  fwrite( &(outputVec[0]), sizeof(double), numMeshPoints, nHandle);
1231 
1232  fclose(nHandle);
1233 
1234  return true;
1235 }
1236 
1237 } // namespace TwoDPDE
1238 } // namespace Device
1239 } // namespace Xyce
1240 
1241 //-----------------------------------------------------------------------------
1242 // Function : DAXLATARRAY::set
1243 // Purpose : This function (and class) is only used in the context
1244 // of outputting sgplot files.
1245 // Special Notes :
1246 // Scope : public
1247 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1248 // Creation Date : 09/30/02
1249 //-----------------------------------------------------------------------------
1250 void DAXLATARRAY::set (const char *name, UINT uOffset, UINT cDim, UINT ac0, UINT ac1, UINT ac2)
1251 {
1252  XLATARRAY xlattmp;
1253  char tmpname[LEN_IDENT+1];
1254  int istrl = strlen(name);
1255  int imax;
1256 
1257  if(istrl >= LEN_IDENT-1) imax = LEN_IDENT-1;
1258  else imax = istrl;
1259 
1260  int i;
1261  for(i=0;i<LEN_IDENT+1;++i) tmpname[i] = 0;
1262 
1263  for(i=0;i<imax;++i)
1264  tmpname[i] = name[i];
1265 
1266  sprintf(xlattmp.szName,"%s",tmpname);
1267 
1268  xlattmp.uOffset = uOffset;
1269  xlattmp.cDim = cDim;
1270  xlattmp.acElements[0] = ac0;
1271  xlattmp.acElements[1] = ac1;
1272  xlattmp.acElements[2] = ac2;
1273  Add(xlattmp);
1274 
1275 }
1276 
1277 //-----------------------------------------------------------------------------
1278 // Function : DAXLATARRAY::DAXLATARRAY
1279 // Purpose : constructor
1280 // Special Notes : This function (and class) is only used in the context
1281 // of outputting sgplot files.
1282 // Scope : public
1283 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1284 // Creation Date : 09/30/02
1285 //-----------------------------------------------------------------------------
1286 DAXLATARRAY::DAXLATARRAY(int numMeshPoints)
1287 {
1288  int c = 10;
1289  cElements = 0;
1290  uInc = cSize = c;
1291  dynarray = new XLATARRAY[c];
1292 
1293  char tmpArg[16]; for(int i=0;i<16;++i) tmpArg[i] = 0;
1294 
1295  // set up axlatarrayicp:
1296  set( "x" , 0*numMeshPoints,1,numMeshPoints,0,0);
1297  set( "y" , 1*numMeshPoints,1,numMeshPoints,0,0);
1298  set( "V" , 2*numMeshPoints,1,numMeshPoints,0,0);
1299  set( "Ne", 3*numMeshPoints,1,numMeshPoints,0,0);
1300  set( "Np" , 4*numMeshPoints,1,numMeshPoints,0,0);
1301  set( "C" , 5*numMeshPoints,1,numMeshPoints,0,0);
1302 }
1303 
std::vector< double > RVec
Definition: N_DEV_2DPDE.h:395
UINT Add(XLATARRAY t)
std::vector< double > displPotential
Definition: N_DEV_2DPDE.h:410
#define TYPE_REGION
std::vector< double > CVec
Definition: N_DEV_2DPDE.h:382
bool given(const std::string &parameter_name) const
std::vector< double > outputVec
Definition: N_DEV_2DPDE.h:415
Pure virtual class to augment a linear system.
std::vector< double > totSrcVec
Definition: N_DEV_2DPDE.h:394
bool labelEdgeType(std::string &labelName)
char szName[15+1]
std::vector< double > minDXVec
Definition: N_DEV_2DPDE.h:386
std::vector< UINT > aiEdge
Definition: N_DEV_2DPDE.h:488
std::vector< double > xVec
Definition: N_DEV_2DPDE.h:380
std::vector< double > nnVec
Definition: N_DEV_2DPDE.h:391
#define LEN_IDENT
std::vector< std::vector< double > > condVec
Definition: N_DEV_2DPDE.h:529
std::vector< double > tnVec
Definition: N_DEV_2DPDE.h:402
std::vector< double > VVec
Definition: N_DEV_2DPDE.h:390
std::vector< double > unVec
Definition: N_DEV_2DPDE.h:398
double interp(double *F, double r, double z)
UINT acElements[3]
std::vector< int > labelIndex
Definition: N_DEV_2DPDE.h:499
XLATARRAY * dynarray
std::vector< DeviceInterfaceNode > dIVec
Definition: N_DEV_2DPDE.h:291
DAXLATARRAY(int numMeshPoints)
const SolverState & getSolverState() const
std::vector< double > yVec
Definition: N_DEV_2DPDE.h:381
std::vector< UINT > aiEdge_nf
Definition: N_DEV_2DPDE.h:489
XLATARRAY * GetPointer(UINT i)
std::vector< double > npVec
Definition: N_DEV_2DPDE.h:392
char szMeshFile[128]
std::vector< double > upVec
Definition: N_DEV_2DPDE.h:399
void set(const char *, UINT, UINT, UINT, UINT, UINT)
#define TYPE_ICONST
std::vector< std::vector< double > > capVec
Definition: N_DEV_2DPDE.h:532
std::vector< double > SVec
Definition: N_DEV_2DPDE.h:396
std::vector< double > tpVec
Definition: N_DEV_2DPDE.h:403