URI:
       tFix time step calculation error due to wrong dx values - cngf-pf - continuum model for granular flows with pore-pressure dynamics (renamed from 1d_fd_simple_shear)
  HTML git clone git://src.adamsgaard.dk/cngf-pf
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit bad8daf5ce300d6b13cb93fed036cc79de183afd
   DIR parent e77fc709072288ae7e2cbc4b66eca6307c2d23fb
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Fri, 28 Jun 2019 11:03:32 +0200
       
       Fix time step calculation error due to wrong dx values
       
       Diffstat:
         M arrays.c                            |       2 +-
         M fluid.c                             |      12 +++++++++++-
       
       2 files changed, 12 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/arrays.c b/arrays.c
       t@@ -74,7 +74,7 @@ spacing(const double* x, const int n)
        
                dx = malloc((n-1)*sizeof(double));
                for (i=0; i<n-1; ++i)
       -                dx[i] = x[i+i] - x[i];
       +                dx[i] = x[i+1] - x[i];
                return dx;
        }
        
   DIR diff --git a/fluid.c b/fluid.c
       t@@ -26,8 +26,16 @@ set_largest_fluid_timestep(struct simulation* sim, const double safety)
        
                dx = spacing(sim->z, sim->nz);
                dx_min = INFINITY;
       -        for (i=0; i<sim->nz-1; ++i)
       +        for (i=0; i<sim->nz-1; ++i) {
       +                if (dx[i] < 0.0) {
       +                        fprintf(stderr, "error: cell spacing negative (%g) in cell %d\n",
       +                                        dx[i], i);
       +                        free(dx);
       +                        exit(10);
       +                }
                        if (dx[i] < dx_min) dx_min = dx[i];
       +        }
       +        free(dx);
        
                /* determine largest diffusion size */
                diff_max = -INFINITY;
       t@@ -37,6 +45,8 @@ set_largest_fluid_timestep(struct simulation* sim, const double safety)
                }
        
                sim->dt = safety*0.5*dx_min*dx_min/diff_max;
       +        if (sim->file_dt*0.5 < sim->dt)
       +                sim->dt = sim->file_dt*0.5;
        }
        
        static