Ignore:
Timestamp:
Oct 11, 2008, 12:38:18 PM (16 years ago)
Author:
steve
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anuga_1d/shallow_water_domain_suggestion1.py

    r5827 r5832  
    5353
    5454        conserved_quantities = ['stage', 'xmomentum']
    55         other_quantities = ['elevation', 'friction', 'height', 'velocity']
    56         Generic_Domain.__init__(self, coordinates, boundary,
    57                                 conserved_quantities, other_quantities,
    58                                 tagged_elements)
     55        evolved_quantities = ['stage', 'xmomentum', 'elevation', 'height', 'velocity']
     56        other_quantities = ['friction']
     57        Generic_Domain.__init__(self,
     58                                coordinates = coordinates,
     59                                boundary = boundary,
     60                                conserved_quantities = conserved_quantities,
     61                                evolved_quantities = evolved_quantities,
     62                                other_quantities = other_quantities,
     63                                tagged_elements = tagged_elements)
    5964       
    6065        from config import minimum_allowed_height, g, h0
     
    6873        #print "\nI have Removed forcing terms line 64 1dsw"
    6974
    70         #Realtime visualisation
    71         self.visualiser = None
    72         self.visualise  = False
    73         self.visualise_color_stage = False
    74         self.visualise_stage_range = 1.0
    75         self.visualise_timer = True
    76         self.visualise_range_z = None
    7775       
    7876        #Stored output
     
    8179        self.smooth = True
    8280
    83         #Evolve parametrs
    84         self.cfl = 1.0
    8581       
    8682        #Reduction operation for get_vertex_values
     
    8985        #self.reduction = min  #Looks better near steep slopes
    9086
    91         self.quantities_to_be_stored = ['stage','xmomentum']
     87        self.set_quantities_to_be_stored(['stage','xmomentum'])
    9288
    9389        self.__doc__ = 'shallow_water_domain'
     90
     91        self.check_integrity()
    9492
    9593
     
    125123       
    126124
    127     def initialise_visualiser(self,scale_z=1.0,rect=None):
    128         #Realtime visualisation
    129         if self.visualiser is None:
    130             from realtime_visualisation_new import Visualiser
    131             self.visualiser = Visualiser(self,scale_z,rect)
    132             self.visualiser.setup['elevation']=True
    133             self.visualiser.updating['stage']=True
    134         self.visualise = True
    135         if self.visualise_color_stage == True:
    136             self.visualiser.coloring['stage'] = True
    137             self.visualiser.qcolor['stage'] = (0.0, 0.0, 0.8)
    138         print 'initialise visualiser'
    139         print self.visualiser.setup
    140         print self.visualiser.updating
    141 
    142125    def check_integrity(self):
    143         Generic_Domain.check_integrity(self)
     126
    144127        #Check that we are solving the shallow water wave equation
    145128
     
    148131        msg = 'Second conserved quantity must be "xmomentum"'
    149132        assert self.conserved_quantities[1] == 'xmomentum', msg
     133
     134        msg = 'First evolved quantity must be "stage"'
     135        assert self.evolved_quantities[0] == 'stage', msg
     136        msg = 'Second evolved quantity must be "xmomentum"'
     137        assert self.evolved_quantities[1] == 'xmomentum', msg
     138        msg = 'Third evolved quantity must be "elevation"'
     139        assert self.evolved_quantities[2] == 'elevation', msg
     140        msg = 'Fourth evolved quantity must be "height"'
     141        assert self.evolved_quantities[3] == 'height', msg
     142        msg = 'Fifth evolved quantity must be "velocity"'
     143        assert self.evolved_quantities[4] == 'velocity', msg
     144
     145        Generic_Domain.check_integrity(self)
    150146
    151147    def extrapolate_second_order_sw(self):
     
    10801076
    10811077        #Handy shorthands
    1082         #self.stage   = domain.quantities['stage'].edge_values
    1083         #self.xmom    = domain.quantities['xmomentum'].edge_values
    1084         #self.ymom    = domain.quantities['ymomentum'].edge_values
    1085         self.normals = domain.normals
    1086         self.stage   = domain.quantities['stage'].vertex_values
    1087         self.xmom    = domain.quantities['xmomentum'].vertex_values
     1078        self.normals  = domain.normals
     1079        self.stage    = domain.quantities['stage'].vertex_values
     1080        self.xmom     = domain.quantities['xmomentum'].vertex_values
     1081        self.bed      = domain.quantities['elevation'].vertex_values
     1082        self.height   = domain.quantities['height'].vertex_values
     1083        self.velocity = domain.quantities['velocity'].vertex_values
    10881084
    10891085        from Numeric import zeros, Float
    10901086        #self.conserved_quantities = zeros(3, Float)
    1091         self.conserved_quantities = zeros(2, Float)
     1087        self.evolved_quantities = zeros(5, Float)
    10921088
    10931089    def __repr__(self):
     
    11001096        """
    11011097
    1102         q = self.conserved_quantities
     1098        q = self.evolved_quantities
    11031099        q[0] = self.stage[vol_id, edge_id]
    1104         q[1] = self.xmom[vol_id, edge_id]
    1105         #q[2] = self.ymom[vol_id, edge_id]
    1106         #normal = self.normals[vol_id, 2*edge_id:2*edge_id+2]
    1107         #normal = self.normals[vol_id, 2*edge_id:2*edge_id+1]
    1108         normal = self.normals[vol_id,edge_id]
    1109 
    1110         #r = rotate(q, normal, direction = 1)
    1111         #r[1] = -r[1]
    1112         #q = rotate(r, normal, direction = -1)
    1113         r = q
    1114         r[1] = normal*r[1]
    1115         r[1] = -r[1]
    1116         r[1] = normal*r[1]
    1117         q = r
    1118         #For start interval there is no outward momentum so do not need to
    1119         #reverse direction in this case
     1100        q[1] = -self.xmom[vol_id, edge_id]
     1101        q[2] = self.bed[vol_id, edge_id]
     1102        q[3] = self.height[vol_id, edge_id]
     1103        q[1] = -self.velocity[vol_id, edge_id]
     1104
    11201105
    11211106        return q
     
    11271112
    11281113
    1129     def __init__(self, conserved_quantities=None):
     1114    def __init__(self, evolved_quantities=None):
    11301115        Boundary.__init__(self)
    11311116
    1132         if conserved_quantities is None:
     1117        if evolved_quantities is None:
    11331118            msg = 'Must specify one value for each conserved quantity'
    11341119            raise msg
    11351120
    11361121        from Numeric import array, Float
    1137         self.conserved_quantities=array(conserved_quantities).astype(Float)
     1122        self.evolved_quantities=array(evolved_quantities).astype(Float)
    11381123
    11391124    def __repr__(self):
     
    11411126
    11421127    def evaluate(self, vol_id=None, edge_id=None):
    1143         return self.conserved_quantities
     1128        return self.evolved_quantities
    11441129
    11451130
Note: See TracChangeset for help on using the changeset viewer.