Esempio n. 1
0
hwrcolor def_color_pgtohwr(pgcolor c) {
  if (c & PGCF_ALPHA) {
    /* ARGB conversion, just premultiply the RGB color */
    return mkcolora( getalpha(c),
		     (getred(c)   * getalpha(c)) >> 7,
		     (getgreen(c) * getalpha(c)) >> 7,
		     (getblue(c)  * getalpha(c)) >> 7
		     );
  }
  else if (vid->bpp==0) {
Esempio n. 2
0
void
blit_alpha (iImage * source, iImage * dest, int source_startx,
	    int source_starty, int destx, int desty, int source_endx,
	    int source_endy, int range)
{
  int x;
  int y;
//check if its out of range yourself :P
  int r, g, b, a;
  int i, j;

//int r2,g2,b2;
  x = dest->GetWidth ();
  y = dest->GetHeight ();


  if (source_endx + destx - source_startx >= x)
    source_endx = x - destx + source_startx;


  if (source_endy + desty - source_starty >= y)
    source_endy = y - desty + source_starty;


  i = 0;
  j = 0;
  for (x = source_startx; x < source_endx; x++)
    {
      for (y = source_starty; y < source_endy; y++)
	{
	  r = getred (source, x, y);
	  g = getgreen (source, x, y);
	  b = getblue (source, x, y);
	  a = getalpha (source, x, y);


	  if (a - range < 1)
	    {
	    }
	  else
	    {
	      setred (dest, i + destx, j + desty, r);
	      setgreen (dest, i + destx, j + desty, g);
	      setblue (dest, i + destx, j + desty, b);
	    }
	  j++;
	}
      j = 0;
      i++;
    }



}
Esempio n. 3
0
hwrcolor directfb_color_pgtohwr(pgcolor c) {
  u8 alpha;
  /* DirectFB API is 32-bit RGBA, so the pgcolor format is almost good enough */
  if (c | PGCF_ALPHA) {
    alpha = getalpha(c);
    c &= 0x00FFFFFF;
    c |= (alpha << 1);
  }
  else
    c |= 0xFF000000;
  return c;
}
Esempio n. 4
0
void yuv16_422_planar_pixel(hwrbitmap dest,
			      s16 x, s16 y, hwrcolor c,
			      s16 lgop)
{
  struct stdbitmap *dstbit = (struct stdbitmap *) dest;

  if (yuv16_422_planar_is_offscreen(dstbit->bits)) {
    /* we are offscreen */
    def_pixel(dest, x, y, c, lgop);
    return;
  }
  else {
    unsigned long r = getred(c);
    unsigned long g = getgreen(c);
    unsigned long b = getblue(c);
    unsigned long a = getalpha(c);

    size_t offset = (dstbit->pitch)*y + x;
    
    u8 *dst_y  = dstbit->bits + offset;
    u8 *dst_uv = dstbit->bits + yuv16_422_planar_y_plane_size + (offset&~1);

    switch (lgop) {      
    case PG_LGOP_NONE: {
      int y, cb, cr;
      
      yuv16_rgb_shadow_buffer[offset] = c;
      
      /*
       * Alpha is null...We're transparent
       */
      if (!a)
	{
	  y = 0;
	  cb = 0;
	  cr = 0;
	}
      else
	rgb_to_ycbcr(r, g, b, &y, &cb, &cr);
      *dst_y = (char)y;
      *dst_uv++ = (char)cb;
      *dst_uv = (char)cr;
      
      break; 
    }
    
    default:
    /* Not supported yet */
      return;
    }
  }
}
Esempio n. 5
0
int
POL::gettok (TOKEN *tok)
{
  int c, toktype;
  int inum;
  double fnum;
  int toksiz = MAXTOK;          /* maximum length of token string */

  while ((c = inchar()) == BLANK || c == TAB)
    ;
  ungetch (c);

  c = lookchar();
  toktype = type(c);

  fnum = 0.0;
  inum = 0;

  if (c == BLANK || c == TAB) {                 /* skip white space */
    getblank(tok->tokstr, toksiz);
    toktype = TT_BLANK;
  } else if (toktype == LETTER) {
    toktype = getalpha (tok->tokstr, toksiz);
  } else if (c == meta.str) {                   /* quoted string */
    getquote (tok->tokstr, toksiz);
    toktype = TT_STRING;
  } else if (type(c) == DIGIT || c == PLUS || c == HYPHEN || c == PERIOD) {
    toktype = getnumber (tok->tokstr, toksiz, &fnum, &inum);
  } else if (c == EOF) {
    tok->tokstr[0] = EOS;
    toktype = TT_EOF;
  } else {
    c = inchar();
    tok->tokstr[0] = c;
    tok->tokstr[1] = EOS;
    toktype = TT_SPECLCHAR;
  }

  tok->type = toktype;
  tok->ready = true;
  if (tok->type == TT_REAL || tok->type == TT_INT) {
    tok->fnum = fnum;
    tok->inum = inum;
  } else {
    tok->fnum = 0.0;
    tok->inum = 0;
  }

  return (toktype);
}
Esempio n. 6
0
//This Blit conserves the alpha, Blit_merge blends the alphaed color in with background.
void
blit (iImage * source, iImage * dest, int source_startx, int source_starty,
      int destx, int desty, int source_endx, int source_endy)
{
  int x;
  int y;
  int r, g, b;
  int i, j;
  int a;

  x = dest->GetWidth ();
  y = dest->GetHeight ();


  if (source_endx + destx - source_startx >= x)
    source_endx = x - destx + source_startx;


  if (source_endy + desty - source_starty >= y)
    source_endy = y - desty + source_starty;


  i = 0;
  j = 0;
  for (x = source_startx; x < source_endx; x++)
    {
      for (y = source_starty; y < source_endy; y++)
	{
	  r = getred (source, x, y);
	  g = getgreen (source, x, y);
	  b = getblue (source, x, y);
	  a = getalpha (source, x, y);


	  setred (dest, i + destx, j + desty, r);
	  setgreen (dest, i + destx, j + desty, g);
	  setblue (dest, i + destx, j + desty, b);
	  setalpha (dest, i + destx, j + desty, a);
	  j++;
	}
      j = 0;
      i++;
    }



}
Esempio n. 7
0
int main(int argc, char **argv)
{
  char deck[54];
  int i, j;
  int mode = 0;  /* default mode is encode, non-zero is decode */

  for (i = 0; i < 54; i++)
    deck[i] = i + 1;

  if (argc > 1 && argv[1][0] == '-')
    {
      if(argv[1][1] == 'd')
	{
	  mode = 1;
	}
      else if (argv[1][1] == 'e')
	{
	  mode = 0;
	}
      else usage();
    }
  else usage();

  argc--;
  argv++;

  /* do key */
  while (argc-- > 1)
    {
      char *ap = *++argv;
      while (*ap)
	{
	  int c = *ap++;
	  char tmp[53];

	  if (c >= 'a' && c <= 'z')
	    c = c - 'a' + 'A';
	  if (c >= 'A' && c <= 'Z')
	    {
	      c = c - 'A' + 1;
	      step(deck);
	      i = 0;
	      for (j = c; j < 53; j++)
		tmp[i++] = deck[j];
	      for (j = 0; j < c; j++)
		tmp[i++] = deck[j];
	      for (j = 0; j < 53; j++)
		deck[j] = tmp[j];
	    }
	}
    }

  j = 0;
  while ((i = getalpha()) != 0)
    {
      putchar(mode ? sumchar(i, -step(deck)) : sumchar(i, step(deck)));
      j++;
      if (j % 5 == 0)
	{
	  if (j == 50)
	    {
	      j = 0;
	      putchar('\n');
	    }
	  else
	    putchar (' ');
	}
    }

  j = j % 5;
  if (j)
    while (j < 5)
      {
	i = 'X';
	putchar(mode ? sumchar(i, -step(deck)) : sumchar(i, step(deck)));
	j++;
      }

  printf("\n");

  return EXIT_SUCCESS;
}
Esempio n. 8
0
void yuv16_422_planar_slab (hwrbitmap dest, 
			    s16 x, s16 y, s16 w,
			    hwrcolor c, s16 lgop)
{
  struct stdbitmap * dstbit = (struct stdbitmap *) dest;

  if (yuv16_422_planar_is_offscreen (dstbit->bits)) {
    /* we are offscreen */
    def_slab (dest, x, y, w, c, lgop);
    return;
  }
  else {
    unsigned long r = getred(c);
    unsigned long g = getgreen(c);
    unsigned long b = getblue(c);
    unsigned long a = getalpha(c);
    int i;

    size_t offset = (dstbit->pitch) * y + x;
    
    u8 * dst_y  = dstbit->bits + offset;
    u8 * dst_uv = dstbit->bits + yuv16_422_planar_y_plane_size 
      + (offset &~ 1);

    switch (lgop) {      
    case PG_LGOP_NONE: {
      int y, cb, cr;
      
      /*
       * Alpha is null...We're transparent
       */
      if (!a) {
	y = 0;
	cb = 0;
	cr = 0;
      } else
	rgb_to_ycbcr (r, g, b, & y, & cb, & cr);

      memset (dst_y, (char) y, w);
      if (cb == cr) {
	memset (dst_uv, (char) cb, w * 2);
      } else {
	for (i = 0; i < w; i += 2) {
	  * dst_uv++ = (char) cb;
	  * dst_uv   = (char) cr;
	}
      }

      if (c == 0) {
	memset (yuv16_rgb_shadow_buffer, 0, w * sizeof (c));
      } else {
	for (i = 0; i < w; i++) {
	  yuv16_rgb_shadow_buffer [offset + i] = c;
	}
      }
      
      break; 
    }
    
    default:
      /* Not supported yet */
      def_slab (dest, x, y, w, c, lgop);
      return;
    }
  }
}
Esempio n. 9
0
//================================================================================
const tensor& DM04_PF::Dm_Dkin2(const stresstensor &Stre, 
                          const straintensor &Stra, 
                          const MaterialParameter &MaterialParameter_in) const
{
    const double oneOver3 = 1.0/3.0;
    const double rt23 = sqrt(2.0/3.0);
    
    tensor I2("I", 2, def_dim_2);    

    double e0 = gete0(MaterialParameter_in);
    double e_r = gete_r(MaterialParameter_in);
    double lambda_c = getlambda_c(MaterialParameter_in);
    double xi = getxi(MaterialParameter_in);
    double Pat = getPat(MaterialParameter_in);
    //double m = getm(MaterialParameter_in);
    double M_cal = getM_cal(MaterialParameter_in);
    double cc = getcc(MaterialParameter_in);
    double A0 = getA0(MaterialParameter_in);
    double nd = getnd(MaterialParameter_in);    

    stresstensor alpha = getalpha(MaterialParameter_in);
    stresstensor z = getz(MaterialParameter_in);

    stresstensor n;
    stresstensor alpha_d;
    stresstensor alpha_d_alpha;
    double g = 0.0;
    double ec = e_r;
    double stateParameter = 0.0;
    double expnd = 1.0;
    //double ad = 0.0;
    double D0 = 0.0;
    stresstensor s_bar;
    double norm_s = 0.0;
    double epsilon_v = 0.0;
    double e = e0;
    double J3D;
    double cos3theta = 0.0;
    double z_n = 0.0;
    double alpha_n = 0.0;
    double s_n = 0.0;

    double p = Stre.p_hydrostatic();
    stresstensor s = Stre.deviator();
            
    s_bar = s - (alpha *p);
    norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() );
    if (p > 0.0 && norm_s > 0.0)
        n = s_bar * (1.0/norm_s);
       
    J3D = n.Jinvariant3();
    cos3theta = -3.0*sqrt(6.0) *J3D;
    
    if (cos3theta > 1.0) 
      cos3theta = 1.0;

    if (cos3theta < -1.0) 
      cos3theta = -1.0;
    
    g = getg(cc, cos3theta);

    if ( (p/Pat) >= 0.0 )
      ec = getec(e_r, lambda_c, xi, Pat, p);
    
    epsilon_v = Stra.Iinvariant1();
    e = e0 + (1.0 + e0) *epsilon_v;
    
    stateParameter = e - ec;    
    expnd = exp(nd*stateParameter);
    
    alpha_n = (alpha("ij")*n("ij")).trace();
    s_n = (s("ij")*n("ij")).trace();

    // way 1
    //ad = g*M_cal*expnd - m;
    //D0 = rt23 * ad - alpha_n;

    // way 2
    D0 = rt23*g*M_cal*expnd - s_n /p;

    tensor dD_dz(2, def_dim_2, 0.0);

    // dD_dz:
    if (z_n > 0.0)
      dD_dz = n *A0;

    // dm_da:
    tensor tensor1 = I2("ij")*dD_dz("mn");
      tensor1.null_indices();
    
    PlasticFlow::PF_tensorR4 = tensor1 *(-D0*oneOver3);   
    
    return PlasticFlow::PF_tensorR4;
}
Esempio n. 10
0
//================================================================================
const tensor& DM04_PF::Dm_Dkin(const stresstensor &Stre, 
                          const straintensor &Stra, 
                          const MaterialParameter &MaterialParameter_in) const
{
    const double oneOver3 = 1.0/3.0;
    const double rt23 = sqrt(2.0/3.0);

    tensor I2("I", 2, def_dim_2);    
    tensor I4 = I2("ij")*I2("kl");
    tensor I4s = ( I4.transpose0110() + I4.transpose0111() ) *0.5;

    double e0 = gete0(MaterialParameter_in);
    double e_r = gete_r(MaterialParameter_in);
    double lambda_c = getlambda_c(MaterialParameter_in);
    double xi = getxi(MaterialParameter_in);
    double Pat = getPat(MaterialParameter_in);
    //double m = getm(MaterialParameter_in);
    double M_cal = getM_cal(MaterialParameter_in);
    double cc = getcc(MaterialParameter_in);
    double A0 = getA0(MaterialParameter_in);
    double nd = getnd(MaterialParameter_in);    

    stresstensor alpha = getalpha(MaterialParameter_in);
    stresstensor z = getz(MaterialParameter_in);

    stresstensor n;
    stresstensor alpha_d;
    stresstensor alpha_d_alpha;
    double g = 0.0;
    double ec = e_r;
    double stateParameter = 0.0;
    double expnd = 1.0;
    //double ad = 0.0;
    double A_d = 0.0;
    double B = 1.0;
    double C = 0.0;
    double D0 = 0.0;
    stresstensor s_bar;
    double norm_s = 0.0;
    double epsilon_v = 0.0;
    double e = e0;
    double J3D;
    double cos3theta = 0.0;
    double z_n = 0.0;
    double alpha_n = 0.0;
    double s_n = 0.0;

    double p = Stre.p_hydrostatic();
    stresstensor s = Stre.deviator();
            
    s_bar = s - (alpha *p);
    norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() );
    if (p > 0.0 && norm_s > 0.0)
        n = s_bar * (1.0/norm_s);
       
    J3D = n.Jinvariant3();
    cos3theta = -3.0*sqrt(6.0) *J3D;
    
    if (cos3theta > 1.0) 
      cos3theta = 1.0;

    if (cos3theta < -1.0) 
      cos3theta = -1.0;
    
    g = getg(cc, cos3theta);

    if ( (p/Pat) >= 0.0 )
      ec = getec(e_r, lambda_c, xi, Pat, p);
    
    epsilon_v = Stra.Iinvariant1();
    e = e0 + (1.0 + e0) *epsilon_v;
    
    stateParameter = e - ec;    
    expnd = exp(nd*stateParameter);
    
    alpha_n = (alpha("ij")*n("ij")).trace();
    s_n = (s("ij")*n("ij")).trace();

    // way 1
    //ad = g*M_cal*expnd - m;
    //D0 = rt23 * ad - alpha_n;

    // way 2
    D0 = rt23*g*M_cal*expnd - s_n /p;

    z_n = (z("ij")*n("ij")).trace();
    if (z_n < 0.0) 
      z_n = 0.0;
    A_d = A0 * (1.0 + z_n);

    B = 1.0 + 1.5 *((1.0-cc)/cc) *g *cos3theta;
    C = 3.0 *sqrt(1.5) *((1.0-cc)/cc) *g;
    
    tensor n_n = n("ik")*n("kj");
      n_n.null_indices();

    tensor nt_nt = n("ij")*n("kl");
      nt_nt.null_indices();

    tensor alpha_I = alpha("ij")*I2("kl");
      alpha_I.null_indices();

    tensor n_I = n("ij")*I2("kl");
      n_I.null_indices();

    // dn_dalpha:
    tensor dn_da = nt_nt - I4s;
    dn_da = dn_da *(p/norm_s);

    // dcos3theta_dalpha:
    tensor dcos3theta_da = dn_da("ijmn")*n_n("ji");
      dcos3theta_da.null_indices();
    dcos3theta_da = dcos3theta_da *(-3.0*sqrt(6.0));

    // dg_da:
    tensor dg_da = dcos3theta_da *(g*g*(1.0-cc)/(2.0*cc));

    // dB_da:
    tensor dB_da = (dg_da*cos3theta + dcos3theta_da*g) *(1.5*(1.0-cc)/cc);

    // dC_ds:
    tensor dC_da = dg_da *(3.0*sqrt(1.5)*(1.0-cc)/cc);

    // dR_da:
    tensor tensor1 = n("ij")*dB_da("mn");
      tensor1.null_indices();
    tensor tensor2 = n_n - I2 *oneOver3;
    tensor tensor3 = tensor2("ij")*dC_da("mn");
      tensor3.null_indices();
    tensor tensor4 = n("kj")*dn_da("ikmn");
      tensor4.null_indices();
    tensor4.transpose1100(); 
    tensor dR_da = dn_da *B + tensor1 + tensor4 *(2.0*C) + tensor3;

    // dad_da:
    tensor dad_da = dg_da *(M_cal*expnd);

    // dD_da:
    
    // way 1
    //tensor tensor5 = alpha("pq")*dn_da("pqmn");
    //  tensor5.null_indices();
    //tensor dD_da = (dad_da *rt23 - n - tensor5) *(-A_d);
    
    // way 2
    tensor tensor5 = s("pq")*dn_da("pqmn");
      tensor5.null_indices();
    tensor dD_da = (dad_da *rt23 - tensor5 *(1.0/p)) *(-A_d);

    if (z_n > 0.0) {
      tensor tensor6 = z("pq")*dn_da("pqmn");
        tensor6.null_indices();
      dD_da += tensor6 *(-A0*D0);
    }

    // dm_da:
    tensor tensor7 = I2("ij")*dD_da("mn");
      tensor7.null_indices();
    
    PlasticFlow::PF_tensorR4 = dR_da + tensor7 *oneOver3;   
    
    return PlasticFlow::PF_tensorR4;
}
Esempio n. 11
0
//================================================================================
const straintensor& DM04_PF::PlasticFlowTensor(const stresstensor& Stre, 
                                               const straintensor& Stra, 
                                               const MaterialParameter &MaterialParameter_in) const
{
    const double oneOver3 = 1.0/3.0;
    const double rt23 = sqrt(2.0/3.0);    
    tensor I2("I", 2, def_dim_2);

    double e0 = gete0(MaterialParameter_in);
    double e_r = gete_r(MaterialParameter_in);
    double lambda_c = getlambda_c(MaterialParameter_in);
    double xi = getxi(MaterialParameter_in);
    double Pat = getPat(MaterialParameter_in);
    //double m = getm(MaterialParameter_in);
    double M_cal = getM_cal(MaterialParameter_in);
    double cc = getcc(MaterialParameter_in);
    double A0 = getA0(MaterialParameter_in);
    double nd = getnd(MaterialParameter_in);    

    stresstensor alpha = getalpha(MaterialParameter_in);
    stresstensor z = getz(MaterialParameter_in);

    stresstensor n;
    stresstensor alpha_d;
    stresstensor alpha_d_alpha;
    double g = 0.0;
    double ec = e_r;
    double stateParameter = 0.0;
    double expnd = 1.0;
    //double ad = 0.0;
    double A_d = 0.0;
    double B = 1.0;
    double C = 0.0;
    double D = 0.0;
    double D0 = 0.0;
    stresstensor s_bar;
    double norm_s = 0.0;
    double epsilon_v = 0.0;
    double e = e0;
    double J3D;
    double cos3theta = 0.0;
    double z_n = 0.0;
    double alpha_n = 0.0;
    double s_n = 0.0;

    double p = Stre.p_hydrostatic();
    stresstensor s = Stre.deviator();
            
    s_bar = s - (alpha *p);
    norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() );
    if (p > 0.0 && norm_s > 0.0)
      n = s_bar * (1.0/norm_s);
       
    J3D = n.Jinvariant3();
    cos3theta = -3.0*sqrt(6.0) *J3D;

    if (p <= 0.0)
      cos3theta = 1.0;
    
    if (cos3theta > 1.0) 
      cos3theta = 1.0;

    if (cos3theta < -1.0) 
      cos3theta = -1.0;
    
    g = getg(cc, cos3theta);

    if ( (p/Pat) >= 0.0 )
      ec = getec(e_r, lambda_c, xi, Pat, p);
    
    epsilon_v = Stra.Iinvariant1();
    e = e0 + (1.0 + e0) *epsilon_v;
    
    stateParameter = e - ec;    
    expnd = exp(nd*stateParameter);
    
    alpha_n = (alpha("ij")*n("ij")).trace();
    s_n = (s("ij")*n("ij")).trace();

    // way 1
    //ad = g*M_cal*expnd - m;
    //D0 = rt23 *ad - alpha_n;

    // way 2, better use this when "p" is small
    D0 = rt23*g*M_cal*expnd - s_n /p;

    z_n = (z("ij")*n("ij")).trace();
    if (z_n < 0.0) 
      z_n = 0.0;
    A_d = A0 * (1.0 + z_n);

    D = D0 *(-A_d);

    B = 1.0 + 1.5 *((1.0-cc)/cc) *g *cos3theta;
    C = 3.0 *sqrt(1.5) *((1.0-cc)/cc) *g;
    
    stresstensor n_n = n("ik")*n("kj");
      n_n.null_indices();

    // note different 'positive-negative' since we assume extension (dilation) positive 
    // which is different from the Ref.
    DM04_PF::DM04m = n *B + n_n *C + I2 *((D-C)*oneOver3);
                           
    return DM04_PF::DM04m;
}
Esempio n. 12
0
int
POL::getcmd()
{
  int tt, found;
  char str[MAXTOK+1];
  KeywordCodeEntry *cmd;
  TOKEN tok;

  tt = getalpha (str, MAXTOK);
  if (tt == TT_ERROR) {
    sys_error (ERR_WARNING, "Error in POL parameter command");
    reader();
    return(false);
  }
  if ((cmd = cmdtable.lookup (str)) == NULL) {
    sys_error  (ERR_WARNING, "POL: Unrecognized command %s", cmd);
    reader();
    return (false);
  } else {
    found = false;
    switch (cmd->getCode()) {
    case PC_TRON:
                    m_bTrace = true;
        found = true;
        break;
    case PC_TROFF:
                    m_bTrace = false;
        found = true;
        break;
    case PC_FILE:
                    found = true;
        tt = gettok (&tok);
        usefile (P_USE_FILE, tok.tokstr);
        break;
    case PC_NL_EOC:
                    found = true;
        m_bNewlineIsEOC = true;
        break;
    case PC_NL_NEOC:
                    found = true;
        m_bNewlineIsEOC = false;
        break;
    case PC_DUMP:
                    found = true;
        printf("eoc = %c  str = %c  com = %c  cmd = %c  prg = %c\n",
          meta.eoc, meta.str, meta.com, meta.cmd, meta.prg);
        printf("con = %c  out = %c  ter = %c  inb = %c\n",
          meta.con, meta.out, meta.ter, meta.inb);
        break;
    }
    if (found == false) {
      tt = gettok (&tok);
      if (tt != TT_SPECLCHAR) {
        sys_error (ERR_SEVERE, "POL: Illegal command character");
        return (false);
      }
      switch(cmd->getCode()) {
                    case PC_EOC:
          meta.eoc = tok.tokstr[0];
          break;
        case PC_STR:
          meta.str = tok.tokstr[0];
          break;
        case PC_COM:
          meta.com = tok.tokstr[0];
          break;
        case PC_CMD:
          meta.cmd = tok.tokstr[0];
          break;
        case PC_PRG:
          meta.prg = tok.tokstr[0];
          break;
        case PC_CON:
          meta.con = tok.tokstr[0];
          break;
        case PC_OUT:
          meta.out = tok.tokstr[0];
          break;
        case PC_TER:
          meta.ter = tok.tokstr[0];
          break;
        case PC_INB:
          meta.inb = tok.tokstr[0];
          break;
        default:
          printf("command not implemented\n");
          break;
      }                         /* switch (tok->type) */
    }                                   /* if (found == false) */
    reader();                   /* clean up command */
  }                                     /* if legal command */

  return (true);
}
Esempio n. 13
0
const straintensor& SANISAND_alpha_Eij::Hij(const PlasticFlow& plastic_flow, const stresstensor& Stre, 
                                            const straintensor& Stra, const MaterialParameter& material_parameter)
{
//    const double rt23 = sqrt(2.0/3.0);    

//    stresstensor a_a_in;
//    double a_in = 0.0;

    double e0 = gete0(material_parameter);
    double e_r = gete_r(material_parameter);
    double lambda = getlambda(material_parameter);
    double xi = getxi(material_parameter);
    double Pat = getPat(material_parameter);
    double alpha_cc = getalpha_cc(material_parameter);
    double c = getc(material_parameter);
    double nb = getnb(material_parameter);
    double h0 = geth0(material_parameter);
    double ch = getch(material_parameter);
    double G0 = getG0(material_parameter);        
    double m = getm(material_parameter);
    stresstensor alpha = getalpha(material_parameter);

    stresstensor n;
    stresstensor s_bar;
    double norm_s = 0.0;
    double r_ef = 0.0;
    double cos3theta = 0.0;
    double g = 0.0;
    double ec = e_r;
    double e = e0;
    double psi = 0.0;
    double alpha_b_c = 0.0;
    stresstensor alpha_b_tensor;
    stresstensor b_ref;
    stresstensor temp_tensor;
    double lower = 0.0;
    double h = G0*h0;

    double p = Stre.p_hydrostatic();
    stresstensor s = Stre.deviator();

    s_bar = s - (alpha *p);
    norm_s = sqrt( (s_bar("ij")*s_bar("ij")).trace() );
    if (p > 0.0 && norm_s > 0.0)
    {
      n = s_bar * (1.0/norm_s);
      r_ef = rt32 * norm_s / p;
      cos3theta = -3.0 * sqrt(6.0) * n.Jinvariant3();
    }   

    if (p <= 0.0)
      cos3theta = 1.0;

    if (cos3theta > 1.0) 
      cos3theta = 1.0;

    if (cos3theta < -1.0) 
      cos3theta = -1.0;
    
    g = getg(c, cos3theta);

    if ( p >= 0.0 )
      ec = getec(e_r, lambda, xi, Pat, p);

    e = e0 + (1.0 + e0) * Stra.Iinvariant1();
    psi = e - ec;    
    alpha_b_c = alpha_cc * exp(-nb*psi);
    alpha_b_tensor = n * (rt23 * g * alpha_b_c);
    b_ref = n * rt23 * alpha_b_c * (1.0+c);
//    b_ref = n * rt23 * alpha_cc * (1.0+c);

    // Method 1
    temp_tensor = b_ref - (alpha_b_tensor - alpha);

    //// Method 2, better to use this when "p" is small 
    //temp_tensor = b_ref - (alpha_b_tensor - s*(1.0/p));

    lower = rt32*(temp_tensor("ij")*n("ij")).trace();
    if ( lower>0 ) 
      h = G0 * h0 * (1-ch*e) * sqrt(Pat/p) / (lower*lower);
//      h = G0 * h0 * (1-ch*e) * sqrt(Pat/p);
//      h = h0;

    // Method 1
    temp_tensor = alpha_b_tensor - alpha; 
    
    // Method 2
    //temp_tensor = alpha_b_tensor+n*m - s*(1.0/p); 

    TensorEvolution::TensorEvolutionHij = temp_tensor * (h*r_ef);
     
    return TensorEvolution::TensorEvolutionHij;
}