src/test/stencils.c
Automatic stencils / boundary conditions
int main()
{
(8);
init_grid
scalar s[];
This should warn (once) that we are assigning a scalar multiple times.
for (int i = 1; i < 2; i++)
foreach_face()
[] = 1; s
This should set s as the y-component of a face vector.
foreach_face(y)
[] = 1; s
This should set v to be a face vector.
vector v[];
foreach_face()
.x[] = 1; v
Same thing for the components of a tensor.
tensor Fq[];
foreach_face()
.x.x[] = Fq.y.x[] = 0.; Fq
This should set Fv.x.y as a vertex scalar.
tensor Fv[];
foreach_vertex()
.x.y[] = 1; Fv
Here flux boundary conditions should be imposed on s[].
scalar a[];
foreach()
[] = (s[0,1] - s[])/Delta; a
Here we use ‘tangential’ values of the face vector y-component ‘s’, so central boundary conditions need to be imposed.
foreach()
[] = (s[1] - s[])/Delta; a
If normal boundary conditions are set, central boundary conditions should be imposed (not just fluxes).
foreach_face(y)
[] = 1;
s
[top] = 0.;
sforeach()
[] = (s[0,1] - s[])/Delta; a
The same but for face vectors.
face vector f[];
foreach_face()
.x[] = 1; f
Flux BCs here.
foreach()
[] = (f.y[0,1] - f.y[])/Delta; a
Central BCs here.
.n[top] = 0.;
fforeach()
[] = (f.y[0,1] - f.y[])/Delta; a
This should warn that we are assigning a face vector using a foreach() loop.
foreach()
.x[] = 2; f
This should warn that we are assigning a vertex scalar using a foreach() loop.
This should warn that we are using a global variable without reduction.
double t = 0;
foreach()
++;
t}