Ignore:
Timestamp:
Jun 5, 2010, 10:58:55 AM (14 years ago)
Author:
hudson
Message:

Almost all failing tests fixed.

File:
1 edited

Legend:

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

    r7778 r7780  
    886886
    887887
    888     def test_that_mesh_methods_exist(self):
    889         """test_that_mesh_methods_exist
    890        
    891         Test that relavent mesh methods are made available in
    892         domain through composition
    893         """
    894         from mesh_factory import rectangular
    895         from shallow_water import Domain
    896 
    897         # Create basic mesh
    898         points, vertices, boundary = rectangular(1, 3)
    899 
    900         # Create shallow water domain
    901         domain = Domain(points, vertices, boundary)                             
    902        
    903        
    904         domain.get_centroid_coordinates()
    905         domain.get_radii()
    906         domain.get_areas()
    907         domain.get_area()
    908         domain.get_vertex_coordinates()
    909         domain.get_triangles()
    910         domain.get_nodes()
    911         domain.get_number_of_nodes()
    912         domain.get_normal(0,0)
    913         domain.get_triangle_containing_point([0.4,0.5])
    914         domain.get_intersecting_segments([[0.0, 0.0], [0.0, 1.0]])
    915         domain.get_disconnected_triangles()
    916         domain.get_boundary_tags()
    917         domain.get_boundary_polygon()
    918         #domain.get_number_of_triangles_per_node()
    919         domain.get_triangles_and_vertices_per_node()
    920         domain.get_interpolation_object()
    921         domain.get_tagged_elements()
    922         domain.get_lone_vertices()
    923         domain.get_unique_vertices()
    924         g = domain.get_georeference()
    925         domain.set_georeference(g)
    926         domain.build_tagged_elements_dictionary()
    927         domain.statistics()
    928         domain.get_extent()
    929 
    930     def NOtest_vertex_within_hole(self):
    931         """ NOTE: This test fails - it is designed to test fitting on
    932             a mesh with a hole, but more info is needed on the specific
    933             problem."""
    934        
    935         # For test_fitting_using_shallow_water_domain example
    936         def linear_function(point):
    937             point = num.array(point)
    938             return point[:,0]+point[:,1]       
    939        
    940         meshname = 'test_mesh.msh'
    941         verbose = False
    942         W = 0
    943         S = 0
    944         E = 10
    945         N = 10
    946 
    947         bounding_polygon = [[W, S], [E, S], [E, N], [W, N]]
    948         hole = [[[.1,.1], [9.9,1.1], [9.9,9.9], [1.1,9.9]]]
    949 
    950         create_mesh_from_regions(bounding_polygon,
    951                                  boundary_tags={'south': [0],
    952                                                 'east': [1],
    953                                                 'north': [2],
    954                                                 'west': [3]},
    955                                  maximum_triangle_area=1,
    956                                  filename=meshname,
    957                                  interior_holes = hole,
    958                                  use_cache=False,
    959                                  verbose=verbose)
    960 
    961         domain = Domain(meshname, use_cache=False, verbose=verbose)
    962         quantity = Quantity(domain)
    963        
    964          # Get (enough) datapoints (relative to georef)
    965         data_points     = [[ 0.66666667, 0.66666667],
    966                            [ 1.33333333, 1.33333333],
    967                            [ 2.66666667, 0.66666667],
    968                            [ 0.66666667, 2.66666667],
    969                            [ 0.0,        1.0],
    970                            [ 0.0,        3.0],
    971                            [ 1.0,        0.0],
    972                            [ 1.0,        1.0],
    973                            [ 1.0,        2.0],
    974                            [ 1.0,        3.0],
    975                            [ 2.0,        1.0],
    976                            [ 3.0,        0.0],
    977                            [ 3.0,        1.0]]
    978 
    979 
    980         attributes = linear_function(data_points)
    981         att = 'spam_and_eggs'
    982 
    983         # Create .txt file
    984         ptsfile = "points.txt"
    985         file = open(ptsfile, "w")
    986         file.write(" x,y," + att + " \n")
    987         for data_point, attribute in map(None, data_points, attributes):
    988             row = (str(data_point[0]) + ',' +
    989                    str(data_point[1]) + ',' +
    990                    str(attribute))
    991             file.write(row + "\n")
    992         file.close()
    993 
    994         # Check that values can be set from file
    995         quantity.set_values(filename=ptsfile, attribute_name=att, alpha=0)
    996         answer = linear_function(quantity.domain.get_vertex_coordinates())
    997 
    998         assert num.allclose(quantity.vertex_values.flat, answer)
    999 
    1000         # Check that values can be set from file using default attribute
    1001         quantity.set_values(filename = ptsfile, alpha = 0)
    1002         assert num.allclose(quantity.vertex_values.flat, answer)       
    1003        
    1004        
    1005 
    1006888#-------------------------------------------------------------
    1007889
Note: See TracChangeset for help on using the changeset viewer.