cngf-pf

continuum model for granular flows with pore-pressure dynamics (renamed from 1d_fd_simple_shear)
git clone git://src.adamsgaard.dk/cngf-pf # fast
git clone https://src.adamsgaard.dk/cngf-pf.git # slow
Log | Files | Refs | README | LICENSE Back to index

deborah.c (2328B)


      1 #include <unistd.h>
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <math.h>
      5 #include <getopt.h>
      6 #include <time.h>
      7 #include <err.h>
      8 
      9 #include "simulation.h"
     10 #include "arg.h"
     11 
     12 #define EPS 1e-12
     13 
     14 /* depth accuracy criteria in meter for solver */
     15 #define TOL 1e-10
     16 #define MAX_ITER 100
     17 
     18 /* uncomment to print time spent per time step to stdout */
     19 /* #define BENCHMARK_PERFORMANCE */
     20 
     21 #ifndef M_PI
     22 #define M_PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062
     23 #endif
     24 
     25 char *argv0;
     26 
     27 static void
     28 usage(void)
     29 {
     30 	fprintf(stderr, "usage: %s "
     31 	        "[-h] "
     32 	        "[-d grain-size] "
     33 	        "[-i fluid-viscosity] "
     34 	        "[-k fluid-permeability] "
     35 	        "[-P grain-compressibility] "
     36 	        "[-p grain-porosity] "
     37 	        "[-s applied-shear-vel] "
     38 	        "[-v] "
     39 	        "\n", argv0);
     40 	exit(1);
     41 }
     42 
     43 static double
     44 deborah_number(const struct simulation *sim)
     45 {
     46 	return sim->alpha * sim->mu_f * sim->d * sim->v_x_fix
     47 		/ (sim->k[0] * (1.0 - sim->phi[0]));
     48 }
     49 
     50 int
     51 main(int argc, char *argv[])
     52 {
     53 	int i;
     54 	double new_phi, new_k;
     55 	struct simulation sim;
     56 
     57 #ifdef BENCHMARK_PERFORMANCE
     58 	clock_t t_begin, t_end;
     59 	double t_elapsed;
     60 
     61 #endif
     62 
     63 #ifdef __OpenBSD__
     64 	if (pledge("stdio", NULL) == -1)
     65 		err(2, "pledge failed");
     66 #endif
     67 
     68 	init_sim(&sim);
     69 	new_phi = sim.phi[0];
     70 	new_k = sim.k[0];
     71 
     72 	ARGBEGIN {
     73 	case 'd':
     74 		sim.d = atof(EARGF(usage()));
     75 		break;
     76 	case 'h':
     77 		usage();
     78 		break;
     79 	case 'i':
     80 		sim.mu_f = atof(EARGF(usage()));
     81 		break;
     82 	case 'k':
     83 		new_k = atof(EARGF(usage()));
     84 		break;
     85 	case 'P':
     86 		sim.alpha = atof(EARGF(usage()));
     87 		break;
     88 	case 'p':
     89 		new_phi = atof(EARGF(usage()));
     90 		break;
     91 	case 's':
     92 		sim.v_x_fix = atof(EARGF(usage()));
     93 		break;
     94 	case 'v':
     95 		printf("%s-" VERSION "\n", argv0);
     96 		return 0;
     97 		break;
     98 	default:
     99 		usage();
    100 	} ARGEND;
    101 
    102 	if (argc > 0)
    103 		usage();
    104 
    105 	sim.nz = 2;
    106 	prepare_arrays(&sim);
    107 
    108 	if (!isnan(new_phi))
    109 		for (i = 0; i < sim.nz; ++i)
    110 			sim.phi[i] = new_phi;
    111 	if (!isnan(new_k))
    112 		for (i = 0; i < sim.nz; ++i)
    113 			sim.k[i] = new_k;
    114 
    115 	check_simulation_parameters(&sim);
    116 
    117 #ifdef BENCHMARK_PERFORMANCE
    118 	t_begin = clock();
    119 #endif
    120 
    121 	printf("%.17g\n", deborah_number(&sim));
    122 
    123 #ifdef BENCHMARK_PERFORMANCE
    124 	t_end = clock();
    125 	t_elapsed = (double) (t_end - t_begin) / CLOCKS_PER_SEC;
    126 	printf("time spent = %g s\n", t_elapsed);
    127 #endif
    128 
    129 	free_arrays(&sim);
    130 
    131 	return 0;
    132 }