Changeset 9281


Ignore:
Timestamp:
Aug 5, 2014, 12:11:23 PM (11 years ago)
Author:
davies
Message:

Adding fractional_step_volume_influx to track mass addition by operators

Location:
trunk/anuga_core/source/anuga
Files:
5 edited

Legend:

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

    r9261 r9281  
    184184        # Create an empty list for fractional step operators
    185185        self.fractional_step_operators = []
    186 
     186        self.fractional_step_volume_influx=0.
    187187
    188188
  • trunk/anuga_core/source/anuga/operators/rate_operators.py

    r9280 r9281  
    7979        # Mass tracking
    8080        self.local_rate=0.
    81         self.rate_integral=0.
     81        #self.volume_added=self.domain.fractional_step_volume_influx
    8282
    8383    def __call__(self):
     
    139139                self.stage_c[indices] = num.maximum(self.stage_c[indices] \
    140140                       + factor*rate*timestep, self.elev_c[indices])
    141 
    142         self.rate_integral=self.rate_integral+self.local_rate
     141        # Update mass inflows from fractional steps
     142        self.domain.fractional_step_volume_influx+=self.local_rate
    143143
    144144    def get_non_spatial_rate(self, t=None):
  • trunk/anuga_core/source/anuga/operators/test_rate_operators.py

    r9280 r9281  
    8787        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
    8888        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    89         assert num.allclose(operator.rate_integral, factor*domain.timestep*(rate*domain.areas[indices]).sum())
     89        assert num.allclose(domain.fractional_step_volume_influx, factor*domain.timestep*(rate*domain.areas[indices]).sum())
    9090
    9191 
     
    149149        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
    150150        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    151         assert num.allclose(operator.rate_integral, factor*domain.timestep*(rate*domain.areas[indices]).sum())
     151        assert num.allclose(domain.fractional_step_volume_influx, factor*domain.timestep*(rate*domain.areas[indices]).sum())
    152152
    153153
     
    271271        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
    272272        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    273         assert num.allclose(operator.rate_integral, ((d-1.)*domain.areas[indices]).sum())
     273        assert num.allclose(domain.fractional_step_volume_influx, ((d-1.)*domain.areas[indices]).sum())
    274274
    275275
     
    301301        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
    302302        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    303         assert num.allclose(operator.rate_integral, (d*domain.areas[indices]).sum())
     303        assert num.allclose(domain.fractional_step_volume_influx, (d*domain.areas[indices]).sum())
    304304
    305305
     
    373373        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
    374374        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    375         assert num.allclose(operator.rate_integral, ((d-1.)*domain.areas[indices]).sum())
     375        assert num.allclose(domain.fractional_step_volume_influx, ((d-1.)*domain.areas[indices]).sum())
    376376
    377377        domain.set_starttime(30.0)
     
    560560        assert num.allclose(Q_ex_all, Q_all)
    561561        assert num.allclose(Q_ex_full, Q_full)
    562         assert num.allclose(operator.rate_integral, ((d-1.)*domain.areas).sum())
     562        assert num.allclose(domain.fractional_step_volume_influx, ((d-1.)*domain.areas).sum())
    563563
    564564    def test_rate_operator_functions_spatial_indices(self):
     
    639639        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    640640        assert num.allclose(Q_ex, Q)
    641         assert num.allclose(operator.rate_integral, ((d-1.)*domain.areas[indices]).sum())
     641        assert num.allclose(domain.fractional_step_volume_influx, ((d-1.)*domain.areas[indices]).sum())
    642642
    643643
     
    719719        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    720720        assert num.allclose(Q_ex, Q)
    721         assert num.allclose(operator.rate_integral, ((d-1.)*domain.areas[indices]).sum())
     721        assert num.allclose(domain.fractional_step_volume_influx, ((d-1.)*domain.areas[indices]).sum())
    722722
    723723
     
    800800        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    801801        assert num.allclose(Q_ex, Q)
    802         assert num.allclose(operator.rate_integral, ((d-1.)*domain.areas[indices]).sum())
     802        assert num.allclose(domain.fractional_step_volume_influx, ((d-1.)*domain.areas[indices]).sum())
    803803
    804804if __name__ == "__main__":
  • trunk/anuga_core/source/anuga/structures/inlet_operator.py

    r9009 r9281  
    8282        if volume >= 0.0 :
    8383            self.inlet.set_stages_evenly(volume)
     84            self.domain.fractional_step_volume_influx+=volume
    8485            if self.velocity is not None:
    8586                depths = self.inlet.get_depths()
    8687                self.inlet.set_xmoms(self.inlet.get_xmoms()+depths*self.velocity[0])
    8788                self.inlet.set_ymoms(self.inlet.get_ymoms()+depths*self.velocity[1])
    88                
    8989        elif current_volume + volume >= 0.0 :
    9090            depth = (current_volume + volume)/total_area
    9191            self.inlet.set_depths(depth)
     92            self.domain.fractional_step_volume_influx+=volume
    9293        else: #extracting too much water!
    9394            self.inlet.set_depths(0.0)
     95            self.domain.fractional_step_volume_influx-=current_volume
    9496            self.applied_Q = current_volume/timestep
    9597
  • trunk/anuga_core/source/anuga/structures/test_inlet_operator.py

    r8974 r9281  
    126126
    127127        assert numpy.allclose((Q1+Q2)*finaltime, vol1-vol0, rtol=1.0e-8)
     128        assert numpy.allclose((Q1+Q2)*finaltime, domain.fractional_step_volume_influx, rtol=1.0e-8)
    128129
    129130
     
    172173
    173174        assert numpy.allclose((Q1)*finaltime, vol1-vol0, rtol=1.0e-8)
     175        assert numpy.allclose((Q1)*finaltime, domain.fractional_step_volume_influx, rtol=1.0e-8)
    174176
    175177
     
    235237       
    236238        assert numpy.allclose(13.5, vol1-vol0, rtol=1.0e-8)
     239        assert numpy.allclose(vol1-vol0, domain.fractional_step_volume_influx, rtol=1.0e-8)
    237240               
    238241    def test_inlet_variable_Q_default(self):
     
    296299
    297300        assert numpy.allclose(31.5, vol1-vol0, rtol=1.0e-8)
     301        assert numpy.allclose(vol1-vol0, domain.fractional_step_volume_influx, rtol=1.0e-8)
    298302
    299303# =========================================================================
Note: See TracChangeset for help on using the changeset viewer.