commit 3e2725c9388be5990e38846b37e38322d66a0e17
parent e7c73faa313ade214e2bdf211d0a913b6d0c2942
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Tue, 16 Feb 2021 15:50:03 +0100
simulation.c: move inertia number into function and reuse
Diffstat:
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/simulation.c b/simulation.c
@@ -408,14 +408,22 @@ lithostatic_pressure_distribution(struct simulation *sim)
/* NEW FUNCTIONS START */
+inline static double
+inertia_number(double gamma_dot_p, double d, double sigma_n_eff, double rho_s)
+{
+ return gamma_dot_p * d / sqrt(sigma_n_eff / rho_s);
+}
+
void
compute_inertia_number(struct simulation *sim)
{
int i;
for (i = 0; i < sim->nz; ++i)
- sim->I[i] = sim->gamma_dot_p[i] * sim->d
- / sqrt(sim->sigma_n_eff[i] / sim->rho_s);
+ sim->I[i] = inertia_number(sim->gamma_dot_p[i],
+ sim->d,
+ sim->sigma_n_eff[i],
+ sim->rho_s);
}
void
@@ -923,8 +931,11 @@ set_coupled_fluid_transient_timestep(struct simulation *sim, const double safety
sim->C);
/* max expected inertia number */
- max_I = max_gamma_dot * sim->d
- / sqrt((sim->sigma_n[sim->nz - 1] - sim->p_f_mod_ampl) / sim->rho_s);
+ max_I = inertia_number(max_gamma_dot,
+ sim->d,
+ sim->sigma_n[sim->nz - 1] - sim->p_f_mod_ampl,
+ sim->rho_s);
+
t_val = xi * (sim->alpha + sim->phi[sim->nz - 1] * sim->beta_f) * sim->mu_f
/ (sim->phi[sim->nz - 1] * sim->phi[sim->nz - 1]
* sim->phi[sim->nz - 1] * sim->L_z * max_I);