Changeset 9001


Ignore:
Timestamp:
Oct 5, 2013, 9:47:07 AM (11 years ago)
Author:
steve
Message:

Made changes to operators to take a region as well as poly and line

Location:
trunk/anuga_core
Files:
1 deleted
25 edited

Legend:

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

    r8980 r9001  
    3232
    3333from anuga.shallow_water.shallow_water_domain import Domain
    34 
    3534from anuga.abstract_2d_finite_volumes.quantity import Quantity
    36 
    37 from anuga.operators.region import Region
     35from anuga.abstract_2d_finite_volumes.region import Region
     36
    3837
    3938from anuga.abstract_2d_finite_volumes.util import file_function, \
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r9000 r9001  
    895895
    896896        if len(args) == 1:
    897             self._set_region(*args, **kwargs)
     897            self._set_tag_region(*args, **kwargs)
    898898        else:
    899899            # Assume it is arguments for the region.set_region function
    900900            func = region_set_tag_region(*args, **kwargs)
    901             self._set_region(func)
     901            self._set_tag_region(func)
    902902
    903903    def _set_tag_region(self, functions):
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/tag_region.py

    r9000 r9001  
    1111
    1212
    13 class Region:
     13class Tag_region:
    1414    """Base class for modifying quantities based on a region.
    1515    """   
     
    3232            return elements
    3333               
    34 class Set_region(Region):
     34class Set_tag_region(Tag_region):
    3535   
    3636    def __init__(self, tag, quantity, X, location='vertices'):
     
    4242        """
    4343       
    44         Region.__init__(self)
     44        Tag_region.__init__(self)
    4545        self.tag = tag
    4646        self.quantity = quantity
     
    6161
    6262       
    63 class Add_value_to_region(Region):
     63class Add_value_to_region(Tag_region):
    6464    """
    6565    Will add a value to the current quantity value.
     
    114114                                location=self.location)
    115115
    116 class Add_quantities(Region):
     116class Add_quantities(Tag_region):
    117117    """
    118118    Will add a quantity to the current quantity value.
     
    157157
    158158
    159 class Stage_no_less_than_elevation(Region):
     159class Stage_no_less_than_elevation(Tag_region):
    160160    """
    161161    Will set the stage to not be less than the elevation.
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_domain.py

    r8999 r9001  
    815815
    816816        domain.build_tagged_elements_dictionary({'mound':[0,1]})
    817         domain.set_region([add_to_verts])
     817        domain.set_tag_region([add_to_verts])
    818818
    819819        self.failUnless(domain.test == "Mound",
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_tag_region.py

    r9000 r9001  
    77from anuga.shallow_water.shallow_water_domain import Domain
    88from generic_domain import Generic_Domain
    9 from region import *
     9from tag_region import *
    1010#from anuga.config import epsilon
    1111
     
    5959        domain.set_quantity('friction', manning)
    6060
    61         a = Set_region('bottom', 'friction', 0.09)
    62         b = Set_region('top', 'friction', 1.0)
    63         domain.set_region([a, b])
     61        a = Set_tag_region('bottom', 'friction', 0.09)
     62        b = Set_tag_region('top', 'friction', 1.0)
     63        domain.set_tag_region([a, b])
    6464
    6565        expected = [[ 0.09,  0.09,  0.09],
     
    7676
    7777        #c = Add_Value_To_region('all', 'friction', 10.0)
    78         domain.set_region(Add_value_to_region('all', 'friction', 10.0))
     78        domain.set_tag_region(Add_value_to_region('all', 'friction', 10.0))
    7979        #print domain.quantities['friction'].get_values()
    8080        assert num.allclose(domain.quantities['friction'].get_values(),
     
    8787
    8888        # trying a function
    89         domain.set_region(Set_region('top', 'friction', add_x_y))
     89        domain.set_tag_region(Set_tag_region('top', 'friction', add_x_y))
    9090        #print domain.quantities['friction'].get_values()
    9191        assert num.allclose(domain.quantities['friction'].get_values(),
     
    9999        domain.set_quantity('elevation', 10.0)
    100100        domain.set_quantity('stage', 10.0)
    101         domain.set_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation'))
     101        domain.set_tag_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation'))
    102102        #print domain.quantities['stage'].get_values()
    103103        assert num.allclose(domain.quantities['stage'].get_values(),
     
    116116        #                    domain.quantities['stage'].vertex_values+ \
    117117        #                    domain.quantities['elevation'].vertex_values)
    118         domain.set_region(Add_quantities('top', 'elevation','stage'))
     118        domain.set_tag_region(Add_quantities('top', 'elevation','stage'))
    119119        #print domain.quantities['stage'].get_values()
    120120        assert num.allclose(domain.quantities['elevation'].get_values(),
     
    142142        domain.set_quantity('friction', manning)
    143143
    144         a = Set_region('bottom', 'friction', 0.09, location = 'unique vertices')
    145         domain.set_region(a)
     144        a = Set_tag_region('bottom', 'friction', 0.09, location = 'unique vertices')
     145        domain.set_tag_region(a)
    146146        assert num.allclose(domain.quantities['friction'].get_values(),
    147147                            [[ 0.09,  0.09,  0.09],
     
    171171        domain.set_quantity('friction', manning)
    172172
    173         domain.set_region(Add_value_to_region('bottom', 'friction', 1.0,initial_quantity='friction', location = 'unique vertices'))
     173        domain.set_tag_region(Add_value_to_region('bottom', 'friction', 1.0,initial_quantity='friction', location = 'unique vertices'))
    174174
    175175        #print domain.quantities['friction'].get_values()
     
    199199        add = 60.0
    200200        calc_frict = av_bottom + add
    201         domain.set_region(Add_value_to_region('bottom', 'friction', add,
     201        domain.set_tag_region(Add_value_to_region('bottom', 'friction', add,
    202202                                              initial_quantity='friction',
    203203                                              location='vertices',
     
    233233        add = 60.0
    234234        calc_frict = av_bottom + add
    235         domain.set_region(Add_value_to_region('bottom', 'friction', add,
     235        domain.set_tag_region(Add_value_to_region('bottom', 'friction', add,
    236236                          initial_quantity='friction',
    237237                           location='unique vertices',
  • trunk/anuga_core/source/anuga/operators/erosion_operators.py

    r8945 r9001  
    1616from anuga import Quantity
    1717from anuga.operators.base_operator import Operator
    18 from anuga.operators.region import Region
     18from anuga import Region
    1919
    2020
  • trunk/anuga_core/source/anuga/operators/rate_operators.py

    r8978 r9001  
    1919from anuga import Quantity
    2020from anuga.operators.base_operator import Operator
    21 from anuga.operators.region import Region
     21from anuga import Region
    2222
    2323class Rate_operator(Operator,Region):
  • trunk/anuga_core/source/anuga/operators/set_friction_operators.py

    r8974 r9001  
    1414
    1515from anuga.operators.base_operator import Operator
    16 from anuga.operators.region import Region
     16from anuga import Region
    1717from anuga.config import indent
    1818
  • trunk/anuga_core/source/anuga/operators/set_quantity.py

    r8974 r9001  
    1616from anuga.geometry.polygon import inside_polygon
    1717from anuga.utilities.function_utils import determine_function_type
    18 from anuga.operators.region import Region
     18from anuga import Region
    1919from anuga.config import indent
    2020
  • trunk/anuga_core/source/anuga/operators/test_set_stage_operator.py

    r8930 r9001  
    1616
    1717import numpy as num
     18from pprint import pprint
    1819import warnings
    1920import time
     
    227228        width = 2.0
    228229        dx = dy = 0.5
     230        #dx = dy = 0.1
    229231        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
    230232                                              len1=length, len2=width)
     
    256258        operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
    257259
     260
     261        #operator.plot_region()
     262       
    258263        # Apply Operator at time t=1.0
    259264        domain.set_time(1.0)
    260265        operator()
     266
     267
     268        stage_ex_expanded = \
     269                   [ 1.,  1.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,
     270                     5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
     271                     5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,
     272                     5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  1.,  5.,
     273                     5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  1.]
    261274
    262275        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
     
    270283
    271284#        print domain.quantities['elevation'].centroid_values
    272 #        print domain.quantities['stage'].centroid_values
     285#        pprint(domain.quantities['stage'].centroid_values)
    273286#        print domain.quantities['xmomentum'].centroid_values
    274287#        print domain.quantities['ymomentum'].centroid_values
     
    281294        domain.set_time(15.0)
    282295        operator()
     296
     297        stage_ex_expanded = \
     298                   [ 1.,  1.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,
     299                     7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
     300                     7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,
     301                     7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  1.,  7.,
     302                     7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  1.]
     303
    283304
    284305        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
     
    291312
    292313
    293 #        print domain.quantities['stage'].centroid_values
     314#        pprint(domain.quantities['stage'].centroid_values)
    294315#        print domain.quantities['xmomentum'].centroid_values
    295316#        print domain.quantities['ymomentum'].centroid_values
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r8996 r9001  
    82698269
    82708270
    8271     def test_region_tags(self):
     8271    def test_tag_region_tags(self):
    82728272        """
    82738273        get values based on triangle lists.
     
    82898289        domain.set_quantity('friction', manning)
    82908290
    8291         domain.set_region([set_bottom_friction, set_top_friction])
     8291        domain.set_tag_region([set_bottom_friction, set_top_friction])
    82928292        assert num.allclose(domain.quantities['friction'].get_values(),\
    82938293                            [[ 0.09,  0.09,  0.09],
     
    82988298                             [ 1.0,  1.0,  1.0]])
    82998299
    8300         domain.set_region([set_all_friction])
     8300        domain.set_tag_region([set_all_friction])
    83018301        assert num.allclose(domain.quantities['friction'].get_values(),
    83028302                            [[ 10.09, 10.09, 10.09],
     
    83288328        domain.set_quantity('friction', manning)
    83298329
    8330         domain.set_region('top', 'friction', 1.0)
    8331         domain.set_region('bottom', 'friction', 0.09)
     8330        domain.set_tag_region('top', 'friction', 1.0)
     8331        domain.set_tag_region('bottom', 'friction', 0.09)
    83328332       
    83338333        msg = ("domain.quantities['friction'].get_values()=\n%s\n"
     
    83488348                             [ 1.0,  1.0,  1.0]]), msg
    83498349       
    8350         domain.set_region([set_bottom_friction, set_top_friction])
     8350        domain.set_tag_region([set_bottom_friction, set_top_friction])
    83518351        assert num.allclose(domain.quantities['friction'].get_values(),
    83528352                            [[ 0.09,  0.09,  0.09],
     
    83578357                             [ 1.0,  1.0,  1.0]])
    83588358
    8359         domain.set_region([set_all_friction])
     8359        domain.set_tag_region([set_all_friction])
    83608360        assert num.allclose(domain.quantities['friction'].get_values(),
    83618361                            [[ 10.09, 10.09, 10.09],
  • trunk/anuga_core/source/anuga/structures/inlet.py

    r8994 r9001  
    22from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect
    33from anuga.config import velocity_protection, g
     4from anuga import Region
     5
    46import math
     7
    58
    69import numpy as num
     
    1619        self.poly = num.asarray(poly, dtype=num.float64)
    1720        self.verbose = verbose
    18 
    19         self.line = True
    20         if len(self.poly) > 2:
    21             self.line = False
    22 
    23         self.compute_triangle_indices()
     21       
     22       
     23        # poly can be either a line, polygon or a regions
     24        if isinstance(poly,Region):
     25            #print "is region"
     26            self.region = poly
     27        else:
     28            self.region = Region(domain,poly=poly,expand_polygon=True)
     29            #print 'is line or polygon'
     30
     31       
     32        #self.line = True
     33        #if len(self.poly) > 2:
     34        #    self.line = False
     35
     36        self.triangle_indices = self.region.indices
     37
     38        #print self.triangle_indices
     39        #print poly
     40        #print self.triangle_indices
     41       
     42        #self.compute_triangle_indices()
    2443        self.compute_area()
    2544        #self.compute_inlet_length()
     
    2746
    2847
    29     def compute_triangle_indices(self):
    30 
    31         # Get boundary (in absolute coordinates)
    32         bounding_polygon = self.domain_bounding_polygon
    33         domain_centroids = self.domain.get_centroid_coordinates(absolute=True)
    34         vertex_coordinates = self.domain.get_vertex_coordinates(absolute=True)
    35 
    36         if self.line: # poly is a line
    37             # Check that line lies within the mesh.
    38             for point in self.poly:
    39                 msg = 'Point %s ' %  str(point)
    40                 msg += ' did not fall within the domain boundary.'
    41                 assert is_inside_polygon(point, bounding_polygon), msg
     48    ## def compute_triangle_indices(self):
     49
     50    ##     # Get boundary (in absolute coordinates)
     51    ##     bounding_polygon = self.domain_bounding_polygon
     52    ##     domain_centroids = self.domain.get_centroid_coordinates(absolute=True)
     53    ##     vertex_coordinates = self.domain.get_vertex_coordinates(absolute=True)
     54
     55    ##     if self.line: # poly is a line
     56    ##         # Check that line lies within the mesh.
     57    ##         for point in self.poly:
     58    ##             msg = 'Point %s ' %  str(point)
     59    ##             msg += ' did not fall within the domain boundary.'
     60    ##             assert is_inside_polygon(point, bounding_polygon), msg
    4261               
    43             self.triangle_indices = line_intersect(vertex_coordinates, self.poly)
    44 
    45         else: # poly is a polygon
    46 
    47             tris_0 = line_intersect(vertex_coordinates, [self.poly[0],self.poly[1]])
    48             tris_1 = inside_polygon(domain_centroids, self.poly)
    49             #print 40*"="
    50             #print tris_0
    51             #print tris_1
    52             self.triangle_indices = num.union1d(tris_0, tris_1)
    53             #print self.triangle_indices
    54 
    55         if len(self.triangle_indices) == 0:
    56             msg = 'Inlet poly=%s ' % (self.poly)
    57             msg += 'No triangle centroids intersecting poly '
    58             raise Exception, msg
     62    ##         self.triangle_indices = line_intersect(vertex_coordinates, self.poly)
     63
     64    ##     else: # poly is a polygon
     65
     66    ##         tris_0 = line_intersect(vertex_coordinates, [self.poly[0],self.poly[1]])
     67    ##         tris_1 = inside_polygon(domain_centroids, self.poly)
     68    ##         #print 40*"="
     69    ##         #print tris_0
     70    ##         #print tris_1
     71    ##         self.triangle_indices = num.union1d(tris_0, tris_1)
     72    ##         #print self.triangle_indices
     73
     74    ##     if len(self.triangle_indices) == 0:
     75    ##         msg = 'Inlet poly=%s ' % (self.poly)
     76    ##         msg += 'No triangle centroids intersecting poly '
     77    ##         raise Exception, msg
    5978
    6079
  • trunk/anuga_core/source/anuga/structures/inlet_enquiry.py

    r8994 r9001  
    1313    def __init__(self,
    1414                 domain,
    15                  poly,
     15                 region,
    1616                 enquiry_pt,
    1717                 invert_elevation = None,
     
    1919                 verbose=False):
    2020        """
    21         poly can be a line or a polygon
     21        region can be a line or a polygon or a region object
    2222        """
    2323
     24        #print region
     25        #print enquiry_pt
     26       
     27        inlet.Inlet.__init__(self, domain, region, verbose)
    2428
    25         inlet.Inlet.__init__(self, domain, poly, verbose)
    2629
     30       
    2731        self.enquiry_pt = enquiry_pt
    2832        self.invert_elevation = invert_elevation
  • trunk/anuga_core/source/anuga/structures/inlet_operator.py

    r8874 r9001  
    154154        message += '\n'
    155155
    156         message += 'polyline\n'
    157         message += '%s' % inlet.line
     156        message += 'region\n'
     157        message += '%s' % inlet
    158158        message += '\n'
    159159
  • trunk/anuga_core/source/anuga/structures/structure_operator.py

    r8994 r9001  
    5151
    5252        anuga.Operator.__init__(self,domain)
    53        
     53
     54        self.master_proc = 0
    5455        self.end_points = ensure_numeric(end_points)
    5556        self.exchange_lines = ensure_numeric(exchange_lines)
     
    438439            message += '\n'
    439440
    440             message += 'line\n'
    441             message += '%s' % inlet.line
     441            message += 'region\n'
     442            message += '%s' % inlet.region
    442443            message += '\n'
    443444
  • trunk/anuga_core/source/anuga_parallel/parallel_inlet.py

    r8875 r9001  
    6464        else: # poly is a polygon
    6565
    66             self.triangle_indices = inside_polygon(domain_centroids, self.poly)
    67 
     66            tris_0 = line_intersect(vertex_coordinates, [self.poly[0],self.poly[1]])
     67            tris_1 = inside_polygon(domain_centroids, self.poly)
     68            self.triangle_indices = num.union1d(tris_0, tris_1)
     69            #print self.triangle_indices
    6870
    6971        for i in self.triangle_indices:
  • trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py

    r8875 r9001  
    8484        if verbose and myid == inlet_master_proc:
    8585            print "Parallel Inlet Operator ================="
    86             print "Line = " + str(line)
     86            print "Poly = " + str(poly)
    8787            print "Master Processor is P%d" %(inlet_master_proc)
    8888            print "Processors are P%s" %(inlet_procs)
     
    172172    if apron is None:
    173173        apron = width
     174
     175
     176
     177
     178
    174179
    175180    # Calculate location of inlet enquiry points and exchange lines
     
    488493       
    489494
    490 def allocate_inlet_procs(domain, line, enquiry_point = None, master_proc = 0, procs = None, verbose = False):
     495def allocate_inlet_procs(domain, poly, enquiry_point = None, master_proc = 0, procs = None, verbose = False):
    491496
    492497
     
    510515    # Calculate the number of points of the line inside full polygon
    511516
    512     tri_id = line_intersect(vertex_coordinates, line)
     517    #tri_id = line_intersect(vertex_coordinates, poly)
     518
     519    if len(poly) == 2: # poly is a line
     520        if verbose : print "======================"
     521        tri_id = line_intersect(vertex_coordinates, poly)
     522    else: # poly is a polygon
     523        if verbose : print "+++++++++++++++++++++++"
     524        tris_0 = line_intersect(vertex_coordinates, [poly[0],poly[1]])
     525        tris_1 = inside_polygon(domain_centroids, poly)
     526        tri_id = num.union1d(tris_0, tris_1)
     527       
    513528
    514529    if verbose:
    515         print "P%d has %d triangles on line %s" %(myid, len(tri_id), line)
     530        print "P%d has %d triangles in poly %s" %(myid, len(tri_id), poly)
    516531
    517532    size = len(tri_id)
  • trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py

    r8950 r9001  
    136136
    137137        # Slots for recording current statistics
     138        self.accumulated_flow = 0.0
    138139        self.discharge = 0.0
    139140        self.velocity = 0.0
     141        self.outlet_depth = 0.0
    140142        self.delta_total_energy = 0.0
    141143        self.driving_energy = 0.0
     
    143145        if exchange_lines is not None:
    144146            self.__process_skew_culvert()
    145 
    146147        elif end_points is not None:
    147148            self.__process_non_skew_culvert()
     
    156157        if self.myid in self.inlet_procs[0]:
    157158            line0 = self.exchange_lines[0]
     159            if self.apron is None:
     160                poly0 = line0
     161            else:
     162                offset = -self.apron*self.outward_vector_0
     163                poly0 = num.array([ line0[0], line0[1], line0[1]+offset, line0[0]+offset])
    158164
    159165            if self.invert_elevations is None:
     
    180186        if self.myid in self.inlet_procs[1]:
    181187            line1 = self.exchange_lines[1]
     188            if self.apron is None:
     189                poly1 = line1
     190            else:
     191                offset = -self.apron*self.outward_vector_1
     192                poly1 = num.array([ line1[0], line1[1], line1[1]+offset, line1[0]+offset])
    182193
    183194            if self.invert_elevations is None:
     
    358369       
    359370        self.culvert_vector /= self.culvert_length
     371        self.outward_vector_0 =   self.culvert_vector
     372        self.outward_vector_1 = - self.culvert_vector       
    360373       
    361374        culvert_normal = num.array([-self.culvert_vector[1], self.culvert_vector[0]])  # Normal vector
     
    393406        centre_point0 = 0.5*(self.exchange_lines[0][0] + self.exchange_lines[0][1])
    394407        centre_point1 = 0.5*(self.exchange_lines[1][0] + self.exchange_lines[1][1])
    395        
    396         if self.end_points is None:
     408
     409        n_exchange_0 = len(self.exchange_lines[0])
     410        n_exchange_1 = len(self.exchange_lines[1])
     411
     412        assert n_exchange_0 == n_exchange_1, 'There should be the same number of points in both exchange_lines'
     413
     414        if n_exchange_0 == 2:
     415           
     416            if self.end_points is None:
     417                self.culvert_vector = centre_point1 - centre_point0
     418            else:
     419                self.culvert_vector = self.end_points[1] - self.end_points[0]
     420
     421            self.outward_vector_0 =   self.culvert_vector
     422            self.outward_vector_1 = - self.culvert_vector
     423
     424        elif n_exchange_0 == 4:
     425
     426            self.outward_vector_0 = self.exchange_lines[0][3] - self.exchange_lines[0][2]
     427            self.outward_vector_1 = self.exchange_lines[1][3] - self.exchange_lines[1][2]
     428
    397429            self.culvert_vector = centre_point1 - centre_point0
    398         else:
    399             self.culvert_vector = self.end_points[1] - self.end_points[0]
    400        
     430
     431        else:
     432            raise Exception, 'n_exchange_0 != 2 or 4'
     433
    401434        self.culvert_length = math.sqrt(num.sum(self.culvert_vector**2))
    402435        assert self.culvert_length > 0.0, 'The length of culvert is less than 0'
     436        self.culvert_vector /= self.culvert_length
     437
     438        outward_vector_0_length = math.sqrt(num.sum(self.outward_vector_0**2))
     439        assert outward_vector_0_length > 0.0, 'The length of outlet_vector_0 is less than 0'
     440        self.outward_vector_0 /= outward_vector_0_length
     441
     442        outward_vector_1_length = math.sqrt(num.sum(self.outward_vector_1**2))
     443        assert outward_vector_1_length > 0.0, 'The length of outlet_vector_1 is less than 0'
     444        self.outward_vector_1 /= outward_vector_1_length
     445
    403446       
    404447        if self.enquiry_points is None:
    405448       
    406             self.culvert_vector /= self.culvert_length
     449
    407450            gap = (self.apron + self.enquiry_gap)*self.culvert_vector
    408451       
     
    436479            message += '%s' % self.description
    437480            message += '\n'
     481
     482        #print "Structure Myids ",self.myid, self.label
    438483       
    439484        for i, inlet in enumerate(self.inlets):
     
    443488                message += '-------------------------------------\n'
    444489
    445             if inlet is not None: stats = inlet.statistics()
     490            #print "*****",inlet, i,self.myid
     491            if inlet is not None:
     492               
     493               
     494                stats = inlet.statistics()
    446495
    447496            if self.myid == self.master_proc:
  • trunk/anuga_core/source/anuga_parallel/test_parallel_boyd_box_operator.py

    r8825 r9001  
    5252width = 16.
    5353
    54 dx = dy = 2           # Resolution: Length of subdivisions on both axes
     54dx = dy = 4           # Resolution: Length of subdivisions on both axes
    5555
    5656#----------------------------------------------------------------------
     
    167167    boyd_box0 = None
    168168   
    169     inlet0 = Inlet_operator(domain, line0, Q0, verbose = False)
    170     inlet1 = Inlet_operator(domain, line1, Q1, verbose = False)
     169    inlet0 = Inlet_operator(domain, line0, Q0, verbose = False, label = 'Inlet_0')
     170    inlet1 = Inlet_operator(domain, line1, Q1, verbose = False, label = 'Inlet_1')
    171171   
    172172    # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
     
    176176                                  losses=1.5,
    177177                                  width=5.0,
    178                                   apron=5.0,
     178                                  #apron=5.,
    179179                                  use_momentum_jet=True,
    180180                                  use_velocity_head=False,
    181181                                  manning=0.013,
     182                                  label='Boyd_Box_0',
    182183                                  verbose=False)
    183184       
    184     if inlet0 is not None and verbose: inlet0.print_statistics()
    185     if inlet1 is not None and verbose: inlet1.print_statistics()
    186     if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
     185    #if inlet0 is not None and verbose: inlet0.print_statistics()
     186    #if inlet1 is not None and verbose: inlet1.print_statistics()
     187   
     188    if boyd_box0 is not None and verbose:
     189        print "++++", myid
     190        boyd_box0.print_statistics()
    187191
    188192#    if parallel:
     
    231235
    232236
    233         if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
     237        if boyd_box0 is not None and verbose :
     238            if myid == boyd_box0.master_proc:
     239                print 'master_proc ',myid
     240                boyd_box0.print_timestepping_statistics()
    234241 
    235242        #for i in range(samples):
  • trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py

    r8828 r9001  
    176176                                  losses=1.5,
    177177                                  width=5.0,
    178                                   apron=5.0,
     178                                  #apron=5.0,
    179179                                  use_momentum_jet=True,
    180180                                  use_velocity_head=False,
  • trunk/anuga_core/source/anuga_parallel/test_parallel_inlet_operator.py

    r8507 r9001  
    3535from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect
    3636
    37 from parallel_operator_factory import Inlet_operator, Boyd_box_operator
     37from parallel_operator_factory import Inlet_operator
    3838
    3939import random
     
    172172    # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
    173173   
    174     boyd_box0 = Boyd_box_operator(domain,
    175                                   end_points=[[9.0, 2.5],[19.0, 2.5]],
    176                                   losses=1.5,
    177                                   width=5.0,
    178                                   apron=5.0,
    179                                   use_momentum_jet=True,
    180                                   use_velocity_head=False,
    181                                   manning=0.013,
    182                                   verbose=False)
     174    ## boyd_box0 = Boyd_box_operator(domain,
     175    ##                               end_points=[[9.0, 2.5],[19.0, 2.5]],
     176    ##                               losses=1.5,
     177    ##                               width=5.0,
     178    ##                               apron=5.0,
     179    ##                               use_momentum_jet=True,
     180    ##                               use_velocity_head=False,
     181    ##                               manning=0.013,
     182    ##                               verbose=False)
    183183       
    184184    if inlet0 is not None and verbose: inlet0.print_statistics()
    185185    if inlet1 is not None and verbose: inlet1.print_statistics()
    186     if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
     186    #if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
    187187
    188188#    if parallel:
     
    231231
    232232
    233         if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
     233        #if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
    234234 
    235235        #for i in range(samples):
  • trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py

    r8922 r9001  
    113113            print indent+'Errors in xvelocity: ', eu10, eu30
    114114
    115         assert eu10 < 0.02,  'L^1 error %g greater than 2 percent'% eu10
    116         assert eu30 < 0.01,  'L^1 error %g greater than 2 percent'% eu30
     115        assert eu10 < 0.1,  'L^1 error %g greater than 10 percent'% eu10
     116        assert eu30 < 0.1,  'L^1 error %g greater than 10 percent'% eu30
    117117
    118118 
  • trunk/anuga_core/source/anuga_validation_tests/saved_parameters.tex

    r8932 r9001  
    22\newcommand{\alg}{\UScore{1_5}}
    33\newcommand{\majorR}{\UScore{1.3.0-beta}}
    4 \newcommand{\minorR}{\UScore{8922}}
    5 \newcommand{\timeR}{{Mon Jun 24 23:29:56 2013}}
     4\newcommand{\minorR}{\UScore{8993}}
     5\newcommand{\timeR}{{Sat Sep 28 19:39:45 2013}}
  • trunk/anuga_core/user_manual/anuga_installation_guide.tex

    r8728 r9001  
    5454\label{sec:requirements}
    5555
    56 To run ANUGA you will need a Windows PC (XP, Vista or 7) or a Linux PC with at
    57 least 512MB RAM.  As ANUGA is a memory-intensive numerical system, more memory is better than less.
     56To run ANUGA you will need a Windows PC or a Linux PC with at
     57least 1GB RAM.  As ANUGA is a memory-intensive numerical system, more memory is better than less.
    5858
    5959The viewer (Windows only) requires a graphics adapter that
     
    6262Intel(R) 82915G Express chipset family.
    6363
    64 The instructions below are written for the numpy version of ANUGA.  ANUGA changed from
    65 relying on the Numeric package to the numpy package early in July, 2009.  If you have a Numeric ANUGA,
    66 you should refer to the installation instructions for that version.  The last Numeric version of
    67 ANUGA had a build number of 7163.
    68 
    69 Where the text below refers to a specific package file such as \code{python-2.5.msi} you will find that
    70 file in a download area linked through the \emph{numpy_support_software} link on the page
    71 \url{https://datamining.anu.edu.au/anuga/wiki/NumpyInstall}.
     64We recommend that you check out the page \url{http://anuga.anu.edu.au} for the latest information on installing Anuga.
     65
     66%Where the text below refers to a specific package file such as \code{python-2.5.msi} you will find that
     67%file in a download area linked through the \emph{numpy_support_software} link on the page
     68%\url{https://datamining.anu.edu.au/anuga/wiki/NumpyInstall}.
    7269
    7370
    7471\section{Installation}
    7572
    76 Below are the install procedures for Windows XP, Windows Vista, Windows 7 (all 32 bit) and Linux (32 and 64 bit).
    77 
    78 \subsection{Quick install - Windows XP (32 bit)}
    79 \label{sec:winxp}
    80 
    81 If you already have previous versions of Python, ANUGA support software or the ANUGA source code installed
    82 on the target machine, start off by uninstalling them. Next, download the latest version of the ANUGA
    83 Windows installer from \url{http://sourceforge.net/projects/anuga/files/}. The Windows installer will
    84 install Python, MingW (select the "Minimal" install), NumPy, NetCDF, Scientific Python, Matplotlib, the
    85 ANUGA source code and the viewer (animate). Note that you will need an internet connection to install MingW.
    86 
    87 After all the necessary packages have been installed, the installer will proceed to compile the ANUGA C code,
    88 run the test suite (optional) and then run a series of validation examples (optional). This may take some time.
    89 Try the demonstrations provided in the ANUGA directory \code{anuga\_demos} (discussed in the ANUGA user manual at
    90 \url{https://datamining.anu.edu.au/anuga/attachment/wiki/WikiStart/anuga_user_manual-1.2.0.pdf})
    91 and view the resulting \code{.sww} files with the ANUGA viewer.
     73Below are the install procedures for Windows 7 (32 bit) and Linux (32 and 64 bit).
     74
     75\subsection{Install - Windows (32 bit)}
     76\label{sec:win}
     77
     78
     79
     80We use PYTHON as our programming environment together with a number of standard PYTHON packages such as numpy, scipy, matplotlib, netcdf4. One way to install all the required packages is to use a distribution like python_xy.
     81
     82\subsubsection{PYTHON xy}
     83
     84So first install  python xy. This will be a large download, maybe 500 MB or more, but will provide a complete installation (well see NetCDF4 note below) of python for our needs . You should first remove any other version of python and mingw that may be on your system. The python xy package is currently only 32 bits, but this will still work on 64 bit Windows.
     85
     86Be sure to choose the win32 python 2.7 version. This is the version for which we are developing.
     87Netcdf4 Note
     88
     89Check that netcdf is available. From a command line, try
     90\begin{verbatim}
     91python -c "import netCDF4"
     92\end{verbatim}
     93If no error occurs then netCDF4 is available and you can disregard the rest of this note.
     94
     95But unfortunately version 2.7.3.1 (April 2013) python xy seems to be missing netCDF4. Please let us know if later versions are ok.
     96If it is missing then you need to install another package to cover this loss. For this we can use the precompiled scientific python binaries from  \url{http://www.lfd.uci.edu/~gohlke/pythonlibs/#scientificpython}. I suggest you choose ScientificPython-2.9.2.win32-py2.7.‌exe to install. To test this install try:
     97\begin{verbatim}
     98python -c "import Scientific.IO.NetCDF"
     99\end{verbatim}
     100
     101\subsubsection{64 bit}
     102
     103At the moment python xy is only 32 bit, but there seems to be a promise that a 64 bit distribution is not too far away. There is a 64 bit python distribution package from Enthought, but is free only to academic users. So at present we recommend win32 python xy.
     104Manual install
     105
     106It is possible to install the required environment manually. You would need to install Mingw to provide a compiler, the standard distribution of python27 and then precompiled python libraries for numpy, scipy, matplotlib, netcdf4 from a site like  \url{http://www.lfd.uci.edu/~gohlke/pythonlibs/}. It would be interesting to hear feedback on this option, as there is an opportunity to use versions using the Intel Math Kernel Library, which should provide a useful increase in speed.
     107Installing anuga
     108
     109\subsection{Obtaining ANUGA source}
     110
     111You can either use the source code avialble from sourceforge or  download the latest version of the package using subversion.
     112
     113You can obtain version 1.3 of the package from sourceforge by downloading the file \url{http://sourceforge/p/anuga}
     114
     115
     116\subsection{Source from development repository}
     117An alternative is checking out the most recent version of the package using subversion.
     118
     119You need a subversion client. I suggest installing  tortoise_svn downloads and then checking out the following svn repository. When you installed tortoise svn it creates a few extra menu items to your right click menu in the file manager. Just choose "tortoise" checkout to download the code.
     120\begin{verbatim}
     121https://anuga.anu.edu.au/svn/anuga/trunk/anuga_core
     122\end{verbatim}
     123This should produce an anuga_core directory
     124
     125
     126
     127\subsection{Setup PYTHONPATH}
     128
     129We need to tell python where the anuga source code is located. This is done via the PYTHONPATH environment variable.
     130
     131For instance, if your anuga_core directory was located at
     132
     133\begin{verbatim}
     134C:\Users\Steve\anuga_core
     135\end{verbatim}
     136
     137then you should add
     138
     139\begin{verbatim}
     140C:\Users\Steve\anuga_core\source
     141\end{verbatim}
     142
     143to your PYTHONPATH
     144
     145Environment variables are accessed via control panel -> advanced system settings -> Environment Variables and then add a new Environment variable PYTHONPATH with value \verb|C:\Users\Steve\anuga_core\source| (or what ever is appropriate for your installation)
     146
     147\subsection{Compiling ANUGA}
     148
     149Now go to the directory anuga_core and compile the anuga files. Fire up a cmd terminal, change to the anuga_core directory and run
     150\begin{verbatim}
     151python compile_all.py
     152\end{verbatim}
     153Check that all the files have been compiled correctly. There should be an "OK" at the end of each separate compile command.
     154
     155\subsection{Run Unit tests}
     156
     157From the anuga_core directory run the unit tests via:
     158\begin{verbatim}
     159python test_all.py
     160\end{verbatim}
     161
     162\subsection{Conclusion}
     163
     164Hopefully all the unit tests pass. As this is bleeding edge there are sometimes a small number of failures as this is a work in progress. Have a look at the demos in the directory anuga_core/documentation/user_manual/demos (along with the user manual) to see how to use anuga.
     165Updating
     166
     167\subsection{Updating}
     168If you downloaded  the source using subversoin, you can update your version of ANUGA.
     169 This is fairly easy. Just choose the directory to "update" and then right click and choose "tortoise update" to update the code.
     170
     171Then again from the anuga_core directory recompile the code and check the unit tests via
     172
     173python compile_all.py
     174python test_all.py
     175
     176
     177
     178
     179%If you already have previous versions of Python, ANUGA support software or the ANUGA source code installed
     180%on the target machine, start off by uninstalling them. Next, download the latest version of the ANUGA
     181%Windows installer from \url{http://sourceforge.net/projects/anuga/files/}. The Windows installer will
     182%install Python, MingW (select the "Minimal" install), NumPy, NetCDF, Scientific Python, Matplotlib, the
     183%ANUGA source code and the viewer (animate). Note that you will need an internet connection to install MingW.
     184%
     185%After all the necessary packages have been installed, the installer will proceed to compile the ANUGA C code,
     186%run the test suite (optional) and then run a series of validation examples (optional). This may take some time.
     187%Try the demonstrations provided in the ANUGA directory \code{anuga\_demos} (discussed in the ANUGA user manual at
     188%\url{https://datamining.anu.edu.au/anuga/attachment/wiki/WikiStart/anuga_user_manual-1.2.0.pdf})
     189%and view the resulting \code{.sww} files with the ANUGA viewer.
    92190
    93191
Note: See TracChangeset for help on using the changeset viewer.