Пример #1
0
int  Restart_read( void )
{
   char *me = "Restart_read";
   char dmpname[MAXLINE], msg[256];
   int error, mdmpflag;
   geta(dmpname) ;
   if (!strcmp(dmpname,"last")) {
      strcpy(dmpname,pbnm);
      getdmplst_last(dmpname,"silo",-1,ifparallel);
   }
   if (!strcmp(dmpname,"prev")) {
      strcpy(dmpname,pbnm);
      getdmplst_last(dmpname,"silo",-2,ifparallel);
   }
   if (!strcmp(dmpname,"next")) {
      strcpy(dmpname,pbnm);
      getdmplst_last(dmpname,"silo",-3,ifparallel);
   }
   if (!strcmp(dmpname,"lastwith")) {
      geta(dmpname) ;
      getdmplst_last(dmpname,"silo",-1,ifparallel);
   }
   mdmpflag = 0;
   if (ifparallel) {
     if (strchr(dmpname,'-') != NULL) {
       mdmpflag = 1;
     }
   }
   error = Restart_read_driver(dmpname,mdmpflag,1) ;
   return(error) ;
}
Пример #2
0
void PremultipleChannels()
{
    for (int i = 0; i < skin.iWidth * skin.iHeight; i++)
        skin.colBits[i] = rgba(	getr(skin.colBits[i])*geta(skin.colBits[i])/255,
                                getg(skin.colBits[i])*geta(skin.colBits[i])/255,
                                getb(skin.colBits[i])*geta(skin.colBits[i])/255,
                                geta(skin.colBits[i]));
}
Пример #3
0
int blend_color(int from, int to, double t)
{
  int r = getr(from) + static_cast<int>((getr(to) - getr(from)) * t);
  int g = getg(from) + static_cast<int>((getg(to) - getg(from)) * t);
  int b = getb(from) + static_cast<int>((getb(to) - getb(from)) * t);
  int a = geta(from) + static_cast<int>((geta(to) - geta(from)) * t);
  return makeacol(MID(0, r, 255),
		  MID(0, g, 255),
		  MID(0, b, 255),
		  MID(0, a, 255));
}
Пример #4
0
term(int a)
{	/* item | monadic item | (expr) | */
	ADDR e;

	switch ((int)readchar()) {

	case '*':
		term(a|1);
		if (geta(cormap, expv, &e) < 0)
			error("%r");
		expv = e;
		return(1);

	case '@':
		term(a|1);
		if (geta(symmap, expv, &e) < 0)
			error("%r");
		expv = e;
		return(1);

	case '-':
		term(a|1);
		expv = -expv;
		return(1);

	case '~':
		term(a|1);
		expv = ~expv;
		return(1);

	case '(':
		expr(2);
		if (readchar()!=')')
			error("syntax error: `)' expected");
		return(1);

	default:
		reread();
		return(item(a));
	}
}
Пример #5
0
int SubMesh_parse( void ) {
   char *me = "SubMesh_parse";
   char op[MAXLINE];
   char type[MAXLINE];
   char msg[MAXLINE];
   int error = 0;
   SubMesh_t    *subm  = NULL;
   subm        = MALLOT(SubMesh_t, 1);
   subm->ndxin = NULL;
   sprintf(op,"submesh");
   error =  NodeWindow_read(op, &subm->ndxin);
   if (error != 0) {
      ctlwarning(me, "Error reading index list for submesh.");
      FREEMEM(subm);
      return(error);
   }
   geta(op);
   geta(subm->name);
   sprintf(op,"SubMesh_%s",subm->name);
   geta(type);
   subm->type = 0;
   if (!strcmp(type,"point")) {
      subm->type = 0;
   } else if (!strcmp(type,"quad")) {
      subm->type = 1;
   } else {
      sprintf(msg, "Type %s not a recognized type of sub mesh.",type);
      ctlwarning(me,msg);
   } 
   error = UserList_parse(op);
   if (error != 0) {
      ctlwarning(me,"Failed to read in list of variables for submesh.");
      NodeWindow_free(subm->ndxin);
      FREEMEM(subm);
      return(-1);
   }
   SubMesh_add(subm);
   return(0);
}
Пример #6
0
Файл: main.c Проект: 4179e1/misc
int main(void)
{
	Hidden *hide;

	hide = hidden_new (1, 2);

	hid_print (hide);

	seta (hide, geta(hide) * 10);

	hid_print (hide);

	return 0;
}
Пример #7
0
void geta_discard(int verbose) 
{
  char tempstr[256];
  if (verbose == TRUE) ctlmsg1("Discarding following unneeded tokens at end of line:\n\t");
  while (ctlflag != iflf) {
    peekc(tempstr);
    if (strcmp(tempstr,"$") != 0) {
      geta(tempstr);
      if (verbose == TRUE) ctlmsg1(tempstr);
      if (ps != NULL)  {
        if (*ps == '$') {
          ps = NULL;
          break;
        }
      }
    }
  }
  if (verbose == TRUE) ctlmsg("");
}
Пример #8
0
void ColorizeBitmap()
{
    if (!skin.colBits)
        return;

    GdiFlush();

    int w = skin.iWidth;
    int h = skin.iHeight;

    // we should swap B and R channels when working with win32 COLORREF
    float koef1r = (255 - getb(opt.colBg)) / 128.0;
    float koef1g = (255 - getg(opt.colBg)) / 128.0;
    float koef1b = (255 - getr(opt.colBg)) / 128.0;

    int br = - 255 + 2 * getb(opt.colBg);
    int bg = - 255 + 2 * getg(opt.colBg);
    int bb = - 255 + 2 * getr(opt.colBg);

    float koef2r = (getb(opt.colBg)) / 128.0;
    float koef2g = (getg(opt.colBg)) / 128.0;
    float koef2b = (getr(opt.colBg)) / 128.0;

    for (int i = 0; i < w * h; i++) {
        long alpha = geta(skin.colBits[i]);
        COLOR32 cl = alpha ? getr(skin.colBits[i])*255/alpha : 0;

        skin.colBits[i] = (cl > 128) ?
                          rgba(
                              PU_DIV255((koef1r * cl + br)*alpha),
                              PU_DIV255((koef1g * cl + bg)*alpha),
                              PU_DIV255((koef1b * cl + bb)*alpha),
                              alpha):
                          rgba(
                              PU_DIV255(koef2r * cl * alpha),
                              PU_DIV255(koef2g * cl * alpha),
                              PU_DIV255(koef2b * cl * alpha),
                              alpha);
    }
}
Пример #9
0
Файл: MD_EL.cpp Проект: lcpt/xc
void XC::MDEvolutionLaw::InitVars(EPState  *EPS) {

    // set initial E_Young corresponding to current stress state
    double p_atm = 100.0; //Kpa atmospheric pressure
    double p = EPS->getStress().p_hydrostatic();
    double E = EPS->getEo() * pow( (p/p_atm), geta());
    EPS->setE( E );
      
    //=========================================================================
    //set initial void ratio from hardening scalar var  (third one)
    double eo = EPS->getScalarVar( 3 );
    seteo( eo );

    ////=========================================================================
    //// Update D 
    //   
    //double m = EPS->getScalarVar(1);
    //XC::stresstensor F = EPS->getTensorVar( 2 );   // getting  F_ij from XC::EPState
    //BJtensor temp_tensor = F("ij") * n("ij");
    //double temp = temp_tensor.trace();
    //
    //if (temp < 0)   temp = 0;
    //double A = getAo() * (1.0 + temp);
    //
    ////Calculating the lode angle theta
    //double J2_bar = r_bar.Jinvariant2();
    //double J3_bar = r_bar.Jinvariant3();
    //double theta = acos( 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5) ) / 3.0;
    //
    //double c = getMe() / getMc();
    //double cd = getke_d() / getkc_d();
    //XC::stresstensor alpha_theta_d = n("ij") * (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m);
    //
    //temp_tensor = A*( alpha_theta_d - alpha );
    //temp_tensor.null_indices();
    //BJtensor temp1 = temp_tensor("ij") * n("ij");
    //double D = temp1.trace();
    //EPS->setScalarVar(2, D);
    
}   
Пример #10
0
int  free_temp_pa( void )
{
  char    *me = "free_temp_pa";
  char     pa_name[128], msg[256];
  int      iblk;
  double  *pa_data;
  ProblemArray_t *prb;
  geta(pa_name);
  prb = ProblemArray_find(pa_name, NULL);
  if (prb == NULL) {
    sprintf(msg,"Object %s does not exist in the registry", pa_name);
    ctlwarning(me,msg);
    return(1);
  }
  if (RGST_QUERY_OBJECT_ATTR(pa_name,"TempVar")  == FALSE) {
    sprintf(msg,"Variable %s is not a temp array, it cannot freed", pa_name);
    ctlwarning(me,msg);
    return(1);
  }
  ProblemArray_free(pa_name);
  return(0) ;
}
Пример #11
0
static int add_analyzer(prelude_client_t *client, void *top,
                        void *(*geta)(void *top, idmef_analyzer_t *analyzer),
                        int (*insa)(void *top, idmef_analyzer_t *analyzer, int pos))
{
        prelude_string_t *str;
        uint64_t wanted_analyzerid, analyzerid;
        idmef_analyzer_t *analyzer = NULL, *canalyzer;

        canalyzer = prelude_client_get_analyzer(client);
        wanted_analyzerid = prelude_client_profile_get_analyzerid(prelude_client_get_profile(client));

        while ( (analyzer = geta(top, analyzer)) && analyzer != canalyzer ) {
                str = idmef_analyzer_get_analyzerid(analyzer);
                if ( ! str )
                        continue;

                analyzerid = strtoull(prelude_string_get_string(str), NULL, 10);
                if ( analyzerid == wanted_analyzerid )
                        return 0;
        }

        return insa(top, idmef_analyzer_ref(prelude_client_get_analyzer(client)), IDMEF_LIST_PREPEND);
}
Пример #12
0
int  getfarg( double *farg, int	lentar )
{
   char sym[128] ;
   int len,ifun ;
   peekc(sym) ;
   if (isbeta(sym)) {
      geta(sym) ;
      ifun = isargfun(sym) ;
      if (RGST_QUERY_OBJECT_ATTR(sym,"DomainVar") == TRUE) {
        len = getfpaa(sym,farg);
      } else if (RGST_QUERY_OBJECT_ATTR(sym,"GlobalArray") == TRUE) {
        len = getfpaa(sym,farg);
      } else if (ifun  >= 0) {
        len = doarg_fun(ifun,farg,lentar);
      } else if (rgst_check_for_obj(sym) == TRUE) {
        len = getrgstdata(R_DOUBLE,sym,(void **)&farg,lentar);
      } else {
      }
   } else {
      len = getflst(&farg,lentar) ;
   }
   return(len) ;
}
Пример #13
0
int ylim( void )
{
   char *me = "ylim";
   int cflag ;
   double y ;
   char op[MAXWORD], msg[128];
   y = getf(&cflag) ;
   if (cflag)
      {
      geta(op) ;
      if (strcmp(op,"de")) {
         sprintf(msg,"'%s' found after ylim instead of expected 'de'",op);
         ctlnotice(me,msg);
      }
      ylimfg = 0 ;
   }
   else {
      ylimfg = 1 ;
      ymn = y ;
      ymx = getf(&cflag) ;
   }
   return(0);
}
Пример #14
0
int fqcyc (
    int fcflag)	
{
  char *me = "fqcyc";
  char msg[512],  vname[64];
  int  i, cflag, ntplot;
  double tempdbl;
  TimePlotCurve_t    *tpc = NULL, **tpc_array = NULL;
  char *err_maxtimeplot = "\n\t maxtimeplot of %d exceeded"
                      "\n\t This should be >= the total number of"
                      "\n\t timeplot ... endmsg, and"
                      "\n\t do 0.0 25.0 1.0 ... endmsg"
                      "\n\t loops in the deck"
                      "\n\t This can be increased by 'set maxtimeplot 999'"
                      "\n\t Set 999 to whatever limit is necessary";
  char *err_maxcycleplot = "\n\t maxcycleplot of %d exceeded"
                      "\n\t This should be >= the total number of"
                      "\n\t cycleplot ... endmsg"
                      "\n\t loops in the deck"
                      "\n\t This can be increased by 'set maxcycleplot 999'"
                      "\n\t Set 999 to whatever limit is necessary";
  char *err_maxtpdata  = "\n\t maxtpdata of %d exceeded"
                      "\n\t This should be >= the total number of"
                      "\n\t timeplot ... endmsg, and"
                      "\n\t do 0.0 25.0 1.0 ... endmsg and "
                      "\n\t cycleplot ... endmsg"
                      "\n\t loops in the deck"
                      "\n\t This can be increased by 'set maxtpdata 999'"
                      "\n\t Set 999 to whatever limit is necessary";
  char *err_maxtplot = "\n\t maxtplot of %d exceeded"
                      "\n\t This should be >= the largest number pf 'tplot'"
                      "\n\t lines within a single timeplot or cycleplot loop"
                      "\n\t This can be increased by 'set maxtplot 999'"
                      "\n\t Set 999 to whatever limit is necessary";
  if (( fcflag == 1 ) || ( fcflag == 2 )) {
    if ( nfq >= maxtimeplot ) {
      sprintf(msg,err_maxtimeplot,maxtimeplot);
      ctlerror(me,msg);
    }
    fq[nfq].t1 = getf(&cflag);
      if (lfchk() == 1) {
      fq[nfq].t2 = plarge;
      fq[nfq].dt = plarge;
    }
    else {
      fq[nfq].t2 = getf(&cflag);
      if (lfchk() == 1) {
        fq[nfq].dt = plarge;
        sprintf(msg,
          "\n\tTime step unspecified on following line:"
          "\n\t%s"
          "\tDefaulting time step to %e",
          line,fq[nfq].dt);
        ctlnotice(me,msg);
      }
      else {
        fq[nfq].dt = getf(&cflag);	
      }
    }
    ifcomfg = 0 ;
    ifexp   = 0 ;
#ifndef NDEBUG
    if  (fq[nfq].t1 < 0) {
      sprintf(msg,
        "\n\tTime begin of %f on following line is bad--it must be >= 0"
        "\n\t%s",
        fq[nfq].t1,line);
      ctlnotice(me,msg);
      return(1);
    }
    if (fq[nfq].t1 > fq[nfq].t2) {
      sprintf(msg,
        "\n\tTime begin of %f is > time end of %f on following line--"
        "\n\tTime begin must be less than time end"
        "\n\t%s",
        fq[nfq].t1,fq[nfq].t2,line);
      ctlnotice(me,msg);
      return(1);
    }
    if (fq[nfq].dt <= 0) {
      sprintf(msg,
        "\n\tTime step of %f on following line is bad--it must be > 0"
        "\n\t%s",
        fq[nfq].dt,line);
      ctlnotice(me,msg);
      return(1);
    }
#endif
    fq[nfq].nextTime = fq[nfq].t1;
    sprintf(msg,"time_freq_%03d",nfq);
    fq[nfq].name = strsave(msg);
    if ( fcflag == 2 ) {
      if ( ntp >= maxtpdata ) {
        sprintf(msg,err_maxtpdata,maxtpdata);
        ctlerror(me,msg);
      }
      fqtp[nfq] = ntp ;
      if (tpdata[ntp] != NULL) {
          sprintf(msg,"PROGRAMMER ERROR - tpdata[%d] already exists",ntp);
        ctlerror(me,msg);
      }
      tpdata[ntp] = TimePlot_construct(1);
      sprintf(msg,"tp_%03d",ntp);
      tpdata[ntp]->name = strsave(msg);
      tpdata[ntp]->fq_name      = strsave(fq[nfq].name);
      tpdata[ntp]->fq_dat       = &fq[nfq];
      tpdata[ntp]->cyc_name     = NULL;
      tpdata[ntp]->cyc_dat      = NULL;
      tpdata[ntp]->num_data_pts = 0;
      tempdbl = (((fq[nfq].t2 - fq[nfq].t1) / (fq[nfq].dt)) + 10);
      if (tempdbl >= (double)INT_MAX) {
        sprintf(msg,"\n\tTime frequency of %f to %f by %12.10f"
                    "\n\tresults in %e entries."
                    "\n\tTrimming the max number of entries to %d",
                    fq[nfq].t1,fq[nfq].t2,fq[nfq].dt,
                    tempdbl,INT_MAX);
        ctlnotice(me,msg);
        tpdata[ntp]->max_data_pts = INT_MAX;
      }
      else {
        tpdata[ntp]->max_data_pts = (int)tempdbl;
      }
      tpdata[ntp]->inc_data_pts  = NTIMES_INCREMENT;
      tpdata[ntp]->alloc_data_pts = 0;
      tpdata[ntp]->tp_curs       = NULL;
      tpdata[ntp]->tp_curs_names = NULL;
      tpdata[ntp]->num_tp_curs   = 0;
      rgst_add(tpdata[ntp]->name,"TimePlot_t",tpdata[ntp],NULL);
      ntp++;
    }
    rgst_add(fq[nfq].name,"FreqMesg_t",&(fq[nfq]),NULL);
    nfq++;
  }
  else if ((fcflag == 0 ) || (fcflag == 3)) {
    if (ncyc >= maxcycleplot) {
       sprintf(msg,err_maxcycleplot,maxcycleplot);
       ctlerror(me,msg);
    }
    cyc[ncyc].c1 = geti(&cflag) ;
    if (lfchk() == 1) {
      cyc[ncyc].c2 = 10000000;
      cyc[ncyc].dc = 10000000;
    }
    else {
      cyc[ncyc].c2 = geti(&cflag) ;
      if (lfchk() == 1) {
        cyc[ncyc].dc = (cyc[ncyc].c2 - cyc[ncyc].c1) / 10;
        sprintf(msg,
          "\n\tCycle step unspecified on following line:"
          "\n\t%s"
          "\tDefaulting cycle step to %d",
          line,cyc[ncyc].dc);
        ctlnotice(me,msg);
      }
      else {
        cyc[ncyc].dc = geti(&cflag) ;
      }
    }
    ifcomfg = 0 ;
    ifexp   = 0 ;
#ifndef NDEBUG
    if  (cyc[ncyc].c1 < 0) {
      sprintf(msg,
        "\n\tCycle begin of %d on following line is bad--it must be >= 0"
        "\n\t%s",
        cyc[ncyc].c1,line);
      ctlnotice(me,msg);
      return(1);
    }
    if (cyc[ncyc].c1 > cyc[ncyc].c2) {
      sprintf(msg,
        "\n\tCycle begin of %d is > cycle end of %d on following line--"
        "\n\tCycle begin must be less than time end"
        "\n\t%s",
        cyc[ncyc].c1,cyc[ncyc].c2,line);
      ctlnotice(me,msg);
      return(1);
    }
    if (cyc[ncyc].dc <= 0) {
      sprintf(msg,
        "\n\tCycle step of %d on following line is bad--it must be > 0"
        "\n\t%s",
        cyc[ncyc].dc,line);
      ctlnotice(me,msg);
      return(1);
    }
#endif
    cyc[ncyc].nextCycle = cyc[ncyc].c1;
    sprintf(msg,"cycle_freq_%03d",ncyc);
    cyc[ncyc].name = strsave(msg);
    if ( fcflag == 3 ) {
      if ( ntp >= maxtpdata ) {
        sprintf(msg,err_maxtpdata,maxtpdata);
        ctlerror(me,msg);
      }
      cyctp[ncyc] = ntp;
      if (tpdata[ntp] != NULL) {
        sprintf(msg,"PROGRAMMER ERROR - tpdata[%d] already exists",ntp);
        ctlerror(me,msg);
      }
      tpdata[ntp] = TimePlot_construct(1);
      sprintf(msg,"tp_%03d",ntp);
      tpdata[ntp]->name = strsave(msg);
      tpdata[ntp]->fq_name      = NULL;
      tpdata[ntp]->fq_dat       = NULL;
      tpdata[ntp]->cyc_name     = strsave(cyc[ncyc].name);
      tpdata[ntp]->cyc_dat      = &cyc[ncyc];
      tpdata[ntp]->num_data_pts = 0;
      tempdbl =((((double)cyc[ncyc].c2 - (double)cyc[ncyc].c1) /
                 ((double)cyc[ncyc].dc)) + (double)10);
      if (tempdbl >= (double)INT_MAX) {
        sprintf(msg,"\n\tCycle frequency of %d to %d by %d"
                    "\n\t results in %e entries"
                    "\n\tTrimming the max number of entries to %d",
                    cyc[ncyc].c1,cyc[ncyc].c2,cyc[ncyc].dc,
                    tempdbl,INT_MAX);
        ctlnotice(me,msg);
        tpdata[ntp]->max_data_pts = INT_MAX;
      }
      else {
        tpdata[ntp]->max_data_pts = (int)tempdbl;
      }
      tpdata[ntp]->inc_data_pts  = NTIMES_INCREMENT;
      tpdata[ntp]->alloc_data_pts = 0;
      tpdata[ntp]->tp_curs       = NULL;
      tpdata[ntp]->tp_curs_names = NULL;
      tpdata[ntp]->num_tp_curs   = 0;
      rgst_add(tpdata[ntp]->name,"TimePlot_t",tpdata[ntp],NULL);
      ntp++;
    }
    rgst_add(cyc[ncyc].name,"CycleMesg_t",&(cyc[ncyc]),NULL);
    ncyc++;
  }
  else  {
    ctlerror(me,"logic error: fcflag must be between 0 and 2");
  }
  if ((fcflag == 1) || (fcflag == 2)) {
    fq[nfq-1].msglen = lineop_grab(&fq[nfq-1].msg, "endmsg",NULL);
  } else {
    cyc[ncyc-1].msglen = lineop_grab(&cyc[ncyc-1].msg, "endmsg",NULL);
  }
  tpc_array = ALLOT(TimePlotCurve_t *, maxtplot);
  if ((fcflag == 2) || (fcflag == 3)) {
    ifexp = 0;
    if (fcflag == 2) {
      line = fq[nfq-1].msg ;
    } else {
      line = cyc[ncyc-1].msg ;
    }
    ps         = line ;
    symflag    = 0 ;
    if (genmd != 0) 
      ctlerror(me,"time plots must come AFTER gen command in input deck");
    tpc_array[0] = TimePlotCurve_create("time",ntp-1);
    ntplot       = 1;
    geta(sym);
    while (strcmp(sym,"endmsg") != 0) {
      if (strcmp(sym,"tplot") != 0) {
        geta(sym);
      }
      else { 
        geta(sym);
        strcpy(vname,sym);
        if (strcmp(vname,"time") == 0) {
          ctlwarning(me,"time cannot be edited");
        }
        else {
          tpc = TimePlotCurve_create(vname,ntp-1);
          tpc_array[ntplot] = tpc;
          if (ntplot++ >= maxtplot) {
            sprintf(msg,err_maxtplot,maxtplot);
            ctlerror(me,msg);
          }
        }
      }         
    }           
    tpdata[ntp-1]->num_tp_curs   = ntplot;
    tpdata[ntp-1]->tp_curs       = ALLOT(TimePlotCurve_t *, ntplot);
    tpdata[ntp-1]->tp_curs_names = ALLOT(char *,            ntplot);
    for (i=0 ; i<ntplot ; i++) { 
      tpdata[ntp-1]->tp_curs[i]       = tpc_array[i];
      tpdata[ntp-1]->tp_curs_names[i] = strsave(tpc_array[i]->name);
    }
    ifexp = 1;
  }
Пример #15
0
int  maxmin( void )
{
   char *me = "maxmin";
   char aname[MAXWORD], fname[10], op[MAXLINE], lab[MAXWORD], msg[MAXLINE];
   int  i, j, k;
   int  ndxmin, ndxmax, array_type;
   int  error = 0;
   int  imin, imax, blkmin, blkmax, len, iblk;
   int *lndx, *undx, *lblk;
   double amin, amax ;
   double *a;
   double *ddata_min;
   double *ddata_max;
   NodeWindow_t *ndxin = NULL, *ndxptr = NULL;
   strcpy(aname,"maxmin") ;
   error = NodeWindow_read(aname,&ndxin);
   geta(op) ;
   if (strcmp(op,"=")) {
      error = 1 ;
      sprintf(msg,"Got %s instead of expected '=' after maxmin",op) ;
      ctlwarning(me,msg);
      newline() ;
      NodeWindow_free(ndxin);
      return(error);
   }
   geta(fname) ;
   if (  (RGST_QUERY_OBJECT_ATTR(fname,"Zonal")  == FALSE)
      && (RGST_QUERY_OBJECT_ATTR(fname,"Nodal") == FALSE)) {
      error = 1 ;
      sprintf(msg,"Unknown field name %s in maxmin command",fname) ;
      ctlwarning(me,msg);
      newline() ;
      NodeWindow_free(ndxin);
      return(error);
   }
   amin   = plarge;
   amax   = -plarge;
   blkmin = -1;
   blkmax = -1;
   array_type = ZONAL_ARRAY;
   if (RGST_QUERY_OBJECT_ATTR(fname,"Nodal") == TRUE) array_type = NODAL_ARRAY;
   ndxptr = ndxin;
   while (ndxptr != NULL) {
      for (iblk = 0; iblk < nblk; iblk++) {
         if (array_type == ZONAL_ARRAY) {
            len =  NodeWindow_fastndx(ndxptr,domains[iblk].gblk, NDX_REAL, 
                   NDX_ZONAL);
         } else {
            len =  NodeWindow_fastndx(ndxptr,domains[iblk].gblk, NDX_REAL, 
                   NDX_NODAL);
         }
         lndx = ndxptr->ndx;
         a = (double *)ProblemArray_ptr(fname, domains[iblk].hash);
         for (i = 0; i < len; i++) {
            if (a[lndx[i]] >= amax) {
               amax = a[lndx[i]];
               ndxmax = lndx[i];
               blkmax = domains[iblk].gblk;
            }
            if (a[lndx[i]] <= amin) {
               amin = a[lndx[i]];
               ndxmin = lndx[i];
               blkmin = domains[iblk].gblk;
            }
         }
         NodeWindow_freendx(ndxptr);
      }
      ndxptr = ndxptr->next;
   }
   if (ifparallel) {
      ddata_min = MALLOT(double,num_procs);
      ddata_max = MALLOT(double,num_procs);
      for (i = 0; i < num_procs; i++) {
         ddata_min[i] = 0.0;
         ddata_max[i] = 0.0;
      }
      ddata_min[myid] = amin;
      ddata_max[myid] = amax;
      comreduce(ddata_min, num_procs,COM_SUM,COM_ALL,COM_DOUBLE);
      comreduce(ddata_max, num_procs,COM_SUM,COM_ALL,COM_DOUBLE);
      amin = plarge;
      amax = -plarge;
      imin = -1;
      imax = -1;
      for (i = 0; i < num_procs; i++) {
         if (ddata_min[i] < amin) {
            imin = i;
            amin = ddata_min[i];
         }
         if (ddata_max[i] > amax) {
            imax = i;
            amax = ddata_max[i];
         }
      }
      FREEMEM(ddata_min);
      FREEMEM(ddata_max);
      if ((imin == -1) || (imax == -1)) {
         sprintf(msg,"Error in finding maxmin of %s",fname);
         ctlwarning(me,msg);
         NodeWindow_free(ndxin);
         return(-1);
      }
      combcast(&blkmax,1,COM_INT,imax); 
      combcast(&blkmin,1,COM_INT,imin); 
      combcast(&ndxmax,1,COM_INT,imax); 
      combcast(&ndxmin,1,COM_INT,imin); 
   }
   if (blkmin >= 0) {
      if (ndims == 2) {
         j = ndxmin / gmap[blkmin].jp;
         i = ndxmin - (j * gmap[blkmin].jp);
	 i = i - 2 * NPNL + 1 + gmap[blkmin].imin;
	 j = j - 2 * NPNL + 1 + gmap[blkmin].jmin;
         sprintf(msg,"%s min:%d(%d,%d) = %e",
                  fname,gmap[blkmin].ublk,i,j,amin) ;
      } else {
         k = ndxmin / gmap[blkmin].kp;
         j = (ndxmin - (k * gmap[blkmin].kp))/gmap[blkmin].jp;
         i = ndxmin - (j * gmap[blkmin].jp) - (k * gmap[blkmin].kp);
	 i = i - 2 * NPNL + 1 + gmap[blkmin].imin;
	 j = j - 2 * NPNL + 1 + gmap[blkmin].jmin;
	 k = k - 2 * NPNL + 1 + gmap[blkmin].kmin;
         sprintf(msg,"%s min:%d(%d,%d,%d) = %e",
                  fname,gmap[blkmin].ublk,i,j,k,amin) ;
      } 
      ctlmsg(msg);
   } 
   if (blkmax >= 0) {
      if (ndims == 2) {
         j = ndxmax / gmap[blkmax].jp;
         i = ndxmax - (j * gmap[blkmax].jp);
	 i = i - 2 * NPNL + 1 + gmap[blkmax].imin;
	 j = j - 2 * NPNL + 1 + gmap[blkmax].jmin;
         sprintf(msg,"%s max:%d(%d,%d) = %e",
                  fname,gmap[blkmax].ublk,i,j,amax) ;
      } else {
         k = ndxmax / gmap[blkmax].kp;
         j = (ndxmax - (k * gmap[blkmax].kp))/gmap[blkmax].jp;
         i = ndxmax - (j * gmap[blkmax].jp) - (k * gmap[blkmax].kp);
	 i = i - 2 * NPNL + 1 + gmap[blkmax].imin;
	 j = j - 2 * NPNL + 1 + gmap[blkmax].jmin;
	 k = k - 2 * NPNL + 1 + gmap[blkmax].kmin;
         sprintf(msg,"%s max:%d(%d,%d,%d) = %e",
                  fname,gmap[blkmax].ublk,i,j,k,amax) ;
      } 
      ctlmsg(msg);
   }
   NodeWindow_free(ndxin);
   return(error) ;
}
Пример #16
0
float *IDLStruct::fgeta(IDL_MEMINT index, int tag_index, 
		       IDL_MEMINT arr_index) {
  return (float *) geta(index, tag_index, arr_index, IDL_TYP_FLOAT);
}
Пример #17
0
Record const &Sky::layer(int index) const
{
    return *geta("layer")[index].as<RecordValue>().record();
}
Пример #18
0
int Sky::layerCount() const
{
    return int(geta("layer").size());
}
Пример #19
0
Record const &Sky::model(int index) const
{
    return *geta("model")[index].as<RecordValue>().record();
}
Пример #20
0
double *IDLStruct::dgeta(IDL_MEMINT index, const char *name, 
		       IDL_MEMINT arr_index) {
  return (double *) geta(index, name, arr_index, IDL_TYP_DOUBLE);
}
Пример #21
0
int ObjectName_input(void ) {
   char *me = "ObjectName_input";
   geta(ObjectName);
   ObjectName_set = 1;
   return(0);
}
Пример #22
0
IDL_ULONG64 *IDLStruct::ul64geta(IDL_MEMINT index, const char *name, 
		       IDL_MEMINT arr_index) {
  return (IDL_ULONG64 *) geta(index, name, arr_index, IDL_TYP_ULONG64);
}
Пример #23
0
IDL_ULONG64 *IDLStruct::ul64geta(IDL_MEMINT index, int tag_index, 
		       IDL_MEMINT arr_index) {
  return (IDL_ULONG64 *) geta(index, tag_index, arr_index, IDL_TYP_ULONG64);
}
Пример #24
0
float *IDLStruct::fgeta(IDL_MEMINT index, const char *name, 
		       IDL_MEMINT arr_index) {
  return (float *) geta(index, name, arr_index, IDL_TYP_FLOAT);
}
Пример #25
0
int main(int argc, char *argv[])
{
    if ( argc != 2 ) /* argc should be 2 for correct execution */
    {
        /* We print argv[0] assuming it is the program name */
        printf( "usage: %s [path to ChioSi_new.dat]", argv[0] );
        exit(EXIT_FAILURE);
    }
    printf("sizeof(double)=%lu\n",sizeof(double));

    int i, iz, ia, np, npts ;
    float aa, xx, yy ;
    FILE *fd ;

    /* Ouverture fichier de donnees */
    fd = fopen(argv[1],"r") ;
    if (fd == NULL)
    {
        printf("Fichier de data %s introuvable\n", argv[1]) ;
        exit(EXIT_FAILURE);
    }
    /* Chargement des data */
    npts = 0 ;
    char* fgets_result;
    for (i=0 ; i<11 ; i++) fgets_result = fgets(line,LNSTR,fd) ;
    if(fgets_result) {
        ;
    }
    while (1)
    {
        if (fgets(line,LNSTR,fd) == NULL) break ;
        if (fgets(line,LNSTR,fd) == NULL) break ;
        if (fgets(line,LNSTR,fd) == NULL) break ;
        sscanf(line,"%d",&iz) ;
        aa = geta((float)iz,1) ;
        ia = (int)(aa+0.5) ;
        if (fgets(line,LNSTR,fd) == NULL) break ;
        sscanf(line,"%d",&np) ;
        for (i=0 ; i<np ; i++)
        {
            if (fgets(line,LNSTR,fd) == NULL) break ;
            sscanf(line,"%f %f",&xx,&yy) ;
            if (npts < MXPTS)
            {
                zd[npts] = iz ;
                ad[npts] = ia ;
                xd[npts] = xx ;
                yd[npts] = yy ;
            }
            npts++ ;
        }
    }
    fclose(fd) ;
    printf("npts=%d\n",npts) ;
    if (npts > MXPTS)
    {
        printf("Attention : %d > %d\n",npts,MXPTS) ;
        return 1 ;
    }
    fflush(stdout) ;
    /* Fit fonctionnelle */
    i = globede_c(npts,zd,ad,xd,yd,1,0,par,istate) ;
    printf("irc_fit=%d\n",i) ;
    fflush(stdout) ;
    if (i !=0 && i != 1) return 1 ;
    /* Calcul et affichage valeur de la fonctionnelle pour chque point */
    for (i=0 ; i<npts ; i++)
        printf(" %3d  %3d   %6.1f   %6.1f   %6.1f\n",(int)(zd[i]+0.5),
               (int)(ad[i]+0.5),xd[i],yd[i],fede(zd[i],ad[i],xd[i])) ;
    return EXIT_SUCCESS ;
}
Пример #26
0
std::string GreensFunction3DAbsSym::dump() const
{
    return (boost::format("D=%.16g, a=%.16g") % getD() % geta()).str();
}
Пример #27
0
IDL_LONG64 *IDLStruct::l64geta(int tag_index, IDL_MEMINT arr_index) {
  return (IDL_LONG64 *) geta(tag_index, arr_index, IDL_TYP_LONG64);
}
Пример #28
0
Файл: MD_EL.cpp Проект: lcpt/xc
void XC::MDEvolutionLaw::UpdateAllVars( EPState *EPS, double dlamda) {
   
    //=========================================================================
    //calculate  n_ij
    XC::stresstensor S = EPS->getStress().deviator();
    double p = EPS->getStress().p_hydrostatic();
    XC::stresstensor alpha = EPS->getTensorVar( 1 );  // alpha_ij

    // Find the norm of alpha
    BJtensor norm_alphat = alpha("ij") * alpha("ij");
    double norm_alpha = sqrt( norm_alphat.trace() );
   
    XC::stresstensor r = S * (1.0 / p);
    //r.reportshort("r");
    XC::stresstensor r_bar = r - alpha;
    XC::stresstensor norm2 = r_bar("ij") * r_bar("ij");
    double norm = sqrt( norm2.trace() );
    
    XC::stresstensor n;
    if ( norm >= d_macheps() ){ 
      n = ( r  - alpha ) *(1.0 / norm );
    }
    else {
      ::printf(" \n\n n_ij not defined!!!! Program exits\n");
      exit(1);
    }
    //EPS->setTensorVar( 3, n); //update n_ij//

    // Update E_Young corresponding to current stress state
    double p_atm = 100.0; //Kpa, atmospheric pressure
    double E = EPS->getE();  // old E_Young
    double E_new = EPS->getEo() * pow( (p/p_atm), geta() ); 
    EPS->setE( E_new );

    // Update void ratio
    
    double e = EPS->getScalarVar(3);
    double D = EPS->getScalarVar(2);
    double elastic_strain_vol = EPS->getdElasticStrain().Iinvariant1();
    double plastic_strain_vol = EPS->getdPlasticStrain().Iinvariant1();

    double de_p = -( 1.0 + e ) * plastic_strain_vol; // plastic change of void ratio ?? e or eo?
    double de_e = -( 1.0 + e ) * elastic_strain_vol; // elastic change of void ratio ????
    clog << "get dPlasticStrain-vol" << plastic_strain_vol << std::endl;
    clog << "get dElasticStrain-vol" << elastic_strain_vol << std::endl;

    clog << "^^^^^^^^^^^ de_e = " << de_e << " de_p = " << de_p << std::endl; 
    double new_e = e + de_p + de_e;

    EPS->setScalarVar( 3, new_e ); // Updating e


    //Calculate the state parameters xi 
    double ec = getec_ref() - getLambda() * log( p/getp_ref() );

    double xi = e - ec;

    // Update D 
       
    double m = EPS->getScalarVar(1);
    XC::stresstensor F = EPS->getTensorVar( 2 );   // getting  F_ij from XC::EPState
    BJtensor temp_tensor = F("ij") * n("ij");
    double temp = temp_tensor.trace();
    if (temp < 0)   temp = 0;
    double A = Ao*(1.0 + temp);

    //Calculating the lode angle theta
    double J2_bar = r_bar.Jinvariant2();
    double J3_bar = r_bar.Jinvariant3();
    double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5);

    if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan
    if (tempd < -1.0 ) tempd = -1.0;

    double theta = acos( tempd ) / 3.0;
    
    //=========================================================================
    //calculate the alpha_theta_b and alpha_theta_d
    double c = getMe() / getMc();

    double cd = getke_d() / getkc_d();
    double alpha_theta_dd = (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m);
    XC::stresstensor alpha_theta_d = n("ij") * alpha_theta_dd * pow(2.0/3.0, 0.5);

    double cb = getke_b() / getkc_b();
    if ( xi > 0 ) xi = 0.0;  // < -xi >
    double alpha_theta_bd = (g_WW(theta, c) * Mc + g_WW(theta, cb) * kc_b * (-xi) - m);
    XC::stresstensor alpha_theta_b = n("ij") *alpha_theta_bd * pow(2.0/3.0, 0.5);
    alpha_theta_b.null_indices();

    XC::stresstensor b;
    b =  alpha_theta_b - alpha;
    b.null_indices();
    XC::stresstensor d;
    d =  alpha_theta_d - alpha;
    d.null_indices();

    BJtensor temp1 = d("ij") * n("ij");
    temp1.null_indices();
    double D_new = temp1.trace() * A;
    //Check the restrictions on D
    if ( (xi > 0.0) && ( D_new < 0.0) )
       D_new = 0.0;  

    EPS->setScalarVar(2, D_new);  // Updating D
    //EPS->setScalarVar(2, 0.0);  // Updating D
    
 
    //=========================================================================
    // Update m
    double dm = dlamda * getCm() * ( 1.0 + e ) * D;
    EPS->setScalarVar(1, m + dm); // Updating m
    clog  << std::endl << "dm = " << dm << std::endl;

    //=========================================================================
    // Update alpha

    //calculate b_ref
    double alpha_c_b = g_WW(0.0, c) * Mc + g_WW(0.0, cb) * kc_b * (-xi) - m;
    double b_ref = 2.0 * pow(2.0/3.0, 0.5) * alpha_c_b;
    
    temp1 = b("ij") * n("ij");
    double bn = temp1.trace();
    clog << "xxxxxxxxxxxxxxxxxxx  bn " << bn << std::endl;


    double h = getho() * fabs(bn) / ( b_ref - fabs(bn) );
    //h = h + pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * bn;

    clog << " ||b|| " << (alpha_theta_bd - norm_alpha) << std::endl;
    clog << " dlamda " << dlamda << " h = " << h << std::endl;

    XC::stresstensor dalpha;
    dalpha = dlamda * h * b("ij");
    //dalpha.null_indices();
    clog << "delta alpha =" << dalpha << std::endl;
    
    //dalpha.reportshortpqtheta("\n dalpha ");
    alpha = alpha + dalpha;
    alpha.null_indices();
    //alpha.reportshort("Alpha");
    EPS->setTensorVar(1, alpha);

    //=========================================================================
    // Update F
    XC::stresstensor dF;
    if ( D > 0.0 ) D = 0.0;
    dF =  dlamda * getCf() * (-D) * ( getFmax() * n("ij") + F("ij") );
    //clog << "dF" << dF;
    
    F = F - dF;
    EPS->setTensorVar(2, F);

}
Пример #29
0
int Sky::modelCount() const
{
    return int(geta("model").size());
}
Пример #30
0
double *IDLStruct::dgeta(IDL_MEMINT index, int tag_index, 
		       IDL_MEMINT arr_index) {
  return (double *) geta(index, tag_index, arr_index, IDL_TYP_DOUBLE);
}