/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/plume/plume2d.c

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #include <glib.h>
00022 #include "plumevars.h"
00023 #include "plumeinput.h"
00024 #include <utils/utils.h>
00025 
00026 //void init_plume2d(plume_inputs *plume_const,river_type river_passed,int ngrains_passed,sedload_type *sedload_passed, double dx,double **deposit,int depositLen);
00027 
00028 gboolean plume2d(Plume_inputs *plume_const,Plume_river river_passed,int ngrains_passed,Plume_sediment *sedload_passed, double dx,double **deposit,int depositLen,Plume_data*);
00029 gboolean plume3d( Plume_inputs *plume_const , Plume_river river       ,
00030                   int n_grains              , Plume_sediment *sedload ,
00031                   Eh_dbl_grid *deposit      , Plume_data *data );
00032 
00033 Plume_data *plume_data_init( Plume_data *data )
00034 {
00035    data->x_len = 0;
00036    data->y_len = 0;
00037    data->ccnc  = NULL;
00038    data->ncnc  = NULL;
00039    data->deps  = NULL;
00040    data->dist  = NULL;
00041    data->ualb  = NULL;
00042    data->pcent = NULL;
00043    data->xval  = NULL;
00044    data->yval  = NULL;
00045 
00046    return data;
00047 }
00048 
00049 void destroy_plume_data( Plume_data *grid )
00050 {
00051    if ( grid )
00052    {
00053       eh_free( grid->xval );
00054       eh_free( grid->yval );
00055 
00056       free_d3tensor( grid->ccnc  );
00057       free_d3tensor( grid->ncnc  );
00058       free_d3tensor( grid->deps  );
00059       free_d3tensor( grid->dist  );
00060       free_dmatrix ( grid->ualb  );
00061       free_dmatrix ( grid->pcent );
00062 
00063       eh_free( grid );
00064    }
00065 }
00066 
00067 gboolean plume2d( Plume_inputs *plume_const , Plume_river river       ,
00068                   int n_grains              , Plume_sediment *sedload ,
00069                   double dx                 , double **deposit        ,
00070                   int deposit_len           , Plume_data *data )
00071 {
00072    int err;
00073    Plume_enviro env;
00074    Plume_ocean ocean;
00075    Plume_grid *grid = data;
00076    Plume_options opt;
00077 
00078    ocean.Cw = plume_const->ocean_concentration;
00079    ocean.So = 1.;
00080    ocean.Sw = 32.1;
00081    ocean.cc = .5;
00082    ocean.vo = 0.;
00083 
00084    grid->ymin    = plume_const->plume_width/2 - plume_const->plume_width;
00085    grid->ymax    = grid->ymin + plume_const->plume_width;
00086    grid->ndx     = plume_const->ndx;
00087    grid->ndy     = plume_const->ndy;
00088    grid->max_len = dx*deposit_len;
00089 
00090    opt.fjrd = 1;
00091    opt.strt = 1;
00092    opt.kwf  = 0;
00093    opt.o1   = 0;
00094    opt.o2   = 1;
00095    opt.o3   = 0;
00096 
00097    env.n_grains = n_grains;
00098    env.lat      = 45.;
00099    env.river = &river;
00100    env.ocean = &ocean;
00101    env.sed   = sedload;
00102 
00103    err = plume( &env , grid , &opt );
00104    if ( !err )
00105    {
00106       // Output data files.
00107       plumeout2( &env , grid , dx,deposit,deposit_len,n_grains,plume_const->plume_width);
00108 
00109       return TRUE;
00110    }
00111    else
00112       return FALSE;
00113 
00114 }
00115 /*
00116 Plume_river plume_init_plume_river( Sed_hydro river )
00117 {
00118    Plume_river riv;
00119 
00120    {
00121       riv.Cs = eh_new( double , sed_sediment_env_n_types() );
00122       for ( n=0 ; n<n_grains ; n++ )
00123          riv.Cs[n] = sed_hydro_nth_conc( river , n );
00124       riv.u0 = sed_hydro_velocity(river);
00125       riv.b0 = sed_hydro_width(river);
00126       riv.d0 = sed_hydro_depth(river);
00127       riv.Q  = sed_hydro_water_flux(river);
00128 
00129       riv.rdirection = G_PI_2;
00130       riv.rma        = 0.;
00131    }
00132 
00133    return riv;
00134 }
00135 
00136 Plume_sediment plume_init_plume_sediment( Sed_sediment sed )
00137 {
00138    Plume_sediment* sedload = eh_new( Plume_sediment , sed_sediment_n_types(sed)-1 );
00139 
00140    {
00141       Sed_type this_type;
00142 
00143       for ( n=1 ; n<n_grains ; n++ )
00144       {
00145          this_type = sed_sediment_type( sed , n );
00146 
00147          sedload[n-1].lambda = sed_type_lambda ( this_type );
00148          sedload[n-1].rho    = sed_type_rho_sat( this_type );
00149       }
00150    }
00151 
00152    return sedload;
00153 }
00154 
00155 Eh_dbl_grid* plume_init_plume_grid( Eh_cell_grid deposit )
00156 {
00157    Eh_dbl_grid* grid;
00158 
00159    {
00160       gssize n;
00161       gssize n_grains = sed_sediment_env_n_types();
00162 
00163       grid = eh_new( Eh_dbl_grid , n_grains-1 );
00164       for ( n=0 ; n<4 ; n++ )
00165       {
00166          grid[n] = eh_grid_new( double , eh_grid_n_x(deposit) , eh_grid_n_y(deposit) );
00167 
00168          eh_grid_set_x_lin( grid[n] , eh_grid_x(deposit)[0] , dx );
00169          eh_grid_set_y_lin( grid[n] , eh_grid_y(deposit)[0] , dy );
00170       }
00171    }
00172 
00173    return grid;
00174 }
00175 
00176 gboolean plume_3d( Plume_inputs* plume_const , Sed_hydro river ,
00177                    Eh_cell_grid deposit      , Plume_data* data )
00178 {
00179    Plume_river         riv = plume_init_plume_river   ( river              );
00180    Plume_sediment* sedload = plume_init_plume_sediment( sed_sediment_env() );
00181    Eh_dbl_grid*       grid = plume_init_plume_grid    ( deposit            );
00182 
00183    plume3d( plume_const , riv , sed_sediment_env_n_types() , sedload , grid , data );
00184 
00185    plume_fill_cell_grid( deposit , grid );
00186 
00187    return TRUE;
00188 }
00189 */
00190 gboolean plume3d( Plume_inputs *plume_const , Plume_river river       ,
00191                   int n_grains              , Plume_sediment *sedload ,
00192                   Eh_dbl_grid *deposit      , Plume_data *data )
00193 {
00194    int err;
00195    Plume_enviro env;
00196    Plume_ocean ocean;
00197    Plume_grid *grid = data;
00198    Plume_options opt;
00199 
00200    ocean.Cw = plume_const->ocean_concentration;
00201    ocean.So = 1.;
00202    ocean.Sw = 32.1;
00203    ocean.cc = .9;
00204    ocean.vo = plume_const->current_velocity;
00205 
00206    grid->ymin    = plume_const->plume_width/2 - plume_const->plume_width;
00207    grid->ymax    = grid->ymin + plume_const->plume_width;
00208    grid->ndx     = plume_const->ndx;
00209    grid->ndy     = plume_const->ndy;
00210    grid->max_len = eh_grid_y(deposit[0])[eh_grid_n_y(deposit[0])-1]
00211                  - eh_grid_y(deposit[0])[0];
00212 
00213    opt.fjrd = 0;
00214    opt.strt = 0;
00215    opt.kwf  = 1;
00216    opt.o1   = 0;
00217    opt.o2   = 1;
00218    opt.o3   = 0;
00219 
00220    if ( fabs(ocean.vo) < 1e-5 )
00221       opt.strt = 1;
00222 
00223    env.n_grains = n_grains;
00224    env.lat      = 49.;
00225    env.river = &river;
00226    env.ocean = &ocean;
00227    env.sed   = sedload;
00228 
00229    err = plume( &env , grid , &opt );
00230    if ( !err )
00231    {
00232       // Output data files.
00233       plumeout3( &env , grid , deposit );
00234 
00235       return TRUE;
00236    }
00237    else
00238       return FALSE;
00239 
00240 }
00241 

Generated on Fri Jan 4 18:04:15 2008 for sedflux by  doxygen 1.5.2