2 #include "ncurses/curses.h"
9 #define Double extern double
24 iff(Title, FINISH)
return(0);
47 if(strcmp(Theory,
"Stokes")==0)
52 printf(
"\nThe dimensionless wavelength is greater than 10.");
53 printf(
"\nStokes theory should not be applied. Exiting.");
60 printf(
"\nThe dimensionless period is greater than 10.");
61 printf(
"\nStokes theory should not be applied. Exiting.");
69 Input2=fopen(Convergence_file,
"r");
70 fgets(dummy,400,Input2);
71 fscanf(Input2,
"%d", &
number);fgets(dummy,400,Input2);
72 fscanf(Input2,
"%le", &
crit);fgets(dummy,400,Input2);
77 Input2 = fopen(Points_file,
"r");
78 fgets(dummy,400,Input2);
82 fscanf(Input2,
"%d", &
Nprofiles);fgets(dummy,400,Input2);
84 fscanf(Input2,
"%d", &
Points);fgets(dummy,400,Input2);
95 fprintf(file,
"# %s", Title);
96 fprintf(file,
"\n\n# Printing input data here to check");
97 fprintf(file,
"\n\n# Height/Depth:%6.3f",
MaxH);
100 fprintf(file,
"\n# Length/Depth:%7.2f",
L);
104 fprintf(file,
"\n# Dimensionless Period T*sqrt(g/d):%7.2f",
T);
106 fprintf(file,
"\n# Current criterion: %s, Dimensionless value:%6.3lf", Currentname,
Current);
108 if(strcmp(Theory,
"Stokes")==0)
110 if(
n<=5) sprintf(Method,
"\n# Solution by %d-order Stokes theory",
n);
114 sprintf(Method,
"\n# Solution by %d-order Stokes theory",
n);
115 printf(
"\n\n# (A value of N > 5 has been specified for the Stokes theory.");
116 printf(
"\n# I do not have a theory for that. The program has set N = 5)");
119 if(strcmp(Theory,
"Fourier")==0)
120 sprintf(Method,
"\n# Solution by %d-term Fourier series",
n);
122 fprintf(file,
"\n%s\n", Method);
130 /(0.0093407*
L*
L*
L+0.0317567*
L*
L+0.078834*
L+1);
131 fprintf(file,
"# %s", Title);
132 fprintf(file,
"\n%s\n", Method);
133 fprintf(file,
"\n# Height/Depth:%6.3f, %3.0lf\%% of the maximum of H/d =%6.3f for this length:",
135 fprintf(file,
"\n# Length/Depth:%7.2f", 2*
pi/
z[1]);
136 fprintf(file,
"\n# Dimensionless Period T*sqrt(g/d):%7.2f",
z[3]/sqrt(
z[1]));
137 fprintf(file,
"\n# Current criterion: %s, Dimensionless value:%6.3lf\n", Currentname,
Current);
145 void Point(
double,
double);
147 fprintf(monitor,
"\n\n# Solution summary:\n\n");
172 pe += 0.25*pow(
Y[i],2);
181 fprintf(Solution,
"\n# Stokes-Ursell number %7.3f", 0.5*
z[2]/pow(
z[1],3));
182 fprintf(Solution,
"\n\n# Integral quantities - notation from Fenton (1988)");
183 fprintf(Solution,
"\n# (1) Quantity, (2) symbol, solution non-dimensionalised by (3) g & wavenumber, and (4) g & mean depth\n");
184 fprintf(Solution,
"\n# Water depth (d)" LO LO,
z[1], 1.);
185 fprintf(Solution,
"\n# Wave length (lambda)" LO LO, 2*
pi,
L);
186 fprintf(Solution,
"\n# Wave height (H)" LO LO,
z[2],
H);
187 fprintf(Solution,
"\n# Wave period (tau)" LO LO,
z[3],
T);
188 fprintf(Solution,
"\n# Wave speed (c)" LO LO,
z[4],
c);
189 fprintf(Solution,
"\n# Eulerian current (u1_)" LO LO,
z[5],
ce);
190 fprintf(Solution,
"\n# Stokes current (u2_)" LO LO,
z[6],
cs);
191 fprintf(Solution,
"\n# Mean fluid speed in frame of wave (U_)" LO LO,
z[7],
ubar);
192 fprintf(Solution,
"\n# Volume flux due to waves (q)" LO LO,
z[8],
z[8]/pow(
kd,1.5));
193 fprintf(Solution,
"\n# Bernoulli constant (r)" LO LO,
z[9],
z[9]/
kd);
194 fprintf(Solution,
"\n# Volume flux (Q)" LO LO,
Q*pow(
kd,1.5),
Q);
195 fprintf(Solution,
"\n# Bernoulli constant (R)" LO LO,
R*
kd,
R);
196 fprintf(Solution,
"\n# Momentum flux (S)" LO LO,
s,
s/
kd/
kd );
198 fprintf(Solution,
"\n# Kinetic energy (T)" LO LO,
ke,
ke/
kd/
kd);
199 fprintf(Solution,
"\n# Potential energy (V)" LO LO,
pe,
pe/
kd/
kd);
200 fprintf(Solution,
"\n# Mean square of bed velocity (ub2_)" LO LO,
ub2,
ub2/
kd);
201 fprintf(Solution,
"\n# Radiation stress (Sxx)" LO LO,
sxx,
sxx/
kd/
kd);
202 fprintf(Solution,
"\n# Wave power (F)" LO LO,
f,
f/pow(
kd,2.5));
204 fprintf(Solution,
"\n\n# Dimensionless coefficients in Fourier series" );
205 fprintf(Solution,
"\n# Potential/Streamfn\tSurface elevations" );
206 fprintf(Solution,
"\n# j, B[j], & E[j], j=1..N\n" );
207 for ( i=1 ; i <=
n ; i++ )
208 fprintf(Solution,
"\n%2d\t%15.7e\t%15.7e", i,
B[i],
Y[i]);
209 fprintf(Solution,
"\n\n" );
213 fprintf(Elevation,
"# %s\n", Title);
214 fprintf(Elevation,
"%s\n", Method);
215 fprintf(Elevation,
"\n# Surface of wave - trough-crest-trough,");
216 fprintf(Elevation,
" note quadratic point spacing clustered around crest");
217 fprintf(Elevation,
"\n# Non-dimensionalised with respect to depth");
218 fprintf(Elevation,
"\n# X/d, eta/d, & check of surface pressure\n");
225 fprintf(Elevation,
"\n%8.4lf\t%7.4f\t%7.0e", X, eta,
Pressure);
227 fprintf(Elevation,
"\n\n");
231 fprintf(Flowfield,
"# %s\n", Title);
232 fprintf(Flowfield,
"%s\n", Method);
233 fprintf(Flowfield,
"\n# Velocity and acceleration profiles and Bernoulli checks\n");
234 fprintf(Flowfield,
"\n# All quantities are dimensionless with respect to g and/or d\n");
235 fprintf(Flowfield,
"\n#*******************************************************************************");
236 fprintf(Flowfield,
"\n# y u v dphi/dt du/dt dv/dt du/dx du/dy Bernoulli check ");
237 fprintf(Flowfield,
"\n# - ------------- ------- ------ ----- ------------- --------------- ");
238 fprintf(Flowfield,
"\n# d sqrt(gd) gd g g sqrt(g/d) gd ");
239 fprintf(Flowfield,
"\n#*******************************************************************************");
245 fprintf(Flowfield,
"\n\n# X/d = %8.4f, Phase = %6.1f°\n", X, X/
L*360);
247 for(i=0 ; i <=
Points; ++i)
251 fprintf(Flowfield,
"\n%7.4f\t%7.4f\t%7.4f\t%7.4f\t%7.4f\t%7.4f\t%7.4f\t%7.4f\t%7.4f",
255 fprintf(Flowfield,
"\n\n");
307 for ( j = 1 ; j <
n ; j++ )
308 kEta +=
Y[j] * cos(j*x*
kd);
309 kEta += 0.5*
Y[
n] * cos(
n*x*
kd);
318 double Cosh, Sinh, Sin, Cos;
319 double coshdelta,sinhdelta;
323 for ( j = 1 ; j <=
n ; j++ )
327 coshdelta = cosh(j*
kd*(y-1.));
328 sinhdelta = sinh(j*
kd*(y-1.));
329 Cosh = coshdelta+sinhdelta*
Tanh[j];
330 Sinh = sinhdelta+coshdelta*
Tanh[j];
331 phi +=
B[j] * Cosh * Sin;
332 u += j *
B[j] * Cosh * Cos;
333 v += j *
B[j] * Sinh * Sin;
334 ux += - j * j *
B[j] * Cosh * Sin;
335 vx += j * j *
B[j] * Sinh * Cos;