void gfs_mac_projection_por (GfsDomain * domain, GfsPorous * por, GfsMultilevelParams * par, gdouble dt, GfsVariable * p, GfsFunction * alpha, GfsVariable ** g, void (* divergence_hook) (GfsDomain * domain, gdouble dt, GfsVariable * div) ) { g_return_if_fail (domain != NULL); g_return_if_fail (par != NULL); g_return_if_fail (p != NULL); g_return_if_fail (g != NULL); gfs_domain_timer_start (domain, "mac_projection"); mac_projection_por (domain, por, par, dt, p, alpha, NULL, g, divergence_hook); gfs_domain_timer_stop (domain, "mac_projection"); if (par->residual.infty > par->tolerance) g_warning ("MAC projection: max residual %g > %g", par->residual.infty, par->tolerance); }
void gfs_approximate_projection_por (GfsDomain * domain, GfsPorous * por, GfsMultilevelParams * par, gdouble dt, GfsVariable * p, GfsFunction * alpha, GfsVariable * res, GfsVariable ** g, void (* divergence_hook) (GfsDomain * domain, gdouble dt, GfsVariable * div) ) { g_return_if_fail (domain != NULL); g_return_if_fail (par != NULL); g_return_if_fail (p != NULL); g_return_if_fail (g != NULL); gfs_domain_timer_start (domain, "approximate_projection"); gfs_pre_projection (domain, por, FTT_DIMENSION); /* compute MAC velocities from centered velocities */ gfs_domain_face_traverse (domain, FTT_XYZ, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttFaceTraverseFunc) gfs_face_reset_normal_velocity, NULL); gfs_domain_face_traverse (domain, FTT_XYZ, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttFaceTraverseFunc) gfs_face_interpolated_normal_velocity, gfs_domain_velocity (domain)); mac_projection_por (domain, por, par, dt, p, alpha, res, g, divergence_hook); gfs_correct_centered_velocities (domain, FTT_DIMENSION, g, dt); gfs_post_projection (domain, por, FTT_DIMENSION); gfs_domain_timer_stop (domain, "approximate_projection"); if (par->residual.infty > par->tolerance) g_warning ("approx projection: max residual %g > %g", par->residual.infty, par->tolerance); }
static void gse_alleviation_diffusion (GfsDomain * domain, GfsVariable * F, FttVector * cg, gdouble dt) { gfs_domain_timer_start (domain, "gse_alleviation"); gdouble ncg = sqrt (cg->x*cg->x + cg->y*cg->y); gdouble dcg = (GFS_WAVE_GAMMA - 1./GFS_WAVE_GAMMA)*ncg/2.; gdouble dtheta = 2.*M_PI/GFS_WAVE (domain)->ntheta; #if 0 gdouble Ts = 4.*GFS_WAVE (domain)->alpha_s*GFS_WAVE (domain)->alpha_s*dt; gdouble dtDss = dt*dcg*dcg*Ts/12.; gdouble dtDnn = dt*(ncg*dtheta)*(ncg*dtheta)*Ts/12.; #else gdouble alpha = GFS_WAVE (domain)->alpha_s*dcg*dt; gdouble beta = GFS_WAVE (domain)->alpha_s*ncg*dtheta*dt; gdouble dtDss = alpha*alpha/3.; gdouble dtDnn = beta*beta/3.; #endif GSEData p; gdouble cost = cg->x/ncg, sint = cg->y/ncg; p.D[0][0] = dtDss*cost*cost + dtDnn*sint*sint; p.D[1][1] = dtDss*sint*sint + dtDnn*cost*cost; p.D[0][1] = p.D[1][0] = (dtDss - dtDnn)*cost*sint; p.F = F; p.Fn = gfs_temporary_variable (domain); p.dF = gfs_temporary_variable (domain); gfs_domain_traverse_leaves (domain, (FttCellTraverseFunc) copy_F, &p); gfs_domain_cell_traverse (domain, FTT_POST_ORDER, FTT_TRAVERSE_NON_LEAFS, -1, (FttCellTraverseFunc) p.Fn->fine_coarse, p.Fn); for (p.dF->component = 0; p.dF->component < 2; p.dF->component++) { gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_ALL, -1, (FttCellTraverseFunc) compute_gradient, &p); gfs_domain_bc (domain, FTT_TRAVERSE_ALL, -1, p.dF); gfs_domain_traverse_leaves (domain, (FttCellTraverseFunc) diffusion, &p); } gts_object_destroy (GTS_OBJECT (p.Fn)); gts_object_destroy (GTS_OBJECT (p.dF)); gfs_domain_timer_stop (domain, "gse_alleviation"); }