Exemplo n.º 1
0
static void diffusion_term (FttCell * cell, DataDif * data)
{
  /* fixme: I need to account for the metric */
  gdouble size, sizenext, size_ratio;
  gdouble un, unext, unprev;

  FttDirection d0;
  for (d0 = 0; d0 < FTT_NEIGHBORS; d0++) {

  FttCellFace face = gfs_cell_face(cell, d0);
  gdouble flux = 0.;  
  gdouble invdens = data->alpha ? gfs_function_face_value (data->alpha, &face) : 1.;
  gdouble visc = gfs_diffusion_cell (data->d->D, cell);

  GfsStateVector * s = GFS_STATE (cell);

  FttDirection od = FTT_OPPOSITE_DIRECTION(d0);

  un = interpolate_value_skew (cell, d0, NULL, data->fd);

  if ((d0 % 2) != 0) {
    unext    = interpolate_value_skew (cell, od , NULL, data->fd);
    unprev   = interpolate_value_skew (cell, d0 , &(d0) , data->fd); 
    sizenext = ftt_cell_size (cell); 
    size     = get_size_next (cell, d0);
  }
  else {
    unext    = interpolate_value_skew (cell, d0, &(d0), data->fd);
    unprev   = interpolate_value_skew (cell, od,      NULL,    data->fd);
    size     = ftt_cell_size (cell); 
    sizenext = get_size_next (cell, d0);
  } 
  size_ratio = ( 1. + sizenext / size ) / 2;
  flux = ( (unext - un)/sizenext - (un - unprev)/size );

  FttComponent c = d0/2;
#if FTT_2D
  FttComponent oc = FTT_ORTHOGONAL_COMPONENT (c);
  flux += size_ratio * transverse_diffusion(cell, oc, d0, un, data->fd);
#else
  static FttComponent orthogonal[FTT_DIMENSION][2] = {
    {FTT_Y, FTT_Z}, {FTT_X, FTT_Z}, {FTT_X, FTT_Y}
  };
  flux += size_ratio * transverse_diffusion(cell, orthogonal[c][0], d0, un, data->fd);
  flux += size_ratio * transverse_diffusion(cell, orthogonal[c][1], d0, un, data->fd);
#endif 

  s->f[d0].v -= invdens*visc*flux;
  }
}
Exemplo n.º 2
0
static void darcy_coefficients (GfsSourceDarcy * sd, FttCell * cell, GfsVariable ** u, FttComponent c1, gdouble f[2])
{
    GfsPorous * por = GFS_POROUS (gfs_object_simulation (sd));
    GfsDomain * domain = GFS_DOMAIN(por);
    GfsFunction * porosity = por->porosity;
    GfsFunction * K = por->K;
    gdouble viscosity = 0.001;
    GfsVariable ** U = gfs_domain_velocity (domain);
    GfsSourceVelocity * sv = GFS_SOURCE_VELOCITY (domain);
    GfsSourceDiffusion * d = source_diffusion_viscosity (U[0]); 

    if (d)
    viscosity = gfs_diffusion_cell (d->D, cell);
       
    f[0] = (viscosity * gfs_function_value (porosity,cell))/gfs_function_value (K,cell);
    
    gdouble modu;
    modu = fabs(sqrt(GFS_VALUE (cell, sv->v[0])*GFS_VALUE (cell, sv->v[0]) + 
		   GFS_VALUE (cell, sv->v[1])*GFS_VALUE (cell, sv->v[1])));

    f[1] = (gfs_function_value (porosity,cell))/sqrt(gfs_function_value (K,cell))*modu;
    
  
}