static void gfs_refine_refine (GfsRefine * refine, GfsSimulation * sim) { gfs_catch_floating_point_exceptions (); gts_container_foreach (GTS_CONTAINER (sim), (GtsFunc) refine_box, refine->maxlevel); gfs_restore_fpe_for_function (refine->maxlevel); }
static gboolean gfs_init_wave_event (GfsEvent * event, GfsSimulation * sim) { if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_init_wave_class ())->parent_class)->event) (event, sim)) { gfs_catch_floating_point_exceptions (); gfs_domain_cell_traverse (GFS_DOMAIN (sim), FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttCellTraverseFunc) init_energy, event); gfs_restore_fpe_for_function (GFS_INIT_WAVE (event)->d); gfs_catch_floating_point_exceptions (); gfs_domain_cell_traverse (GFS_DOMAIN (sim), FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttCellTraverseFunc) scale_energy, event); gfs_restore_fpe_for_function (GFS_INIT_WAVE (event)->hs); return TRUE; } return FALSE; }
void gfs_source_darcy_implicit (GfsDomain * domain, gdouble dt) { GfsSourceDarcy * s; g_return_if_fail (domain != NULL); if ((s = gfs_has_source_darcy (domain))) { GfsSimulation * sim = GFS_SIMULATION (domain); gdouble olddt = sim->advection_params.dt; sim->advection_params.dt = dt; gfs_catch_floating_point_exceptions (); gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttCellTraverseFunc) (FTT_DIMENSION==3? implicit_darcy_3D : implicit_darcy_2D), s); if (gfs_restore_floating_point_exceptions ()) { gchar * c = g_strconcat ("\n", gfs_function_description (s->darcycoeff, FALSE), NULL); if (s->forchhicoeff) c = g_strconcat (c, "\n", gfs_function_description (s->forchhicoeff, FALSE), NULL); /* fixme: memory leaks */ g_message ("floating-point exception in user-defined function(s):%s", c); exit (1); } sim->advection_params.dt = olddt; } }
static gboolean gfs_init_face_values_event (GfsEvent * event, GfsSimulation * sim) { if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_init_face_values_class ())->parent_class)->event) (event, sim)) { GSList * i = GFS_INIT (event)->f; while (i) { VarFunc * vf = i->data; FaceInitData data; FttComponent c = FTT_DIMENSION; if (!strcmp (vf->v[0]->name, "U")) { if (vf->n > 1) g_assert_not_implemented (); data.v1 = GFS_SKEW_SYMMETRIC(sim)->velfaces[0]; data.v2 = GFS_SKEW_SYMMETRIC(sim)->velfaces[1]; data.f = vf->f[0]; c = FTT_X; } else if (!strcmp (vf->v[0]->name, "V")) { data.v1 = GFS_SKEW_SYMMETRIC(sim)->velfaces[2]; data.v2 = GFS_SKEW_SYMMETRIC(sim)->velfaces[3]; data.f = vf->f[0]; c = FTT_Y; } #if (!FTT_2D) else if (!strcmp (vf->v[0]->name, "W")) { data.v1 = GFS_SKEW_SYMMETRIC(sim)->velfaces[4]; data.v2 = GFS_SKEW_SYMMETRIC(sim)->velfaces[5]; data.f = vf->f[0]; c = FTT_Z; } #endif if (c < FTT_DIMENSION) { gfs_catch_floating_point_exceptions (); gfs_domain_face_traverse (GFS_DOMAIN (sim), c, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttFaceTraverseFunc) init_fd, &data); gfs_restore_fpe_for_function (vf->f[0]); } i = i->next; } return TRUE; } return FALSE; }
static gboolean gfs_source_darcy_event (GfsEvent * event, GfsSimulation * sim) { if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_source_darcy_class ())->parent_class)->event) (event, sim)) { /* do object-specific event here */ if (GFS_SOURCE_DARCY (event)->beta < 1.) { gfs_catch_floating_point_exceptions (); gfs_domain_traverse_layers (GFS_DOMAIN (sim), (FttCellTraverseFunc) save_darcy, event); if (gfs_restore_floating_point_exceptions ()) { GfsSourceDarcy * c = GFS_SOURCE_DARCY (event); gchar * s = g_strconcat ("\n", gfs_function_description (c->darcycoeff, FALSE), NULL); if (c->forchhicoeff) s = g_strconcat (s, "\n", gfs_function_description (c->forchhicoeff, FALSE), NULL); /* fixme: memory leaks */ g_message ("floating-point exception in user-defined function(s):%s", s); exit (1); } } return TRUE; } return FALSE; }
static void gfs_refine_solid_refine (GfsRefine * refine, GfsSimulation * sim) { if (sim->solids) { RefineCut p; p.refine = refine; p.domain = GFS_DOMAIN (sim); GSList * i = sim->solids->items; while (i) { p.surface = GFS_SOLID (i->data)->s; gfs_catch_floating_point_exceptions (); if (GFS_SURFACE (p.surface)->s) gfs_domain_traverse_cut (GFS_DOMAIN (sim), p.surface, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, (FttCellTraverseCutFunc) refine_cut_cell, &p); else gfs_domain_cell_traverse (GFS_DOMAIN (sim), FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, (FttCellTraverseFunc) refine_implicit_cell, &p); gfs_restore_fpe_for_function (refine->maxlevel); i = i->next; } } }