Ejemplo n.º 1
0
Archivo: graf.c Proyecto: imr/ngspice
void
gr_iplot(struct plot *plot)
{
    struct dbcomm *db;
    int dontpop;        /* So we don't pop w/o push. */
    char buf[30];

    hit = 0;
    for (db = dbs; db; db = db->db_next) {
        if (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL) {

            if (db->db_graphid)
                PushGraphContext(FindGraph(db->db_graphid));

            set(plot, db, FALSE, VF_PLOT);

            dontpop = 0;
            if (iplot(plot, db->db_graphid)) {
                /* graph just assigned */
                db->db_graphid = currentgraph->graphid;
                dontpop = 1;
            }

            set(plot, db, TRUE, VF_PLOT);

            if (!dontpop && db->db_graphid)
                PopGraphContext();

        } else if (db->db_type == DB_TRACENODE || db->db_type == DB_TRACEALL) {

            struct dvec *v, *u;
            int len;

            set(plot, db, FALSE, VF_PRINT);

            len = plot->pl_scale->v_length;

            dontpop = 0;
            for (v = plot->pl_dvecs; v; v = v->v_next) {
                if (v->v_flags & VF_PRINT) {
                    u = plot->pl_scale;
                    if (len <= 1 || hit <= 0 || hit2 < 0) {
                        if (len <= 1 || hit2 < 0)
                            term_clear();
                        else
                            term_home();
                        hit = 1;
                        hit2 = 1;
                        printf(
                            "\tExecution trace (remove with the \"delete\" command)");
                        term_cleol();
                        printf("\n");

                        if (u) {
                            printf("%12s:", u->v_name);
                            if (isreal(u)) {
                                printf("%s",
                                       getitright(buf, u->v_realdata[len - 1]));
                            } else {
                                /* MW. Complex data here, realdata is NULL
                                   (why someone use realdata here again) */
                                printf("%s",
                                       getitright(buf, u->v_compdata[len - 1].cx_real));
                                printf(", %s",
                                       getitright(buf, u->v_compdata[len - 1].cx_imag));
                            }
                            term_cleol();
                            printf("\n");
                        }
                    }
                    if (v == u)
                        continue;
                    printf("%12s:", v->v_name);
                    if (isreal(v)) {
                        printf("%s", getitright(buf, v->v_realdata[len - 1]));
                    } else {
                        /* MW. Complex data again */
                        printf("%s", getitright(buf, v->v_compdata[len - 1].cx_real));
                        printf(", %s", getitright(buf, v->v_compdata[len - 1].cx_imag));
                    }
                    term_cleol();
                    printf("\n");
                }
            }
            set(plot, db, TRUE, VF_PRINT);
        }
    }
}
Ejemplo n.º 2
0
void CDelphiFastSOR::postItr(const vector<delphi_real>& rmaxl,const vector<delphi_real>& rmsl)
{
   /*
    * remap into phimap
    */
   for (delphi_integer iy = 0; iy < (iGrid*iGrid*iGrid-1)/2; iy++)
   {
      delphi_integer ix = iy*2;
      prgfPhiMap[ix]   = phimap1[iy];
      prgfPhiMap[ix+1] = phimap2[iy];
   }
   prgfPhiMap[iGrid*iGrid*iGrid-1] = phimap1[iHalfGridNum-1];

#ifdef VERBOSE
   cout << endl;
   cout << "finished qdiffx linear iterations "; pTimer->showTime(); cout << endl;
   cout << "total time elapsed so far: "; pTimer->showElapse(); cout << endl;
   //cout << "mean,max change (kT/e)   : " << rmsch2 << " " << rmxch2 << endl;
#endif

   /*
    * plot convergence history
    */
   if (bLogGraph)
   {
      int iclr = 1, iscl = 1, imk = 0, iplt = 0;
      char symb = 'M';
      string title = "    linear iteration convergence history   ";
      vector<string> iplot(nyran,strEmpty60);
      delphi_real ymin,ymax;

      conplt(rmaxl,title,iclr,iscl,imk,iplt,symb,1,iLinIterateNum,iplot,ymin,ymax);

      iclr = 0;
      conplt(rmsl,title,iclr,iscl,imk,iplt,symb,1,iLinIterateNum,iplot,ymin,ymax);

      iscl = 0; imk = 1;
      conplt(rmaxl,title,iclr,iscl,imk,iplt,symb,1,iLinIterateNum,iplot,ymin,ymax);

      symb = 'A'; iplt = 1;
      conplt(rmsl,title,iclr,iscl,imk,iplt,symb,1,iLinIterateNum,iplot,ymin,ymax);
   }

   /*
    * give some intermediate output of phi
    */
   if (bLogPotential)
   {
      int m,n,nn,ii;
      const delphi_real *** phimap = pdc->getKey_constPtr<delphi_real>("phimap",iGrid,iGrid,iGrid); // pointer to 3D phimap
      int midg = (iGrid+1)/2;
      for (m = 1; m <= 5; m++)
      {
         n = (iGrid-1)/4; nn = (m-1)*n+1;
         cout << "phi " << "  " << right << nn << "   " << right << midg << endl;
         for (ii = 1; ii <= iGrid; ii++)
            cout << right << phimap[ii-1][midg-1][nn-1] << "   ";
         cout << endl << endl;
      }
   }

}