Ignore:
Timestamp:
May 13, 2013, 5:09:25 PM (12 years ago)
Author:
davies
Message:

Updates to bal_dev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c

    r8865 r8866  
    8585}
    8686
     87// minmod limiter
     88int _minmod(double a, double b){
     89    // Compute minmod
     90
     91    if(sign(a)!=sign(b)){
     92        return 0.0;
     93    }else{
     94        return min(fabs(a), fabs(b))*sign(a);
     95    }
     96
     97
     98}
     99
    87100// Innermost flux function (using stage w=z+h)
    88101int _flux_function_central(double *q_left, double *q_right,
     
    116129  double s_min, s_max, soundspeed_left, soundspeed_right;
    117130  double denom, inverse_denominator, z;
    118   double uint, t1, t2, t3;
     131  double uint, t1, t2, t3, min_speed;
    119132  // Workspace (allocate once, use many)
    120133  static double q_left_rotated[3], q_right_rotated[3], flux_right[3], flux_left[3];
     
    145158  if(h_left>h0){
    146159    u_left = uh_left/max(h_left, 1.0e-06);
     160    uh_left=h_left*u_left;
    147161  }else{
    148162    u_left=0.;
     163    uh_left=h_left*u_left;
    149164  }
    150165  //u_left = _compute_speed(&uh_left, &h_left,
     
    158173  if(h_right>h0){
    159174    u_right = uh_right/max(h_right, 1.0e-06);
     175    uh_right=h_right*u_right;
    160176  }else{
    161177    u_right=0.;
     178    uh_right=h_right*u_right;
    162179  }
    163180
     
    236253  // Flux computation
    237254  denom = s_max - s_min;
    238   if (denom < epsilon)
     255  //if (denom < -epsilon)
     256  if (0==1)
    239257  {
    240258    // Both wave speeds are very small
     
    242260
    243261    *max_speed = 0.0;
    244     *pressure_flux = 0.0;
    245     //*pressure_flux = 0.5*g*0.5*(h_left*h_left+h_right*h_right);
     262    //*pressure_flux = 0.0;
     263    *pressure_flux = 0.5*g*0.5*(h_left*h_left+h_right*h_right);
    246264  }
    247265  else
     
    249267    // Maximal wavespeed
    250268    *max_speed = max(s_max, -s_min);
    251    
    252     inverse_denominator = 1.0/denom;
     269    //min_speed=min(s_max, -s_min);
     270 
     271    inverse_denominator = 1.0/max(denom,1.0e-100);
    253272    for (i = 0; i < 3; i++)
    254273    {
    255274      edgeflux[i] = s_max*flux_left[i] - s_min*flux_right[i];
     275
    256276      // Standard smoothing term
    257277      //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]);
     278
     279      // Adjustment to the scheme by Kurganov and Lin 2007 Communications in Computational
     280      // Physics 2:141-163
     281      //uint = (s_max*q_right_rotated[i] - s_min*q_left_rotated[i] - (flux_right[i] - flux_left[i]))*inverse_denominator;
     282      //t1 = (q_right_rotated[i] - uint);
     283      //t2 = (-q_left_rotated[i] + uint);
     284      //t3 = _minmod(t1,t2);
     285      //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]-t3);
     286
    258287      //GD HACK: Here, we supress the 'smoothing' part of the flux -- like scaling diffusion by local wave speed
     288      //if(i!=2){
    259289      edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i])*
    260                       (min(*max_speed/(max(speed_max_last,1e-06)),1.0));//(min(hc/h_left,min(hc_n/h_right,1.0)));
     290                     (min(*max_speed/(max(speed_max_last,1.0e-100)),1.0));//(min(hc/h_left,min(hc_n/h_right,1.0)));
     291      //}
     292
    261293      edgeflux[i] *= inverse_denominator;
    262294    }
     
    449481            // bedslope_work contains all gravity related terms -- weighting of
    450482            // conservative and non-conservative versions.
    451             if(hc> -h0){
     483            if(hc> h0){
    452484              bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux);
    453485              //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux);
     
    471503                edgeflux_store[nm3 + 2 ] = edgeflux[2];
    472504
    473                 if(hc_n> -h0){
     505                if(hc_n> h0){
    474506                  bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux);
    475507                  //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux);
     
    493525            if ((tri_full_flag[k] == 1) ) {
    494526
    495                 if(call%timestep_order!=0) max_speed = max_speed_array[k]; // HACK to Ensure that local timestep is the same as the last timestep
     527                if((call-2)%timestep_order!=0) max_speed = max_speed_array[k]; // HACK to Ensure that local timestep is the same as the last timestep
    496528
    497529                if (max_speed > epsilon) {
     
    585617            // GD HACK
    586618            // Option to limit advective fluxes
    587             if(hc > h0){
     619            if(hc > -h0){
    588620                stage_explicit_update[k] += edgeflux_store[ki3+0];
    589621                // Cut these terms for shallow flows, and protect stationary states from round-off error
     
    598630            if(n<0){
    599631                boundary_flux_sum[0] += edgeflux_store[ki3];
    600                 //printf("%f, %f, %d \n", boundary_flux_sum[0], timestep, ki3);
    601632            }
    602633
    603634            // GD HACK
    604635            // Compute bed slope term
    605             if(hc > h0){
     636            if(hc > -h0){
    606637                xmom_explicit_update[k] -= normals[ki2]*pressuregrad_store[ki];
    607638                ymom_explicit_update[k] -= normals[ki2+1]*pressuregrad_store[ki];
     
    621652    }  // end cell k
    622653
    623     if(call%timestep_order==0) timestep=local_timestep;
     654    if((call-2)%timestep_order==0) timestep=local_timestep; // Hack to ensure we only update the timestep on the first call within each rk2/rk3 step
    624655
    625656    // Look for 'dry' edges, and set momentum (& component of momentum_update)
     
    729760            //xmomc[k] = 0.;//xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;
    730761            //ymomc[k] = 0.;//ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;
    731             xmomc[k] = xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;
    732             ymomc[k] = ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;
     762            //xmomc[k] = xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;
     763            //ymomc[k] = ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;
     764            xmomc[k] = xmomc[k]*max(hc-minimum_allowed_height,0.)/(minimum_allowed_height);// 0.0;
     765            ymomc[k] = ymomc[k]*max(hc-minimum_allowed_height,0.)/(minimum_allowed_height);// 0.0;
    733766
    734767        if (hc <= 0.0){
     
    805838  // Any provisional jump with magnitude < TINY does not contribute to
    806839  // the limiting process.
     840  //return 0;
    807841 
    808842  for (i=0;i<3;i++){
     
    821855  dqv[1]=dqv[1]*phi;
    822856  dqv[2]=dqv[2]*phi;
     857
     858 
     859  //printf("%lf \n ", beta_w);
    823860   
    824861  return 0;
     
    11201157              }else{
    11211158                // Constant stage extrapolation
    1122                 stage_edge_values[k3]   = stage_centroid_values[k];
    1123                 stage_edge_values[k3+1] = stage_centroid_values[k];
    1124                 stage_edge_values[k3+2] = stage_centroid_values[k];
     1159                //stage_edge_values[k3]   = stage_centroid_values[k];
     1160                //stage_edge_values[k3+1] = stage_centroid_values[k];
     1161                //stage_edge_values[k3+2] = stage_centroid_values[k];
    11251162              }
    11261163            //}else{
     
    12231260              //}
    12241261              // First order momentum / velocity extrapolation
    1225               //stage_edge_values[k3]    = stage_centroid_values[k];
    1226               //stage_edge_values[k3+1]  = stage_centroid_values[k];
    1227               //stage_edge_values[k3+2]  = stage_centroid_values[k];
     1262              stage_edge_values[k3]    = stage_centroid_values[k];
     1263              stage_edge_values[k3+1]  = stage_centroid_values[k];
     1264              stage_edge_values[k3+2]  = stage_centroid_values[k];
    12281265              xmom_edge_values[k3]    = xmom_centroid_values[k];
    12291266              xmom_edge_values[k3+1]  = xmom_centroid_values[k];
     
    12511288            //hfactor=hmin/(hmin + 0.004);
    12521289          //}
    1253           hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height*10.)), 1.0);
     1290          hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height*2.)), 1.0);
    12541291          //hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height)), 1.0);
    12551292         
     
    13171354          //if(count_wet_neighbours[k]>0){
    13181355          limit_gradient(dqv, qmin, qmax, beta_tmp);
     1356          //printf("%lf \n ", beta_tmp);
    13191357          //}
    13201358          //}
Note: See TracChangeset for help on using the changeset viewer.