Changeset 8751


Ignore:
Timestamp:
Mar 11, 2013, 8:17:49 PM (12 years ago)
Author:
davies
Message:

Updates to gd in-development algorithms

Location:
trunk
Files:
10 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga_validation_tests/utilities/fabricate.py

    • Property svn:executable deleted
  • trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain.py

    r8547 r8751  
    6363        # Most of these override the options in config.py
    6464        #------------------------------------------------
    65         self.set_CFL(1.0)
     65        self.set_CFL(1.00)
    6666        self.set_use_kinematic_viscosity(False)
    67         self.timestepping_method='rk2'
     67        self.timestepping_method='rk2' #'euler'#'rk2'#'euler'#'rk2'
    6868        # The following allows storage of the negative depths associated with this method
    6969        self.minimum_storable_height=-99999999999.0
     
    235235
    236236        # Shortcuts
     237        if(domain.timestepping_method!='rk2'):
     238            err_mess='ERROR: Timestepping method is ' + domain.timestepping_method +'. '+\
     239                     'You need to use rk2 timestepping with this solver, ' +\
     240                     ' because there is presently a hack in compute fluxes central. \n'+\
     241                     ' The HACK: The timestep will only ' +\
     242                     'be recomputed on every 2nd call to compute_fluxes_central, to support'+\
     243                     ' correct treatment of wetting and drying'
     244
     245            raise Exception, err_mess
     246
    237247        Stage = domain.quantities['stage']
    238248        Xmom = domain.quantities['xmomentum']
     
    268278                                           int(domain.optimise_dry_cells),
    269279                                           Stage.centroid_values,
     280                                           Xmom.centroid_values,
     281                                           Ymom.centroid_values,
    270282                                           Bed.centroid_values,
    271283                                           Bed.vertex_values)
  • trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c

    r8549 r8751  
    206206  denom = s_max - s_min;
    207207  if (denom < epsilon)
    208   { // FIXME (Ole): Try using h0 here
     208  {
     209    // Both wave speeds are very small
    209210    memset(edgeflux, 0, 3*sizeof(double));
    210211
     
    263264        int optimise_dry_cells,
    264265        double* stage_centroid_values,
     266        double* xmom_centroid_values,
     267        double* ymom_centroid_values,
    265268        double* bed_centroid_values,
    266269        double* bed_vertex_values) {
     
    273276    // See ANUGA manual under flux limiting
    274277    int k, i, m, n,j;
    275     int ki, nm = 0, ki2; // Index shorthands
     278    int ki, nm = 0, ki2,ki3, nm3; // Index shorthands
    276279
    277280    // Workspace (making them static actually made function slightly slower (Ole))
     
    281284    int neighbours_wet[3];//Work array
    282285    int useint;
    283     double stage_edge_lim, scale_factor_shallow, bedtop, bedbot, pressure_flux, hc, hc_n, tmp;
    284     //double max_bed_edgevalue[number_of_elements]; // FIXME: Set memory explicitly
     286    double stage_edge_lim, outgoing_flux_edges, bedtop, bedbot, pressure_flux, hc, hc_n, tmp, tmp2;
    285287    static long call = 1; // Static local variable flagging already computed flux
    286288
    287     double *max_bed_edgevalue, *min_bed_edgevalue;
     289    double *max_bed_edgevalue, *min_bed_edgevalue, *edgeflux_store, *pressuregrad_store;
    288290
    289291    max_bed_edgevalue = malloc(number_of_elements*sizeof(double));
    290     //min_bed_edgevalue = malloc(number_of_elements*sizeof(double));
    291     // Start computation
     292    edgeflux_store = malloc(number_of_elements*9*sizeof(double));
     293    pressuregrad_store = malloc(number_of_elements*3*sizeof(double));
     294
    292295    call++; // Flag 'id' of flux calculation for this timestep
    293296
     
    298301    memset((char*) ymom_explicit_update, 0, number_of_elements * sizeof (double));
    299302
    300 
    301303    // Compute minimum bed edge value on each triangle
    302304    for (k = 0; k < number_of_elements; k++){
    303305        max_bed_edgevalue[k] = max(bed_edge_values[3*k],
    304306                                   max(bed_edge_values[3*k+1], bed_edge_values[3*k+2]));
    305         //max_bed_edgevalue[k]= 0.5*(max_bed_edgevalue[j]+bed_centroid_values[k]);
    306         //min_bed_edgevalue[k] = min(bed_edge_values[3*k],
    307         //                           min(bed_edge_values[3*k+1], bed_edge_values[3*k+2]));
    308    
    309307    }
    310308
     
    315313        for (i = 0; i < 3; i++) {
    316314            ki = k * 3 + i; // Linear index to edge i of triangle k
     315            ki2 = 2 * ki; //k*6 + i*2
     316            ki3 = 3*ki;
    317317
    318318            if (already_computed_flux[ki] == call) {
     
    328328            hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.0);
    329329
    330             //if(ql[0]<=zl){
    331             //    ql[1]=0.;
    332             //    ql[2]=0.;
    333             //}
    334330            // Get right hand side values either from neighbouring triangle
    335331            // or from boundary array (Quantities at neighbour on nearest face).
     
    350346                m = neighbour_edges[ki];
    351347                nm = n * 3 + m; // Linear index (triangle n, edge m)
     348                nm3 = nm*3;
    352349
    353350                qr[0] = stage_edge_values[nm];
     
    357354            }
    358355           
    359 
    360356            if (fabs(zl-zr)>1.0e-10) {
    361357                report_python_error(AT,"Discontinuous Elevation");
    362358                return 0.0;
    363359            }
    364            
     360           
     361            // GD HACK -- although I think this is a common technique
    365362            //If one centroid is dry, then extrapolate its edge values from the neighbouring centroid,
    366363            // unless the local centroid value is smaller
    367364            if(n>=0){
    368                 //if(hc==0.0){
    369365                if((hc<=H0)&&(hc_n>H0)){
    370366                    ql[0]=max(min(qr[0],stage_centroid_values[k]),zl);
    371                     //ql[0]=max(min(qr[0],0.5*(stage_centroid_values[k]+stage_centroid_values[n])),zl);
    372                     //ql[0]=max(min(qr[0],stage_centroid_values[k]),zl);
    373367                }
    374                 //if(hc_n==0.0){
    375368                if((hc_n<=H0)&&(hc>H0)){
    376369                    qr[0]=max(min(ql[0],stage_centroid_values[n]),zr);
    377                     //qr[0]=max(min(ql[0],0.5*(stage_centroid_values[n]+stage_centroid_values[k])),zr);
    378                     //qr[0]=ql[0];
    379370                }
    380 
    381                 //if((hc_n<=H0)&&(hc<=H0)){
    382                 //    ql[0] = zl;
    383                 //    qr[0] = zr;
    384                 //}
    385371
    386372            }else{
    387373                // Treat the boundary case
    388                 //if((hc==0.0)){
    389                 //    ql[0]=max(min(qr[0],stage_centroid_values[k]),zl);
    390                 //    //ql[0]=max(min(qr[0],ql[0]),zl);
    391                 //}
     374                // ??
    392375            }
    393             //if(k==229 | n==229){
    394             //    printf(" ---------------\n ");
    395             //    printf("k, ql, qr, zl, zr==%d, %20.20e, %20.20e, %20.20e, %20.20e \n", k, ql[0], qr[0], zl, zr);
    396 
    397             //}
    398            
    399             // Outward pointing normal vector (domain.normals[k, 2*i:2*i+2])
    400             ki2 = 2 * ki; //k*6 + i*2
    401376
    402377            // Edge flux computation (triangle k, edge i)
     
    406381                    edgeflux, &max_speed, &pressure_flux);
    407382
    408             // Prevent outflow from 'seriously' dry cells
    409             // Idea: The cell will not go dry if:
    410             // mass_flux = edgeflux[0]*(dt*edgelength) <= (1/3)Area_triangle*hc
    411             if((stage_centroid_values[k]<=max_bed_edgevalue[k])|
    412                (ql[0]<=zl)){
    413                 if(edgeflux[0]>0.0){
    414                     tmp=min((1.0/3.0)*areas[k]*hc/(edgelengths[ki]*max(timestep,epsilon)), 1.0); // 28/7 -- Right answer for channel flow problem.
    415                     tmp = min(min(edgeflux[0], tmp)/edgeflux[0], 1.0);
    416                     if((tmp<0.)|tmp>1.0){
    417                         printf("Invalid tmp value\n");
    418                     }
    419                     edgeflux[0]*=tmp;
    420                     edgeflux[1]*=tmp;
    421                     edgeflux[2]*=tmp;
    422                 }
    423             }
    424             if(n>=0){
    425                 if((stage_centroid_values[n]<=max_bed_edgevalue[n])|
    426                    (qr[0]<=zr)){
    427                     if(edgeflux[0]<0.0){
    428                         tmp=min((1.0/3.0)*areas[n]*hc_n/(edgelengths[ki]*max(timestep,epsilon)), 1.0); // 28/7 -- Right answer for channel flow problem.
    429                         tmp = min( max(edgeflux[0], -tmp)/edgeflux[0], 1.0);
    430                         if((tmp<0.)|tmp>1.0){
    431                             printf("Invalid tmp value\n");
    432                         }
    433                         edgeflux[0]*=tmp;
    434                         edgeflux[1]*=tmp;
    435                         edgeflux[2]*=tmp;
    436                     }
    437                 }
    438             }
    439383           
    440             //if(k==229|n==229){
    441             //    printf("++edgeflux=, %20.20e, %20.20e, %20.20e \n", edgeflux[0],edgeflux[1], edgeflux[2]);
    442             //}
    443 
    444384            // Multiply edgeflux by edgelength
    445385            length = edgelengths[ki];
     
    448388            edgeflux[2] *= length;
    449389
     390            edgeflux_store[ki3 + 0 ] = -edgeflux[0];
     391            edgeflux_store[ki3 + 1 ] = -edgeflux[1];
     392            edgeflux_store[ki3 + 2 ] = -edgeflux[2];
    450393
    451394            // Update triangle k with flux from edge i
    452             stage_explicit_update[k] -= edgeflux[0];
    453             xmom_explicit_update[k] -= edgeflux[1];
    454             ymom_explicit_update[k] -= edgeflux[2];
    455 
    456             // Compute bed slope term
    457             //if(hc>-9999.0){
    458                 //Bedslope approx 1:
    459             if(hc>H0){
    460                 // Add the pressure gradient flux term back in
    461                 // Do this to avoid the above mass-conservative limiting
    462                 // Because limiting the pressure term would destroy balancing with the bedslope term
    463                 //edgeflux[1]+=normals[ki2]*pressure_flux;
    464                 //edgeflux[2]+=normals[ki2+1]*pressure_flux;
    465 
    466                 //bedslope_work = -0.5*g*max(stage_centroid_values[k]-zl,0.)*(stage_centroid_values[k]-zl)*length;
    467                 bedslope_work = length*g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux*length;
    468                 xmom_explicit_update[k] -= normals[ki2]*bedslope_work;
    469                 ymom_explicit_update[k] -= normals[ki2+1]*bedslope_work;
    470             }else{
    471                 //bedslope_work = 0.;//-pressure_flux*length ;//g*length*( 0.*(ql[0])-0.5*max(ql[0]-zl,0.)*(ql[0]-zl) );
    472                 xmom_explicit_update[k] *= 0.;
    473                 ymom_explicit_update[k] *= 0.;
    474             }
     395
     396            // bedslope_work contains all gravity related terms -- weighting of
     397            // conservative and non-conservative versions.
     398            bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux);
     399            //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope
     400            pressuregrad_store[ki] = bedslope_work;
     401
    475402           
    476             //if(k==229|n==229){
    477             //    printf("--k-pres, xmom, bedwrk, %20.20e, %20.20e, %20.20e \n", pressure_flux*length, xmom_explicit_update[k], bedslope_work);
    478             ////    printf(" Edgesum: %20.20e\n", edgelengths[3*k]*normals[6*k]*g*hc*stage_edge_values[3*k]
    479             ////                   + edgelengths[3*k+1]*normals[6*k+2]*g*hc*stage_edge_values[3*k+1]
    480             ////                   + edgelengths[3*k+2]*normals[6*k+4]*g*hc*stage_edge_values[3*k+2]);
    481             //}
    482                 //
    483                 // Bedslope approx 2
    484                 //stage_edge_lim = ql[0]; // Limit this to be between a constant stage and constant depth extrapolation
    485                 //if(stage_edge_lim > max(stage_centroid_values[k], zl +hc)){
    486                 //    stage_edge_lim = max(stage_centroid_values[k], zl+hc);
    487                 //}
    488                 //if(stage_edge_lim < min(stage_centroid_values[k], zl +hc)){
    489                 //    stage_edge_lim = min(stage_centroid_values[k], zl+hc);
    490                 //}
    491                 //bedslope_work = g*hc*(stage_edge_lim)*length-0.5*g*max(stage_edge_lim-zl,0.)*(stage_edge_lim-zl)*length;
    492 
    493                 // Bedslope approx 3
    494                 //bedslope_work = -0.5*g*max(stage_centroid_values[k]-zl,0.)*(stage_centroid_values[k]-zl)*length;
    495                 //
    496             //}else{
    497             //   // Treat nearly dry cells
    498             //   bedslope_work =-0.5*g*max(ql[0]-zl,0.)*(ql[0]-zl)*length; //
    499             //   //
    500             //   //bedslope_work = -pressure_flux*length;
    501             //   xmom_explicit_update[k] -= normals[ki2]*bedslope_work;
    502             //   ymom_explicit_update[k] -= normals[ki2+1]*bedslope_work;
    503             //   //xmom_explicit_update[k] = 0.0;
    504             //   //ymom_explicit_update[k] = 0.0;
    505 
    506             ////}
    507 
    508403            already_computed_flux[ki] = call; // #k Done
    509404
     
    511406            // Update neighbour n with same flux but reversed sign
    512407            if (n >= 0) {
    513                 stage_explicit_update[n] += edgeflux[0];
    514                 xmom_explicit_update[n] += edgeflux[1];
    515                 ymom_explicit_update[n] += edgeflux[2];
    516                 //Add bed slope term here
    517                 //if(hc_n>-9999.0){
    518                 //if(stage_centroid_values[n] > max_bed_edgevalue[n]){
    519                     // Bedslope approx 1:
    520                 if(hc_n>H0){
    521                     //bedslope_work = -0.5*g*max(stage_centroid_values[n]-zr,0.)*(stage_centroid_values[n]-zr)*length;
    522                     bedslope_work = length*g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux*length;
    523                     xmom_explicit_update[n] += normals[ki2]*bedslope_work;
    524                     ymom_explicit_update[n] += normals[ki2+1]*bedslope_work;
    525                 }else{
    526                     //bedslope_work = 0.;//-pressure_flux*length;//g*length*(0.*(qr[0])-0.5*max(qr[0]-zr,0.)*(qr[0]-zr));
    527                     xmom_explicit_update[n] *= 0.;
    528                     ymom_explicit_update[n] *= 0.;
    529                 }
    530                 //if(k==229| n==229){
    531                 //    printf("-n-pres,xmom,bedwrk, %20.20e, %20.20e, %20.20e \n", pressure_flux*length, xmom_explicit_update[n], bedslope_work);
    532                 //}
    533 
    534                     //
    535                     // Bedslope approx 2:
    536                     //stage_edge_lim = qr[0];
    537                     //if(stage_edge_lim > max(stage_centroid_values[n], zr +hc_n)){
    538                     //    stage_edge_lim = max(stage_centroid_values[n], zr+hc_n);
    539                     //}
    540                     //if(stage_edge_lim < min(stage_centroid_values[n], zr +hc_n)){
    541                     //    stage_edge_lim = min(stage_centroid_values[n], zr+hc_n);
    542                     //}
    543                     //bedslope_work = g*hc_n*(stage_edge_lim)*length-0.5*g*max(stage_edge_lim-zr,0.)*(stage_edge_lim-zr)*length;
    544                     //
    545                     // Bedslope approx 3
    546                     //bedslope_work = -0.5*g*max(stage_centroid_values[n]-zr,0.)*(stage_centroid_values[n]-zr)*length;
    547                     //
    548                 //}else{
    549                 //    // Treat nearly dry cells
    550                 //    bedslope_work = -0.5*g*max(qr[0]-zr,0.)*(qr[0]-zr)*length; //-pressure_flux*length; //-0.5*g*max(qr[0]-zr,0.)*(qr[0]-zr)*length;
    551                 //    //bedslope_work = -pressure_flux*length;
    552                 //    xmom_explicit_update[n] += normals[ki2]*bedslope_work;
    553                 //    ymom_explicit_update[n] += normals[ki2+1]*bedslope_work;
    554 
    555                 //    //xmom_explicit_update[n] = 0.0;
    556                 //    //ymom_explicit_update[n] = 0.0;
    557                 //}
     408
     409                edgeflux_store[nm3 + 0 ] = edgeflux[0];
     410                edgeflux_store[nm3 + 1 ] = edgeflux[1];
     411                edgeflux_store[nm3 + 2 ] = edgeflux[2];
     412
     413                bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux);
     414                //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; 
     415                pressuregrad_store[nm] = bedslope_work;
     416
    558417
    559418                already_computed_flux[nm] = call; // #n Done
     
    561420
    562421            // Update timestep based on edge i and possibly neighbour n
    563             if (tri_full_flag[k] == 1) {
     422            // GD HACK:
     423            // FIXME: Presently this 'hacked' to only update the timestep on
     424            // every 2nd call.  This works for rk2 timestepping only, and is
     425            // needed for correct wetting and drying treatment
     426            if ((tri_full_flag[k] == 1) && (call%2==0)) {
    564427                if (max_speed > epsilon) {
    565428                    // Apply CFL condition for triangles joining this edge (triangle k and triangle n)
     
    573436                    }
    574437
    575                     // Ted Rigby's suggested less conservative version
    576                     //if(n>=0){
    577                     //  timestep = min(timestep, (radii[k]+radii[n])/max_speed);
    578                     //}else{
    579                     //  timestep = min(timestep, radii[k]/max_speed);
    580                     //}
    581438                }
    582439            }
     
    584441        } // End edge i (and neighbour n)
    585442
    586         //if(k==2082){
    587         //    printf("xmom_explicit: %20.20e \n", xmom_explicit_update[k]);
    588         //}
     443        // Keep track of maximal speeds
     444        max_speed_array[k] = max_speed;
     445
     446    } // End triangle k
     447 
     448    // GD HACK
     449    // Limit edgefluxes, for mass conservation near wet/dry cells
     450    for(k=0; k< number_of_elements; k++){
     451        // Only check cells that are **near dry**
     452        // Found I could get problems by checking all cells
     453        if(stage_centroid_values[k] <= max_bed_edgevalue[k] + H0){
     454            hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.);
     455            // Loop over every edge
     456            for(i = 0; i<3; i++){
     457                if(i==0){
     458                    // Add up the outgoing flux through the cell
     459                    outgoing_flux_edges=0.0;
     460                    for(useint=0; useint<3; useint++){
     461                        if(edgeflux_store[3*(3*k+useint)]< 0.){
     462                            //outgoing_flux_edges+=1.0;
     463                            outgoing_flux_edges+=(edgeflux_store[3*(3*k+useint)]*timestep);
     464                        }
     465                    }
     466                }
     467
     468                ki=3*k+i;   
     469                ki2=ki*2;
     470                ki3 = ki*3;
     471               
     472                // Prevent outflow from 'seriously' dry cells
     473                // Idea: The cell will not go dry if:
     474                // total_outgoing_flux <= cell volume = Area_triangle*hc
     475                if((edgeflux_store[ki3]< 0.0) && (outgoing_flux_edges<0.)){
     476                   
     477                    // This bound could be improved (e.g. we could actually sum
     478                    // the + and - fluxes and check if they are too large).
     479                    // However, the advantage is that we don't have to worry
     480                    // about subsequent changes to the + edgeflux caused by
     481                    // constraints associated with neighbouring triangles.
     482                    tmp = (areas[k]*hc)/(fabs(outgoing_flux_edges)+1.0e-10) ;
     483                    if(tmp< 1.0){
     484                        // Idea: we should be close to conserving mass if this holds,
     485                        // --- consider CFL condition.
     486                        tmp2 = min(hc/((stage_edge_values[ki]-bed_edge_values[ki])+1.0e-10), 1.0);
     487                        //tmp2=(xmom_centroid_values[k]*xmom_centroid_values[k]+ymom_centroid_values[k]*ymom_centroid_values[k]);
     488                        //tmp2/=(xmom_edge_values[ki]*xmom_edge_values[ki]+ ymom_edge_values[ki]*ymom_edge_values[ki]+1.0e-10);
     489                        //tmp2 = sqrt(tmp2);
     490                        //tmp2 = min(tmp2, 1.0);
     491                        edgeflux_store[ki3+0]*=tmp2;
     492                        edgeflux_store[ki3+1]*=tmp2;
     493                        edgeflux_store[ki3+2]*=tmp2;
     494
     495                        // Compute neighbour edge index
     496                        n = neighbours[ki];
     497                        if(n>=0){
     498                            nm = 3*n + neighbour_edges[ki];
     499                            nm3 = nm*3;
     500                            edgeflux_store[nm3+0]*=tmp2;
     501                            edgeflux_store[nm3+1]*=tmp2;
     502                            edgeflux_store[nm3+2]*=tmp2;
     503                        }
     504                    }
     505                }
     506            }
     507        }
     508     }
     509
     510
     511    // Now add up stage, xmom, ymom explicit updates
     512    for(k=0; k<number_of_elements; k++){
     513        hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.);
     514        stage_explicit_update[k]=0.;
     515        xmom_explicit_update[k]=0.;
     516        ymom_explicit_update[k]=0.;
     517
     518        for(i=0;i<3;i++){
     519            ki=3*k+i;   
     520            ki2=ki*2;
     521            ki3 = ki*3;
     522
     523            // GD HACK
     524            // Option to limit advective fluxes
     525            if(hc > H0){
     526                stage_explicit_update[k] += edgeflux_store[ki3+0];
     527                // Cut these terms for shallow flows, and protect stationary states from round-off error
     528                xmom_explicit_update[k] += edgeflux_store[ki3+1];
     529                ymom_explicit_update[k] += edgeflux_store[ki3+2];
     530            }else{
     531                stage_explicit_update[k] += edgeflux_store[ki3+0];
     532            }
     533
     534
     535            // GD HACK
     536            // Compute bed slope term
     537            if(hc>H0){
     538                xmom_explicit_update[k] -= normals[ki2]*pressuregrad_store[ki];
     539                ymom_explicit_update[k] -= normals[ki2+1]*pressuregrad_store[ki];
     540            }else{
     541                xmom_explicit_update[k] *= 0.;
     542                ymom_explicit_update[k] *= 0.;
     543            }
     544
     545        } // end edge i
    589546
    590547        // Normalise triangle k by area and store for when all conserved
     
    594551        xmom_explicit_update[k] *= inv_area;
    595552        ymom_explicit_update[k] *= inv_area;
    596 
    597         //if(k==2082){
    598         //    printf(" inv_area: %20.20e \n", inv_area);
    599         //    printf("xmom_explicit: %20.20e \n", xmom_explicit_update[k]);
    600         //}
    601         // Keep track of maximal speeds
    602         max_speed_array[k] = max_speed;
    603 
    604     } // End triangle k
    605  
    606      
    607     //bedtop=0.;
     553    }  // end cell k
     554
     555    // Look for 'dry' edges, and set momentum (& component of momentum_update)
     556    // in that direction to zero. If we don't do this, then it is possible for
     557    // the bedslope term normal to that edge to be nonzero, and for momentum to
     558    // keep 'building' up in the cell without being able to flow out.
     559    //
    608560    //for(k=0; k<number_of_elements; k++){
    609     //      bedtop = bedtop + stage_explicit_update[k]*areas[k];
     561    //    // Ignore "Dry" centroid cells, which will automatically have their
     562    //    // momentum set to zero (in _protect)
     563    //    if(stage_centroid_values[k] - bed_centroid_values[k] > H0){
     564    //        for(i=0;i<3;i++){
     565    //            ki=3*k+i;
     566    //            if(stage_edge_values[ki] - bed_edge_values[ki] <=0.){
     567    //              // Compute magnitude of momentum_update in direction normal to edge
     568    //              tmp =  xmom_explicit_update[k]*normals[2*ki] + ymom_explicit_update[k]*normals[2*ki+1];
     569    //              if(tmp > 0.){
     570    //                  // Set component of momentum_update normal to edge to zero
     571    //                  // [equivalently, subtract component of momentum_update normal to edge]
     572    //                  xmom_explicit_update[k] -= tmp*normals[2*ki];
     573    //                  ymom_explicit_update[k] -= tmp*normals[2*ki+1]; 
     574    //                 
     575    //              }
     576    //             
     577    //              // Compute magnitude of momentum in direction normal to edge
     578    //              //tmp =  xmom_centroid_values[k]*normals[2*ki] + ymom_centroid_values[k]*normals[2*ki+1];
     579    //              //if(tmp > 0.){
     580    //              //    // Set component of momentum normal to edge to zero
     581    //              //    // [equivalently, subtract component of momentum normal to edge]
     582    //              //    xmom_centroid_values[k] -= tmp*normals[2*ki];
     583    //              //    ymom_centroid_values[k] -= tmp*normals[2*ki+1]; 
     584    //              //   
     585    //              //}
     586    //           }
     587    //        }
     588    //    }
    610589    //}
    611     //printf("Bedtop = %20.20e \n ", bedtop);
    612     //    for(i=0;i<number_of_elements;i++){
    613     //        bedtop=max(bedtop, fabs(ymom_edge_values[3*k+i]));
    614     //    }
     590       
    615591    //   
    616592    //   
     
    634610    free(max_bed_edgevalue);
    635611    //free(min_bed_edgevalue);
     612    free(edgeflux_store);
     613    free(pressuregrad_store);
    636614
    637615    return timestep;
     
    668646      hc = wc[k] - zc[k];
    669647      // Definine the maximum bed edge value on triangle k.
    670       bmax = 0.5*max((zv[3*k]+zv[3*k+1]),max((zv[3*k+1]+zv[3*k+2]),(zv[3*k+2]+zv[3*k])));
    671 
    672       if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) {
    673         // Set momentum to zero and ensure h is non negative
     648      //bmax = 0.5*max((zv[3*k]+zv[3*k+1]),max((zv[3*k+1]+zv[3*k+2]),(zv[3*k+2]+zv[3*k])));
     649
     650      //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) {
     651      //  xmomc[k]*=0.1;
     652      //  ymomc[k]*=0.1;
     653      //}
     654
     655
     656      //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) {
     657      if (hc < minimum_allowed_height) {
     658            // Set momentum to zero and ensure h is non negative
    674659            xmomc[k] = 0.0;
    675660            ymomc[k] = 0.0;
     
    689674
    690675                 wc[k] = max(wc[k], bmin);
    691                  printf(" mass_add, %f, %f, %f,%d\n", xc[k], yc[k], wc[k], k) ;
     676                 printf(" mass_add, %f, %f, %f,%f,%f,%d\n", xc[k], yc[k], wc[k],zc[k],wc[k]-zc[k], k) ;
    692677             
    693678
     
    804789  double dx1, dx2, dy1, dy2, dxv0, dxv1, dxv2, dyv0, dyv1, dyv2, dq0, dq1, dq2, area2, inv_area2;
    805790  double dqv[3], qmin, qmax, hmin, hmax, bedmax, stagemin;
    806   double hc, h0, h1, h2, beta_tmp, hfactor, xtmp, ytmp, weight;
     791  double hc, h0, h1, h2, beta_tmp, hfactor, xtmp, ytmp, weight, tmp;
    807792  double dk, dv0, dv1, dv2, de[3], demin, dcmax, r0scale, vect_norm, l1, l2;
    808793 
     
    844829      }
    845830
     831  //
    846832  // Compute some useful statistics on wetness/dryness
     833  //
    847834  for(k=0; k<number_of_elements;k++){
    848       count_wet_neighbours[k]=0;
    849835      cell_wetness_scale[k] = 0.;
    850836      // Check if cell k is wet
    851837      if(stage_centroid_values[k] > elevation_centroid_values[k] + minimum_allowed_height+epsilon){
     838      //if(stage_centroid_values[k] > max_elevation_edgevalue[k] + minimum_allowed_height+epsilon){
    852839          cell_wetness_scale[k] = 1.; 
    853840      }
     841  }
     842  //
     843  for(k=0; k<number_of_elements;k++){
    854844      // Count the wet neighbours
     845      count_wet_neighbours[k]=0;
    855846      for (i=0; i<3; i++){
    856847        ktmp = surrogate_neighbours[3*k+i];             
    857         if(stage_centroid_values[ktmp] > max_elevation_edgevalue[ktmp]){
     848        if( (ktmp >= 0) && cell_wetness_scale[ktmp]>0.){
     849            count_wet_neighbours[k]+=1;
     850        }else if(ktmp<=0){
     851            // Boundary condition -- FIXME: assume wet
    858852            count_wet_neighbours[k]+=1;
    859853        }
     854         
    860855       
    861856      }
     
    865860  // First treat all 'fully wet' cells, then treat 'partially dry' cells
    866861  for(k_wetdry=0; k_wetdry<2; k_wetdry++){
    867       //if(((stage_centroid_values[k] > max_elevation_edgevalue[k]))==k_wetdry){
    868       //if(((stage_centroid_values[k] < elevation_centroid_values[k]+minimum_allowed_height))==k_wetdry){
    869       // For partially wet cells, we now know that the edges of neighbouring
    870       // fully wet cells have been defined
    871862
    872863      // Begin extrapolation routine
     
    935926          //==============================================
    936927          // Number of boundaries <= 1
     928          // 'Typical case'
    937929          //==============================================   
    938930       
     
    953945          //if(stage_centroid_values[k2]<=max_elevation_edgevalue[k2]+epsilon){
    954946          //if(stage_centroid_values[k2]<=elevation_centroid_values[k2]+minimum_allowed_height+epsilon){
    955           if(cell_wetness_scale[k2]==0.0){
     947          if(k2<0 || cell_wetness_scale[k2]==0.0){
    956948              k2 = k ;
    957949          }
    958950          //if(stage_centroid_values[k0]<=max_elevation_edgevalue[k0]+epsilon){
    959951          //if(stage_centroid_values[k0]<=elevation_centroid_values[k0]+minimum_allowed_height+epsilon){
    960           if(cell_wetness_scale[k0]==0.0){
     952          if(k0 < 0 || cell_wetness_scale[k0]==0.0){
    961953              k0 = k ;
    962954          }
    963955          //if(stage_centroid_values[k1]<=max_elevation_edgevalue[k1]+epsilon){
    964956          //if(stage_centroid_values[k1]<=elevation_centroid_values[k1]+minimum_allowed_height+epsilon){
    965           if(cell_wetness_scale[k1]==0.0){
     957          if(k1 < 0 || cell_wetness_scale[k1]==0.0){
    966958              k1 = k ;
    967959          }
     
    1003995          area2 = dy2*dx1 - dy1*dx2;
    1004996           
    1005           // Treat triangles with zero or 1 wet neighbours.
    1006           if ((area2 <= 0)|(cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0))
     997          // Treat triangles with zero or 1 wet neighbours (area2 <=0.)
     998          if ((area2 <= 0.))// || (cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0))
    1007999          {
    10081000            //if((cell_wetness_scale[k]==1.0) | (k==k0)&&(k==k1)&&(k==k2)){
    1009               stage_edge_values[k3]   = stage_centroid_values[k];
    1010               stage_edge_values[k3+1] = stage_centroid_values[k];
    1011               stage_edge_values[k3+2] = stage_centroid_values[k];
     1001            //if(count_wet_neighbours[k] > 5.){
     1002                stage_edge_values[k3]   = stage_centroid_values[k];
     1003                stage_edge_values[k3+1] = stage_centroid_values[k];
     1004                stage_edge_values[k3+2] = stage_centroid_values[k];
     1005            //}else{
    10121006            //}else{
    10131007              // Dry cell with a single 'wet' neighbour
     
    10281022              //if( (k==k0) & (k==k1) & (k==k2)){
    10291023              //    // Isolated wet cell  -- use constant depth extrapolation for stage
    1030               //    //stage_edge_values[k3]   = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3];
    1031               //    //stage_edge_values[k3+1] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+1];
    1032               //    //stage_edge_values[k3+2] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+2];
    1033 
     1024              //    stage_edge_values[k3]   = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3];
     1025              //    stage_edge_values[k3+1] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+1];
     1026              //    stage_edge_values[k3+2] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+2];
     1027              //}
    10341028              //    // Isolated wet cell -- constant depth extrapolation, but don't let water flow uphill
    10351029              //    //stage_edge_values[k3]   = min(stage_centroid_values[k], stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3]);
     
    11221116         
    11231117          // Calculate heights of neighbouring cells
    1124           hc = stage_centroid_values[k]  - elevation_centroid_values[k];
    1125           h0 = stage_centroid_values[k0] - elevation_centroid_values[k0];
    1126           h1 = stage_centroid_values[k1] - elevation_centroid_values[k1];
    1127           h2 = stage_centroid_values[k2] - elevation_centroid_values[k2];
    1128           hmin = min(min(h0, min(h1, h2)), hc);
    1129 
    1130           hfactor = 0.0;
    1131           //if (hmin > 0.001)
    1132           if (hmin > 0.)
    1133           //if (hc>0.0)
    1134           {
     1118          //hc = stage_centroid_values[k]  - elevation_centroid_values[k];
     1119          //h0 = stage_centroid_values[k0] - elevation_centroid_values[k0];
     1120          //h1 = stage_centroid_values[k1] - elevation_centroid_values[k1];
     1121          //h2 = stage_centroid_values[k2] - elevation_centroid_values[k2];
     1122          //hmin = min(min(h0, min(h1, h2)), hc);
     1123          //// GD FIXME: No longer needed?
     1124          //hfactor = 0.0;
     1125          ////if (hmin > 0.001)
     1126          //if (hmin > 0.)
     1127          ////if (hc>0.0)
     1128          //{
    11351129            hfactor = 1.0 ;//hmin/(hmin + 0.004);
    11361130            //hfactor=hmin/(hmin + 0.004);
    1137           }
     1131          //}
    11381132         
    11391133          //-----------------------------------
     
    11561150          b = dx1*dq2 - dx2*dq1;
    11571151          b *= inv_area2;
    1158          
     1152          // d(stage)/dx = - u*sqrt(u**2 + v**2)*n**2/depth
     1153          //hc=max(stage_centroid_values[k] - elevation_centroid_values[k],0.0);
     1154          //tmp = sqrt(xmom_centroid_values[k]*xmom_centroid_values[k] +
     1155          //           ymom_centroid_values[k]*ymom_centroid_values[k])*0.03*0.03;
     1156          //tmp /=max(hc*hc*hc, 1.0e-09);
     1157          //a = -xmom_centroid_values[k]*tmp;
     1158          //b = -ymom_centroid_values[k]*tmp;
    11591159          // Calculate provisional jumps in stage from the centroid
    11601160          // of triangle k to its vertices, to be limited
     
    11671167          // from the centroid to the min and max
    11681168          find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax);
    1169          
     1169       
    11701170          beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor;
    11711171       
     
    11731173          // Limit the gradient
    11741174          // This is more complex for stage than other quantities
    1175           if((count_wet_neighbours[k]>0)){//&&(k_wetdry==0)){
     1175          //if((count_wet_neighbours[k]>0)&&(cell_wetness_scale[k]=1.0)){//&&(k_wetdry==0)){
     1176          //if(stage_centroid_values[k] > max_elevation_edgevalue[k]){
    11761177              limit_gradient(dqv, qmin, qmax, beta_tmp);
    11771178              stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0];
    11781179              stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1];
    11791180              stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2];
    1180           }else{
    1181           ////if(count_wet_neighbours[k]==0){
    1182           //    //weight=max(cell_wetness_scale[k] - (stage_centroid_values[k]-elevation_centroid_values[k]), 0.);
    1183           //    //weight/=(max_elevation_edgevalue[k] - elevation_centroid_values[k]);
    1184           //    //weight=min(weight, 1.0);
    1185           //    //weight==0;
    1186           //    //weight=0.;
    1187           //    // 'Shallow flow on steep slope'
    1188           //    //limit_gradient(dqv, qmin, qmax, beta_tmp);
    1189               stage_edge_values[k3+0] =stage_centroid_values[k] + dqv[0];
    1190               stage_edge_values[k3+1] =stage_centroid_values[k] + dqv[1];
    1191               stage_edge_values[k3+2] =stage_centroid_values[k] + dqv[2];
    1192 
    1193           //    // There exists a neighbouring bed cell with elevation > minimum
    1194           //    // neighbouring stage value
    1195 
    1196           //    // We have to be careful in this situation. Limiting the stage gradient can
    1197           //    // cause problems for shallow flows down steep slopes (rainfall-runoff type problems)
    1198           //    // Previously 'balance_deep_and_shallow' was used to deal with this issue
    1199           //    //for(i=0; i<3; i++){
    1200           //    //    stage_edge_values[k3+i] = weight*stage_edge_values[k3+i] +
    1201           //    //                             (1.0-weight)*(stage_centroid_values[k] -elevation_centroid_values[k]
    1202           //    //                                           +elevation_edge_values[k3+i]);
    1203           //    //}
    1204           }
     1181          // IDEA: extrapolate assuming slope is that of steady flow??
     1182          // GD HACK - FIXME
     1183          // Note that 'near-dry' cells which don't exchange mass with
     1184          // neighbouring cells have to revert to having a constant stage
     1185          // extrapolation, or else they will have a residual bed slope term.
     1186          // This helps! -- But probably makes rainfall-runoff problems worse.
     1187          //ii = (stage_edge_values[k3+0] > elevation_edge_values[k3+0])+
     1188          //     (stage_edge_values[k3+1] > elevation_edge_values[k3+1])+
     1189          //     (stage_edge_values[k3+2] > elevation_edge_values[k3+2]);
     1190          //if(ii<2){
     1191          //    stage_edge_values[k3+0] = stage_centroid_values[k] ;
     1192          //    stage_edge_values[k3+1] = stage_centroid_values[k] ;
     1193          //    stage_edge_values[k3+2] = stage_centroid_values[k] ;
     1194          //}
     1195          //}else{
     1196          // d(stage)/dx = - u*sqrt(u**2 + v**2)*n**2/depth
     1197          //    hc=max(stage_centroid_values[k] - elevation_centroid_values[k],0.0);
     1198          //    tmp = sqrt(xmom_centroid_values[k]*xmom_centroid_values[k] +
     1199          //               ymom_centroid_values[k]*ymom_centroid_values[k])*0.03*0.03;
     1200          //    tmp /=max(hc*hc*hc, 1.0e-09);
     1201          //    a = -xmom_centroid_values[k]*tmp;
     1202          //    b = -ymom_centroid_values[k]*tmp;
     1203          //    dqv[0] = a*dxv0 + b*dyv0;
     1204          //    dqv[1] = a*dxv1 + b*dyv1;
     1205          //    dqv[2] = a*dxv2 + b*dyv2;
     1206          //////if(count_wet_neighbours[k]==0){
     1207          ////    //weight=max(cell_wetness_scale[k] - (stage_centroid_values[k]-elevation_centroid_values[k]), 0.);
     1208          ////    //weight/=(max_elevation_edgevalue[k] - elevation_centroid_values[k]);
     1209          ////    //weight=min(weight, 1.0);
     1210          ////    //weight==0;
     1211          //      weight=0.;
     1212          ////    // 'Shallow flow on steep slope'
     1213              //limit_gradient(dqv, qmin, qmax, beta_tmp);
     1214              //stage_edge_values[k3+0] =stage_centroid_values[k] + dqv[0];
     1215              //stage_edge_values[k3+1] =stage_centroid_values[k] + dqv[1];
     1216              //stage_edge_values[k3+2] =stage_centroid_values[k] + dqv[2];
     1217          //
     1218          ////    // There exists a neighbouring bed cell with elevation > minimum
     1219          ////    // neighbouring stage value
     1220
     1221          ////    // We have to be careful in this situation. Limiting the stage gradient can
     1222          ////    // cause problems for shallow flows down steep slopes (rainfall-runoff type problems)
     1223          ////    // Previously 'balance_deep_and_shallow' was used to deal with this issue
     1224          //    for(i=0; i<3; i++){
     1225          //        stage_edge_values[k3+i] = weight*stage_edge_values[k3+i] +
     1226          //                                 (1.0-weight)*(stage_centroid_values[k] -elevation_centroid_values[k]
     1227          //                                               +elevation_edge_values[k3+i]);
     1228          //    }
     1229          //}
    12051230           
    12061231          //-----------------------------------
     
    12401265          //if((k!=k0)&(k!=k1)&(k!=k2))
    12411266          //if(stagemin>=bedmax){
    1242           if((count_wet_neighbours[k]>0) &&
    1243             (cell_wetness_scale[k]==1.0)){
    1244             //(stage_centroid_values[k]>(minimum_allowed_height+elevation_centroid_values[k]))){
     1267          if((count_wet_neighbours[k]>0)){ // &&
     1268            // (cell_wetness_scale[k]==1.0)){
     1269          //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){
    12451270            limit_gradient(dqv, qmin, qmax, beta_tmp);
    12461271          }else{
     
    12931318          // Limit the gradient
    12941319          //if(stagemin>=bedmax){
    1295           if((count_wet_neighbours[k]>0)&&
    1296              (cell_wetness_scale[k]==1.0)){
     1320          if((count_wet_neighbours[k]>0)){//&&
     1321             //(cell_wetness_scale[k]==1.0)){
    12971322            //(stage_centroid_values[k]>(minimum_allowed_height+elevation_centroid_values[k]))){
     1323          //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){
    12981324            limit_gradient(dqv, qmin, qmax, beta_tmp);
    12991325          }else{
     
    16351661    *max_speed_array, //Keeps track of max speeds for each triangle
    16361662    *stage_centroid_values,
     1663    *xmom_centroid_values,
     1664    *ymom_centroid_values,
    16371665    *bed_centroid_values,
    16381666    *bed_vertex_values;
     
    16421670   
    16431671  // Convert Python arguments to C
    1644   if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOiOOO",
     1672  if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOiOOOOO",
    16451673            &timestep,
    16461674            &epsilon,
     
    16671695            &optimise_dry_cells,
    16681696            &stage_centroid_values,
     1697            &xmom_centroid_values,
     1698            &ymom_centroid_values,
    16691699            &bed_centroid_values,
    16701700            &bed_vertex_values)) {
     
    16951725  CHECK_C_CONTIG(max_speed_array);
    16961726  CHECK_C_CONTIG(stage_centroid_values);
     1727  CHECK_C_CONTIG(xmom_centroid_values);
     1728  CHECK_C_CONTIG(ymom_centroid_values);
    16971729  CHECK_C_CONTIG(bed_centroid_values);
    16981730  CHECK_C_CONTIG(bed_vertex_values);
     
    17291761                     optimise_dry_cells,
    17301762                     (double*) stage_centroid_values -> data,
     1763                     (double*) xmom_centroid_values -> data,
     1764                     (double*) ymom_centroid_values -> data,
    17311765                     (double*) bed_centroid_values -> data,
    17321766                     (double*) bed_vertex_values -> data);
  • trunk/anuga_work/development/gareth/tests/channel_floodplain/channel_floodplain1.py

    r8547 r8751  
    1414#from anuga import *
    1515#from balanced_basic import *
    16 #from balanced_dev import *
    17 from anuga_tsunami import *
     16from balanced_dev import *
     17#from anuga_tsunami import *
    1818#from balanced_basic.swb2_domain import *
    1919#from balanced_basic.swb2_domain import Domain
  • trunk/anuga_work/development/gareth/tests/dam_break/dam_break.py

    r8547 r8751  
    5151# Setup Algorithm
    5252#------------------------------------------------------------------------------
    53 domain.set_timestepping_method('rk2')
    54 domain.set_default_order(2)
     53#domain.set_timestepping_method('rk2')
     54#domain.set_default_order(2)
    5555
    5656print domain.get_timestepping_method()
    5757
    58 domain.use_edge_limiter = True
     58#domain.use_edge_limiter = True
    5959#domain.use_edge_limiter = False
    60 domain.tight_slope_limiters = True
    61 domain.use_centroid_velocities = False
     60#domain.tight_slope_limiters = True
     61#domain.use_centroid_velocities = False
    6262
    63 domain.CFL = 1.0
     63#domain.CFL = 1.0
    6464
    6565#domain.beta_w      = 0.6
  • trunk/anuga_work/development/gareth/tests/dam_break/plotme.py

    r8547 r8751  
    99p2_st=util.get_centroids(p_st)
    1010
    11 p_dev = util.get_output('dam_break_20120831_172309/dam_break.sww', 0.001)
     11p_dev = util.get_output('dam_break_20130219_202649/dam_break.sww', 0.001)
    1212p2_dev=util.get_centroids(p_dev, velocity_extrapolation=True)
    1313
  • trunk/anuga_work/development/gareth/tests/okushiri/run_okushiri.py

    r8547 r8751  
    2424import anuga
    2525import project
    26 #from balanced_dev import *
    27 from anuga_tsunami import *
     26from balanced_dev import *
     27#from anuga_tsunami import *
    2828
    2929def main(elevation_in_mesh=False):
  • trunk/anuga_work/development/gareth/tests/parabolic/parabolaplot.py

    r8396 r8751  
    1111import util
    1212
    13 p=util.get_output('parabola_v2.sww', 0.01)
     13p=util.get_output('parabola_v2.sww', 0.001)
    1414p2=util.get_centroids(p, velocity_extrapolation=True)
    1515
  • trunk/anuga_work/development/gareth/tests/runup/runup.py

    r8547 r8751  
    5656Bt=anuga.Transmissive_boundary(domain)          # Continue all values of boundary -- not used in this example
    5757Bd=anuga.Dirichlet_boundary([-0.2,0.,0.])       # Constant boundary values -- not used in this example
    58 Bw=anuga.Time_boundary(domain=domain,
    59         f=lambda t: [(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1,0.0,0.0]) # Time varying boundary -- get rid of the 0.0 to do a runup.
     58#Bw=anuga.Time_boundary(domain=domain,
     59#       f=lambda t: [(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1,0.0,0.0]) # Time varying boundary -- get rid of the 0.0 to do a runup.
    6060
    6161#----------------------------------------------
  • trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py

    r8607 r8751  
    1414#from swb2_domain import *
    1515#from balanced_basic import *
    16 #from balanced_dev import *
    17 from anuga_tsunami import *
     16from balanced_dev import *
     17#from anuga_tsunami import *
     18
    1819#---------
    1920#Setup computational domain
     
    2324domain=Domain(points,vertices,boundary)    # Create Domain
    2425domain.set_name('runup_sinusoid_v2')                         # Output to file runup.sww
    25 domain.set_datadir('.')                          # Use current folder
    26 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
    27 #domain.set_store_vertices_uniquely(True)
     26
    2827#------------------
    2928# Define topography
    3029#------------------
    3130scale_me=1.0
    32 
    3331#domain.minimum_allowed_height=domain.minimum_allowed_height*scale_me # Seems needed to make the algorithms behave
    3432
     
    3735
    3836def stagefun(x,y):
    39     stge=-0.2*scale_me #+0.01*(x>0.9)
     37    stge=-0.2*scale_me #+0.1*(x>0.9)
    4038    #topo=topography(x,y)
    4139    return stge#*(stge>topo) + (topo)*(stge<=topo)
     
    5351domain.get_quantity('stage').smooth_vertex_values()
    5452
     53#print domain.forcing_terms
     54#assert 0==1
    5555# Experiment with rain.
    5656# rainin = anuga.shallow_water.forcing.Rainfall(domain, rate=0.001) #, center=(0.,0.), radius=1000. )
     
    6464Bd=anuga.Dirichlet_boundary([-0.1*scale_me,0.,0.])       # Constant boundary values -- not used in this example
    6565def waveform(t):
    66     return (0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1
     66    return -0.1 #(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1
    6767Bt2=anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain,waveform)
    6868#Bw=anuga.Time_boundary(domain=domain,
     
    7272# Associate boundary tags with boundary objects
    7373#----------------------------------------------
    74 domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom':Br})
     74domain.set_boundary({'left': Br, 'right': Bt2, 'top': Br, 'bottom':Br})
    7575
    7676#------------------------------
     
    7878#------------------------------
    7979
    80 for t in domain.evolve(yieldstep=0.2,finaltime=40.0):
     80for t in domain.evolve(yieldstep=0.200,finaltime=40.00):
    8181    print domain.timestepping_statistics()
    8282    xx = domain.quantities['xmomentum'].centroid_values
     
    8484    dd = domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values
    8585    dd_raw=1.0*dd
    86     dd = (dd)*(dd>1.0e-03)+1.0e-03
     86    dd = dd*(dd>1.0e-03)+1.0e-03*(dd<=1.0e-03)
    8787    vv = ( (xx/dd)**2 + (yy/dd)**2)**0.5
    8888    vv = vv*(dd>1.0e-03)
  • trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoidplot.py

    r8353 r8751  
    1515#------------------
    1616#v=(p.y==0.5)
    17 v=(p2.y==p2.y[80])
     17myind=(abs(p2.y-0.5)).argmin()
     18v=(p2.y==p2.y[myind])
    1819
    1920#--------------------
  • trunk/anuga_work/development/gareth/tests/shallow_steep_slope/channel_SU_sparse.py

    r8549 r8751  
    2929# Setup computational domain
    3030#------------------------------------------------------------------------------
    31 points, vertices, boundary = rectangular_cross(10, 10,
    32                                 len1=100.0, len2=100.0) # Mesh
     31points, vertices, boundary = rectangular_cross(14, 10,
     32                                len1=140.0, len2=100.0) # Mesh
    3333domain = Domain(points, vertices, boundary) # Create domain
    3434domain.set_name('channel_SU_2_v2') # Output name
    35 #domain.set_store_vertices_uniquely(True)
    36 #domain.CFL=1.0
    3735#------------------------------------------------------------------------------
    3836# Setup initial conditions
    3937#------------------------------------------------------------------------------
    4038def topography(x, y):
    41         return -x/10. #+ numpy.sin(x/10.) +abs(y-50.)/100. # linear bed slope
     39        return -x/10. + 1.*(numpy.sin(x/10.) +abs(y-50.)/10.) -0.*(x>80.) # linear bed slope
    4240
    4341def stagetopo(x,y):
    44     stg= -x/10. +0.06309625 # Constant depth
     42    stg= topography(x,y) + 0.163 #-x/10. +0.06309625 -50.*(x>80.)# Constant depth
    4543    #topo=topography(x,y)
    4644    return stg#*(stg>topo) + topo*(stg<=topo)
     
    6866#Bo = anuga.Transmissive_boundary(domain)
    6967#Bd = anuga.Dirichlet_boundary([-20., 0., 0.])
    70 domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br})
     68domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
    7169
    7270
Note: See TracChangeset for help on using the changeset viewer.