GfsDefine
From Gerris
Define is used to define text macros in parameter files, similar to the macros of the C preprocessor (and still more similar to those of m4).
Examples of valid macros are:
Define PI 3.14159265359
Define SQUARE(x) (x*x)
Define REYNOLDS(U,L,nu) (U*L/nu)
Note that Define
macros are more general than the C macros which can be defined using GfsGlobal. They apply to the parameter file as a whole rather than just to the GfsFunctions. For example, this parameter file:
... Define LEVEL 7 ... Refine LEVEL ... OutputSimulation { start = end } sim-LEVEL.gfs ...
will result in Gerris generating a simulation file called sim-7.gfs
.
Note that macro support needs to be turned on explicitly (using the -m
or -D
options when starting gerris). Note also that the -m
or -D
options should not be used when restarting a simulation from a (binary) simulation file (e.g. created using GfsOutputSimulation).
Macros may be used but not defined in external files included via GfsInclude.
The builtins from m4 are also available, prefixed with m4_; thus for example to defer deciding till run-time whether a uniform mesh refinement were in order, one could write
Refine m4_ifelse(UNIFORM, 1, 6, (x>0 ? 6 : 5))
and call gerris with either -DUNIFORM=1
or -DUNIFORM=0
.
Examples
- Collapse of a column of grains
- Starting vortex of a NACA 2414 aerofoil
- Savart--Plateau--Rayleigh instability of a water column
- Forced isotropic turbulence in a triply-periodic box
- Wingtip vortices behind a rectangular NACA 2414 wing
- Lunar tides in Cook Strait, New Zealand
- Tsunami runup onto a complex three-dimensional beach
- The 2004 Indian Ocean tsunami
- Time-reversed advection of a VOF concentration
- Comparison between explicit and implicit diffusion schemes on concentration tracer
- Viscous flow past a sphere
- Bagnold flow of a granular material
- Coriolis formulation in 3-D
- Wind-driven stratified lake
- Circular droplet in equilibrium
- Axisymmetric spherical droplet in equilibrium
- Shape oscillation of an inviscid droplet
- Oscillations in a parabolic container
- Parabolic container with embedded solid
- Tsunami runup onto a plane beach
- Circular dam break on a sphere
- Circular dam break on a rotating sphere
- Circular dam break on a ``cubed sphere''
- Advection of a cosine bell around the sphere
- Creeping Couette flow between eccentric cylinders
- Flow between eccentric cylinders on a stretched grid
- Groundwater flow with piecewise constant permeability
Define D 0.04623
Define RHOF 0.001
Define RHO(T) (T + RHOF*(1. - T))
Define MUF 0.0001
Define LDOMAIN 32.
Define H0 6.26
Define R0 1.
Define LEVEL 10
Define FRAMEPERIOD 0.02
Define RHO_L 998.
Define RHO_G 1.2
Define MU_L 1.003e-3
Define MU_G 1.8e-5
Define RADIUS 0.2
Define EPSILON 0.02
Define VAR(T,min,max) (min + CLAMP(T,0,1)*(max - min))
Define RHO(T) VAR(T, RHO_G/RHO_L, 1.)
Define MUR(T) VAR(T, MU_G/MU_L, 1.)
Define MU 0.01
Define VOLUME (8.*M_PI*M_PI*M_PI)
Define Ubar (SU/VOLUME)
Define Vbar (SV/VOLUME)
Define Wbar (SW/VOLUME)
Define Unbar (Un/VOLUME)
Define FRAMEPERIOD 0.02
Define M2F (2.*M_PI/44700.)
Define M2(t) (A_amp*cos (M2F*t)+B_amp*sin (M2F*t))
Define DRY 1e-4
Define RADIUS 6371220.
Define LENGTH 6000e3
Define LONGITUDE 94.
Define LATITUDE 8.
Define DRY 0.01
Define MAXLEVEL 12
Define LEVEL (fabs (rx) < 0.46 && fabs (ry) < 0.46 ? MAXLEVEL : 5)
Define CIRCLE (ellipse (0, -.236338, 0.2, 0.2))
Define GAUSSIAN (exp(-100.*((x + 0.2)*(x + 0.2) + (y + .236338)*(y + .236338))))
Define R sqrt(x*x+y*y)
Define R0 0.25
Define GAUSSIAN (exp(-250.*((R-R0)*(R-R0))))
Define A0 0.5
Define U0 1.
Define ALPHA 0.43
Define D 0.04
Define U0 (sqrt(cos(ALPHA))*(-0.114 + 0.3*tan(ALPHA))/(D*(0.64 - tan(ALPHA))))
Define UB(x) ((1. - pow(1. - x, 1.5))*2./3.*U0)
Define U0 2
Define V0 3
Define Vsol0 (-A0*sin(Phi)*sin(2*Omega*t) + B0*sin(Phi)*cos(2*Omega*t) + C0)
Define Wsol0 (A0*cos(Phi)*sin(2*Omega*t) - B0*cos(Phi)*cos(2*Omega*t) + D0)
Define W0 1
Define Phi (M_PI/4.)
Define Omega 7.292e-5
Define A0 U0
Define B0 (sin(Phi)*V0-cos(Phi)*W0)
Define C0 (cos(Phi)*(cos(Phi)*V0+sin(Phi)*W0))
Define D0 (sin(Phi)*(cos(Phi)*V0+sin(Phi)*W0))
Define Usol0 (A0*cos(2*Omega*t)+B0*sin(2*Omega*t))
Define ALPHA 1e-4
Define ALPHAT 1e-3
Define CIRCLE (ellipse (-0.5,0.5,0.4,0.4))
Define MU sqrt(0.8/LAPLACE)
Define CIRCLE (ellipse (-0.5,0.,0.4,0.4))
Define MU sqrt(0.8/LAPLACE)
Define EPSILON 0.05
Define VAR(T,min,max) (min + CLAMP(T,0,1)*(max - min))
Define RHO(T) VAR(T, 1., 1e-3)
Define RADIUS(x,y) (DIAMETER/2.*(1. + EPSILON*cos (2.*atan2 (y, x))))
Define h0 10.
Define a 3000.
Define tau 1e-3
Define B 5
Define G 9.81
Define h0 10.
Define a 3000.
Define tau 1e-3
Define B 5
Define G 9.81
Define SLOPE (0.3/pow(2., LEVEL))
Define ANGLE (atan(SLOPE))
Define R(x,y) ((x)*cos(ANGLE) + (y)*sin(ANGLE))
Define MINLEVEL 7
Define DRY 1e-3
Define LENGTH (150./180.*M_PI)
Define LENGTH (150./180.*M_PI)
Define LENGTH (150./180.*M_PI)
Define U0 (2.*M_PI)
Define R1 (1./sinh(1.5))
Define R2 (1./sinh(1.))
Define X1 (1./tanh(1.5))
Define X2 (1./tanh(1.))
Define ECC (X2 - X1)
Define R1 (1./sinh(1.5))
Define R2 (1./sinh(1.))
Define X1 (1./tanh(1.5))
Define X2 (1./tanh(1.))
Define ECC (X2 - X1)
Define THETA atan2(y,x)