Changeset 4839


Ignore:
Timestamp:
Nov 21, 2007, 10:45:34 AM (17 years ago)
Author:
duncan
Message:

speeding up slow functions in general mesh. Fix for ticket 201. Also checking in GA validation test for profiling fitting

Files:
3 added
8 edited

Legend:

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

    r4836 r4839  
    301301       
    302302        V = self.vertex_coordinates
    303         if absolute is True:
    304             if not self.geo_reference.is_absolute():
    305                 V = self.geo_reference.get_absolute(V)
    306 
    307         if triangle_id is None:       
     303
     304        if triangle_id is None:   
     305            if absolute is True:
     306                if not self.geo_reference.is_absolute():
     307                    V = self.geo_reference.get_absolute(V)
     308     
    308309            return V
    309310        else:
     
    313314            assert 0 <= i < self.number_of_triangles
    314315           
    315             i3 = 3*i
    316             return array([V[i3,:], V[i3+1,:], V[i3+2,:]])
    317 
     316            i3 = 3*i 
     317            if absolute is True and not self.geo_reference.is_absolute():
     318                offset=array([self.geo_reference.get_xllcorner(),
     319                                  self.geo_reference.get_yllcorner()])
     320                return array([V[i3,:]+offset,
     321                              V[i3+1,:]+offset,
     322                              V[i3+2,:]+offset])
     323            else:
     324                return array([V[i3,:], V[i3+1,:], V[i3+2,:]])
     325               
    318326
    319327
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r4821 r4839  
    841841            raise msg
    842842
    843         if False:  # FIXME (Ole): True takes less memory,
     843        if True:  # FIXME (Ole): True takes less memory,
    844844                   # but appears to be slower.
    845845            vertex_attributes = fit_to_mesh(filename,
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r4808 r4839  
    4343                assert allclose(V[3*i+j,:], nodes[k])
    4444
     45    def test_get_vertex_coordinates_with_geo_ref(self):
     46        x0 = 314036.58727982
     47        y0 = 6224951.2960092
     48        geo = Geo_reference(56, x0, y0)
     49       
     50        a = [0.0, 0.0]
     51        b = [0.0, 2.0]
     52        c = [2.0, 0.0]
     53        d = [0.0, 4.0]
     54        e = [2.0, 2.0]
     55        f = [4.0, 0.0]
     56
     57        nodes = array([a, b, c, d, e, f])
     58
     59        nodes_absolute = geo.get_absolute(nodes)
     60       
     61        #bac, bce, ecf, dbe, daf, dae
     62        triangles = array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     63
     64        domain = General_mesh(nodes, triangles,
     65                       geo_reference = geo)
     66        verts = domain.get_vertex_coordinates(triangle_id=0)       
     67        self.assert_(allclose(array([b,a,c]), verts))
     68        verts = domain.get_vertex_coordinates(triangle_id=0)       
     69        self.assert_(allclose(array([b,a,c]), verts))
     70        verts = domain.get_vertex_coordinates(triangle_id=0,
     71                                              absolute=True)       
     72        self.assert_(allclose(array([nodes_absolute[1],
     73                                     nodes_absolute[0],
     74                                     nodes_absolute[2]]), verts))
     75        verts = domain.get_vertex_coordinates(triangle_id=0,
     76                                              absolute=True)       
     77        self.assert_(allclose(array([nodes_absolute[1],
     78                                     nodes_absolute[0],
     79                                     nodes_absolute[2]]), verts))
     80       
     81       
    4582
    4683    def test_get_vertex_coordinates_triangle_id(self):
  • anuga_core/source/anuga/coordinate_transforms/geo_reference.py

    r4663 r4839  
    243243        #if self.is_absolute():
    244244        #    return points
    245        
    246 
    247245        is_list = False
    248246        if type(points) == types.ListType:
  • anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py

    r4665 r4839  
    3030from anuga.fit_interpolate.fit import Fit, fit_to_mesh
    3131from anuga.fit_interpolate.interpolate import benchmark_interpolate
     32from anuga.coordinate_transforms.geo_reference import Geo_reference
    3233
    3334def mem_usage():
     
    8384        #print "max_points_per_cell", max_points_per_cell
    8485
     86        geo = Geo_reference(xllcorner = 2.0,
     87                 yllcorner = 2.0)
    8588        mesh_dict = self._build_regular_mesh_dict(maxArea=maxArea,
    8689                                                  is_segments=segments_in_mesh,
    87                                                   save=save)
    88         points_dict = self._build_points_dict(num_of_points=num_of_points)
     90                                                  save=save,
     91                                                  geo=geo)
     92        points_dict = self._build_points_dict(num_of_points=num_of_points,
     93                                                  geo=geo)
    8994
    9095
     
    98103                       ".txt"
    99104                   
     105        # Apply the geo_ref to the points, so they are relative
     106        # Pass in the geo_ref
    100107       
    101108        domain = Domain(mesh_dict['vertices'], mesh_dict['triangles'],
    102                         use_cache=False, verbose=False)
     109                        use_cache=False, verbose=False,
     110                                     geo_reference=geo)
    103111        #Initial time and memory
    104112        t0 = time.time()
     
    106114        m0 = mem_usage()
    107115       
     116        # Apply the geo_ref to the points, so they are relative
     117        # Pass in the geo_ref
     118        geospatial = Geospatial_data(points_dict['points'],
     119                                     points_dict['point_attributes'],
     120                                     geo_reference=geo)
    108121        if is_fit is True:
    109122
    110             print "Fit in Fit"
    111             geospatial = Geospatial_data(points_dict['points'],
    112                                      points_dict['point_attributes'])
     123            # print "Fit in Fit"
    113124            if use_file_type == None:
    114125                points = geospatial
    115126                filename = None
    116127            else:
    117                 #check that the type
     128                #FIXME (DSG) check that the type
    118129                fileName = tempfile.mktemp("." + use_file_type)
    119130                geospatial.export_points_file(fileName, absolute=True)
     
    147158        else:
    148159            # run an interploate problem.
    149             print "Interpolate!"
     160            #print "Interpolate!"
    150161           
    151162            if run_profile:
    152                 s="""benchmark_interpolate(mesh_dict['vertices'],mesh_dict['vertex_attributes'],mesh_dict['triangles'],points_dict['points'],max_points_per_cell=max_points_per_cell)"""
     163                # pass in the geospatial points
     164                # and the mesh origin
     165                 
     166                s="""benchmark_interpolate(mesh_dict['vertices'],mesh_dict['vertex_attributes'],mesh_dict['triangles'],geospatial,max_points_per_cell=max_points_per_cell,mesh_origin=geo)"""
    153167                pobject = profile.Profile()
    154168                presult = pobject.runctx(s,
     
    169183                   
    170184            else:
     185                # pass in the geospatial points
    171186                 benchmark_interpolate(mesh_dict['vertices'],
    172187                                       mesh_dict['vertex_attributes'],
    173188                                       mesh_dict['triangles'],
    174                                        points_dict['points'],
     189                                       geospatial,
     190                                       mesh_origin=geo,
    175191                                       max_points_per_cell=max_points_per_cell)
    176192        time_taken_sec = (time.time()-t0)
     
    186202                                 maxArea=1000,
    187203                                 is_segments=True,
    188                                  save=False):
     204                                 save=False,
     205                                 geo=None):
    189206      # make a normalised mesh
    190         # pretty regular size, with some segments thrown in.
     207        # pretty regular size, with some segments thrown in.
     208
     209        #x_min =
    191210        m = Mesh()
    192211        m.addUserVertex(0,0)
     
    235254        return mesh_dict
    236255
    237     def _build_points_dict(self, num_of_points=20000):
     256    def _build_points_dict(self, num_of_points=20000,
     257                                 geo=None):
    238258       
    239259        points_dict = {}
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r4833 r4839  
    295295                          triangles, points,
    296296                          max_points_per_cell=None,
    297                           start_blocking_len=500000):
     297                          start_blocking_len=500000,
     298                          mesh_origin=None):
    298299    """
     300    points: Interpolate mesh data to these positions.
     301              List of coordinate pairs [x, y] of
     302              data points or an nx2 Numeric array or a Geospatial_data object
     303             
    299304    No test for this yet.
    300305    Note, this has no time the input data has no time dimension.  Which is
     
    306311    interp = Interpolate(vertices,
    307312                         triangles,
    308                          max_vertices_per_cell=max_points_per_cell)
     313                         max_vertices_per_cell=max_points_per_cell,
     314                         mesh_origin=mesh_origin)
    309315           
    310316    calc = interp.interpolate(vertex_attributes
    311317                              ,points
    312318                              ,start_blocking_len=start_blocking_len)
     319    #print "calc", calc
     320   
    313321def interpolate_sww2csv(sww_file,
    314322                        points,
  • anuga_core/source/anuga/fit_interpolate/run_long_benchmark.py

    r4596 r4839  
    1616
    1717use_least_squares_list = [False]
    18 is_fit_list = [True]
    19 num_of_points_list = [50, 500] #, 10000, 100000] #, 10000000]
    20 maxArea_list = [0.5, 0.055, 0.06] #, 0.00001, 0.0000001]
     18is_fit_list = [True, False]
     19num_of_points_list = [50, 1000] #, 500, 10000, 100000] #, 10000000]
     20maxArea_list = [0.01, 0.001, 0.0001] #,0.00001] #, 0.0000001] #, 0.06, 0.00001, 0.0000001]
    2121max_points_per_cell_list = [8]
    22 use_file_type_list = [None,'txt', 'pts']
     22use_file_type_list = ['pts']
    2323
    2424fd = open(ofile,'a')
     
    3535
    3636
    37 for maxArea in maxArea_list:
    38     for use_file_type in use_file_type_list:
    39         for is_fit in is_fit_list:
     37for is_fit in is_fit_list:
     38    for maxArea in maxArea_list:
     39        for use_file_type in use_file_type_list:
    4040            for num_of_points in num_of_points_list:
    4141                for max_points_per_cell in max_points_per_cell_list:
    4242   
    43                     time, mem, num_tri = ben.trial(num_of_points=num_of_points
    44                                                    ,maxArea=maxArea
    45                                                    ,max_points_per_cell=max_points_per_cell
    46                                                    ,is_fit=is_fit
    47                                                    ,segments_in_mesh=False
    48                                                    ,use_file_type=use_file_type
    49                                                    ,save=True
    50                                                )
     43                    time, mem, num_tri = ben.trial(
     44                        num_of_points=num_of_points
     45                        ,maxArea=maxArea
     46                        ,max_points_per_cell=max_points_per_cell
     47                        ,is_fit=is_fit
     48                        ,segments_in_mesh=False
     49                        ,use_file_type=use_file_type
     50                        ,save=True
     51                        )
    5152                    print "time",time
    5253                    print "mem", mem
     54                    print "num_tri", num_tri
    5355                    fd.write(str(use_file_type) + delimiter +
    5456                             str(num_of_points) + delimiter +
  • anuga_validation/automated_validation_tests/UQ_runup_2006/validate_uq_runup.py

    r4774 r4839  
    1 """Automatic verification that the ANUGA code validates against the okushiri
    2 dataset as expected. See anuga_validation/okushiri_2005 for more details
     1"""Automatic verification that the ANUGA code validates against the UQ runup
     2dataset as expected.
    33"""
    44
Note: See TracChangeset for help on using the changeset viewer.