Changeset 8650


Ignore:
Timestamp:
Nov 29, 2012, 9:47:06 AM (12 years ago)
Author:
steve
Message:

Added in a maximum_quantity which is like add_quantity to the quantity class

Location:
trunk/anuga_core/source
Files:
4 edited

Legend:

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

    r8582 r8650  
    683683        self.set_quantity(name, Q1 + Q2)
    684684
     685    def minimum_quantity(self, name,
     686                           *args, **kwargs):
     687        """min of values to a named quantity
     688
     689        E.g minimum_quantity('elevation', X)
     690
     691        Option are the same as in set_quantity.
     692        """
     693
     694        # Do the expression stuff
     695        if kwargs.has_key('expression'):
     696            expression = kwargs['expression']
     697            Q2 = self.create_quantity_from_expression(expression)
     698        else:
     699            # Create new temporary quantity
     700            Q2 = Quantity(self)
     701
     702            # Assign specified values to temporary quantity
     703            Q2.set_values(*args, **kwargs)
     704
     705        # MIn temporary quantity to named quantity
     706        Q1 = self.get_quantity(name)
     707        self.set_quantity(name, Q1.minimum(Q2))
     708
     709    def maximum_quantity(self, name,
     710                           *args, **kwargs):
     711        """max of values to a named quantity
     712
     713        E.g maximum_quantity('elevation', X)
     714
     715        Option are the same as in set_quantity.
     716        """
     717
     718        # Do the expression stuff
     719        if kwargs.has_key('expression'):
     720            expression = kwargs['expression']
     721            Q2 = self.create_quantity_from_expression(expression)
     722        else:
     723            # Create new temporary quantity
     724            Q2 = Quantity(self)
     725
     726            # Assign specified values to temporary quantity
     727            Q2.set_values(*args, **kwargs)
     728
     729        # Max temporary quantity to named quantity
     730        Q1 = self.get_quantity(name)
     731        self.set_quantity(name, Q1.maximum(Q2))
     732
    685733    def get_quantity_names(self):
    686734        """Get a list of all the quantity names that this domain is aware of.
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r8618 r8650  
    220220
    221221        return result
     222
     223
     224
     225
     226
     227    def maximum(self, other):
     228        """Max of self with anything that could populate a quantity
     229
     230        E.g other can be a constant, an array, a function, another quantity
     231        (except for a filename or points, attributes (for now))
     232        - see set_values for details
     233        """
     234
     235        if isinstance(other, Quantity):
     236            Q = other
     237        else:
     238            Q = Quantity(self.domain)
     239            Q.set_values(other)
     240
     241        result = Quantity(self.domain)
     242
     243        # The maximum of vertex_values, edge_values and centroid_values
     244        # are calculated and assigned directly without using
     245        # set_values (which calls interpolate). Otherwise
     246        # edge and centroid values wouldn't be max from q1 and q2
     247        result.vertex_values = num.maximum(self.vertex_values, Q.vertex_values)
     248        result.edge_values = num.maximum(self.edge_values, Q.edge_values)
     249        result.centroid_values = num.maximum(self.centroid_values, Q.centroid_values)
     250
     251        return result
     252
     253
     254    def minimum(self, other):
     255        """Max of self with anything that could populate a quantity
     256
     257        E.g other can be a constant, an array, a function, another quantity
     258        (except for a filename or points, attributes (for now))
     259        - see set_values for details
     260        """
     261
     262        if isinstance(other, Quantity):
     263            Q = other
     264        else:
     265            Q = Quantity(self.domain)
     266            Q.set_values(other)
     267
     268        result = Quantity(self.domain)
     269
     270        # The minimum of vertex_values, edge_values and centroid_values
     271        # are calculated and assigned directly without using
     272        # set_values (which calls interpolate). Otherwise
     273        result.vertex_values = num.minimum(self.vertex_values, Q.vertex_values)
     274        result.edge_values = num.minimum(self.edge_values, Q.edge_values)
     275        result.centroid_values = num.minimum(self.centroid_values, Q.centroid_values)
     276
     277        return result
     278
    222279
    223280    ############################################################################
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r8644 r8650  
    523523            flag = str(float(str(flag))).replace(".","_")
    524524
    525         flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_0_limited', '2_5', 'tsunami']
     525        flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_0_limited', '2_5', 'tsunami', 'yusuke']
    526526
    527527        if flag in flow_algorithms:
     
    576576            self.set_timestepping_method(2)
    577577            self.set_default_order(2)
    578             beta_w      = 1.7
     578            beta_w      = 1.5
    579579            beta_w_dry  = 0.2
    580             beta_uh     = 1.7
     580            beta_uh     = 1.5
    581581            beta_uh_dry = 0.2
    582             beta_vh     = 1.7
     582            beta_vh     = 1.5
    583583            beta_vh_dry = 0.2
    584584            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
     
    606606
    607607        if self.flow_algorithm == 'tsunami':
    608 
    609608            self.set_tsunami_defaults()
    610609
    611610
     611        if self.flow_algorithm == 'yusuke':
     612            # To speed up calculation we also turn off
     613            # the update of other quantities
     614           
     615            self.set_tsunami_defaults()
     616
     617
     618           
    612619
    613620        if self.flow_algorithm == '2_5':
     
    13711378        """
    13721379
     1380
     1381
     1382        if self.flow_algorithm == 'yusuke':
     1383            return
     1384
     1385       
    13731386        # The centroid values of height and x and y velocity
    13741387        # might not have been setup
  • trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r8585 r8650  
    163163            merge.sww_merge_parallel(global_name,self.numproc,verbose,delete_old)
    164164
     165    def write_time(self):
     166
     167        if self.processor == 0:
     168            Domain.write_time(self)
     169
    165170
    166171# =======================================================================
Note: See TracChangeset for help on using the changeset viewer.