Ejemplo n.º 1
0
static void poisson_mixed_coeff_por (FttCell * cell, PoissonCoeff_por * p)
{
  if (GFS_IS_MIXED (cell)) {
    gdouble alpha = p->alpha ? (gfs_function_value (p->alpha, cell)*gfs_function_value (p->phi , cell)) : gfs_function_value (p->phi, cell);
    if (((cell)->flags & GFS_FLAG_DIRICHLET) == 0)
      /* Neumann condition (prescribed flux) */
      GFS_STATE (cell)->solid->v.x += alpha;
    else {
      /* Dirichlet */
      GfsSolidVector * s = GFS_STATE (cell)->solid;
      FttVector m = {1.,1.,1.};
      gfs_domain_solid_metric (p->domain, cell, &m);
      FttComponent c;
      for (c = 0; c < FTT_DIMENSION; c++)
        (&s->v.x)[c] += alpha*(&m.x)[c]*(s->s[2*c + 1] - s->s[2*c]);
    }

    if (alpha <= 0. && p->positive) {
      FttVector p;
      ftt_cell_pos (cell, &p);
      g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
             "alpha is negative (%g) at cell (%g,%g,%g).\n"
             "Please check your definition.",
             alpha, p.x, p.y, p.z);
    }
  }
}
Ejemplo n.º 2
0
static void implicit_darcy_2D (FttCell * cell, GfsSourceDarcy * s)
{
    
    GfsSourceVelocity * sv = GFS_SOURCE_VELOCITY (s);
    gdouble m[2][2];
    gdouble f[2];
    GfsSimulation * sim = gfs_object_simulation (s);
    gdouble dt = sim->advection_params.dt;

    darcy_coefficients (s, cell, sv->v, FTT_X, f);
    gdouble d = s->darcycoeff ? gfs_function_value (s->darcycoeff, cell):0.;
    gdouble e = s->forchhicoeff ? gfs_function_value (s->forchhicoeff, cell):0.;

    f[0] *= d;
    f[1] *= e;

    m[0][0] = 1. + (f[0]+f[1])*dt;
    m[0][1] = 0;
    darcy_coefficients (s, cell, sv->v, FTT_Y, f);
    m[1][0] = 0;
    m[1][1] = 1. + (f[0]+f[1])*dt;

    gdouble det = m[0][0]*m[1][1] - m[0][1]*m[1][0];
    gdouble u = GFS_VALUE (cell, sv->v[0]);
    gdouble v = GFS_VALUE (cell, sv->v[1]);

    GFS_VALUE (cell, sv->v[0]) = (  m[1][1]*u - m[0][1]*v)/det;
    GFS_VALUE (cell, sv->v[1]) = (- m[1][0]*u + m[0][0]*v)/det;
}
Ejemplo n.º 3
0
static void init_energy (FttCell * cell, GfsInitWave * event)
{
  GfsWave * wave = GFS_WAVE (gfs_object_simulation (event));
  for (wave->ik = 0; wave->ik < wave->nk; wave->ik++)
    for (wave->ith = 0; wave->ith < wave->ntheta; wave->ith++)
      GFS_VALUE (cell, wave->F[wave->ik][wave->ith]) = gfs_function_value (event->d, cell);
}
Ejemplo n.º 4
0
static gdouble gfs_source_darcy_mac_value (GfsSourceGeneric * s,
					      FttCell * cell,
					      GfsVariable * v)
{
  GfsSourceVelocity * sv = GFS_SOURCE_VELOCITY (s);
  GfsSourceDarcy * sd = GFS_SOURCE_DARCY (s);

#if FTT_2D
  gdouble f[2];
  darcy_coefficients (sd, cell, sv->v, v->component, f);
  switch (v->component) {
  case FTT_X: return    -(f[0]+f[1])*GFS_VALUE (cell, sv->v[0]);
  case FTT_Y: return    -(f[0]+f[1])*GFS_VALUE (cell, sv->v[1]);
  default: g_assert_not_reached ();
  }
#else  /* 3D */
  gdouble f = gfs_function_value (sd->darcycoeff, cell);

//gdouble e = sd->forchhi ? gfs_function_value (sd->forchhi, cell) : 0.;

  switch (v->component) {
  case FTT_X: return - f*GFS_VALUE (cell, sv->v[0]);
  case FTT_Y: return - f*GFS_VALUE (cell, sv->v[1]);
  case FTT_Z: return - f*GFS_VALUE (cell, sv->v[2]);
  default: g_assert_not_reached ();
  }
#endif /* 3D */
  return 0.;
}
Ejemplo n.º 5
0
static void refine_cut_cell (FttCell * cell, GfsGenericSurface * s, RefineCut * p)
{
  GTS_OBJECT (s)->reserved = p->surface;
  GFS_REFINE_SOLID (p->refine)->v->data = s;
  if (ftt_cell_level (cell) < gfs_function_value (p->refine->maxlevel, cell))
    ftt_cell_refine_single (cell, p->domain->cell_init, p->domain->cell_init_data);
  GFS_REFINE_SOLID (p->refine)->v->data = NULL;
}
Ejemplo n.º 6
0
static void correct_por_undo (FttCell * cell, gpointer * data)
{
  FttComponent c;
  GfsVariable **v = data[0];
  guint * dimension = data[1];
  GfsPorous *por = data[2];

  for (c = 0; c < *dimension; c++)
  GFS_VALUE (cell, v[c]) *= (1/gfs_function_value (por->porosity, cell)); 
}
Ejemplo n.º 7
0
static void save_darcy (FttCell * cell, GfsSourceDarcy * s)
{
  GfsSourceVelocity * sv = GFS_SOURCE_VELOCITY (s);

  gdouble f[2];
  darcy_coefficients (s, cell, sv->v, FTT_X, f);
  darcy_coefficients (s, cell, sv->v, FTT_Y, f);

  gdouble d = s->darcycoeff ? gfs_function_value (s->darcycoeff, cell)*(1. - s->beta):0.;
  gdouble e = s->forchhicoeff ? gfs_function_value (s->forchhicoeff, cell)*(1. - s->beta) : 0.;

  d *= f[0];
  e *= f[1];

  GFS_VALUE (cell, s->u[0]) = - (d+e)*GFS_VALUE (cell, sv->v[0]);
  GFS_VALUE (cell, s->u[1]) = - (d+e)*GFS_VALUE (cell, sv->v[1]);
#if !FTT_2D
  GFS_VALUE (cell, s->u[2]) = - (d+e)*GFS_VALUE (cell, sv->v[2]);
#endif /* 3D */
}
Ejemplo n.º 8
0
static void scale_energy (FttCell * cell, GfsInitWave * event)
{
  GfsWave * wave = GFS_WAVE (gfs_object_simulation (event));
  gdouble E = cell_E (cell, NULL, GFS_DOMAIN (wave));
  if (E > 0.) {
    gdouble Hs = gfs_function_value (event->hs, cell);
    gdouble scaling = Hs*Hs/(16.*E);
    guint ik, ith;
    for (ik = 0; ik < wave->nk; ik++)
      for (ith = 0; ith < wave->ntheta; ith++)
	GFS_VALUE (cell, wave->F[ik][ith]) *= scaling;
  }
}
Ejemplo n.º 9
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;
    
  
}
Ejemplo n.º 10
0
static gboolean refine_maxlevel (FttCell * cell, GfsFunction * maxlevel)
{
  return (ftt_cell_level (cell) < gfs_function_value (maxlevel, cell));
}
Ejemplo n.º 11
0
static void refine_implicit_cell (FttCell * cell, RefineCut * p)
{
  guint maxlevel = gfs_function_value (p->refine->maxlevel, cell);
  if (ftt_cell_level (cell) < maxlevel && gfs_cell_is_cut (cell, p->surface, FALSE, maxlevel))
    ftt_cell_refine_single (cell, p->domain->cell_init, p->domain->cell_init_data);
}