diff --git a/raster/r.sim/simlib/hydro.c b/raster/r.sim/simlib/hydro.c index ccdf2735b3d..0ea8db6bfd4 100644 --- a/raster/r.sim/simlib/hydro.c +++ b/raster/r.sim/simlib/hydro.c @@ -235,16 +235,17 @@ void main_loop(const Setup *setup, const Geometry *geometry, #endif double hhc = pow(d1, 3. / 5.); double velx, vely; + /* Diffusion coefficient of this walker's move */ + float dif; if (hhc > settings->hhmax && inputs->wdepth == NULL) { /* increased diffusion if w.depth > hhmax */ - grids->dif[k][l] = - (settings->halpha + 1) * deldif; + dif = (settings->halpha + 1) * deldif; velx = sim->vavg[lw].x; vely = sim->vavg[lw].y; } else { - grids->dif[k][l] = deldif; + dif = deldif; velx = grids->v1[k][l]; vely = grids->v2[k][l]; } @@ -262,10 +263,9 @@ void main_loop(const Setup *setup, const Geometry *geometry, } } - sim->w[lw].x += - (velx + - grids->dif[k][l] * gaux); /* move the walker */ - sim->w[lw].y += (vely + grids->dif[k][l] * gauy); + /* Move the walker. */ + sim->w[lw].x += (velx + dif * gaux); + sim->w[lw].y += (vely + dif * gauy); if (hhc > settings->hhmax && inputs->wdepth == NULL) { diff --git a/raster/r.sim/simlib/input.c b/raster/r.sim/simlib/input.c index e651d6d0c11..643cb36f2db 100644 --- a/raster/r.sim/simlib/input.c +++ b/raster/r.sim/simlib/input.c @@ -34,7 +34,6 @@ void alloc_grids_water(const Geometry *geometry, const Outputs *outputs, grids->gama = G_alloc_matrix(geometry->my, geometry->mx); if (outputs->err != NULL) grids->gammas = G_alloc_matrix(geometry->my, geometry->mx); - grids->dif = G_alloc_fmatrix(geometry->my, geometry->mx); } void alloc_grids_sediment(const Geometry *geometry, const Outputs *outputs, @@ -47,7 +46,6 @@ void alloc_grids_sediment(const Geometry *geometry, const Outputs *outputs, /* memory allocation for output grids */ - grids->dif = G_alloc_fmatrix(geometry->my, geometry->mx); if (outputs->erdep != NULL || outputs->et != NULL) grids->er = G_alloc_fmatrix(geometry->my, geometry->mx); } diff --git a/raster/r.sim/simlib/simlib.h b/raster/r.sim/simlib/simlib.h index edd2e7302e8..61215aec31a 100644 --- a/raster/r.sim/simlib/simlib.h +++ b/raster/r.sim/simlib/simlib.h @@ -120,7 +120,6 @@ typedef struct { float **er; // Erosion [output] float **ct; // Transport capacity coefficient [input] float **trap; // Traps [input] - float **dif; // Diffusion coefficient [internal] } Grids; struct point2D {