Ejemplo n.º 1
0
static void wave_init (GfsWave * wave)
{
  wave->nk = 25;
  wave->ntheta = 24;
  wave->alpha_s = 0.;
  /* default for g is acceleration of gravity on Earth with kilometres as
     spatial units, hours as time units and Hz as frequency units */
  GFS_SIMULATION (wave)->physical_params.g = 9.81/1000.*3600.;

  GfsAdvectionParams * par = &GFS_SIMULATION (wave)->advection_params;
  par->gradient = gfs_center_van_leer_gradient;
  par->flux = gfs_face_advection_flux;
  par->use_centered_velocity = FALSE;  

  static GfsDerivedVariableInfo derived_variable[] = {
    { "Hs", "Significant wave height", cell_hs },
    { "Energy", "Wave energy", cell_E },
    { "Frequency", "Wave frequency", cell_frequency },
    { "Direction", "Wave direction (angle)", cell_direction },
    { NULL, NULL, NULL}
  };
  GfsDerivedVariableInfo * v = derived_variable;
  while (v->name) {
    g_assert (gfs_domain_add_derived_variable (GFS_DOMAIN (wave), *v));
    v++;
  }
}
Ejemplo n.º 2
0
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;
  }
}
Ejemplo n.º 3
0
static void gfs_porous_read (GtsObject ** o, GtsFile * fp)
{


	/* call read method of parent */
	(* GTS_OBJECT_CLASS (gfs_porous_class ())->parent_class->read) (o, fp);
	if (fp->type == GTS_ERROR)
		return;

	GfsPorous * por = GFS_POROUS (*o);
	GfsSimulation * sim = GFS_SIMULATION (por);
	/* do object-specific read here */

	if (fp->type != '{') {
		gts_file_error (fp, "expecting an opening brace");
		return;
	}

	fp->scope_max++;
	gts_file_next_token (fp);

	while (fp->type != GTS_ERROR && fp->type != '}') {
		if (fp->type == '\n') {
			gts_file_next_token (fp);
			continue;
		}

		if (fp->type != GTS_STRING) {
			gts_file_error (fp, "expecting a keyword");
			return;
		}

		if (!strcmp (fp->token->str, "porosity")) {
			gts_file_next_token (fp);
			if (fp->type != '=')
				gts_file_error (fp, "expecting `='");
			else{
				gts_file_next_token (fp);
				gfs_function_read (por->porosity, sim, fp);
			}
		}


		if (!strcmp (fp->token->str, "K")) {
			gts_file_next_token (fp);
			if (fp->type != '=')
				gts_file_error (fp, "expecting `='");
			else{
				gts_file_next_token (fp);
				gfs_function_read (por-> K, sim , fp);
			}
		}
	}
	if (fp->type == GTS_ERROR)
		return;
	if (fp->type != '}') {
		gts_file_error (fp, "expecting a closing brace");
		return;

		fp->scope_max--;
		gts_file_next_token (fp);
		/* do not forget to prepare for next read */
	}
}