Changeset 8582 for trunk/anuga_core


Ignore:
Timestamp:
Sep 18, 2012, 3:42:23 PM (13 years ago)
Author:
steve
Message:

Moved Gareth's tsunami algorithm over to main trunk

Location:
trunk/anuga_core
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r8578 r8582  
    141141        self.geo_reference = self.mesh.geo_reference
    142142
     143        self.verbose = verbose
    143144
    144145        if verbose: log.critical('Domain: Expose quantity names and types')
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r8578 r8582  
    344344
    345345        # We demand that vertex values are stored uniquely
    346         self.set_store_vertices_smoothly(False)
     346        #self.set_store_vertices_smoothly(False)
    347347
    348348        self.maximum_allowed_speed=0.0
     349        #self.minimum_allowed_height=0.01
     350       
    349351        #self.forcing_terms.append(manning_friction_explicit)
    350352        #self.forcing_terms.remove(manning_friction_implicit)
    351353
    352         print '##########################################################################'
    353         print '#'
    354         print '# Using anuga_tsunami solver in anuga_work/development/gareth/experimental/anuga_tsunami/'
    355         print "#"
    356         print "# This solver is experimental. Here are some tips on using it"
    357         print "#"
    358         print "# 1) When plotting outputs, I strongly suggest you examine centroid values, not vertex values"
    359         print "# , as the latter can be completely misleading near strong gradients in the flow. "
    360         print "# There is a plot_util.py script in anuga_core/utilities/ which might help you extract"
    361         print "# quantities at centroid values from sww files."
    362         print "# Note that to accuractely compute centroid values from sww files, the files need to store "
    363         print "# vertices uniquely. This makes for large sww files (3x), but is the price to pay for the right answer"
    364         print "# (unless we alter IO to allow centroids to be written to sww files, which would then affect"
    365         print "# ANUGA viewer as well -- I expect this would be lots of work)"
    366         print "#"
    367         print "# 2) In field scale applications (where the depth is typically > 1m), I suggest you set"
    368         print "# domain.minimum_allowed_height=0.01 (the default is 1.0e-3). "
    369         print "#"
    370         print "# 3) This solver is not expected to perform well in problems with very"
    371         print "# shallow water flowing down steep slopes (such that the stage_centroid_value "
    372         print "# is less than the maximum bed_edge_value on a given triangle). However, analytical tests"
    373         print "# suggest it can do typical wetting/drying situations very well (parabolic oscillations test case) "
    374         print "#"
    375         print "# 4) This solver allows the stage_centroid_value to drop to slightly below the minimum bed_vertex_value"
    376         print "# on it's triangle. In other ANUGA versions (e.g. 1.2.1), the limit would be the"
    377         print "# bed_centroid_value. This means that triangles store slightly more water than they are"
    378         print "# typically interpreted to store, which might have significance in some applications."
    379         print "#"
    380         print "# You will probably be able to tell this is causing you problems by convergence testing"
    381         print "#"
    382         print '# 5) Note that many options in config.py have been overridden by the solver -- I have '
    383         print '# deliberately attempted to get the solver to perform well with consistent values of '
    384         print '# these parameters -- so I would advise against changing them unless you at least check that '
    385         print '# it really does improve things'
    386         print '#'
    387         print '##########################################################################'
     354#        print '##########################################################################'
     355#        print '#'
     356#        print '# Using anuga_tsunami solver in anuga_work/development/gareth/experimental/anuga_tsunami/'
     357#        print "#"
     358#        print "# This solver is experimental. Here are some tips on using it"
     359#        print "#"
     360#        print "# 1) When plotting outputs, I strongly suggest you examine centroid values, not vertex values"
     361#        print "# , as the latter can be completely misleading near strong gradients in the flow. "
     362#        print "# There is a plot_util.py script in anuga_core/utilities/ which might help you extract"
     363#        print "# quantities at centroid values from sww files."
     364#        print "# Note that to accuractely compute centroid values from sww files, the files need to store "
     365#        print "# vertices uniquely. This makes for large sww files (3x), but is the price to pay for the right answer"
     366#        print "# (unless we alter IO to allow centroids to be written to sww files, which would then affect"
     367#        print "# ANUGA viewer as well -- I expect this would be lots of work)"
     368#        print "#"
     369#        print "# 2) In field scale applications (where the depth is typically > 1m), I suggest you set"
     370#        print "# domain.minimum_allowed_height=0.01 (the default is 1.0e-3). "
     371#        print "#"
     372#        print "# 3) This solver is not expected to perform well in problems with very"
     373#        print "# shallow water flowing down steep slopes (such that the stage_centroid_value "
     374#        print "# is less than the maximum bed_edge_value on a given triangle). However, analytical tests"
     375#        print "# suggest it can do typical wetting/drying situations very well (parabolic oscillations test case) "
     376#        print "#"
     377#        print "# 4) This solver allows the stage_centroid_value to drop to slightly below the minimum bed_vertex_value"
     378#        print "# on it's triangle. In other ANUGA versions (e.g. 1.2.1), the limit would be the"
     379#        print "# bed_centroid_value. This means that triangles store slightly more water than they are"
     380#        print "# typically interpreted to store, which might have significance in some applications."
     381#        print "#"
     382#        print "# You will probably be able to tell this is causing you problems by convergence testing"
     383#        print "#"
     384#        print '# 5) Note that many options in config.py have been overridden by the solver -- I have '
     385#        print '# deliberately attempted to get the solver to perform well with consistent values of '
     386#        print '# these parameters -- so I would advise against changing them unless you at least check that '
     387#        print '# it really does improve things'
     388#        print '#'
     389#        print '##########################################################################'
    388390
    389391
     
    11231125            areas = self.areas
    11241126
    1125             protect(self.minimum_allowed_height, self.maximum_allowed_speed,
     1127            mass_error = protect(self.minimum_allowed_height, self.maximum_allowed_speed,
    11261128                self.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas)
     1129
     1130            if mass_error > 0.0 and self.verbose :
     1131                print 'Cumulative mass protection: %g m^3 '% mass_error
    11271132
    11281133
     
    12781283            areas = self.areas
    12791284
    1280             protect(self.minimum_allowed_height, self.maximum_allowed_speed,
     1285            mass_error = protect(self.minimum_allowed_height, self.maximum_allowed_speed,
    12811286                self.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas)
     1287
     1288            print 'Cumulative mass protection: python'+str(mass_error)+'m^3 '
     1289
    12821290
    12831291        else:
  • trunk/anuga_core/source/anuga/shallow_water/swb2_domain_ext.c

    r8580 r8582  
    558558
    559559// Protect against the water elevation falling below the triangle bed
    560 int _protect(int N,
     560double _protect(int N,
    561561         double minimum_allowed_height,
    562562         double maximum_allowed_speed,
     
    573573  double hc, bmin, bmax;
    574574  double u, v, reduced_speed;
    575   static double mass_error=0.;
     575  double mass_error=0.;
    576576  // This acts like minimum_allowed height, but scales with the vertical
    577577  // distance between the bed_centroid_value and the max bed_edge_value of
     
    626626    }
    627627
     628/*
    628629  if(mass_added==1){
    629630     printf("Cumulative mass protection: %f m^3 \n", mass_error);
    630631  }
    631   return 0;
     632*/
     633  return mass_error;
    632634}
    633635
     
    17341736  int N;
    17351737  double minimum_allowed_height, maximum_allowed_speed, epsilon;
     1738  double mass_error;
    17361739
    17371740  // Convert Python arguments to C
     
    17471750  N = wc -> dimensions[0];
    17481751
    1749   _protect(N,
     1752  mass_error = _protect(N,
    17501753       minimum_allowed_height,
    17511754       maximum_allowed_speed,
     
    17591762       (double*) areas -> data);
    17601763
    1761   return Py_BuildValue("");
     1764  return Py_BuildValue("d", mass_error);
    17621765}
    17631766
  • trunk/anuga_core/source/anuga_parallel/parallel_api.py

    r8553 r8582  
    6868        domain_store = domain.get_store()
    6969        domain_minimum_storable_height = domain.minimum_storable_height
     70        domain_flow_algorithm = domain.get_flow_algorithm()
     71        domain_minimum_allowed_height = domain.get_minimum_allowed_height()
    7072        georef = domain.geo_reference
    7173        number_of_global_triangles = domain.number_of_triangles
     
    7779            # FIXME SR: Creates cPickle dump
    7880            send((domain_name, domain_dir, domain_store, \
    79                   domain_minimum_storable_height, georef, \
     81                  domain_minimum_storable_height, domain_flow_algorithm, \
     82                  domain_minimum_allowed_height, georef, \
    8083                  number_of_global_triangles, number_of_global_nodes), p)
    8184    else:
     
    8386
    8487        domain_name, domain_dir, domain_store, \
    85                   domain_minimum_storable_height, \
    86                   georef, number_of_global_triangles, \
     88                  domain_minimum_storable_height, domain_flow_algorithm, \
     89                  domain_minimum_allowed_height, georef, number_of_global_triangles, \
    8790                  number_of_global_nodes = receive(0)
    8891
     
    236239    domain.set_store(domain_store)
    237240    domain.set_minimum_storable_height(domain_minimum_storable_height)
     241    domain.set_minimum_allowed_height(domain_minimum_allowed_height)
     242    domain.set_flow_algorithm(domain_flow_algorithm)
    238243    domain.geo_reference = georef   
    239244
  • trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py

    r8573 r8582  
    2121# Sequential interface
    2222#---------------------------
    23 from anuga import Domain
    2423from anuga import Transmissive_boundary, Reflective_boundary
    2524from anuga import rectangular_cross_domain
     
    4443    #dx = dy = 0.00125
    4544    #dx = dy  = 0.5
    46     seq_domain = rectangular_cross_domain(int(length/dx), int(width/dy),
     45    domain = rectangular_cross_domain(int(length/dx), int(width/dy),
    4746                                              len1=length, len2=width, verbose=verbose)
    4847
    49     seq_domain.set_store(False)
    50     seq_domain.set_quantity('elevation', lambda x,y : -1.0-x )
    51     seq_domain.set_quantity('stage', 1.0)
    52     seq_domain.print_statistics()
     48
     49    domain.set_store(True)
     50    domain.set_quantity('elevation', lambda x,y : -1.0-x )
     51    domain.set_quantity('stage', 1.0)
     52    domain.set_flow_algorithm('tsunami')
     53    domain.print_statistics()
    5354else:
    54     seq_domain = None
     55    domain = None
    5556
    5657t1 = time.time()
     
    6566barrier()
    6667
    67 # setup parameters to test using different ghost_layer_widths
    68 parameters = dict(ghost_layer_width = 2)
    69 domain = distribute(seq_domain,verbose=verbose, parameters=parameters)
    70 
    71 del seq_domain
     68#-------------------------------------------------------------------------
     69# Distribute domain
     70#-------------------------------------------------------------------------
     71domain = distribute(domain,verbose=verbose)
    7272
    7373
     
    121121if myid == 0 : print 'after set quantity'
    122122
    123 # Set Evolve parameters
    124 domain.set_flow_algorithm('2_0')
    125 
    126 
    127 
    128 
    129 #domain.update_ghosts()
    130 
    131 
    132 #print 'after evolve parameters'
    133 
    134 
    135 #import pdb; pdb.set_trace()
    136 
    137123
    138124
  • trunk/anuga_core/validation_tests/Tests/Simple/runup_sinusoid/runup_sinusoid.py

    r8548 r8582  
    99
    1010from math import sin, pi, exp
    11 from anuga.shallow_water.shallow_water_domain import Domain as Domain
    12 #from anuga.shallow_water_balanced2.swb2_domain import Domain as Domain
    13 #path.append('/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/development/gareth/balanced_basic')
    14 #from swb2_domain import *
    15 #from balanced_basic import *
    16 #from balanced_dev import *
     11
     12from anuga import Domain
     13
    1714#---------
    1815#Setup computational domain
    1916#---------
    20 points, vertices, boundary = anuga.rectangular_cross(40,40, len1=1., len2=1.)
     17domain = anuga.rectangular_cross_domain(40,40, len1=1., len2=1.)
    2118
    22 domain=Domain(points,vertices,boundary)    # Create Domain
    23 domain.set_name('runup_sinusoid_v2')                         # Output to file runup.sww
    24 domain.set_datadir('.')                          # Use current folder
    25 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
    26 #domain.set_store_vertices_uniquely(True)
    27 #domain.minimum_allowed_height=0.001
    2819
    2920#------------------------------------------------------------------------------
     
    3526domain.set_flow_algorithm(alg)
    3627domain.set_CFL(cfl)
     28
     29
     30domain.set_name('runup_sinusoid_v2')                         # Output to file runup.sww
     31domain.set_datadir('.')                          # Use current folder
     32domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
     33#domain.set_store_vertices_uniquely(True)
     34domain.set_minimum_allowed_height(0.01)
     35
    3736
    3837
     
    8786#------------------------------
    8887
    89 for t in domain.evolve(yieldstep=0.1,finaltime=20.0):
     88for t in domain.evolve(yieldstep=0.5,finaltime=20.0):
    9089    print domain.timestepping_statistics()
    9190    xx = domain.quantities['xmomentum'].centroid_values
  • trunk/anuga_core/validation_tests/Tests/Simple/runup_sinusoid/runup_sinusoidplot.py

    r8433 r8582  
    3030        pyplot.draw()
    3131        pyplot.plot( (0,1),(0,0), 'r' )
    32         pyplot.title(str(i)+'/200') # : velocity does not converge to zero' )
     32        pyplot.title(str(i)+'/40') # : velocity does not converge to zero' )
    3333        pyplot.xlabel('x')
    3434        pyplot.ylabel('Velocity (m/s)')
  • trunk/anuga_core/validation_tests/parameters.py

    r8528 r8582  
    88
    99
    10 alg = '2_0'
     10alg = 'tsunami'
    1111cfl = 1.0
    1212
Note: See TracChangeset for help on using the changeset viewer.