Ignore:
Timestamp:
Jan 31, 2007, 12:07:32 PM (18 years ago)
Author:
ole
Message:

Added diagnosticts about which triangle is responsible for the largest computed speed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r4020 r4200  
    44
    55   Copyright 2004
    6    Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
     6   Ole Nielsen, Stephen Roberts, Duncan Gray
    77   Geoscience Australia
    88"""
    99
    10 from Numeric import allclose
     10from Numeric import allclose, argmax
    1111from anuga.config import epsilon
    1212
     
    216216        self.already_computed_flux = zeros((N, 3), Int)
    217217
     218        # Storage for maximal speeds computed for each triangle by compute_fluxes
     219        # This is used for diagnostics only
     220        self.max_speed = zeros(N, Float)
     221
    218222        if mesh_filename is not None:
    219223            # If the mesh file passed any quantity values
     
    546550        ##assert hasattr(self, 'boundary_objects')
    547551
    548     def write_time(self):
    549         print self.timestepping_statistics()
    550 
    551 
    552     def timestepping_statistics(self):
     552    def write_time(self, track_location=False):
     553        print self.timestepping_statistics(track_location)
     554
     555
     556    def timestepping_statistics(self, track_location=False):
    553557        """Return string with time stepping statistics for printing or logging
     558
     559        Optional boolean keyword track_location decides whether to report location of smallest timestep.
    554560        """
    555561
     
    568574                     self.max_timestep, self.number_of_steps,
    569575                     self.number_of_first_order_steps)
     576
     577        if track_location is True:
     578            msg += '\n'
     579            # Find index of largest computed flux speed
     580            i = argmax(self.max_speed)
     581
     582            x, y = self.get_centroid_coordinates()[i]
     583
     584            s = 'Triangle #%d with centroid (%.4f, %.4f) ' %(i, x, y)
     585            s += 'had the largest computed speed: %.4f m/s' %(self.max_speed[i])
     586
     587            # FIXME (Ole): Maybe add all quantity values at vertices
     588
     589            msg += s
    570590
    571591        return msg
Note: See TracChangeset for help on using the changeset viewer.