00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SAKURA_LOCAL_IS_INCLUDED
00022 # define SAKURA_LOCAL_IS_INCLUDED
00023
00024 #define TURBIDITY_CURRENT_DEFAULT_EA (0.00153)
00025 #define TURBIDITY_CURRENT_DEFAULT_EB (0.00204)
00026 #define TURBIDITY_CURRENT_DEFAULT_SUA (400.)
00027 #define TURBIDITY_CURRENT_DEFAULT_SUB (2.0)
00028 #define TURBIDITY_CURRENT_DEFAULT_CD (0.004)
00029 #define TURBIDITY_CURRENT_DEFAULT_TAN_PHI (0.36397023426620)
00030 #define TURBIDITY_CURRENT_DEFAULT_MU (1.3e-6)
00031 #define TURBIDITY_CURRENT_DEFAULT_DENSITY_SEA_WATER (1028.)
00032 #define TURBIDITY_CURRENT_DEFAULT_CHANNEL_WIDTH (100.0)
00033 #define TURBIDITY_CURRENT_DEFAULT_CHANNEL_LENGTH (30000.0)
00034
00035 #include <glib.h>
00036 #include <utils/utils.h>
00037 #include <sed/sed_sedflux.h>
00038 #include "sakura.h"
00039 #include "sakura_utils.h"
00040
00041
00042
00043 #define HMIN 0.0000001
00044 #define UPPERLIMIT 20
00045
00048
00049 #define G (9.81)
00050
00052 #define R (1.65)
00053
00055 #define Ro (2.0)
00056
00058 # define DAY (86400.)
00059
00060
00061 typedef struct
00062 {
00063 double* rho_grain;
00064 double* rho_dep;
00065 double* u_settling;
00066 gint len;
00067 }
00068 Sakura_sediment;
00069
00070 typedef struct
00071 {
00072 double u;
00073 double h;
00074 double c;
00075 double* c_grain;
00076 gint n_grain;
00077 }
00078 Sakura_node;
00079
00080 typedef struct
00081 {
00082 double* x;
00083 double* w;
00084 double* h;
00085 double* u;
00086 double* c;
00087 double** c_grain;
00088
00089 double** d;
00090 double** e;
00091
00092 gint len;
00093 gint n_grain;
00094 }
00095 Sakura_array;
00096
00097 Sakura_sediment* sakura_sediment_new ( gint n_grains );
00098 Sakura_sediment* sakura_sediment_destroy ( Sakura_sediment* s );
00099 Sakura_sediment* sakura_sediment_set_rho_grain ( Sakura_sediment* s , double* x );
00100 Sakura_sediment* sakura_sediment_set_rho_dep ( Sakura_sediment* s , double* x );
00101 Sakura_sediment* sakura_sediment_set_u_settling( Sakura_sediment* s , double* x );
00102
00103 Sakura_array* sakura_array_new ( gint len , gint n_grain );
00104 Sakura_array* sakura_array_destroy( Sakura_array* a );
00105 Sakura_array* sakura_array_copy ( Sakura_array* d , Sakura_array* s );
00106 Sakura_array* sakura_array_set_x ( Sakura_array* a , double* x );
00107 Sakura_array* sakura_array_set_w ( Sakura_array* a , double* w );
00108 Sakura_array* sakura_array_set_bc ( Sakura_array* a , Sakura_node* inflow , Sakura_node* outflow );
00109 double sakura_array_mass_in_susp ( Sakura_array* a , Sakura_sediment* s );
00110 double sakura_array_mass_eroded ( Sakura_array* a , Sakura_sediment* s );
00111 double sakura_array_mass_deposited( Sakura_array* a , Sakura_sediment* s );
00112
00113 Sakura_node* sakura_node_new ( double u , double c , double h , double* c_grain , gint len );
00114 Sakura_node* sakura_node_set ( Sakura_node* x , double u , double c , double h , double* c_grain , gint len );
00115 Sakura_node* sakura_node_destroy( Sakura_node* x );
00116
00117 gboolean sakura_set_outflow( Sakura_node* out , Sakura_array* a , double x_head , double dt , double dx );
00118 double sakura_get_sin_slope( Sakura_get_func f , gpointer data , Sakura_array* a , gint i );
00119 gboolean calculate_mid_vel( Sakura_array* a_mid , Sakura_array* a , gint ind_head , Sakura_const_st* Const );
00120 gboolean calculate_next_vel( Sakura_array* a_last , Sakura_array* a_mid , Sakura_array* a_next , gint ind_head , Sakura_const_st* Const );
00121 gboolean compute_c_grain( Sakura_array* a , Sakura_array* a_last , double* u , gint i , double dx , Sakura_const_st* Const , Sakura_sediment* sed );
00122 gboolean calculate_next_c_and_h( Sakura_array* a_new , Sakura_array* a_last , double* u_temp , gint ind_head , Sakura_const_st* Const , Sakura_sediment* sed );
00123 gboolean calculate_mid_c_and_h( Sakura_array* a_mid , Sakura_array* a_last , Sakura_array* a_next );
00124 gint calculate_head_index( Sakura_array* a , double* u , gint ind_head , double dx , double dt , double* x_head );
00125
00126 typedef struct
00127 {
00128 double* x;
00129 double* depth;
00130 double* width;
00131 double* slope;
00132 double** dep;
00133 gint n_grains;
00134 gint len;
00135 double dx;
00136 }
00137 Sakura_bathy_st;
00138
00139 typedef struct
00140 {
00141 double duration;
00142 double width;
00143 double depth;
00144 double velocity;
00145 double q;
00146 double* fraction;
00147 double rho_flow;
00148 gint n_grains;
00149 }
00150 Sakura_flood_st;
00151
00152 typedef struct
00153 {
00154 double* size_equiv;
00155 double* lambda;
00156 double* bulk_density;
00157 double* grain_density;
00158 double* u_settling;
00159 double* reynolds_no;
00160 gint n_grains;
00161 }
00162 Sakura_sediment_st;
00163
00164 typedef struct
00165 {
00166 Sakura_bathy_st* b;
00167 double* phe;
00168 gint n_grains;
00169 }
00170 Sakura_arch_st;
00171
00172 #define SAKURA_DEFAULT_BASIN_LEN (80.)
00173 #define SAKURA_DEFAULT_DX (100.)
00174 #define SAKURA_DEFAULT_DT (30.)
00175 #define SAKURA_DEFAULT_OUT_TIME (3600.)
00176 #define SAKURA_DEFAULT_MAX_TIME (86400.)
00177 #define SAKURA_DEFAULT_RHO_SEA_WATER (1028.)
00178 #define SAKURA_DEFAULT_RHO_RIVER_WATER (1028.)
00179
00180 #define SAKURA_DEFAULT_LAMBDA { 25. , 16.8 , 9. , 3.2 , 2.4 }
00181 #define SAKURA_DEFAULT_SIZE_EQUIV { 202. , 105. , 69. , 25. , 10. }
00182 #define SAKURA_DEFAULT_SIZE_COMP { 150. , 50. , 25. , 5. , 1. }
00183 #define SAKURA_DEFAULT_GRAIN_FRACTION { 0. , .1 , .2 , .3 , .4 }
00184 #define SAKURA_DEFAULT_FLOW_FRACTION { 1. , 1. , 1. , 1. , 1. }
00185 #define SAKURA_DEFAULT_BULK_DENSITY { 1850. , 1600. , 1400. , 1300. , 1200. }
00186 #define SAKURA_DEFAULT_GRAIN_DENSITY { 2650. , 2650. , 2650. , 2650. , 2650. }
00187 #define SAKURA_DEFAULT_DEP_START (2.)
00188 #define SAKURA_DEFAULT_SIZE_BOTTOM (64.)
00189 #define SAKURA_DEFAULT_BULK_DENSITY_BOTTOM (1600.)
00190 #define SAKURA_DEFAULT_BOTTOM_FRACTION { .2 , .2 , .2 , .2 , .2 }
00191 #define SAKURA_DEFAULT_N_GRAINS (5)
00192
00193 #define SAKURA_DEFAULT_SUA (30.)
00194 #define SAKURA_DEFAULT_SUB (.5)
00195 #define SAKURA_DEFAULT_EA (0.00153)
00196 #define SAKURA_DEFAULT_EB (0.0204)
00197 #define SAKURA_DEFAULT_CD (0.004)
00198 #define SAKURA_DEFAULT_FRICTION_ANGLE (20.)
00199 #define SAKURA_DEFAULT_MU_WATER (1.3)
00200
00201 #define SAKURA_DEFAULT_FLOOD_FILE "sakura_flood.kvf"
00202
00203 typedef struct
00204 {
00205 double basin_len;
00206 double dx;
00207 double dt;
00208 double out_dt;
00209 double max_t;
00210 double rho_sea_water;
00211 double rho_river_water;
00212 double* lambda;
00213 double* size_equiv;
00214 double* size_comp;
00215 double* grain_fraction;
00216 double* flow_fraction;
00217 double* bulk_density;
00218 double* grain_density;
00219 double dep_start;
00220 double size_bottom;
00221 double rho_bottom;
00222 double* bottom_fraction;
00223 double sua;
00224 double sub;
00225 double e_a;
00226 double e_b;
00227 double c_drag;
00228 double tan_phi;
00229 double mu_water;
00230 char* flood_file;
00231 gint n_grains;
00232
00233 double channel_width;
00234 double channel_len;
00235 }
00236 Sakura_param_st;
00237
00238 double** sakura_wrapper( Sakura_bathy_st* b ,
00239 Sakura_flood_st* f ,
00240 Sakura_sediment_st* s ,
00241 Sakura_const_st* c ,
00242 gint* n_grains ,
00243 gint* len );
00244
00245 void sakura_set_width( Sakura_bathy_st* bathy_data ,
00246 double river_width ,
00247 double spreading_angle );
00248
00249 Sakura_param_st* sakura_scan_parameter_file( const gchar* file , GError** error );
00250 Sakura_param_st* sakura_check_params ( Sakura_param_st* p , GError** error );
00251 Sakura_bathy_st* sakura_scan_bathy_file ( const gchar* file , Sakura_param_st* p , GError** error );
00252 Sakura_flood_st** sakura_scan_flood_file ( const gchar* file , Sakura_param_st* p , GError** error );
00253 Sakura_flood_st* sakura_set_flood_data ( Sed_hydro h , double rho_river_water );
00254 Sakura_flood_st* sakura_sed_set_flood_data ( Sed_hydro h , double rho_river_water );
00255 Sakura_flood_st* sakura_destroy_flood_data ( Sakura_flood_st* f );
00256 Sakura_sediment_st* sakura_set_sediment_data ( Sakura_param_st* p );
00257 Sakura_const_st* sakura_set_constant_data ( Sakura_param_st* p , Sakura_bathy_st* b );
00258 Sakura_const_st* sakura_set_constant_output_data( Sakura_const_st* c , const gchar* file , gint* id , gint dt );
00259 Sakura_bathy_st* sakura_set_bathy_data ( double** bathy , gint len , double dx , gint n_grains );
00260 Sakura_bathy_st* sakura_new_bathy_data ( gint n_grains , gint len );
00261 Sakura_bathy_st* sakura_copy_bathy_data ( Sakura_bathy_st* d , const Sakura_bathy_st* s );
00262 Sakura_bathy_st* sakura_destroy_bathy_data ( Sakura_bathy_st* b );
00263 Sakura_bathy_st* sakura_update_bathy_data ( Sakura_bathy_st* b , double** deposition , double** erosion , gint n_grains );
00264 gint sakura_write_data ( const gchar* file , Eh_dbl_grid deposit );
00265 gint sakura_write_output ( const gchar* file ,
00266 Sakura_bathy_st* b ,
00267 double** deposit ,
00268 gssize n_grains );
00269 double sakura_reynolds_number( double rho_grain , double equiv_dia , double rho_river_water , double mu_river_water );
00270 double sakura_settling_velocity( double rho_grain , double equiv_dia , double rho_river_water , double mu_river_water );
00271
00272 void sakura_get_phe ( Sakura_arch_st* data , double x , Sakura_phe_st* phe_data );
00273 double sakura_add ( Sakura_arch_st* data , double x , Sakura_cell_st* s );
00274 double sakura_remove ( Sakura_arch_st* data , double x , Sakura_cell_st* s );
00275 double sakura_get_depth( Sakura_arch_st* data , double x );
00276
00277 void sakura_sed_get_phe ( Sed_cube p , double y , Sakura_phe_st* phe_data );
00278 double sakura_sed_add_sediment ( Sed_cube p , double y , Sakura_cell_st* s );
00279 double sakura_sed_remove_sediment( Sed_cube p , double y , Sakura_cell_st* s );
00280 double sakura_sed_get_depth ( Sed_cube p , double y );
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 #endif