static void init_fd (FttCellFace * face, FaceInitData * fd) { if (face->d % 2 != 0) GFS_VALUE (face->cell, fd->v2) = gfs_function_face_value (fd->f, face); else GFS_VALUE (face->cell, fd->v1) = gfs_function_face_value (fd->f, face); }
static void poisson_coeff_por (FttCellFace * face, PoissonCoeff_por * p) { gdouble alpha = p->alpha ? (gfs_function_face_value (p->alpha, face)*gfs_function_face_value (p->phi, face)) : gfs_function_face_value (p->phi, face); gdouble v = p->lambda2[face->d/2]*alpha*gfs_domain_face_fraction (p->domain, face)/ gfs_domain_face_scale_metric (p->domain, face, face->d/2); if (alpha <= 0. && p->positive) { FttVector p; ftt_face_pos (face, &p); g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "alpha is negative (%g) at face (%g,%g,%g).\n" "Please check your definition.", alpha, p.x, p.y, p.z); } GFS_STATE (face->cell)->f[face->d].v += v; switch (ftt_face_type (face)) { case FTT_FINE_FINE: GFS_STATE (face->neighbor)->f[FTT_OPPOSITE_DIRECTION (face->d)].v += v; break; case FTT_FINE_COARSE: GFS_STATE (face->neighbor)->f[FTT_OPPOSITE_DIRECTION (face->d)].v += v/FTT_CELLS_DIRECTION (face->d); break; default: g_assert_not_reached (); } }
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; } }