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 "plumevars.h" 00022 #include "plumeinput.h" 00023 00024 #include <utils/utils.h> 00025 00026 //grid_type_3d *grid; 00027 //river_type river; 00028 //int ngrains; /* actual number of grains simulated */ 00029 //sedload_type *sedload; 00030 //ocean_type ocean; 00031 00032 /* 00033 * Other Parameters 00034 */ 00035 //int fjrd; /* Flag for Fjord conditions, fjrd = 1; coastal, fjrd = 0 */ 00036 //int kwf; /* Kelvin Wave Flag, 0 = not, 1 = yes */ 00037 //double lat; /* latitude north in degrees [0:90] */ 00038 00039 /* 00040 * Set up grids (ymin,ymax used in Fjord runs (fr == 0) and for vo == 0 00041 */ 00042 //int ndy; /* N points within rivermouth (used for dy), must be odd!! 00043 // * (11 is a good number, reducing mass balance errors) */ 00044 //int ndx; /* x-grid spacing = ndx * dy 00045 // * (open ocean use 1, fjords use 3 to 10) */ 00046 //int dy, dx; /* actual bin spacing [calculated] */ 00047 //double ymin; /* Y (alongshore) range (m) [< -2*bo] */ 00048 //double ymax; /* [> 2*bo] */ 00049 //double xmin; /* X (crossshore) range (m) [0] */ 00050 //double xmax; /* [lots] */ 00051 //int o1, o2, o3; /* output flags for 1=standalone, 2=SEDFLUX-2D, 3=SEDFLUX-3D */ 00052 00053 //int strt; /* Straight plume flag, if straight (or Fjord) = 1, else = 0 */ 00054 00055 00056 FILE *fidlog; /* Log file */ 00057 00058 //--- 00059 // Grid data 00060 //--- 00061 //double ***ccnc, ***ncnc, ***deps, ***dist; 00062 //double **ualb, **pcent, **sln; 00063 //double *xval, *yval; 00064 //int lc, lpc, lx, ly, zx, zy; 00065 00066 //--- 00067 // Mass balance 00068 //--- 00069 //double Qsr, Qsw[4], Tsr, Tsd[2], merr; 00070 00071 int 00072 plume( Plume_enviro *env , Plume_grid *grid , Plume_options *opt ) 00073 { 00074 int err; 00075 Plume_mass_bal mb; 00076 00077 // Constants derived from Input Parameters 00078 err = plumeset( env , grid , opt ); 00079 00080 // Check for Hydraulic Jumps 00081 err = plumejump( env->river ); 00082 00083 // Set flag for fjords or Straight plumes 00084 00085 if ( opt->fjrd || fabs(env->ocean->vo) < ucrit*env->river->u0 ) 00086 opt->strt = 1; // assume: vo ~ 0 00087 else 00088 opt->strt = 0; 00089 /* 00090 if ( opt->fjrd ) 00091 opt->strt = 1; 00092 */ 00093 00094 // Check input values 00095 err = plumecheck( env , grid , opt ); 00096 if( err ) 00097 { 00098 // fprintf( stderr, " PlumeCheck ERROR: Plume Aborted \n\n" ); 00099 if ( opt->o1 ) 00100 fprintf( fidlog, " PlumeCheck ERROR: Plume Aborted \n\n" ); 00101 return -1; 00102 } 00103 00104 // Create nicely centered X/Y arrays 00105 eh_return_val_if_fail( plumearray( grid , env , opt )==0 , -1 ); 00106 00107 // Calculate centerline position and distance from mouth 00108 eh_return_val_if_fail( plumecent( env , grid , opt )==0 , -1 ); 00109 00110 // Calculate distance from/along centerline for all other pts 00111 eh_return_val_if_fail( plumedist( grid , opt )==0 , -1 ); 00112 00113 // Calculate the plume concentrations 00114 eh_return_val_if_fail( plumeconc( env , grid , opt )==0 , -1 ); 00115 00116 // Mass Conservation Checks and corrections 00117 eh_return_val_if_fail( plumemass( env , grid , &mb )==0 , -1 ); 00118 00119 return 0; 00120 00121 } 00122 00123