Skip to content

Commit 5102c66

Browse files
committed
Fix some formatting of comments in SWE.c
1 parent ce39449 commit 5102c66

File tree

1 file changed

+63
-41
lines changed
  • src/raster/r.damflood

1 file changed

+63
-41
lines changed

src/raster/r.damflood/SWE.c

+63-41
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ float velocita_breccia(int i, double h)
4343
{
4444
// double h;
4545
// int i;
46-
// float g=9.81;
46+
// float g = 9.81;
4747
float v;
4848

4949
if (i == 1) {
@@ -62,7 +62,7 @@ void shallow_water(double **m_h1, double **m_u1, double **m_v1, float **m_z,
6262
int method, int num_cell, int num_break, double t)
6363
{
6464

65-
/*FUNCTION VARIABLES*/
65+
/* FUNCTION VARIABLES */
6666
double h_dx, h_sx, h_up, h_dw, Fup, Fdw, Fdx, Fsx, Gup, Gdw, Gdx, Gsx;
6767
double u_sx, u_dx, v_dx, v_sx, v_up, v_dw, u_up, u_dw;
6868

@@ -82,23 +82,24 @@ void shallow_water(double **m_h1, double **m_u1, double **m_v1, float **m_z,
8282

8383
// DESCRIPTION OF METHOD
8484
// First cycle: Calculation of new water heights at time t + 1:
85-
// - Downstream of the dam: Apply continuity equation to shallow water
86-
// In practice, the new height is evaluated through a balance
87-
// of the incoming and outgoing flows in the two main directions
88-
// - Upstream of the dam:
89-
// - In methods 1 and 2:
90-
// - The continuity equation is applied to the volume of the lake
91-
// Physically this leads to a less realistic but avoids
92-
// the oscillations that causes numerical instability.
93-
// - In the more general case the equations are applied to the whole lake
85+
// - Downstream of the dam: Apply continuity equation to shallow water.
86+
// In practice, the new height is evaluated through a balance
87+
// of the incoming and outgoing flows in the two main directions
88+
// - Upstream of the dam:
89+
// - In methods 1 and 2:
90+
// - The continuity equation is applied to the volume of the lake.
91+
// Physically this leads to a less realistic but avoids the
92+
// oscillations that causes numerical instability.
93+
// - In the more general case, the equations are applied to the whole
94+
// lake
9495

9596
for (row = 1; row < nrows - 1; row++) {
9697
for (col = 1; col < ncols - 1; col++) {
9798
if (m_lake[row][col] == 0 && m_DAMBREAK[row][col] <= 0) {
9899

99-
//*******************************************/
100-
/* CONTINUITY EQUATION --> h(t+1) */
101-
//*******************************************/
100+
/*******************************************
101+
* CONTINUITY EQUATION --> h(t+1)
102+
*******************************************/
102103
// x direction
103104
// right intercell
104105
if (m_u1[row][col] > 0 && m_u1[row][col + 1] > 0) {
@@ -168,8 +169,9 @@ void shallow_water(double **m_h1, double **m_u1, double **m_v1, float **m_z,
168169
}
169170
F = Fdx - Fsx;
170171

171-
// dGup =m_v1[row][col] * m_h1[row][col]; y direction
172-
// intercell up
172+
/* dGup = m_v1[row][col] * m_h1[row][col]; */
173+
// y direction
174+
// intercell up
173175
if (m_v1[row][col] > 0 && m_v1[row - 1][col] > 0) {
174176
Gup = m_v1[row][col] * m_h1[row][col];
175177
}
@@ -242,29 +244,48 @@ void shallow_water(double **m_h1, double **m_u1, double **m_v1, float **m_z,
242244
m_h2[row][col] = m_h1[row][col] - timestep / res_ew * F -
243245
timestep / res_ns * G;
244246

245-
/*if ((row==20||row==21||row==22||row==23)&&(col==18||col==19)){
246-
printf("EQ. CONTINUITY --> row:%d, col:%d\n)",row,
247-
col);
248-
printf("m_h1[row][col]:%f,m_u1[row][col]:%f,m_v1[row][col]:%f",m_h1[row][col],m_u1[row][col],m_v1[row][col]);
249-
printf("m_h1[row][col+1]:%f,m_h1[row][col-1]:%f,m_h1[row+1][col]:%f,
250-
m_h1[row-1][col]:%f\n",m_h1[row][col+1],m_h1[row][col-1],m_h1[row+1][col],
251-
m_h1[row-1][col]); printf("h_dx:%f, h_sx:%f, h_up%f,
252-
h_dw:%f\n",h_dx, h_sx, h_up, h_dw);
253-
printf("m_u1[row][col+1]:%f,m_u1[row][col-1]:%f,m_v1[row+1][col]:%f,
254-
m_v1[row-1][col]:%f\n",m_u1[row][col+1],m_u1[row][col-1],m_v1[row+1][col],
255-
m_v1[row-1][col]); printf("v_up: %f,v_dw:%f,u_dx:%f,u_sx:%f
256-
\n",v_up, v_dw, u_dx, u_sx); printf("Fdx: %f,Fsx: %f, F: %f,
257-
Gup:%f, Gdw:%f, G: %f\n",Fdx, Fsx, F,Gup, Gdw, G);
258-
printf("m_h2(row,col): %f\n \n", m_h2[row][col]);
259-
}*/
247+
/* if ((row == 20 || row == 21 || row == 22 || row == 23) &&
248+
(col == 18 || col == 19)) {
249+
printf("EQ. CONTINUITY --> row:%d, col:%d\n)", row, col);
250+
printf("m_h1[row][col]:%f, "
251+
"m_u1[row][col]:%f, "
252+
"m_v1[row][col]:%f",
253+
m_h1[row][col], m_u1[row][col], m_v1[row][col]);
254+
printf("m_h1[row][col+1]:%f, "
255+
"m_h1[row][col-1]:%f, "
256+
"m_h1[row+1][col]:%f, "
257+
"m_h1[row-1][col]:% f\n",
258+
m_h1[row][col + 1], m_h1[row][col - 1],
259+
m_h1[row + 1][col], m_h1[row - 1][col]);
260+
printf("h_dx:%f, h_sx:%f, h_up%f, h_dw:%f\n", h_dx, h_sx,
261+
h_up, h_dw);
262+
printf("m_u1[row][col+1]:%f, "
263+
"m_u1[row][col-1]:%f, "
264+
"m_v1[row+1][col]:%f, "
265+
"m_v1[row-1][col]:%f\n",
266+
m_u1[row][col + 1], m_u1[row][col - 1],
267+
m_v1[row + 1][col], m_v1[row - 1][col]);
268+
printf("v_up: %f, v_dw:%f, "
269+
"u_dx:%f, u_sx:%f\n",
270+
v_up, v_dw, u_dx, u_sx);
271+
printf("Fdx: %f,Fsx: %f, F: %f, "
272+
"Gup:%f, Gdw:%f, G: %f\n",
273+
Fdx, Fsx, F, Gup, Gdw, G);
274+
printf("m_h2(row,col): %f\n \n", m_h2[row][col]);
275+
} */
260276

261-
/*if( (row==1 || row==(nrows-2) || col==1 || col==(ncols-2)) &&
262-
(m_v2[1][col]>0 || m_v2[nrows-2][col]<0 || m_u1[row][1]<0 ||
263-
m_u1[row][ncols-2]>0 )){ if (warn==0){ G_warning("At the time %.3f the
264-
computational region is smaller than inundation",t); warn=1;
265-
G_message("warn=%d",warn);
266-
}
267-
}*/
277+
/* if (((row == 1 || row == (nrows - 2)) ||
278+
(col == 1 || col == (ncols - 2))) &&
279+
(m_v2[1][col] > 0 || m_v2[nrows - 2][col] < 0 ||
280+
m_u1[row][1] < 0 || m_u1[row][ncols - 2] > 0)) {
281+
if (warn == 0) {
282+
G_warning("At the time %.3f the computational region "
283+
"is smaller than inundation",
284+
t);
285+
warn = 1;
286+
G_message("warn=%d", warn);
287+
}
288+
} */
268289

269290
if (m_h2[row][col] < 0) {
270291
/*G_warning("At the time %f h is lesser than 0
@@ -301,7 +322,8 @@ void shallow_water(double **m_h1, double **m_u1, double **m_v1, float **m_z,
301322

302323
if (method == 1 || method == 2) {
303324
//*******************************************************************
304-
// Calculation of flow rate Q coming out of the lake only in the case of spillway Hp (hypothesis)
325+
// Calculation of flow rate Q coming out of the lake only in the
326+
// case of spillway Hp (hypothesis)
305327
/* Hypothesis: method 1 or 2 */
306328
if (m_DAMBREAK[row][col] > 0) {
307329
if ((m_z[row][col] + m_h1[row][col]) >
@@ -670,12 +692,12 @@ void shallow_water(double **m_h1, double **m_u1, double **m_v1, float **m_z,
670692
(m_z[row][col + 1] + m_h2[row][col + 1]))
671693
m_u2[row][col] = velocita_breccia(
672694
method,
673-
m_h2[row][col]); //velocity on the spillway
695+
m_h2[row][col]); // velocity on the spillway
674696
else if ((m_z[row][col] + m_h2[row][col]) >
675697
(m_z[row][col - 1] + m_h2[row][col - 1]))
676698
m_u2[row][col] = -velocita_breccia(
677699
method,
678-
m_h2[row][col]); //velocity on the spillway
700+
m_h2[row][col]); // velocity on the spillway
679701
else
680702
m_u2[row][col] = 0.0;
681703
}

0 commit comments

Comments
 (0)