Пример #1
0
static void fill_cartesian_matrix ( GfsCartesianGrid * cgd, GfsVariable * v, GfsDomain * domain )
{
  guint i,j,k;
  FttVector pos;
  FttCell * cell;

  for (i = 0; i < cgd->n[0]; i++)
    for (j = 0; j < cgd->n[1]; j++)
      for (k = 0; k < cgd->n[2]; k++) {
        pos.x = cgd->x[0][i];
        pos.y = cgd->x[1][j];
        pos.z = cgd->x[2][k];

        cell = gfs_domain_locate (domain, pos, -1, NULL);
        cgd->v[k+cgd->n[2]*(i*cgd->n[1]+j)] = gfs_interpolate (cell, pos, v);
      }
}
Пример #2
0
static void ftt_sample(FttCell *cell, gpointer data)
{
  ftts_t ftts = *((ftts_t*)data);
  int level   = ftt_cell_level(cell);
  double size = ftt_cell_size(cell);
  bbox_t bb   = bilinear_bbox(ftts.B[0]);

  FttVector p;
  ftt_cell_pos(cell,&p);

  /* the number in each directon we will sample */

  int n = POW2(ftts.depth-level);
  
  /* cell coordinates at this level */

  int ic = (p.x - bb.x.min)/size;
  int jc = (p.y - bb.y.min)/size;

  /* subgrid extent */

  double xmin = p.x - size/2.0;
  double ymin = p.y - size/2.0;
  double d = size/n;

#ifdef FFTS_DEBUG
  printf("%f %f (%i %i %i %i)\n",p.x,p.y,level,n,ic,jc);
#endif 

  int i,j;

  for (i=0 ; i<n ; i++)
    {
      double x = xmin + (i+0.5)*d;
      int ig = ic*n + i;

      for (j=0 ; j<n ; j++)
	{
	  double y = ymin + (j+0.5)*d;
	  int jg = jc*n + j;

	  /* 
	     ig, jg are the global indicies, so give a sample
	     point for the bilinear struct. Note that (x,y) and
	     (x0,y0) shoule be the same, else the bilinear and
	     octree grids are not aligned.
	  */

#ifdef FFTS_DEBUG
	  double x0, y0;
	  bilinear_getxy(ig, jg, ftts.B[0], &x0, &y0);
#endif

	  FttVector p;

	  p.x = x;
	  p.y = y;

	  double 
	    u = gfs_interpolate(cell,p,ftts.u),
	    v = gfs_interpolate(cell,p,ftts.v);

	  bilinear_setz(ig,jg,u,ftts.B[0]);
	  bilinear_setz(ig,jg,v,ftts.B[1]);

#ifdef FFTS_DEBUG
	  printf("  (%f %f) (%f %f) (%i %i) %f %f (%f %f)\n",
		 x, y, x0, y0, ig, jg, u, v, x-x0, y-y0);
#endif
	}
    }
}