73 for (
int _c = 0;
_c < 4;
_c++) {
154 for (
int _s = 0;
_s < 1;
_s++) {
166 display (
"squares (color = 'eta > zb ? eta : nodata', spread = -1);");
195#define gmetric(i) (2.*fm.x[i]/(cm[i] + cm[i-1]))
197# define a_baro(eta, i) (G*gmetric(i)*(eta[i-1] - eta[i])/Delta)
224 static double pdt = 0.;
227 double H = 0.,
um = 0.;
228 double Hr = 0.,
Hl = 0.;
236 double hl =
h[-1] >
dry ?
h[-1] : 0.;
237 double hr =
h[] >
dry ?
h[] : 0.;
257 int i = - (
a + 1.)/2.;
335 fprintf (
stderr,
"src/layered/hydro.h:%d: warning: could not conserve barotropic flux "
349 for (
int _s = 0;
_s < 1;
_s++) {
352 int i = -(
a + 1.)/2.;
353 double g =
s.gradient ?
361 double syy = (
s.gradient ?
s.gradient (
s[
i,-1],
s[
i],
s[
i,1]) :
397 fprintf (
stderr,
"src/layered/hydro.h:%d: warning: h1 = %g < - 1e-12 at %g,%g,%d,%g\n",
402 for (
int _f = 0;
_f < 1;
_f++)
406 for (
int _f = 0;
_f < 1;
_f++)
522#define slope_limited(dz) (fabs(dz) < max_slope ? (dz) : \
523 ((dz) > 0. ? max_slope : - max_slope))
525#define hpg(pg,phi,i,code) do { \
526 double dz = zb[i] - zb[i-1]; \
529 if (h[i] + h[i-1] > dry) { \
530 double s = Delta*slope_limited(dz/Delta); \
531 pg = (h[i-1] - s)*phi[i-1] - (h[i] + s)*phi[i]; \
532 if (point.l < nl - 1) { \
533 double s = Delta*slope_limited((dz + h[i] - h[i-1])/Delta); \
534 pg += (h[i-1] + s)*phi[i-1,0,1] - (h[i] - s)*phi[i,0,1]; \
536 pg *= gmetric(i)*hf.x[i]/(Delta*(h[i] + h[i-1])); \
538 dz += h[i] - h[i-1]; \
557 double dz =
zb[1] -
zb[-1];
564 w[] -= (
hu.
x[0,0,-1] +
hu.
x[1,0,-1])
593#define radiation(ref) _radiation(point, ref, _s)
613 for (
int _c = 0;
_c < 4;
_c++)
615 shallow =
true;
break;
622 for (
int _c = 0;
_c < 4;
_c++)
639 for (
int _c = 0;
_c < 4;
_c++) {
658#define conserve_elevation() conserve_layered_elevation()
687 for (
int l = 0;
l <
nl;
l++)
696 for (
int i = 0;
i < 2;
i++) {
706 for (
int l = 0;
l <
nl;
l++)
738 for (
int i = 0;
i <
nl;
i++)
vector g[]
We store the combined pressure gradient and acceleration field in g*.
static double interpolate_linear(Point point, scalar v, double xp=0., double yp=0., double zp=0.)
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
void display(const char *commands, bool overwrite=false)
static number sq(number x)
scalar * list_copy(scalar *l)
static int sign(number x)
scalar * list_append(scalar *list, scalar s)
scalar f[]
The primary fields are:
static void restriction_elevation(Point point, scalar h)
Cell restriction is simpler.
static double default_sea_level
static void prolongation_elevation(Point point, scalar h)
We also need to define a consistent prolongation function.
void vertical_velocity(scalar w, vector hu, vector hf)
void event_pressure(void)
Event: pressure (i++, last)
double dtmax
The maximum timestep dtmax can be used to impose additional stability conditions.
event acceleration(i++, last)
Vertical diffusion (including viscosity) is added by this code.
void output_fluxes(Flux *fluxes, scalar h, vector u)
static void refine_layered_elevation(Point point, scalar h)
But we need to re-define the water depth refinement function.
scalar * tracers
Here we set the gradient functions for each tracer (as defined in the user-provided tracers list).
void event_init(void)
After user initialisation, we define the free-surface height .
void event_defaults0(void)
The allocation of fields for each layer is split in two parts, because we need to make sure that the ...
void event_face_fields(void)
Event: face_fields (i++, last)
void event_update_eta(void)
Finally the free-surface height is updated.
static void refine_eta(Point point, scalar eta)
void event_cleanup(void)
Event: cleanup (t = end, last)
double _radiation(Point point, double ref, scalar s)
void event_defaults(void)
Other fields, such as here, are added by this event.
trace void advect(scalar *tracers, vector hu, vector hf, double dt)
event half_advection(i++, last)
This is where the 'two-step advection' of the implicit scheme plugs itself (nothing is done for the e...
double(* gradient)(double, double, double)
static void restriction_eta(Point point, scalar eta)
event set_dtmax(i++, last) dtmax
double segment_flux(coord segment[2], double *flux, scalar h, vector u)
void conserve_layered_elevation(void)
We overload the conserve_elevation() function.
which uses a global _layer index *int _layer
static void restriction_volume_average(Point point, scalar s)
static void refine_linear(Point point, scalar s)
void set_prolongation(scalar s, void(*prolongation)(Point, scalar))
void set_restriction(scalar s, void(*restriction)(Point, scalar))
A NULL-terminated array of Flux structures passed to output_fluxes()* will create a file (called name...
macro foreach_segment(coord S[2], coord p[2], Reduce reductions=None)
The macro below traverses the set of sub-segments intersecting the mesh and spanning the [A:B] segmen...
double minmod2(double s0, double s1, double s2)