#include /* Prototype for 'vsxynt' ... */ int vsxynt(char *name, double time, double *x, double *y, int n); double f(double x) { return exp(-pow((x-0.5)/0.1,2.0)); } /*========================================================== Vswave: Generates time-series of profiles of left-moving "wave" (f(t+x) = constant) and outputs to 'vs' server. ==========================================================*/ #define N 65 int main(int argc, char **argv) { int n = N; double x[N], y[N]; int i, j, nx, nt; double h, t, dt; n = N; nx = n; nt = n; h = 1.0 / (nx - 1); x[0] = 0.0; for( j = 0; j < nx - 2; j++ ) { x[j+1] = x[j] + h; } t = 0.0; dt = 1.0 / (nt - 1); for( i = 0; i < nt; i++ ) { for( j = 0; j < nx; j++ ) { y[j] = f(fmod(x[j]+t,1.0)); } vsxynt("Vswave",t,x,y,nx); t += dt; } }