tReorder solver so that all BCs are set before both explicit and implicit schem… | |
git clone git://src.adamsgaard.dk/cngf-pf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit b74712ec694639379b78101a07ad091788d133b8 | |
parent f8eebc7a6073ea57ae8fe945301258901b09e33f | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 28 Jun 2019 12:38:09 +0200 | |
Reorder solver so that all BCs are set before both explicit and implicit schemes | |
Diffstat: | |
M fluid.c | 41 ++++++++++++++++++-----------… | |
1 file changed, 24 insertions(+), 17 deletions(-) | |
--- | |
diff --git a/fluid.c b/fluid.c | |
t@@ -3,6 +3,8 @@ | |
#include "simulation.h" | |
#include "arrays.h" | |
+/* #define DEBUG true */ | |
+ | |
void | |
hydrostatic_fluid_pressure_distribution(struct simulation* sim) | |
{ | |
t@@ -107,19 +109,6 @@ darcy_solver_1d(struct simulation* sim, | |
double epsilon, theta, p_f, p_f_top, r_norm_max; | |
double *dp_f_expl, *dp_f_impl, *p_f_ghost_out, *r_norm; | |
- /* compute explicit solution to pressure change */ | |
- dp_f_expl = zeros(sim->nz); | |
- for (i=0; i<sim->nz; ++i) | |
- dp_f_expl[i] = darcy_pressure_change_1d(i, | |
- sim->nz, | |
- sim->p_f_ghost, | |
- sim->phi, | |
- sim->k, | |
- sim->dz, | |
- sim->dt, | |
- sim->beta_f, | |
- sim->mu_f); | |
- | |
/* choose integration method, parameter in [0.0; 1.0] | |
* epsilon = 0.0: explicit | |
* epsilon = 0.5: Crank-Nicolson | |
t@@ -133,16 +122,34 @@ darcy_solver_1d(struct simulation* sim, | |
theta = 0.05; | |
/* theta = 1.7; */ | |
- /* compute implicit solution to pressure change */ | |
- dp_f_impl = zeros(sim->nz); | |
- p_f_ghost_out = zeros(sim->nz+2); | |
- r_norm = zeros(sim->nz); | |
p_f_top = sine_wave(sim->t, | |
sim->p_f_mod_ampl, | |
sim->p_f_mod_freq, | |
sim->p_f_mod_phase, | |
sim->p_f_top); | |
+ /* set fluid BCs */ | |
+ set_bc_dirichlet(sim->p_f_ghost, sim->nz, +1, p_f_top); | |
+ sim->p_f_ghost[idx1g(sim->nz-1)] = p_f_top; /* Include top node in BC … | |
+ set_bc_neumann(sim->p_f_ghost, sim->nz, -1); | |
+ | |
+ /* compute explicit solution to pressure change */ | |
+ dp_f_expl = zeros(sim->nz); | |
+ for (i=0; i<sim->nz; ++i) | |
+ dp_f_expl[i] = darcy_pressure_change_1d(i, | |
+ sim->nz, | |
+ sim->p_f_ghost, | |
+ sim->phi, | |
+ sim->k, | |
+ sim->dz, | |
+ sim->dt, | |
+ sim->beta_f, | |
+ sim->mu_f); | |
+ | |
+ /* compute implicit solution to pressure change */ | |
+ dp_f_impl = zeros(sim->nz); | |
+ p_f_ghost_out = zeros(sim->nz+2); | |
+ r_norm = zeros(sim->nz); | |
for (iter=0; iter<max_iter; ++iter) { | |
set_bc_dirichlet(sim->p_f_ghost, sim->nz, +1, p_f_top); |