Changeset 8396


Ignore:
Timestamp:
Apr 12, 2012, 9:00:47 PM (13 years ago)
Author:
davies
Message:

balanced_dev: Discouraging use of balanced_basic, and updates to
util.py, and experimental boundary conditions

Location:
trunk/anuga_work/development/gareth
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/gareth/balanced_basic/swb2_domain.py

    r8302 r8396  
    6969        self.forcing_terms.remove(gravity)
    7070        print 'Using shallow_water_balanced2 solver in /balanced_basic/'
    71 
    72 
    73 
     71        print 'I SUGGEST YOU DO NOT USE THIS ONE -- THE BALANCED DEV SOLVER SEEMS BETTER,'
     72        print 'AND IS BETTER TESTED (as of 6/4/2012)'
     73        print 'IT PRESENTLY LIVES IN anuga_work/development/gareth/experimental/balanced_dev'
     74        print ' '
     75        print 'The following error is intended to draw your attention to the message above'
     76
     77        assert 0==1
    7478    #-----------------
    7579    # Flux computation
  • trunk/anuga_work/development/gareth/experimental/balanced_dev/__init__.py

    r8385 r8396  
    325325
    326326    return domain
    327     
     327   
    328328import logging as log
    329329
  • trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_boundary_conditions.py

    r8385 r8396  
    11
    22from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\
    3      import Boundary
     3     import Boundary, File_boundary
    44
    55#from swb2_domain_ext import rotate
    6 
    7 class Transmissive_boundary(Boundary):
    8     """Transmissive boundary returns same conserved quantities as
    9     those present in its neighbour volume.
    10 
    11     Underlying domain must be specified when boundary is instantiated
    12     """
    13 
    14     def __init__(self, domain = None):
    15         Boundary.__init__(self)
    16 
    17         if domain is None:
    18             msg = 'Domain must be specified for transmissive boundary'
    19             raise Exception, msg
    20 
    21         self.domain = domain
    22 
    23     def __repr__(self):
    24         return 'Transmissive_boundary(%s)' %self.domain
    25 
    26     def evaluate(self, vol_id, edge_id):
    27         """Transmissive boundaries return the edge values
    28         of the volume they serve.
    29         """
    30 
    31         if self.domain.get_centroid_transmissive_bc() :
    32             q = self.domain.get_evolved_quantities(vol_id)
    33         else:
    34             q = self.domain.get_evolved_quantities(vol_id, edge = edge_id)
    35         return q
    36 
    376#####
    387
     
    153122
    154123        return q
     124
     125
     126class  zero_mass_flux_zero_t_transmissive_n_momentum_boundary(Boundary):
     127    """ Boundary which operates directly on the fluxes
     128        Sets boundary values of h=neighbour_h, uh=neighbour_uh, vh=0.
     129        and ensure that:
     130        flux[0] = 0.0
     131    """
     132    def __init__(self, domain = None):
     133        Boundary.__init__(self)
     134
     135        if domain is None:
     136            msg = 'Domain must be specified for zero_mass_flux_zero_t_transmissive_n_momentum_boundary'
     137            raise Exception, msg
     138
     139        self.domain = domain
     140
     141    def __repr__(self):
     142        return 'zero_mass_flux_zero_t_transmissive_n_momentum_boundary(%s)' %self.domain
     143
     144    def evaluate(self, vol_id, edge_id):
     145        """ Apply chosen values to q[1], q[2]
     146        """
     147
     148        if self.domain.get_centroid_transmissive_bc() :
     149            q = self.domain.get_evolved_quantities(vol_id)
     150        else:
     151            q = self.domain.get_evolved_quantities(vol_id, edge = edge_id)
     152
     153        normal = self.domain.normals[vol_id, 2*edge_id:2*edge_id+2]
     154
     155        r = rotate(q, normal, direction = 1)
     156        #r[1] = -r[1]
     157        tdamp=0.0
     158        ndamp=1.0
     159        r[1]=r[1]*ndamp
     160        r[2]=r[2]*tdamp
     161        q = rotate(r, normal, direction = -1)
     162
     163        # q[1]=0.
     164        # q[2]=0.
     165
     166        return q
     167
     168
    155169###
    156170def rotate(q,normal,direction=1):
     
    170184
    171185    return out
    172    
  • trunk/anuga_work/development/gareth/tests/merimbula_steve/run_sw_merimbula.py

    r8354 r8396  
    3636
    3737from anuga import rectangular_cross
    38 from balanced_dev import create_domain_from_file
     38#from balanced_dev import create_domain_from_file
    3939#from balanced_basic import create_domain_from_file
    4040#from anuga import create_domain_from_file
  • trunk/anuga_work/development/gareth/tests/parabolic/parabolaplot.py

    r8353 r8396  
    44# Import Modules
    55#---------------
    6 import anuga
     6#import anuga
    77#import struct
    88import numpy
  • trunk/anuga_work/development/gareth/tests/urban_flow/ideal_urban.py

    r8384 r8396  
    1313
    1414from balanced_dev import *
    15 from balanced_dev import create_domain_from_regions as create_domain_from_regions
     15#from balanced_dev import create_domain_from_regions as create_domain_from_regions
    1616#------------------------------------------------------------------------------
    1717# Useful parameters for controlling this case
  • trunk/anuga_work/development/gareth/tests/util.py

    r8385 r8396  
    1313                       transect (e.g. a channel cross-section) -- see example below
    1414
    15 
     15    util.sort_sww_filenames -- match sww filenames by a wildcard, and order
     16                               them according to their 'time'. This means that
     17                               they can be stuck together using 'combine_outputs' correctly
     18 
    1619
    1720    Here is an example ipython session which uses some of these functions:
     
    2427    > pyplot.ion() # Interactive plotting
    2528    > pyplot.scatter(xxx[1],p.vel[140,xxx[0]],color='red') # Plot along the transect
     29
     30    FIXME: TODO -- Convert to a single function 'get_output', which can either take a
     31          single filename, a list of filenames, or a wildcard defining a number of
     32          filenames, and ensure that in each case, the output will be as desired.
    2633
    2734"""
     
    8087                p1.yvel, p1.vel, p1.minimum_allowed_height
    8188
    82 
     89####################
     90
     91def sort_sww_filenames(sww_wildcard):
     92    # Function to take a 'wildcard' sww filename,
     93    # and return a list of all filenames of this type,
     94    # sorted by their time.
     95    # This can then be used efficiently in 'combine_outputs'
     96    # if you have many filenames starting with the same pattern
     97    import glob
     98    filenames=glob.glob(sww_wildcard)
     99   
     100    # Extract time from filenames
     101    file_time=range(len(filenames)) # Predefine
     102     
     103    for i,filename in enumerate(filenames):
     104        filesplit=filename.rsplit('_time_')
     105        if(len(filesplit)>1):
     106            file_time[i]=int(filesplit[1].split('_0.sww')[0])
     107        else:
     108            file_time[i]=0         
     109   
     110    name_and_time=zip(file_time,filenames)
     111    name_and_time.sort() # Sort by file_time
     112   
     113    output_times, output_names = zip(*name_and_time)
     114   
     115    return list(output_names)
     116
     117##############
    83118
    84119class get_output:
  • trunk/anuga_work/development/gareth/tests/wave/run_wave.py

    r8384 r8396  
    1212import sys
    1313import anuga
    14 from anuga import Domain
     14#from anuga import Domain
    1515
    1616from balanced_dev import *
    17 from balanced_dev import Domain as Domain
     17#from balanced_dev import Domain as Domain
    1818
    1919from math import cos
     
    8181Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
    8282Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary
     83Bz = swb2_boundary_conditions.zero_mass_flux_zero_momentum_boundary(domain) # Strong reflections
     84Bz1 = swb2_boundary_conditions.zero_mass_flux_zero_t_transmissive_n_momentum_boundary(domain) # Strong reflections
     85Bz2 = swb2_boundary_conditions.zero_mass_flux_zero_n_transmissive_t_momentum_boundary(domain) # Strong reflections
     86Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Strong reflections
    8387Bd = anuga.Dirichlet_boundary([1,0.,0.]) # Constant boundary values
    8488amplitude = 1
     
    97101
    98102Bw2 = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, waveform)
     103#Bw3 = swb2_boundary_conditions.Transmissive_momentum_nudge_stage_boundary(domain, waveform)
    99104                   
    100105
Note: See TracChangeset for help on using the changeset viewer.