Changeset 9148


Ignore:
Timestamp:
Jun 12, 2014, 7:55:33 AM (11 years ago)
Author:
steve
Message:

Working on validation tests

Location:
trunk/anuga_core/source/anuga
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/config.py

    r9125 r9148  
    7272tight_slope_limiters = True
    7373
    74 use_edge_limiter = False  # The edge limiter is better, but most runs have been
    75                           # using vertex limiting. Validations passed with this
    76                           # one True 9th May 2008, but many unit tests need
    77                           # backward compatibility flag set FIXME(Ole).
     74use_edge_limiter = False    # The edge limiter is better, but most runs have been
     75                            # using vertex limiting. Validations passed with this
     76                            # one True 9th May 2008, but many unit tests need
     77                            # backward compatibility flag set FIXME(Ole).
    7878
    7979# Use centroid velocities to reconstruct momentum at vertices in
  • trunk/anuga_core/source/anuga/file/sww.py

    r9120 r9148  
    77class NewQuantity(exceptions.Exception): pass
    88class DataDomainError(exceptions.Exception): pass
    9 class DataMissingValuesError(exceptions.Exception): pass
    109class DataTimeError(exceptions.Exception): pass
    1110
     
    811810
    812811
    813          # dimension definitions
     812        # dimension definitions
    814813        #outfile.createDimension('number_of_volumes', number_of_volumes)
    815814        #outfile.createDimension('number_of_vertices', 3)
  • trunk/anuga_core/source/anuga/shallow_water/swDE1_domain_ext.c

    r9121 r9148  
    9696//
    9797//}
     98
     99
     100// Innermost flux function (using stage w=z+h)
     101int _flux_function_toro(double *q_left, double *q_right,
     102                           double h_left, double h_right,
     103                           double hle, double hre,
     104                           double n1, double n2,
     105                           double epsilon,
     106                           double ze,
     107                           double limiting_threshold,
     108                           double g,
     109                           double *edgeflux, double *max_speed,
     110                           double *pressure_flux, double hc,
     111                           double hc_n, double speed_max_last)
     112{
     113
     114  /*Compute fluxes between volumes for the shallow water wave equation
     115    cast in terms of the 'stage', w = h+z using
     116
     117        HLL scheme of Fraccarollo and Toro Experimental and numerical assessment of the shallow
     118water model for two-dimensional dam-break type. Journal of Computational Physics,
     11933(6):843–864, 1995.
     120
     121    FIXME: Several variables in this interface are no longer used, clean up
     122  */
     123
     124  int i;
     125
     126  double w_left,  uh_left, vh_left, u_left;
     127  double w_right, uh_right, vh_right, u_right;
     128  double s_min, s_max, soundspeed_left, soundspeed_right;
     129  double u_m, h_m, soundspeed_m, s_m;
     130  double denom, inverse_denominator;
     131  double uint, t1, t2, t3, min_speed, tmp;
     132  // Workspace (allocate once, use many)
     133  static double q_left_rotated[3], q_right_rotated[3], flux_right[3], flux_left[3];
     134
     135  // Copy conserved quantities to protect from modification
     136  q_left_rotated[0] = q_left[0];
     137  q_right_rotated[0] = q_right[0];
     138  q_left_rotated[1] = q_left[1];
     139  q_right_rotated[1] = q_right[1];
     140  q_left_rotated[2] = q_left[2];
     141  q_right_rotated[2] = q_right[2];
     142
     143  // Align x- and y-momentum with x-axis
     144  _rotate(q_left_rotated, n1, n2);
     145  _rotate(q_right_rotated, n1, n2);
     146
     147
     148  // Compute speeds in x-direction
     149  //w_left = q_left_rotated[0];
     150  uh_left=q_left_rotated[1];
     151  vh_left=q_left_rotated[2];
     152  if(hle>0.0){
     153    u_left = uh_left/hle ; //max(h_left, 1.0e-06);
     154    uh_left=h_left*u_left;
     155    vh_left=h_left/(hle)*vh_left;
     156  }else{
     157    u_left=0.;
     158    uh_left=0.;
     159    vh_left=0.;
     160  }
     161
     162  //u_left = _compute_speed(&uh_left, &hle,
     163  //            epsilon, h0, limiting_threshold);
     164
     165  //w_right = q_right_rotated[0];
     166  uh_right = q_right_rotated[1];
     167  vh_right = q_right_rotated[2];
     168  if(hre>0.0){
     169    u_right = uh_right/hre;//max(h_right, 1.0e-06);
     170    uh_right=h_right*u_right;
     171    vh_right=h_right/hre*vh_right;
     172  }else{
     173    u_right=0.;
     174    uh_right=0.;
     175    vh_right=0.;
     176  }
     177  //u_right = _compute_speed(&uh_right, &hre,
     178  //              epsilon, h0, limiting_threshold);
     179
     180
     181
     182  // Maximal and minimal wave speeds
     183  soundspeed_left  = sqrt(g*h_left);
     184  soundspeed_right = sqrt(g*h_right);
     185
     186  // Toro for shallow water
     187  u_m = 0.5*(u_left + u_right) + soundspeed_left - soundspeed_right;
     188  h_m = (u_left + 2.0*soundspeed_left - u_right + 2.0*soundspeed_right);
     189  h_m = h_m*h_m/(16.0*g);
     190  soundspeed_m = sqrt(g*h_m);
     191
     192
     193  if(h_left < 1.0e-10){
     194          s_min = u_right - 2.0*soundspeed_right;
     195          s_max = u_right + soundspeed_right;
     196          s_m   = s_min;
     197  }
     198  else if (h_right < 1.0e-10){
     199          s_min = u_left - soundspeed_left;
     200          s_max = u_left + 2.0*soundspeed_left;
     201          s_m = s_max;
     202  }
     203  else {
     204          s_max = max(u_right + soundspeed_right, u_m + soundspeed_right);
     205          s_min = min(u_left - soundspeed_left, u_m - soundspeed_m);
     206  }
     207
     208  if (s_max < 0.0)
     209  {
     210    s_max = 0.0;
     211  }
     212
     213  if (s_min > 0.0)
     214  {
     215    s_min = 0.0;
     216  }
     217
     218
     219  // Flux formulas
     220  flux_left[0] = u_left*h_left;
     221  flux_left[1] = u_left*uh_left; //+ 0.5*g*h_left*h_left;
     222  flux_left[2] = u_left*vh_left;
     223
     224  flux_right[0] = u_right*h_right;
     225  flux_right[1] = u_right*uh_right ; //+ 0.5*g*h_right*h_right;
     226  flux_right[2] = u_right*vh_right;
     227
     228  // Flux computation
     229  denom = s_max - s_min;
     230  if (denom < epsilon)
     231  {
     232    // Both wave speeds are very small
     233    memset(edgeflux, 0, 3*sizeof(double));
     234
     235    *max_speed = 0.0;
     236    //*pressure_flux = 0.0;
     237    *pressure_flux = 0.5*g*0.5*(h_left*h_left+h_right*h_right);
     238  }
     239  else
     240  {
     241    // Maximal wavespeed
     242    *max_speed = max(s_max, -s_min);
     243
     244    inverse_denominator = 1.0/max(denom,1.0e-100);
     245    for (i = 0; i < 3; i++)
     246    {
     247      edgeflux[i] = s_max*flux_left[i] - s_min*flux_right[i];
     248
     249      // Standard smoothing term
     250      // edgeflux[i] += 1.0*(s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]);
     251      // Smoothing by stage alone can cause high velocities / slow draining for nearly dry cells
     252      if(i==0) edgeflux[i] += (s_max*s_min)*(max(q_right_rotated[i],ze) - max(q_left_rotated[i],ze));
     253      if(i==1) edgeflux[i] += (s_max*s_min)*(uh_right - uh_left);
     254      if(i==2) edgeflux[i] += (s_max*s_min)*(vh_right - vh_left);
     255
     256      edgeflux[i] *= inverse_denominator;
     257    }
     258    // Separate pressure flux, so we can apply different wet-dry hacks to it
     259    *pressure_flux = 0.5*g*( s_max*h_left*h_left -s_min*h_right*h_right)*inverse_denominator;
     260
     261
     262    // Rotate back
     263    _rotate(edgeflux, n1, -n2);
     264  }
     265
     266  return 0;
     267}
     268
     269
     270
     271
    98272
    99273// Innermost flux function (using stage w=z+h)
     
    516690
    517691            // Edge flux computation (triangle k, edge i)
    518             _flux_function_central(ql, qr, 
     692            _flux_function_central(ql, qr,
    519693                    h_left, h_right,
    520694                    hle, hre,
  • trunk/anuga_core/source/anuga/structures/boyd_box_operator.py

    r9029 r9148  
    3636                 manning=0.013,
    3737                 enquiry_gap=0.0,
     38                 smoothing_timescale=0.0,
    3839                 use_momentum_jet=True,
    3940                 use_velocity_head=True,
     
    9091        self.case = 'N/A'
    9192       
     93        # May/June 2014 -- allow 'smoothing ' of driving_energy, delta total energy, and outflow_enq_depth
     94        self.smoothing_timescale=0.
     95        self.smooth_delta_total_energy=0.
     96        self.smooth_Q=0.
     97        # Set them based on a call to the discharge routine with smoothing_timescale=0.
     98        # [values of self.smooth_* are required in discharge_routine, hence dummy values above]
     99        Qvd=self.discharge_routine()
     100        self.smooth_delta_total_energy=1.0*self.delta_total_energy
     101        self.smooth_Q=Qvd[0]
     102        # Finally, set the smoothing timescale we actually want
     103        self.smoothing_timescale=smoothing_timescale
     104
     105       
    92106        if verbose:
    93107            print self.get_culvert_slope()
     
    129143            self.outflow = self.inlets[0]
    130144            self.delta_total_energy = -self.delta_total_energy
     145           
     146           
     147           
    131148
    132149
  • trunk/anuga_core/source/anuga/utilities/plot_utils.py

    r9123 r9148  
    7070    which would make an object p2 that is like p, but holds information at centroids
    7171    """
    72     def __init__(self, filename_list, minimum_allowed_height=1.0e-03):
     72    def __init__(self, filename_list, minimum_allowed_height=1.0e-03, verbose=False):
    7373        #
    7474        # Go through the sww files in 'filename_list', and combine them into one object.
     
    7676
    7777        for i, filename in enumerate(filename_list):
    78             print i, filename
     78            if verbose: print i, filename
    7979            # Store output from filename
    8080            p_tmp = get_output(filename, minimum_allowed_height)
     
    139139       p then contains most relevant information as e.g., p.stage, p.elev, p.xmom, etc
    140140    """
    141     def __init__(self, filename, minimum_allowed_height=1.0e-03):
     141    def __init__(self, filename, minimum_allowed_height=1.0e-03, verbose=False):
    142142        self.x, self.y, self.time, self.vols, self.stage, \
    143143                self.height, self.elev, self.friction, self.xmom, self.ymom, \
    144144                self.xvel, self.yvel, self.vel, self.minimum_allowed_height,\
    145145                self.xllcorner, self.yllcorner = \
    146                 read_output(filename, minimum_allowed_height)
     146                read_output(filename, minimum_allowed_height,verbose=verbose)
    147147        self.filename=filename
    148 
    149 
    150 def read_output(filename, minimum_allowed_height):
     148        self.verbose = verbose
     149
     150
     151def read_output(filename, minimum_allowed_height,verbose):
    151152    # Input: The name of an .sww file to read data from,
    152153    #                    e.g. read_sww('channel3.sww')
     
    240241         This is done because presently centroid elevations do not change over time.
    241242    """
    242     def __init__(self,p, velocity_extrapolation=False):
     243    def __init__(self,p, velocity_extrapolation=False, verbose=False):
    243244       
    244245        self.time, self.x, self.y, self.stage, self.xmom,\
    245246             self.ymom, self.height, self.elev, self.friction, self.xvel, \
    246247             self.yvel, self.vel= \
    247              get_centroid_values(p, velocity_extrapolation)
     248             get_centroid_values(p, velocity_extrapolation,verbose=verbose)
    248249                                 
    249250
    250 def get_centroid_values(p, velocity_extrapolation):
     251def get_centroid_values(p, velocity_extrapolation, verbose=False):
    251252    # Input: p is the result of e.g. p=util.get_output('mysww.sww'). See the get_output class defined above
    252253    # Output: Values of x, y, Stage, xmom, ymom, elev, xvel, yvel, vel at centroids
     
    332333    else:
    333334        # Get centroid values from file
    334         print 'Reading centroids from file'
     335        if verbose: print 'Reading centroids from file'
    335336        stage_cent=fid.variables['stage_c'][:]
    336337        elev_cent=fid.variables['elevation_c'][:]
  • trunk/anuga_core/source/anuga/utilities/sww_merge.py

    r9020 r9148  
    356356        ftri_ids = num.where(tri_full_flag>0)
    357357        ftri_l2g = num.compress(tri_full_flag, tri_l2g)
     358       
     359        #f_ids = num.argwhere(tri_full_flag==1).reshape(-1,)
     360        #f_gids = tri_l2g[f_ids]
    358361
    359362        #print l_volumes
     
    361364        #print tri_l2g
    362365        #print ftri_l2g
    363 
    364         fg_volumes = num.compress(tri_full_flag,l_volumes,axis=0)
    365         g_volumes[ftri_l2g] = fg_volumes
     366       
     367        f_volumes0 = num.compress(tri_full_flag,volumes[:,0])
     368        f_volumes1 = num.compress(tri_full_flag,volumes[:,1])
     369        f_volumes2 = num.compress(tri_full_flag,volumes[:,2])
     370       
     371        g_volumes[ftri_l2g,0] = node_l2g[f_volumes0]
     372        g_volumes[ftri_l2g,1] = node_l2g[f_volumes1]
     373        g_volumes[ftri_l2g,2] = node_l2g[f_volumes2]
     374
     375        #fg_volumes = num.compress(tri_full_flag,l_volumes,axis=0)
     376        #g_volumes[ftri_l2g] = fg_volumes
    366377
    367378
     
    662673
    663674        # Just pick out the full triangles
    664         ftri_ids = num.where(tri_full_flag>0)
    665         ftri_l2g = num.compress(tri_full_flag, tri_l2g)
    666 
    667         assert num.allclose(f_ids, ftri_ids)
    668         assert num.allclose(ftri_l2g, f_gids)
     675        #ftri_ids = num.where(tri_full_flag>0)
     676        #ftri_l2g = num.compress(tri_full_flag, tri_l2g)
     677
     678        #assert num.allclose(f_ids, ftri_ids)
     679        #assert num.allclose(ftri_l2g, f_gids)
    669680
    670681        g_vids = (3*f_gids.reshape(-1,1) + num.array([0,1,2])).reshape(-1,)
     
    708719            #             num.array(fid.variables[quantity],dtype=num.float32)
    709720            q = fid.variables[quantity]
    710             out_s_c_quantities[quantity][ftri_l2g] = \
    711                          num.array(q,dtype=num.float32)[ftri_ids]
     721            out_s_c_quantities[quantity][f_gids] = \
     722                         num.array(q,dtype=num.float32)[f_ids]
    712723
    713724       
     
    717728            #print q.shape
    718729            for i in range(n_steps):
    719                 out_d_c_quantities[quantity][i][ftri_l2g] = \
    720                            num.array(q[i],dtype=num.float32)[ftri_ids]
     730                out_d_c_quantities[quantity][i][f_gids] = \
     731                           num.array(q[i],dtype=num.float32)[f_ids]
    721732
    722733        fid.close()
  • trunk/anuga_core/source/anuga/validation_utilities/parameters.py

    r9117 r9148  
    77__date__ ="$20/08/2012 11:20:00 PM$"
    88
    9 alg = 'DE1'
     9alg = 'DE0'
    1010cfl = 1.0
    1111
     12# If a file local_parameters.py exits in current directory
     13# use the parameters defined there to override the parameters set here.
    1214try:
    13     from anuga_validation_tests.local_parameters import *
     15    from local_parameters import *
    1416except:
    1517    pass
  • trunk/anuga_core/source/anuga/validation_utilities/run_validation.py

    r9117 r9148  
    77
    88def run_validation_script(script):
    9     from anuga.validation_utilities.fabricate import run
     9    #from anuga.validation_utilities.fabricate import run
    1010    from anuga.validation_utilities.parameters import alg,cfl
    11     run('python', script,  '-alg', alg, '-cfl', cfl)
     11   
     12    import subprocess
     13    cmd = 'python %s -cfl %s -alg %s' % (script, str(cfl), str(alg))
     14    print 50*'='
     15    print 'Run '+cmd
     16    print 50*'='
     17    subprocess.call([cmd], shell=True)
     18    #run('python', script,  '-alg', alg, '-cfl', cfl)
    1219
    1320   
Note: See TracChangeset for help on using the changeset viewer.