[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet popinet at users.sf.net
Fri May 15 02:55:16 UTC 2009


The following commit has been merged in the upstream branch:
commit fb923c1ec27069d6826681b9254f0ac56e930544
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Tue Apr 29 18:38:10 2008 +1000

    Map module also scales z coordinate
    
    darcs-hash:20080429083810-d4795-2c185de19fcc8f79e501b666ebf39d31285cef2c.gz

diff --git a/modules/map.mod b/modules/map.mod
index fc7e503..b646ad5 100644
--- a/modules/map.mod
+++ b/modules/map.mod
@@ -18,6 +18,7 @@
  */
 
 #include <proj_api.h>
+#include "simulation.h"
 #include "map.h"
 
 /* GfsMapProjection: Header */
@@ -31,7 +32,7 @@ struct _GfsMapProjection {
   gdouble cosa, sina;
 
   /*< public >*/
-  gdouble lon, lat, scale, angle;
+  gdouble lon, lat, scale, angle, zscale;
 };
 
 #define GFS_MAP_PROJECTION(obj)            GTS_OBJECT_CAST (obj,\
@@ -51,10 +52,11 @@ static void gfs_map_projection_read (GtsObject ** o, GtsFile * fp)
     return;
 
   GtsFileVariable var[] = {
-    {GTS_DOUBLE, "lon",   TRUE},
-    {GTS_DOUBLE, "lat",   TRUE},
-    {GTS_DOUBLE, "scale", TRUE},
-    {GTS_DOUBLE, "angle", TRUE},
+    {GTS_DOUBLE, "lon",    TRUE},
+    {GTS_DOUBLE, "lat",    TRUE},
+    {GTS_DOUBLE, "scale",  TRUE},
+    {GTS_DOUBLE, "angle",  TRUE},
+    {GTS_DOUBLE, "zscale", TRUE},
     {GTS_NONE}
   };
   GfsMapProjection * map = GFS_MAP_PROJECTION (*o);
@@ -62,6 +64,7 @@ static void gfs_map_projection_read (GtsObject ** o, GtsFile * fp)
   var[1].data = &map->lat;
   var[2].data = &map->scale;
   var[3].data = &map->angle;
+  var[4].data = &map->zscale;
 
   gts_file_assign_variables (fp, var);
   if (fp->type == GTS_ERROR)
@@ -69,6 +72,8 @@ static void gfs_map_projection_read (GtsObject ** o, GtsFile * fp)
 
   map->cosa = cos (map->angle*DEG_TO_RAD);
   map->sina = sin (map->angle*DEG_TO_RAD);
+  if (!var[4].set)
+    map->zscale = map->scale;
 
   char * parms[] = {
     "proj=lcc", /* Lambert Conformal Conic */
@@ -91,8 +96,8 @@ static void gfs_map_projection_write (GtsObject * o, FILE * fp)
 {
   (* GTS_OBJECT_CLASS (gfs_map_projection_class ())->parent_class->write) (o, fp);
   GfsMapProjection * map = GFS_MAP_PROJECTION (o);
-  fprintf (fp, " { lon = %.8g lat = %.8g scale = %.8g angle = %.8g }",
-	   map->lon, map->lat, map->scale, map->angle);
+  fprintf (fp, " { lon = %.8g lat = %.8g scale = %g angle = %g zscale = %g }",
+	   map->lon, map->lat, map->scale, map->angle, map->zscale);
 }
 
 static void gfs_map_projection_destroy (GtsObject * object)
@@ -114,6 +119,7 @@ static void projection_transform (GfsMap * map, const FttVector * src, FttVector
   odata.v /= m->scale;
   dest->x = odata.u*m->cosa - odata.v*m->sina;
   dest->y = odata.v*m->cosa + odata.u*m->sina;
+  dest->z = src->z/m->zscale*GFS_DOMAIN (gfs_object_simulation (map))->lambda.z;
 }
 
 static void projection_inverse (GfsMap * map, const FttVector * src, FttVector * dest)
@@ -128,6 +134,7 @@ static void projection_inverse (GfsMap * map, const FttVector * src, FttVector *
   odata = pj_inv (idata, GFS_MAP_PROJECTION (map)->pj);
   dest->x = odata.u*RAD_TO_DEG;
   dest->y = odata.v*RAD_TO_DEG;
+  dest->z = src->z*m->zscale/GFS_DOMAIN (gfs_object_simulation (map))->lambda.z;
 }
 
 static void gfs_map_projection_class_init (GfsMapClass * klass)
@@ -144,7 +151,7 @@ static void gfs_map_projection_init (GfsMapProjection * object)
   /* Wellington */
   object->lon = 174.777222;
   object->lat = -41.288889;
-  object->scale = 5e5;
+  object->scale = object->zscale = 5e5;
   object->angle = 0.; object->cosa = 1.; object->sina = 0.;
   object->pj = NULL;
 }
diff --git a/modules/terrain.mod b/modules/terrain.mod
index 09e7e29..8c7d375 100644
--- a/modules/terrain.mod
+++ b/modules/terrain.mod
@@ -548,7 +548,7 @@ static gboolean refine_terrain_from_boundary (FttCell * cell, GfsRefineTerrain *
 {
   FttVector p;
   ftt_cell_pos (cell, &p);
-  gdouble h = ftt_cell_size (cell)/2., zmin = (p.z - h)*4000., zmax = (p.z + h)*4000.;
+  gdouble h = ftt_cell_size (cell)/2., zmin = p.z - h, zmax = p.z + h;
   p.z = t->front;
   GfsDomain * domain = GFS_DOMAIN (gfs_object_simulation (t));
   FttCell * boundary = gfs_domain_locate (domain, p, ftt_cell_level (cell));
@@ -617,15 +617,15 @@ static void draw_terrain (FttCell * cell, gpointer * data)
   FttVector p;
   ftt_cell_pos (cell, &p);
   p.x += h/2.; p.y += h/2.;
-  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p)/4000.);
+  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p));
   p.x -= h;
-  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p)/4000.);
+  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p));
   p.y -= h;
-  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p)/4000.);
+  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p));
   p.x += h;
-  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p)/4000.);
+  fprintf (fp, "%g %g %g\n", p.x, p.y, cell_value (cell, t->h, p));
   p.y += h;
-  fprintf (fp, "%g %g %g\n\n\n", p.x, p.y, cell_value (cell, t->h, p)/4000.);
+  fprintf (fp, "%g %g %g\n\n\n", p.x, p.y, cell_value (cell, t->h, p));
 }
 
 static void draw_level (GfsDomain * domain, GfsRefine * refine, guint level, const gchar * name)
@@ -692,7 +692,7 @@ static void terrain_coarse_fine (FttCell * parent, GfsVariable * v)
 	hc[3] = h[3]/4.;
 #if !FTT_2D
 	ftt_cell_pos (child.c[n], &p);
-	gdouble zmin = (p.z - size)*4000., zmax = (p.z + size)*4000.;
+	gdouble zmin = p.z - size, zmax = p.z + size;
 	gdouble dx, dy;
 	gdouble minmax[2] = { G_MAXDOUBLE, - G_MAXDOUBLE };
 	for (dx = -1.; dx <= 1.; dx += 2.)
@@ -1023,8 +1023,8 @@ static guint surface_segment_intersection (GfsGenericSurface * s1,
   FttVector pE, pD;
   pE.x = I->E->x; pE.y = I->E->y;
   pD.x = I->D->x; pD.y = I->D->y;
-  gdouble vE = I->E->z - cell_value (cell, GFS_SURFACE_TERRAIN (s1)->h, pE)/4000.;
-  gdouble vD = I->D->z - cell_value (cell, GFS_SURFACE_TERRAIN (s1)->h, pD)/4000.;
+  gdouble vE = I->E->z - cell_value (cell, GFS_SURFACE_TERRAIN (s1)->h, pE);
+  gdouble vD = I->D->z - cell_value (cell, GFS_SURFACE_TERRAIN (s1)->h, pD);
   
   if ((vE > 0. && vD <= 0.) || (vE <= 0. && vD > 0.)) {
     I->n = 1;
@@ -1069,8 +1069,8 @@ static void surface_segment_normal (GfsGenericSurface * s1,
   p.y = I->E->y + I->x*(I->D->y - I->E->y);
   p.x = (p.x - q.x)/size;
   p.y = (p.y - q.y)/size;
-  n[0] = - (GFS_VALUE (cell, h[1]) + GFS_VALUE (cell, h[3])*p.y)/4000./size;
-  n[1] = - (GFS_VALUE (cell, h[2]) + GFS_VALUE (cell, h[3])*p.x)/4000./size;
+  n[0] = - (GFS_VALUE (cell, h[1]) + GFS_VALUE (cell, h[3])*p.y)/size;
+  n[1] = - (GFS_VALUE (cell, h[2]) + GFS_VALUE (cell, h[3])*p.x)/size;
   n[2] = 1.;
 }
 

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list