URI: 
       tSwap array pointers instead of copying values in iterative solvers - 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 64a84fc4e4904e2645cf9202427d8796ee34ac9f
   DIR parent 561018bfb5915a45d9340eb3e1268a0c9e3a4b43
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Wed,  6 May 2020 14:03:33 +0200
       
       Swap array pointers instead of copying values in iterative solvers
       
       Diffstat:
         M fluid.c                             |       8 +++++---
         M simulation.c                        |      10 ++++++----
       
       2 files changed, 11 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/fluid.c b/fluid.c
       t@@ -156,8 +156,8 @@ darcy_solver_1d(struct simulation *sim,
        {
                int i, iter, solved = 0;
                double epsilon, theta, p_f_top, r_norm_max = NAN;
       -        double *dp_f_dt_expl;
       -        double *p_f_ghost_old, *dp_f_dt_impl, *p_f_ghost_new, *r_norm;
       +        double *dp_f_dt_expl, *p_f_ghost_old, *dp_f_dt_impl, *p_f_ghost_new;
       +        double *tmp, *r_norm;
        
                /* choose integration method, parameter in [0.0; 1.0]
                 * epsilon = 0.0: explicit
       t@@ -260,7 +260,9 @@ darcy_solver_1d(struct simulation *sim,
                                print_array(p_f_ghost_new, sim->nz + 2);
        #endif
        
       -                        copy_values(p_f_ghost_new, sim->p_f_ghost, sim->nz + 2);
       +                        tmp = p_f_ghost_new;
       +                        p_f_ghost_new = sim->p_f_ghost;
       +                        sim->p_f_ghost = tmp;
        #ifdef DEBUG
                                puts(".. p_f_ghost after update:");
                                print_array(sim->p_f_ghost, sim->nz + 2);
   DIR diff --git a/simulation.c b/simulation.c
       t@@ -634,7 +634,7 @@ implicit_1d_jacobian_poisson_solver(struct simulation *sim,
        {
                int iter, i;
                double r_norm_max = NAN;
       -        double *g_ghost_out = empty(sim->nz + 2), *r_norm = empty(sim->nz);
       +        double *tmp, *g_ghost_out = empty(sim->nz + 2), *r_norm = empty(sim->nz);
        
                for (iter = 0; iter < max_iter; ++iter) {
        #ifdef DEBUG
       t@@ -657,7 +657,9 @@ implicit_1d_jacobian_poisson_solver(struct simulation *sim,
                                                              sim->xi);
                        r_norm_max = max(r_norm, sim->nz);
        
       -                copy_values(g_ghost_out, sim->g_ghost, sim->nz + 2);
       +                tmp = g_ghost_out;
       +                g_ghost_out = sim->g_ghost;
       +                sim->g_ghost = tmp;
        
                        if (r_norm_max <= rel_tol) {
                                set_bc_dirichlet(sim->g_ghost, sim->nz, -1, 0.0);
       t@@ -731,8 +733,8 @@ coupled_shear_solver(struct simulation *sim,
                             const double rel_tol)
        {
                int i, coupled_iter, stress_iter = 0;
       -        double *r_norm, r_norm_max, *oldval;
       -        double vel_res_norm = NAN, mu_wall_orig = sim->mu_wall;
       +        double *r_norm, *tmp, *oldval;
       +        double r_norm_max, vel_res_norm = NAN, mu_wall_orig = sim->mu_wall;
        
                if (sim->transient) {
                        r_norm = empty(sim->nz);