tFix memory leak when resizing phi or k arrays - cngf-pf - continuum model for … | |
git clone git://src.adamsgaard.dk/cngf-pf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit e5bea95a69c6cb7776be8560c0b2751297355d92 | |
parent 949508fb9e7495371105b2b53629722c92d508f4 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Mon, 15 Apr 2019 20:30:00 +0200 | |
Fix memory leak when resizing phi or k arrays | |
Diffstat: | |
M 1d_fd_simple_shear.png | 0 | |
M 1d_fd_simple_shear_rheology.png | 0 | |
M 1d_fd_simple_shear_rheology_iverso… | 0 | |
M 1d_fd_simple_shear_rheology_kamb.p… | 0 | |
M 1d_fd_simple_shear_rheology_tulacz… | 0 | |
M main.c | 5 ++--- | |
M parameter_defaults.h | 7 +++++-- | |
M simulation.c | 4 +++- | |
8 files changed, 10 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/1d_fd_simple_shear.png b/1d_fd_simple_shear.png | |
Binary files differ. | |
diff --git a/1d_fd_simple_shear_rheology.png b/1d_fd_simple_shear_rheology.png | |
Binary files differ. | |
diff --git a/1d_fd_simple_shear_rheology_iverson.png b/1d_fd_simple_shear_rheol… | |
Binary files differ. | |
diff --git a/1d_fd_simple_shear_rheology_kamb.png b/1d_fd_simple_shear_rheology… | |
Binary files differ. | |
diff --git a/1d_fd_simple_shear_rheology_tulaczyk.png b/1d_fd_simple_shear_rheo… | |
Binary files differ. | |
diff --git a/main.c b/main.c | |
t@@ -88,8 +88,8 @@ int main(int argc, char* argv[]) | |
{NULL, 0, NULL, 0} | |
}; | |
- double new_phi = NAN; | |
- double new_k = NAN; | |
+ double new_phi = sim.phi[0]; | |
+ double new_k = sim.k[0]; | |
while ((opt = getopt_long(argc, argv, optstring, longopts, NULL)) != -1) { | |
switch (opt) { | |
case -1: /* no more arguments */ | |
t@@ -187,7 +187,6 @@ int main(int argc, char* argv[]) | |
sprintf(sim.name, "%s", argv[i]); | |
} | |
- | |
prepare_arrays(&sim); | |
if (!isnan(new_phi)) | |
diff --git a/parameter_defaults.h b/parameter_defaults.h | |
t@@ -34,7 +34,7 @@ struct simulation init_sim(void) | |
sim.mu_s = atan(DEG2RAD(22.0)); /* Damsgaard et al 2013 */ | |
- sim.phi = initval(0.25, sim.nz); /* Damsgaard et al 2013 */ | |
+ sim.phi = initval(0.25, 1); /* Damsgaard et al 2013 */ | |
/* lower values of d mean that the shear velocity curve can have sharper | |
* curves, e.g. at the transition from μ ≈ μ_s */ | |
t@@ -60,7 +60,10 @@ struct simulation init_sim(void) | |
sim.beta_f = 4.5e-10; /* Water, Goren et al 2011 */ | |
sim.mu_f = 1e-3; /* Water, Goren et al 2011 */ | |
sim.rho_f = 1e3; /* Water */ | |
- sim.k = initval(1.9e-15, sim.nz); /* Damsgaard et al 2015 */ | |
+ sim.k = initval(1.9e-15, 1); /* Damsgaard et al 2015 */ | |
+ | |
+ sim.p_f_mod_ampl = 0.0; /* no fluid-pressure variations */ | |
+ sim.p_f_mod_freq = 0.0; /* no fluid-pressure variations */ | |
return sim; | |
} | |
diff --git a/simulation.c b/simulation.c | |
t@@ -13,8 +13,10 @@ void prepare_arrays(struct simulation* sim) | |
sim->sigma_n_eff = zeros(sim->nz); /* effective normal stress */ | |
sim->sigma_n = zeros(sim->nz); /* normal stess */ | |
sim->p_f_ghost = zeros(sim->nz+2); /* water pressure with ghost nodes */ | |
- sim->k = zeros(sim->nz); /* hydraulic permeability */ | |
+ free(sim->phi); | |
sim->phi = zeros(sim->nz); /* porosity */ | |
+ free(sim->k); | |
+ sim->k = zeros(sim->nz); /* permeability */ | |
sim->xi = zeros(sim->nz); /* cooperativity length */ | |
sim->gamma_dot_p = zeros(sim->nz); /* shear velocity */ | |
sim->v_x = zeros(sim->nz); /* shear velocity */ |