[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:56:05 UTC 2009
The following commit has been merged in the upstream branch:
commit d5cd0a2669ab6fc4beaab3169e4020dc442b3216
Author: Stephane Popinet <popinet at users.sf.net>
Date: Fri Aug 22 14:18:05 2008 +1000
New object GfsInitStokesWave
darcs-hash:20080822041805-d4795-0d6109c29f35ca64c435d691d77aee3a257c50af.gz
diff --git a/modules/CW263.f b/modules/CW263.f
index 20332dc..854a484 100644
--- a/modules/CW263.f
+++ b/modules/CW263.f
@@ -171,18 +171,18 @@ c
endif
zel= 2*pi/k
c
- open(12,file='cw263.psi')
- itl= 'Solved by CW263'
- datim= 'Space for date & time:'
- ver= 5.01
- el0= 9.81*zt**2/(2*pi)
- hl0= zh/el0
- dl0= zd/el0
- wl0= zel/el0
- write(12,101) itl,datim,ver,hl0,dl0,wl0,zh,zd,zt,nfun-1,zu
- write(12,102) (eta(i),c(i+1),i=1,nfun-1),eta(nfun)
- write(12,107) (amp(i)/zh,i=0,nfun-1)
- close(12)
+c$$$ open(12,file='cw263.psi')
+c$$$ itl= 'Solved by CW263'
+c$$$ datim= 'Space for date & time:'
+c$$$ ver= 5.01
+c$$$ el0= 9.81*zt**2/(2*pi)
+c$$$ hl0= zh/el0
+c$$$ dl0= zd/el0
+c$$$ wl0= zel/el0
+c$$$ write(12,101) itl,datim,ver,hl0,dl0,wl0,zh,zd,zt,nfun-1,zu
+c$$$ write(12,102) (eta(i),c(i+1),i=1,nfun-1),eta(nfun)
+c$$$ write(12,107) (amp(i)/zh,i=0,nfun-1)
+c$$$ close(12)
c
101 format(a/a,f10.2/3f16.10/3f16.10,i5,f16.10)
102 format(1p2e25.16)
@@ -784,9 +784,9 @@ c
rat= ha/hb
endif
c
- if (nverb.ne.0.or.rat.gt.1.0) then
- write(*,'(a,f5.3)') ' H/Hb = ',rat
- endif
+c if (nverb.ne.0.or.rat.gt.1.0) then
+c write(*,'(a,f5.3)') ' H/Hb = ',rat
+c endif
if (rat.gt.1.0) stop
c
return
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 08c83d1..43ad197 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -19,7 +19,9 @@ pkglib_LTLIBRARIES = \
libterrain2D.la \
libterrain3D.la \
libterrain2D3.la \
- $(TIDE)
+ $(TIDE) \
+ libstokes2D.la \
+ libstokes3D.la
bin_PROGRAMS = \
xyz2rsurface \
@@ -29,12 +31,14 @@ bin_PROGRAMS = \
EXTRA_DIST = \
map.mod \
tide.mod \
- terrain.mod
+ terrain.mod \
+ stokes.mod
BUILT_SOURCES = \
map.c \
tide.c \
- terrain.c
+ terrain.c \
+ stokes.c
AM_LDFLAGS = $(NO_UNDEFINED)\
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)\
@@ -70,6 +74,11 @@ libtide2D3_la_SOURCES = tide.c
libtide2D3_la_CFLAGS = $(AM_CFLAGS) $(GSL_CFLAGS) -DFTT_2D3=1
libtide2D3_la_LIBADD = -Lfes2004 -lfes -lnetcdf $(GSL_LIBS)
+libstokes3D_la_SOURCES = stokes.c CW263.f
+libstokes3D_la_CFLAGS = $(AM_CFLAGS)
+libstokes2D_la_SOURCES = stokes.c CW263.f
+libstokes2D_la_CFLAGS = $(AM_CFLAGS) -DFTT_2D=1
+
xyz2rsurface_SOURCES = xyz2rsurface.c rsurface.c rsurface.h
xyz2rsurface_LDADD = -LRStarTree -lcSmRST
xyz2rsurface_CFLAGS = $(AM_CFLAGS)
diff --git a/modules/stokes.mod b/modules/stokes.mod
new file mode 100644
index 0000000..93f2e61
--- /dev/null
+++ b/modules/stokes.mod
@@ -0,0 +1,192 @@
+/* Gerris - The GNU Flow Solver (-*-C-*-)
+ * Copyright (C) 2001-2008 National Institute of Water and Atmospheric Research
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+#include <stdlib.h>
+#include <math.h>
+#include "event.h"
+#include "solid.h"
+
+extern void cw260_ (const float * zd,
+ const float * zt,
+ const float * zh,
+ const float * zu,
+ const int * nverb,
+ int * nfun,
+ float * zel);
+
+extern void kmts_ (const int * nfun,
+ const float * xx,
+ const float * yy,
+ const float * tt,
+ float * uu,
+ float * vv,
+ float * ut,
+ float * vt,
+ float * du,
+ float * dv,
+ float * etah);
+
+/* GfsInitStokesWave: Header */
+
+typedef struct _GfsInitStokesWave GfsInitStokesWave;
+
+struct _GfsInitStokesWave {
+ /*< private >*/
+ GfsGenericInit parent;
+
+ /*< public >*/
+ gdouble steepness, depth;
+};
+
+#define GFS_INIT_STOKES_WAVE(obj) GTS_OBJECT_CAST (obj,\
+ GfsInitStokesWave,\
+ gfs_init_stokes_wave_class ())
+
+GfsGenericInitClass * gfs_init_stokes_wave_class (void);
+
+/* GfsInitStokesWave: Object */
+
+#define WAVELENGTH 100. /* metres */
+
+static int order = 0;
+
+static void gfs_init_stokes_wave_read (GtsObject ** o, GtsFile * fp)
+{
+ if (GTS_OBJECT_CLASS (gfs_init_stokes_wave_class ())->parent_class->read)
+ (* GTS_OBJECT_CLASS (gfs_init_stokes_wave_class ())->parent_class->read)
+ (o, fp);
+ if (fp->type == GTS_ERROR)
+ return;
+
+ GfsInitStokesWave * w = GFS_INIT_STOKES_WAVE (*o);
+ GtsFileVariable var[] = {
+ {GTS_DOUBLE, "depth", TRUE},
+ {GTS_DOUBLE, "steepness", TRUE},
+ {GTS_NONE}
+ };
+ var[0].data = &w->depth;
+ var[1].data = &w->steepness;
+ gts_file_assign_variables (fp, var);
+ if (fp->type == GTS_ERROR)
+ return;
+
+ float zd = WAVELENGTH*w->depth, zh = w->steepness*WAVELENGTH/M_PI, zu = 0., l;
+ int nverb = 0;
+
+ float min = 1., max = 100., zt = (min + max)/2.;
+ do {
+ cw260_ (&zd, &zt, &zh, &zu, &nverb, &order, &l);
+ fprintf (stderr, "# order: %d wavelength: %g period: %g\n",
+ order, l, zt);
+ if (l > WAVELENGTH)
+ max = zt;
+ if (l < WAVELENGTH)
+ min = zt;
+ zt = (min + max)/2.;
+ } while (fabs (l - WAVELENGTH) > 1e-4);
+}
+
+static void gfs_init_stokes_wave_write (GtsObject * o, FILE * fp)
+{
+ if (GTS_OBJECT_CLASS (gfs_init_stokes_wave_class ())->parent_class->write)
+ (* GTS_OBJECT_CLASS (gfs_init_stokes_wave_class ())->parent_class->write)
+ (o, fp);
+
+ fprintf (fp, " { depth = %g steepness = %g }\n",
+ GFS_INIT_STOKES_WAVE (o)->depth,
+ GFS_INIT_STOKES_WAVE (o)->steepness);
+}
+
+static void init_velocity (FttCell * cell, GfsVariable ** velocity)
+{
+ FttVector p;
+ gfs_cell_cm (cell, &p);
+ float x = (p.x + 0.5)*WAVELENGTH, y = p.y*WAVELENGTH, t = 0., u, v, ut, vt, du, dv, etah;
+ kmts_ (&order, &x, &y, &t, &u, &v, &ut, &vt, &du, &dv, &etah);
+ GFS_VALUE (cell, velocity[0]) = u/sqrt(WAVELENGTH*9.81);
+ GFS_VALUE (cell, velocity[1]) = v/sqrt(WAVELENGTH*9.81);
+}
+
+static gdouble stokes_height (gdouble x, gdouble y, gdouble z, gdouble t)
+{
+ float xx = (x + 0.5)*WAVELENGTH, yy = WAVELENGTH, u, v, ut, vt, du, dv, etah, t1 = 0.;
+ kmts_ (&order, &xx, &yy, &t1, &u, &v, &ut, &vt, &du, &dv, &etah);
+ return etah/WAVELENGTH - y;
+}
+
+static gboolean gfs_init_stokes_wave_event (GfsEvent * event, GfsSimulation * sim)
+{
+ if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_init_stokes_wave_class ())->parent_class)->event)
+ (event, sim)) {
+ GfsVariable ** velocity = gfs_domain_velocity (GFS_DOMAIN (sim));
+ GfsVariable * t = gfs_variable_from_name (GFS_DOMAIN (sim)->variables, "T");
+ g_assert (velocity);
+ g_assert (t);
+ gfs_domain_cell_traverse (GFS_DOMAIN (sim), FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+ (FttCellTraverseFunc) init_velocity, velocity);
+ GfsSurface * surface = GFS_SURFACE (gts_object_new (GTS_OBJECT_CLASS (gfs_surface_class ())));
+ surface->f = gfs_function_spatial_new (gfs_function_spatial_class (), stokes_height);
+ gfs_object_simulation_set (surface->f, sim);
+ gfs_domain_init_fraction (GFS_DOMAIN (sim), GFS_GENERIC_SURFACE (surface), t);
+ gts_object_destroy (GTS_OBJECT (surface));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void gfs_init_stokes_wave_class_init (GfsGenericInitClass * klass)
+{
+ GFS_EVENT_CLASS (klass)->event = gfs_init_stokes_wave_event;
+ GTS_OBJECT_CLASS (klass)->read = gfs_init_stokes_wave_read;
+ GTS_OBJECT_CLASS (klass)->write = gfs_init_stokes_wave_write;
+}
+
+static void gfs_init_stokes_wave (GfsInitStokesWave * w)
+{
+ w->depth = 0.5;
+ w->steepness = 0.3;
+}
+
+GfsGenericInitClass * gfs_init_stokes_wave_class (void)
+{
+ static GfsGenericInitClass * klass = NULL;
+
+ if (klass == NULL) {
+ GtsObjectClassInfo gfs_init_stokes_wave_info = {
+ "GfsInitStokesWave",
+ sizeof (GfsInitStokesWave),
+ sizeof (GfsGenericInitClass),
+ (GtsObjectClassInitFunc) gfs_init_stokes_wave_class_init,
+ (GtsObjectInitFunc) gfs_init_stokes_wave,
+ (GtsArgSetFunc) NULL,
+ (GtsArgGetFunc) NULL
+ };
+ klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_generic_init_class ()),
+ &gfs_init_stokes_wave_info);
+ }
+
+ return klass;
+}
+
+const gchar * g_module_check_init (void);
+
+const gchar * g_module_check_init (void)
+{
+ gfs_init_stokes_wave_class ();
+ return NULL;
+}
diff --git a/src/utils.c b/src/utils.c
index 4baba51..a336e6e 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1118,8 +1118,6 @@ GfsFunctionClass * gfs_function_spatial_class (void)
return klass;
}
-typedef gdouble (* GfsFunctionSpatialFunc) (double x, double y, double z, double t);
-
/**
* gfs_function_spatial_value:
* @f: a #GfsFunction.
@@ -1144,6 +1142,19 @@ gdouble gfs_function_spatial_value (GfsFunction * f, FttVector * p)
return f->val;
}
+GfsFunction * gfs_function_spatial_new (GfsFunctionClass * klass,
+ GfsFunctionSpatialFunc func)
+{
+ GfsFunction * object;
+
+ g_return_val_if_fail (func != NULL, NULL);
+
+ object = GFS_FUNCTION (gts_object_new (GTS_OBJECT_CLASS (klass)));
+ object->f = func;
+
+ return object;
+}
+
/* GfsFunctionConstant: object */
static void gfs_function_constant_init (GfsFunction * f)
diff --git a/src/utils.h b/src/utils.h
index c2f1a00..8e46189 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -110,7 +110,11 @@ GString * gfs_function_expression (GtsFile * fp,
#define GFS_IS_FUNCTION_SPATIAL(obj) (gts_object_is_from_class (obj,\
gfs_function_spatial_class ()))
+typedef gdouble (* GfsFunctionSpatialFunc) (double x, double y, double z, double t);
+
GfsFunctionClass * gfs_function_spatial_class (void);
+GfsFunction * gfs_function_spatial_new (GfsFunctionClass * klass,
+ GfsFunctionSpatialFunc func);
gdouble gfs_function_spatial_value (GfsFunction * f, FttVector * p);
/* GfsFunctionConstant: Header */
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list