Changeset 8833


Ignore:
Timestamp:
Apr 16, 2013, 8:32:09 PM (12 years ago)
Author:
steve
Message:

Hopefully merewether (and other parallel scripts) will run when pypar is not installed

Location:
trunk/anuga_core/source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga_parallel/parallel_boyd_box_operator.py

    r8832 r8833  
    11import anuga
    22import math
    3 import pypar
    43
    54from anuga.structures.boyd_box_operator import boyd_box_function
     
    259258    def discharge_routine(self):
    260259
     260        import pypar
     261
    261262        local_debug = False
    262263
  • trunk/anuga_core/source/anuga_parallel/parallel_boyd_pipe_operator.py

    r8832 r8833  
    11import anuga
    22import math
    3 import pypar
    43
    54from anuga.structures.boyd_pipe_operator import boyd_pipe_function
     
    106105
    107106    def parallel_safe(self):
     107        """
     108        Set that operator is parallel safe
     109        """
    108110
    109111        return True
    110112
    111113
    112 
    113 
    114     def debug_discharge_routine(self):
    115 
    116 
    117 
    118         local_debug = False
    119 
    120         if self.use_velocity_head:
    121             self.delta_total_energy = self.inlets[0].get_enquiry_total_energy() - self.inlets[1].get_enquiry_total_energy()
    122         else:
    123             self.delta_total_energy = self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage()
    124 
    125         self.inflow  = self.inlets[0]
    126         self.outflow = self.inlets[1]
    127 
    128         self.inflow_index = 0
    129         self.outflow_index = 1
    130 
    131         if self.delta_total_energy < 0:
    132             self.inflow  = self.inlets[1]
    133             self.outflow = self.inlets[0]
    134             self.delta_total_energy = -self.delta_total_energy
    135             self.inflow_index = 1
    136             self.outflow_index = 0
    137 
    138 
    139         if self.inflow.get_enquiry_depth() > 0.01: #this value was 0.01:
    140             if local_debug:
    141                 anuga.log.critical('Specific E & Deltat Tot E = %s, %s'
    142                              % (str(self.inflow.get_enquiry_specific_energy()),
    143                                 str(self.delta_total_energy)))
    144                 anuga.log.critical('culvert type = %s' % str(culvert_type))
    145             # Water has risen above inlet
    146 
    147 
    148             msg = 'Specific energy at inlet is negative'
    149             assert self.inflow.get_enquiry_specific_energy() >= 0.0, msg
    150 
    151             if self.use_velocity_head :
    152                 self.driving_energy = self.inflow.get_enquiry_specific_energy()
    153             else:
    154                 self.driving_energy = self.inflow.get_enquiry_depth()
    155 
    156             depth = self.culvert_height
    157             width = self.culvert_width
    158             flow_width = self.culvert_width
    159             # intially assume the culvert flow is controlled by the inlet
    160             # check unsubmerged and submerged condition and use Min Q
    161             # but ensure the correct flow area and wetted perimeter are used
    162             Q_inlet_unsubmerged = 0.544*anuga.g**0.5*width*self.driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged
    163             Q_inlet_submerged = 0.702*anuga.g**0.5*width*depth**0.89*self.driving_energy**0.61  # Flow based on Inlet Ctrl Inlet Submerged
    164 
    165             # FIXME(Ole): Are these functions really for inlet control?
    166             if Q_inlet_unsubmerged < Q_inlet_submerged:
    167                 Q = Q_inlet_unsubmerged
    168                 dcrit = (Q**2/anuga.g/width**2)**0.333333
    169                 if dcrit > depth:
    170                     dcrit = depth
    171                     flow_area = width*dcrit
    172                     perimeter= 2.0*(width+dcrit)
    173                 else: # dcrit < depth
    174                     flow_area = width*dcrit
    175                     perimeter= 2.0*dcrit+width
    176                 outlet_culvert_depth = dcrit
    177                 self.case = 'Inlet unsubmerged Box Acts as Weir'
    178             else: # Inlet Submerged but check internal culvert flow depth
    179                 Q = Q_inlet_submerged
    180                 dcrit = (Q**2/anuga.g/width**2)**0.333333
    181                 if dcrit > depth:
    182                     dcrit = depth
    183                     flow_area = width*dcrit
    184                     perimeter= 2.0*(width+dcrit)
    185                 else: # dcrit < depth
    186                     flow_area = width*dcrit
    187                     perimeter= 2.0*dcrit+width
    188                 outlet_culvert_depth = dcrit
    189                 self.case = 'Inlet submerged Box Acts as Orifice'
    190 
    191             dcrit = (Q**2/anuga.g/width**2)**0.333333
    192             # May not need this .... check if same is done above
    193             outlet_culvert_depth = dcrit
    194             if outlet_culvert_depth > depth:
    195                 outlet_culvert_depth = depth  # Once again the pipe is flowing full not partfull
    196                 flow_area = width*depth  # Cross sectional area of flow in the culvert
    197                 perimeter = 2*(width+depth)
    198                 self.case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL'
    199             else:
    200                 flow_area = width * outlet_culvert_depth
    201                 perimeter = width+2*outlet_culvert_depth
    202                 self.case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
    203             # Initial Estimate of Flow for Outlet Control using energy slope
    204             #( may need to include Culvert Bed Slope Comparison)
    205             hyd_rad = flow_area/perimeter
    206             culvert_velocity = math.sqrt(self.delta_total_energy/((self.sum_loss/2/anuga.g)+(self.manning**2*self.culvert_length)/hyd_rad**1.33333))
    207             Q_outlet_tailwater = flow_area * culvert_velocity
    208            
    209            
    210             if self.delta_total_energy < self.driving_energy:
    211                 # Calculate flows for outlet control
    212 
    213                 # Determine the depth at the outlet relative to the depth of flow in the Culvert
    214                 if self.outflow.get_enquiry_depth() > depth:        # The Outlet is Submerged
    215                     outlet_culvert_depth=depth
    216                     flow_area=width*depth       # Cross sectional area of flow in the culvert
    217                     perimeter=2.0*(width+depth)
    218                     self.case = 'Outlet submerged'
    219                 else:   # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
    220                     dcrit = (Q**2/anuga.g/width**2)**0.333333
    221                     outlet_culvert_depth=dcrit   # For purpose of calculation assume the outlet depth = Critical Depth
    222                     if outlet_culvert_depth > depth:
    223                         outlet_culvert_depth=depth
    224                         flow_area=width*depth
    225                         perimeter=2.0*(width+depth)
    226                         self.case = 'Outlet is Flowing Full'
    227                     else:
    228                         flow_area=width*outlet_culvert_depth
    229                         perimeter=(width+2.0*outlet_culvert_depth)
    230                         self.case = 'Outlet is open channel flow'
    231 
    232                 hyd_rad = flow_area/perimeter
    233 
    234 
    235 
    236                 # Final Outlet control velocity using tail water
    237                 culvert_velocity = math.sqrt(self.delta_total_energy/((self.sum_loss/2/anuga.g)+(self.manning**2*self.culvert_length)/hyd_rad**1.33333))
    238                 Q_outlet_tailwater = flow_area * culvert_velocity
    239 
    240                 Q = min(Q, Q_outlet_tailwater)
    241             else:
    242                
    243                 pass
    244                 #FIXME(Ole): What about inlet control?
    245 
    246             culv_froude=math.sqrt(Q**2*flow_width/(anuga.g*flow_area**3))
    247        
    248             if local_debug:
    249                 anuga.log.critical('FLOW AREA = %s' % str(flow_area))
    250                 anuga.log.critical('PERIMETER = %s' % str(perimeter))
    251                 anuga.log.critical('Q final = %s' % str(Q))
    252                 anuga.log.critical('FROUDE = %s' % str(culv_froude))
    253 
    254             # Determine momentum at the outlet
    255             barrel_velocity = Q/(flow_area + anuga.velocity_protection/flow_area)
    256 
    257         # END CODE BLOCK for DEPTH  > Required depth for CULVERT Flow
    258 
    259         else: # self.inflow.get_enquiry_depth() < 0.01:
    260             Q = barrel_velocity = outlet_culvert_depth = 0.0
    261 
    262         # Temporary flow limit
    263         if barrel_velocity > self.max_velocity:
    264             barrel_velocity = self.max_velocity
    265             Q = flow_area * barrel_velocity
    266 
    267         return Q, barrel_velocity, outlet_culvert_depth
    268 
     114   
    269115    def discharge_routine(self):
     116        """
     117        Get info from inlets and then call sequential function
     118        """
     119
     120        import pypar
    270121
    271122        local_debug = False
  • trunk/anuga_core/source/anuga_parallel/parallel_inlet.py

    r8420 r8833  
    99import numpy as num
    1010from anuga.structures.inlet import Inlet
    11 import pypar
     11
    1212
    1313class Parallel_Inlet(Inlet):
     
    3838            self.procs = procs
    3939
     40        import pypar
    4041        self.myid = pypar.rank()
    4142
     
    104105        # WARNING: requires synchronization, must be called by all procs associated
    105106        # with this inlet
    106        
     107
     108        import pypar
    107109        local_area = self.area
    108110        area = local_area
     
    145147        # with this inlet
    146148
     149        import pypar
    147150        local_stage = num.sum(self.get_stages()*self.get_areas())
    148151        global_area = self.get_global_area()
     
    184187        # with this inlet
    185188
     189        import pypar
    186190        global_area = self.get_global_area()
    187191        local_xmoms = num.sum(self.get_xmoms()*self.get_areas())
     
    214218        # with this inlet
    215219
     220        import pypar
    216221        global_area = self.get_global_area()
    217222        local_ymoms = num.sum(self.get_ymoms()*self.get_areas())
     
    244249        # with this inlet
    245250
     251        import pypar
    246252        local_volume = num.sum(self.get_depths()*self.get_areas())
    247253        volume = local_volume
     
    353359        # with this inlet
    354360
     361        import pypar
    355362        centroid_coordinates = self.domain.get_full_centroid_coordinates(absolute=True)
    356363        areas = self.get_areas()
     
    474481        # WARNING: requires synchronization, must be called by all procs associated
    475482        # with this inlet
     483
     484        import pypar
    476485
    477486        message = ''
  • trunk/anuga_core/source/anuga_parallel/parallel_inlet_enquiry.py

    r8592 r8833  
    44
    55import numpy as num
    6 import pypar
    76
    87import parallel_inlet
     
    2524        parallel_inlet.Parallel_Inlet.__init__(self, domain, polyline,
    2625                                                master_proc = master_proc, procs = procs, verbose=verbose)
    27    
     26
     27        import pypar
     28
    2829        self.enquiry_pt = enquiry_pt
    2930        self.outward_culvert_vector = outward_culvert_vector
  • trunk/anuga_core/source/anuga_parallel/parallel_inlet_operator.py

    r8687 r8833  
    1010from anuga.structures.inlet_operator import Inlet_operator
    1111import parallel_inlet
    12 import pypar
     12
    1313
    1414class Parallel_Inlet_operator(Inlet_operator):
     
    4444                 verbose = False):
    4545
     46        import pypar
    4647        self.domain = domain
    4748        self.domain.set_fractional_step_operator(self)
     
    9596    def __call__(self):
    9697
     98        import pypar
    9799        volume = 0
    98100
  • trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py

    r8825 r8833  
    22# and open the template in the editor.
    33
    4 import pypar
     4
    55
    66import os.path
     
    4949                   logging = False,
    5050                   master_proc = 0,
    51                    procs = range(0,pypar.size()),
     51                   procs = None,
    5252                   verbose = False):
    5353
     
    6565                                                              verbose = verbose)
    6666   
     67    import pypar
     68    if procs is None:
     69        procs = range(0,pypar.size())
    6770
    6871    myid = pypar.rank()
     
    128131                       verbose=False,
    129132                       master_proc=0,
    130                        procs=range(0,pypar.size())):
     133                       procs=None):
    131134
    132135    # If not parallel domain then allocate serial Boyd box operator
     
    151154                                                                    logging=logging,
    152155                                                                    verbose=verbose)
     156
     157    import pypar
     158    if procs is None:
     159        procs = range(0,pypar.size())
    153160
    154161    myid = pypar.rank()
     
    282289                       verbose=False,
    283290                       master_proc=0,
    284                        procs=range(0,pypar.size())):
     291                       procs=None):
    285292
    286293    # If not parallel domain then allocate serial Boyd box operator
     
    305312                                                                    verbose=verbose)
    306313
     314    import pypar
     315    if procs is None:
     316        procs = range(0,pypar.size())
     317       
    307318    myid = pypar.rank()
    308319
     
    477488       
    478489
    479 def allocate_inlet_procs(domain, line, enquiry_point = None, master_proc = 0, procs = range(0, pypar.size()), verbose = False):
    480 
     490def allocate_inlet_procs(domain, line, enquiry_point = None, master_proc = 0, procs = None, verbose = False):
     491
     492
     493    import pypar
     494    if procs is None:
     495        procs = range(0, pypar.size())
     496       
    481497    myid = pypar.rank()
    482498    vertex_coordinates = domain.get_full_vertex_coordinates(absolute=True)
  • trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py

    r8832 r8833  
    77from anuga.utilities.numerical_tools import ensure_numeric
    88from anuga.structures.inlet_enquiry import Inlet_enquiry
    9 import pypar
     9
    1010
    1111class Parallel_Structure_operator(anuga.Operator):
     
    5757                 enquiry_proc = None):
    5858
     59        import pypar
    5960        self.myid = pypar.rank()
    6061        self.num_procs = pypar.size()
     
    180181
    181182    def __call__(self):
     183
     184        import pypar
    182185
    183186        timestep = self.domain.get_timestep()
     
    392395        # with this structure
    393396
     397        import pypar
     398
    394399        message = ' '
    395400
  • trunk/anuga_core/source/anuga_validation_tests/Case_studies/Merewether

    • Property svn:ignore set to
      .python_cache
  • trunk/anuga_core/source/anuga_validation_tests/Case_studies/Merewether/merewether.py

    r8829 r8833  
    2929import project                 # Definition of file names and polygons
    3030
     31verbose = project.verbose
     32use_cache = project.use_cache
     33
    3134#------------------------------------------------------------------------------
    3235# Preparation of topographic data
     
    4144if myid == 0:
    4245    # Create DEM from asc data
    43     anuga.asc2dem(asc_name, verbose=True) #use_cache=True,
     46    anuga.asc2dem(asc_name, verbose=verbose, use_cache=use_cache)
    4447
    4548    # Create pts file for onshore DEM
    46     anuga.dem2pts(dem_name, verbose=True) #use_cache=True,
     49    anuga.dem2pts(dem_name, verbose=verbose, use_cache=use_cache)
    4750
    4851#------------------------------------------------------------------------------
     
    6972                                mesh_filename=meshname,
    7073                                interior_regions=interior_regions,
    71                                 use_cache=False,
    72                                 verbose=True)
     74                                use_cache=use_cache,
     75                                verbose=verbose)
    7376
    7477    #------------------------------------------------------------------------------
     
    7881    domain.set_quantity('friction', 0.02)
    7982    domain.set_quantity('elevation', filename='topography1.pts',
    80                                           use_cache=True,
    81                                           verbose=True)
     83                                          use_cache=use_cache,
     84                                          verbose=verbose)
    8285
    8386else:
  • trunk/anuga_core/source/anuga_validation_tests/Case_studies/Merewether/project.py

    r8829 r8833  
    77import anuga.utilities
    88from os.path import join
     9
     10verbose = True
     11use_cache = True
     12
    913
    1014###############################
Note: See TracChangeset for help on using the changeset viewer.