Changeset 9059


Ignore:
Timestamp:
Mar 9, 2014, 9:11:36 PM (11 years ago)
Author:
steve
Message:

changed the order of calls in anuga.init.py to hopefully call the correct Boyd_box_operator in parallel

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

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/__init__.py

    r9029 r9059  
    3131from anuga.__metadata__ import __version__, __date__, __author__
    3232
     33#--------------------------------
     34# Important basic classes
     35#--------------------------------
    3336from anuga.shallow_water.shallow_water_domain import Domain
    3437from anuga.abstract_2d_finite_volumes.quantity import Quantity
    3538from anuga.abstract_2d_finite_volumes.region import Region
    36 
     39from anuga.operators.base_operator import Operator
     40from anuga.structures.structure_operator import Structure_operator
    3741
    3842from anuga.abstract_2d_finite_volumes.util import file_function, \
     
    6367from anuga.geometry.polygon import read_polygon
    6468from anuga.caching import cache
     69from os.path import join
     70from anuga.config import indent
     71
     72
     73
     74#----------------------------
     75# Parallel api (needs operators)
     76#----------------------------
     77from anuga_parallel.parallel_api import distribute
     78from anuga_parallel.parallel_api import myid, numprocs, get_processor_name
     79from anuga_parallel.parallel_api import send, receive
     80from anuga_parallel.parallel_api import pypar_available, barrier, finalize
     81
    6582
    6683#-----------------------------
     
    135152from anuga.shallow_water.sww_interrogate import get_flow_through_cross_section
    136153   
    137 
    138154#---------------------------
    139155# Operators
    140156#---------------------------
    141 from anuga.operators.base_operator import Operator
    142157from anuga.operators.kinematic_viscosity_operator import Kinematic_viscosity_operator
    143158
     
    145160from anuga.operators.set_friction_operators import Depth_friction_operator
    146161
     162
    147163#---------------------------
    148164# Structure Operators
    149165#---------------------------
    150 from anuga.structures.structure_operator import Structure_operator
    151 from anuga.structures.boyd_box_operator import Boyd_box_operator
    152 from anuga.structures.boyd_pipe_operator import Boyd_pipe_operator
    153 from anuga.structures.weir_orifice_trapezoid_operator import Weir_orifice_trapezoid_operator
    154 from anuga.structures.inlet_operator import Inlet_operator
     166
     167
     168if pypar_available:
     169    from anuga_parallel.parallel_operator_factory import Inlet_operator
     170    from anuga_parallel.parallel_operator_factory import Boyd_box_operator
     171    from anuga_parallel.parallel_operator_factory import Boyd_pipe_operator
     172    from anuga_parallel.parallel_operator_factory import Weir_orifice_trapezoid_operator
     173else:
     174    from anuga.structures.boyd_box_operator import Boyd_box_operator
     175    from anuga.structures.boyd_pipe_operator import Boyd_pipe_operator
     176    from anuga.structures.weir_orifice_trapezoid_operator import Weir_orifice_trapezoid_operator
     177    from anuga.structures.inlet_operator import Inlet_operator
     178
     179#----------------------------
     180# Parallel distribute
     181#----------------------------
     182
     183
     184#----------------------------
     185#
     186#Added by Petar Milevski 10/09/2013
     187#import time, os
     188
     189from anuga.utilities.model_tools import get_polygon_from_single_file
     190from anuga.utilities.model_tools import get_polygons_from_Mid_Mif
     191from anuga.utilities.model_tools import get_polygon_list_from_files
     192from anuga.utilities.model_tools import get_polygon_dictionary
     193from anuga.utilities.model_tools import get_polygon_value_list
     194from anuga.utilities.model_tools import read_polygon_dir
     195from anuga.utilities.model_tools import read_hole_dir_multi_files_with_single_poly
     196from anuga.utilities.model_tools import read_multi_poly_file
     197from anuga.utilities.model_tools import read_hole_dir_single_file_with_multi_poly
     198from anuga.utilities.model_tools import read_multi_poly_file_value
     199from anuga.utilities.model_tools import Create_culvert_bridge_Operator
     200
    155201
    156202#---------------------------
     
    374420
    375421
    376 #Added by Petar Milevski 10/09/2013
    377 import time, os
    378 from os.path import join
    379 from anuga.config import indent
    380 
    381 from anuga.utilities.model_tools import get_polygon_from_single_file
    382 from anuga.utilities.model_tools import get_polygons_from_Mid_Mif
    383 from anuga.utilities.model_tools import get_polygon_list_from_files
    384 from anuga.utilities.model_tools import get_polygon_dictionary
    385 from anuga.utilities.model_tools import get_polygon_value_list
    386 from anuga.utilities.model_tools import read_polygon_dir
    387 from anuga.utilities.model_tools import read_hole_dir_multi_files_with_single_poly
    388 from anuga.utilities.model_tools import read_multi_poly_file
    389 from anuga.utilities.model_tools import read_hole_dir_single_file_with_multi_poly
    390 from anuga.utilities.model_tools import read_multi_poly_file_value
    391 
    392 from anuga.utilities.model_tools import Create_culvert_bridge_Operator
    393 
    394 from anuga_parallel.parallel_api import distribute
    395 from anuga_parallel.parallel_api import myid, numprocs, get_processor_name
    396 from anuga_parallel.parallel_api import send, receive
    397 from anuga_parallel.parallel_api import pypar_available, barrier, finalize
    398 
    399 if pypar_available:
    400     #from anuga_parallel.parallel_meshes import parallel_rectangle
    401     #from anuga_parallel.parallel_shallow_water import Parallel_domain as Parallel_shallow_water_domain
    402     #from anuga_parallel.parallel_advection     import Parallel_domain as Parallel_advection_domain
    403     from anuga_parallel.parallel_operator_factory import Inlet_operator, Boyd_box_operator, Boyd_pipe_operator, Weir_orifice_trapezoid_operator
    404 
    405 
    406 from anuga.structures.weir_orifice_trapezoid_operator import Weir_orifice_trapezoid_operator
    407 
     422
     423
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r9029 r9059  
    335335
    336336
     337    def save_data_to_dem(self,filename=None):
     338
     339
     340        #FIXME SR: Should add code to deal with parallel
     341
     342        ids = self.domain.tri_full_flag == 1
     343        c_v = self.centroid_values[ids].reshape((-1,1))
     344        c_x = self.domain.centroid_coordinates[ids,0].reshape((-1,1))
     345        c_y = self.domain.centroid_coordinates[ids,1].reshape((-1,1))
     346
     347        import numpy
     348
     349        c_xyv = numpy.hstack((c_x, c_y, c_v))
     350
     351        if filename is None:
     352            filename= self.name
     353
     354        if self.domain.parallel:
     355            fullfilename = filename+'_centroid_data_P%g_%g.csv'% \
     356                    ( self.domain.numproc, self.domain.processor)
     357        else:
     358            fullfilename = filename+'_centroid_data.csv'
     359
     360        numpy.savetxt(fullfilename, c_xyv, delimiter=',', fmt =  ['%.15e', '%.15e', '%.15e' ])
     361
     362
     363        if self.domain.parallel:
     364            import pypar
     365            pypar.barrier()
     366
     367            # On processor 0 catenate the files
     368            if self.domain.processor == 0:
     369                import shutil
     370                import os
     371                destination = open(filename+'_centroid_data.csv','wb')
     372                np = self.domain.numproc
     373                files = [ filename+'_centroid_data'+"_P"+str(np)+"_"+str(v)+".csv" for v in range(np)]
     374                for file in files:
     375                    shutil.copyfileobj(open(file,'rb'), destination)
     376                destination.close()
     377                for file in files:
     378                    os.remove(file)
     379
    337380
    338381
     
    357400            plt.show()
    358401       
     402
     403    def save_to_array(self,
     404                cellsize=10,
     405                NODATA_value=-9999.0,
     406                easting_min=None,
     407                easting_max=None,
     408                northing_min=None,
     409                northing_max=None,
     410                origin=None,
     411                verbose=False):
     412       
     413        """Interpolate quantity to an array
     414        """
     415   
     416
     417        verbose = True
     418       
     419        from anuga.geometry.polygon import inside_polygon, outside_polygon
     420        from anuga.abstract_2d_finite_volumes.util import \
     421             apply_expression_to_dictionary
     422   
     423   
     424   
     425        #Get extent and reference
     426       
     427        domain = self.domain
     428
     429        volumes = domain.triangles
     430       
     431
     432        x,y,_,v= self.get_vertex_values(xy=True)
     433       
     434       
     435        vertex_coordinates = domain.vertex_coordinates
     436
     437        # store the connectivity data
     438        #points = num.concatenate((x[:,num.newaxis],y[:,num.newaxis]), axis=1)
     439#         self.writer.store_triangulation(fid,
     440#                                         points,
     441#                                         V.astype(num.float32),
     442#                                         points_georeference=\
     443#                                         domain.geo_reference)
     444       
     445        false_easting = 500000
     446        false_northing = 10000000
     447   
     448   
     449   
     450        geo_ref = self.domain.geo_reference
     451       
     452        xllcorner = geo_ref.get_xllcorner()
     453        yllcorner = geo_ref.get_yllcorner()
     454       
     455        if verbose:
     456            print
     457            print xllcorner
     458            print yllcorner
     459            print x
     460            print y
     461            print vertex_coordinates[:,0]
     462            print vertex_coordinates[:,1]
     463           
     464       
     465       
     466        # Create grid and update xll/yll corner and x,y
     467        # Relative extent
     468        if easting_min is None:
     469            xmin = min(x)
     470        else:
     471            xmin = easting_min - xllcorner
     472   
     473        if easting_max is None:
     474            xmax = max(x)
     475        else:
     476            xmax = easting_max - xllcorner
     477   
     478        if northing_min is None:
     479            ymin = min(y)
     480        else:
     481            ymin = northing_min - yllcorner
     482   
     483        if northing_max is None:
     484            ymax = max(y)
     485        else:
     486            ymax = northing_max - yllcorner
     487   
     488   
     489        """
     490        msg = 'xmax must be greater than or equal to xmin.\n'
     491        msg += 'I got xmin = %f, xmax = %f' %(xmin, xmax)
     492        assert xmax >= xmin, msg
     493   
     494        msg = 'ymax must be greater than or equal to xmin.\n'
     495        msg += 'I got ymin = %f, ymax = %f' %(ymin, ymax)
     496        assert ymax >= ymin, msg
     497   
     498        if verbose: log.critical('Creating grid')
     499        ncols = int((xmax-xmin)/cellsize) + 1
     500        nrows = int((ymax-ymin)/cellsize) + 1
     501   
     502        # New absolute reference and coordinates
     503        newxllcorner = xmin + xllcorner
     504        newyllcorner = ymin + yllcorner
     505   
     506        x = x + xllcorner - newxllcorner
     507        y = y + yllcorner - newyllcorner
     508   
     509   
     510        grid_values = num.zeros( (nrows*ncols, ), num.float)
     511        #print '---',grid_values.shape
     512   
     513        num_tri =  len(volumes)
     514        norms = num.zeros(6*num_tri, num.float)
     515   
     516        #Use fasr method to calc grid values
     517        from calc_grid_values_ext import calc_grid_values
     518   
     519        calc_grid_values(nrows, ncols, cellsize, NODATA_value,
     520                         x,y, norms, volumes, result, grid_values)
     521   
     522   
     523        fid.close()
     524       
     525        #print outside_indices
     526   
     527        if verbose:
     528            log.critical('Interpolated values are in [%f, %f]'
     529                         % (num.min(grid_values), num.max(grid_values)))
     530   
     531   
     532   
     533        return x,y, grid_values.reshape(nrows,ncols)[::-1,:]
     534
     535        """
     536
     537
     538
     539
     540
     541
    359542
    360543
     
    11211304        Parameters
    11221305        """
    1123 
    1124 
    1125 
    1126 
    1127 #         msg = 'Filename must be a text string'
    1128 #         assert isinstance(filename, basestring), msg
    1129 #         
    1130 #         msg = 'Extension should be .grd or asc'
    1131 #         assert os.path.splitext(filename)[1] in ['.grd', '.asc'], msg
    1132 #         
    1133 #
    1134 #         msg = "set_values_from_grd_file is only defined for location='vertices' or 'centroids'"
    1135 #         assert location in ['vertices', 'centroids'], msg
    1136 #
    1137 #             
    1138 #
    1139 #             
    1140 #     
    1141 #         root = filename[:-4]
    1142 #     
    1143 #     
    1144 #         #Read DEM data
    1145 #         datafile = open(filename)
    1146 #     
    1147 #         if verbose: log.critical('Reading data from %s' % (filename))
    1148 #     
    1149 #         lines = datafile.readlines()
    1150 #         datafile.close()
    1151 #     
    1152 #         if verbose: log.critical('Got %d lines' % len(lines))
    1153 #     
    1154 #
    1155 #         ncols = int(lines[0].split()[1].strip())
    1156 #         nrows = int(lines[1].split()[1].strip())
    1157 #
    1158 #     
    1159 #         # Do cellsize (line 4) before line 2 and 3
    1160 #         cellsize = float(lines[4].split()[1].strip())
    1161 #     
    1162 #         # Checks suggested by Joaquim Luis
    1163 #         # Our internal representation of xllcorner
    1164 #         # and yllcorner is non-standard.
    1165 #         xref = lines[2].split()
    1166 #         if xref[0].strip() == 'xllcorner':
    1167 #             xllcorner = float(xref[1].strip()) # + 0.5*cellsize # Correct offset
    1168 #         elif xref[0].strip() == 'xllcenter':
    1169 #             xllcorner = float(xref[1].strip())
    1170 #         else:
    1171 #             msg = 'Unknown keyword: %s' % xref[0].strip()
    1172 #             raise Exception, msg
    1173 #     
    1174 #         yref = lines[3].split()
    1175 #         if yref[0].strip() == 'yllcorner':
    1176 #             yllcorner = float(yref[1].strip()) # + 0.5*cellsize # Correct offset
    1177 #         elif yref[0].strip() == 'yllcenter':
    1178 #             yllcorner = float(yref[1].strip())
    1179 #         else:
    1180 #             msg = 'Unknown keyword: %s' % yref[0].strip()
    1181 #             raise Exception, msg
    1182 #     
    1183 #         NODATA_value = int(float(lines[5].split()[1].strip()))
    1184 #     
    1185 #         assert len(lines) == nrows + 6
    1186 #     
    1187 #   
    1188 #         #Store data
    1189 #         import numpy
    1190 #     
    1191 #         datafile = open(filename)
    1192 #         Z = numpy.loadtxt(datafile, skiprows=6)
    1193 #         datafile.close()
    1194 #         
    1195 #         #print Z.shape
    1196 #         #print Z
    1197 #         
    1198 #         # For raster data we need to a flip and transpose
    1199 #         Z = numpy.flipud(Z)
    1200 #
    1201 #         # Transpose z to have y coordinates along the first axis and x coordinates
    1202 #         # along the second axis
    1203 #         Z = Z.transpose()
    1204 #     
    1205 #         x = num.linspace(xllcorner, xllcorner+cellsize*(ncols-1), ncols)
    1206 #         y = num.linspace(yllcorner, yllcorner+cellsize*(nrows-1), nrows)
    12071306       
    12081307       
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r8978 r9059  
    247247                                                   [2.2, 2.8, 4.0],
    248248                                                   [2.5, -0.5, -2.0]])
    249 
    250 
    251         #assert allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
    252         #                                       [5., 5., 5.],
    253         #                                       [4.5, 4.5, 0.],
    254         #                                       [3.0, -1.5, -1.5]])
     249       
     250    def test_save_to_array(self):
     251        quantity = Quantity(self.mesh4,
     252                            [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
     253       
     254       
     255        assert num.allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
     256
     257
     258        quantity.save_to_array()
     259       
     260       
     261
     262
     263
    255264
    256265    def test_get_extrema_1(self):
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_region.py

    r9054 r9059  
    6767        domain = Domain(points, vertices, boundary)
    6868       
    69         region = Region(domain, polygon=[[0.0,0.0], [0.5,0.0], [0.5,0.5]])
     69        poly = [[0.0,0.0], [0.5,0.0], [0.5,0.5]]
     70       
     71        print poly
     72        region = Region(domain, polygon=poly)
    7073       
    7174        expected_indices = [1]
  • trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r8823 r9059  
    701701            self.verbose_block_size = (self.last_row + 10)/10
    702702            self.block_number = 0
    703             self.number_of_blocks = self.number_of_points/self.max_read_lines
     703            self.number_of_blocks = int(self.number_of_points/self.max_read_lines)
    704704            # This computes the number of full blocks. The last block may be
    705705            # smaller and won't be included in this estimate.
    706706
    707707            if self.verbose is True:
    708                 log.critical('Geospatial_data: Reading %d points (in ~%d blocks) from file %s. '
     708                log.critical('Geospatial_data: Reading %d points (in %d block(s)) from file %s. '
    709709                             % (self.number_of_points, self.number_of_blocks+1,
    710710                                self.file_name))
  • trunk/anuga_core/source/anuga/operators/erosion_operators.py

    r9001 r9059  
    104104            # Update all three vertices for each cell
    105105            #--------------------------------------
    106             self.elev_v[:] = self.elev_v + 0.0
     106            self.elev_c[:] = self.elev_c + 0.0
    107107
    108108        else:
     
    114114            ind = self.indices
    115115            m = num.sqrt(self.xmom_c[ind]**2 + self.ymom_c[ind]**2)
    116             m = num.vstack((m,m,m)).T  # Stack up m to apply to vertices
    117             m = num.where(m>self.threshold, m, 0.0)
    118 
    119             de = m*dt
    120             self.elev_v[ind] = num.maximum(self.elev_v[ind] - de, self.base)
     116           
     117            if self.domain.flow_algorithm == 'DE1':
     118                m = num.where(m>self.threshold, m, 0.0)
     119   
     120                de = m*dt
     121                height = self.stage_c[ind] - self.elev_c[ind]
     122                self.elev_c[ind] = num.maximum(self.elev_v[ind] - de, self.base)
     123                self.stage_c[ind] = self.elev_c[ind] + height
     124            else:
     125                m = num.vstack((m,m,m)).T  # Stack up m to apply to vertices
     126                m = num.where(m>self.threshold, m, 0.0)
     127   
     128                de = m*dt
     129                self.elev_v[ind] = num.maximum(self.elev_v[ind] - de, self.base)
    121130
    122131            self.max_change = num.max(de)
     
    141150
    142151        #------------------------------------------
    143         # Apply changes to elevation vertex values
     152        # Apply changes to elevation values
    144153        # via the update_quantites routine
    145154        #------------------------------------------
     
    151160        # Cleanup elevation and stage quantity values
    152161        #-----------------------------------------
     162        self.clean_up_elevation_stage()
     163       
     164       
     165       
     166       
     167    def clean_up_elevation_stage(self):
     168       
     169        #----------------------------------------------
     170        # Don't need to clean up if using discontinuous
     171        # elevation
     172        #----------------------------------------------
     173        if self.domain.flow_algorithm == 'DE1':
     174            return
     175       
     176       
     177        #-----------------------------------------------
     178        # Clean up to conserve volume and make elevation
     179        # continuous
     180        #-----------------------------------------------
    153181        if self.indices is None:
    154182
    155             #--------------------------------------
    156             # Update all three vertices for each cell
    157             #--------------------------------------
    158             self.elev_v[:] = self.elev_v + 0.0
    159183
    160184            #--------------------------------------
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r9052 r9059  
    369369        #self.forcing_terms.append(manning_friction_explicit)
    370370        #self.forcing_terms.remove(manning_friction_implicit)
    371 
    372 #        print '##########################################################################'
    373 #        print '#'
    374 #        print "#"
    375 #        print "# Here are some tips on using the 'tsunami' solver"
    376 #        print "#"
    377 #        print "# 1) When plotting outputs, I strongly suggest you examine centroid values, not vertex values"
    378 #        print "# , as the latter can be completely misleading near strong gradients in the flow. "
    379 #        print "# There is a plot_util.py script in anuga_core/utilities/ which might help you extract"
    380 #        print "# quantities at centroid values from sww files."
    381 #        print "# Note that to accuractely compute centroid values from sww files, the files need to store "
    382 #        print "# vertices uniquely. This makes for large sww files (3x), but is the price to pay for the right answer"
    383 #        print "# (unless we alter IO to allow centroids to be written to sww files, which would then affect"
    384 #        print "# ANUGA viewer as well -- I expect this would be lots of work)"
    385 #        print "#"
    386 #        print "# 2) In field scale applications (where the depth is typically > 1m), I suggest you set"
    387 #        print "# domain.minimum_allowed_height=0.01 (the default is 1.0e-3). "
    388 #        print "#"
    389 #        print "# 3) This solver is not expected to perform well in problems with very"
    390 #        print "# shallow water flowing down steep slopes (such that the stage_centroid_value "
    391 #        print "# is less than the maximum bed_edge_value on a given triangle). However, analytical tests"
    392 #        print "# suggest it can do typical wetting/drying situations very well (parabolic oscillations test case) "
    393 #        print "#"
    394 #        print "# 4) This solver allows the stage_centroid_value to drop to slightly below the minimum bed_vertex_value"
    395 #        print "# on it's triangle. In other ANUGA versions (e.g. 1.2.1), the limit would be the"
    396 #        print "# bed_centroid_value. This means that triangles store slightly more water than they are"
    397 #        print "# typically interpreted to store, which might have significance in some applications."
    398 #        print "#"
    399 #        print "# You will probably be able to tell this is causing you problems by convergence testing"
    400 #        print "#"
    401 #        print '# 5) Note that many options in config.py have been overridden by the solver -- we have '
    402 #        print '# deliberately attempted to get the solver to perform well with consistent values of '
    403 #        print '# these parameters -- so I advise against changing them unless you at least check that '
    404 #        print '# it really does improve things'
    405 #        print '#'
    406 #        print '##########################################################################'
     371        if self.processor == 0 and self.verbose:
     372            print '##########################################################################'
     373            print '#'
     374            print "#"
     375            print "# Here are some tips on using the 'tsunami' solver"
     376            print "#"
     377            print "# 1) When plotting outputs, I strongly suggest you examine centroid values, not vertex values"
     378            print "# , as the latter can be completely misleading near strong gradients in the flow. "
     379            print "# There is a plot_util.py script in anuga_core/utilities/ which might help you extract"
     380            print "# quantities at centroid values from sww files."
     381            print "# Note that to accuractely compute centroid values from sww files, the files need to store "
     382            print "# vertices uniquely. This makes for large sww files (3x), but is the price to pay for the right answer"
     383            print "# (unless we alter IO to allow centroids to be written to sww files, which would then affect"
     384            print "# ANUGA viewer as well -- I expect this would be lots of work)"
     385            print "#"
     386            print "# 2) In field scale applications (where the depth is typically > 1m), I suggest you set"
     387            print "# domain.minimum_allowed_height=0.01 (the default is 1.0e-3). "
     388            print "#"
     389            print "# 3) This solver is not expected to perform well in problems with very"
     390            print "# shallow water flowing down steep slopes (such that the stage_centroid_value "
     391            print "# is less than the maximum bed_edge_value on a given triangle). However, analytical tests"
     392            print "# suggest it can do typical wetting/drying situations very well (parabolic oscillations test case) "
     393            print "#"
     394            print "# 4) This solver allows the stage_centroid_value to drop to slightly below the minimum bed_vertex_value"
     395            print "# on it's triangle. In other ANUGA versions (e.g. 1.2.1), the limit would be the"
     396            print "# bed_centroid_value. This means that triangles store slightly more water than they are"
     397            print "# typically interpreted to store, which might have significance in some applications."
     398            print "#"
     399            print "# You will probably be able to tell this is causing you problems by convergence testing"
     400            print "#"
     401            print '# 5) Note that many options in config.py have been overridden by the solver -- we have '
     402            print '# deliberately attempted to get the solver to perform well with consistent values of '
     403            print '# these parameters -- so I advise against changing them unless you at least check that '
     404            print '# it really does improve things'
     405            print '#'
     406            print '##########################################################################'
    407407
    408408    def set_DE1_defaults(self):
     
    461461        self.call=1 # Integer counting how many times we call compute_fluxes_central
    462462
    463         print '##########################################################################'
    464         print '#'
    465         print '# Using discontinuous elevation solver DE1 '
    466         print '#'
    467         print '# Mostly designed for rk2 timestepping'
    468         print '#'
    469         print '# Make sure you use centroid values when reporting on important output quantities'
    470         print '#'
    471         print '# NOTE: anuga-viewer sometimes shows very shallow regions in this solver as '
    472         print '# erratically jumping from "totally dry" to "barely wet". In all my checks of centroid'
    473         print '# values at such locations, I never found that it was really occurring. It may be'
    474         print '# a problem with the viewer rather than this algorithm. '
    475         print '##########################################################################'
     463        if self.processor == 0 and self.verbose:
     464            print '##########################################################################'
     465            print '#'
     466            print '# Using discontinuous elevation solver DE1 '
     467            print '#'
     468            print '# Mostly designed for rk2 timestepping'
     469            print '#'
     470            print '# Make sure you use centroid values when reporting on important output quantities'
     471            print '#'
     472            print '# NOTE: anuga-viewer sometimes shows very shallow regions in this solver as '
     473            print '# erratically jumping from "totally dry" to "barely wet". In all my checks of centroid'
     474            print '# values at such locations, I never found that it was really occurring. It may be'
     475            print '# a problem with the viewer rather than this algorithm. '
     476            print '##########################################################################'
    476477
    477478
     
    615616           2.5
    616617           tsunami
     618           DE1
    617619        """
    618620
     
    15491551                self.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas)
    15501552
    1551             print 'Cumulative mass protection: python'+str(mass_error)+'m^3 '
     1553            if mass_error > 0.0 and self.verbose :
     1554                print 'Cumulative mass protection: '+str(mass_error)+' m^3 '
    15521555
    15531556        elif self.flow_algorithm == 'DE1':
     
    15661569            yc = self.centroid_coordinates[:,1]
    15671570
    1568             protect(self.minimum_allowed_height, self.maximum_allowed_speed,
     1571            mass_error = protect(self.minimum_allowed_height, self.maximum_allowed_speed,
    15691572                    self.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas, xc, yc)
     1573           
     1574            if mass_error > 0.0 and self.verbose :
     1575                print 'Cumulative mass protection: '+str(mass_error)+' m^3 '
    15701576           
    15711577        else:
  • trunk/anuga_core/source/anuga/shallow_water/swDE1_domain_ext.c

    r9051 r9059  
    596596
    597597// Protect against the water elevation falling below the triangle bed
    598 int _protect(int N,
     598double _protect(int N,
    599599         double minimum_allowed_height,
    600600         double maximum_allowed_speed,
     
    613613  double hc, bmin, bmax;
    614614  double u, v, reduced_speed;
    615   static double mass_error=0.;
     615  double mass_error=0.;
    616616  // This acts like minimum_allowed height, but scales with the vertical
    617617  // distance between the bed_centroid_value and the max bed_edge_value of
     
    651651    }
    652652
    653   if(mass_added==1){
    654      printf("Cumulative mass protection: %f m^3 \n", mass_error);
    655   }
    656   return 0;
     653  //if(mass_added==1){
     654  //  printf("Cumulative mass protection: %f m^3 \n", mass_error);
     655  //}
     656  return mass_error;
    657657}
    658658
     
    20312031
    20322032  int N;
     2033  double mass_error;
    20332034  double minimum_allowed_height, maximum_allowed_speed, epsilon;
    20342035
     
    20452046  N = wc -> dimensions[0];
    20462047
    2047   _protect(N,
     2048  mass_error = _protect(N,
    20482049       minimum_allowed_height,
    20492050       maximum_allowed_speed,
     
    20592060       (double*) yc -> data );
    20602061
    2061   return Py_BuildValue("");
     2062  return Py_BuildValue("d", mass_error);
    20622063}
    20632064
  • trunk/anuga_core/source/anuga/structures/test_boyd_pipe_operator.py

    r9055 r9059  
    1212import numpy
    1313
    14 verbose = True
     14verbose = False
    1515#diameter = width
    1616
Note: See TracChangeset for help on using the changeset viewer.