Changeset 7725


Ignore:
Timestamp:
May 14, 2010, 11:57:16 AM (14 years ago)
Author:
hudson
Message:

Added test_vertex_within_hole to test fitting on a mesh with a hole.

File:
1 edited

Legend:

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

    r7573 r7725  
    55
    66from anuga.abstract_2d_finite_volumes.domain import *
     7from anuga.pmesh.mesh_interface import create_mesh_from_regions
    78from anuga.config import epsilon
    8 
     9from anuga.shallow_water import Reflective_boundary
     10from anuga.shallow_water import Dirichlet_boundary
    911import numpy as num
     12from anuga.pmesh.mesh import Segment, Vertex, Mesh
    1013
    1114
     
    10541057        domain.get_extent()
    10551058
     1059    def NOtest_vertex_within_hole(self):
     1060        """ NOTE: This test fails - it is designed to test fitting on
     1061            a mesh with a hole, but more info is needed on the specific
     1062            problem."""
     1063       
     1064        # For test_fitting_using_shallow_water_domain example
     1065        def linear_function(point):
     1066            point = num.array(point)
     1067            return point[:,0]+point[:,1]       
     1068       
     1069        meshname = 'test_mesh.msh'
     1070        verbose = False
     1071        W = 0
     1072        S = 0
     1073        E = 10
     1074        N = 10
     1075
     1076        bounding_polygon = [[W, S], [E, S], [E, N], [W, N]]
     1077        hole = [[[.1,.1], [9.9,1.1], [9.9,9.9], [1.1,9.9]]]
     1078
     1079        create_mesh_from_regions(bounding_polygon,
     1080                                 boundary_tags={'south': [0],
     1081                                                'east': [1],
     1082                                                'north': [2],
     1083                                                'west': [3]},
     1084                                 maximum_triangle_area=1,
     1085                                 filename=meshname,
     1086                                 interior_holes = hole,
     1087                                 use_cache=False,
     1088                                 verbose=verbose)
     1089
     1090        domain = Domain(meshname, use_cache=False, verbose=verbose)
     1091        quantity = Quantity(domain)
     1092       
     1093         # Get (enough) datapoints (relative to georef)
     1094        data_points     = [[ 0.66666667, 0.66666667],
     1095                           [ 1.33333333, 1.33333333],
     1096                           [ 2.66666667, 0.66666667],
     1097                           [ 0.66666667, 2.66666667],
     1098                           [ 0.0,        1.0],
     1099                           [ 0.0,        3.0],
     1100                           [ 1.0,        0.0],
     1101                           [ 1.0,        1.0],
     1102                           [ 1.0,        2.0],
     1103                           [ 1.0,        3.0],
     1104                           [ 2.0,        1.0],
     1105                           [ 3.0,        0.0],
     1106                           [ 3.0,        1.0]]
     1107
     1108
     1109        attributes = linear_function(data_points)
     1110        att = 'spam_and_eggs'
     1111
     1112        # Create .txt file
     1113        ptsfile = "points.txt"
     1114        file = open(ptsfile, "w")
     1115        file.write(" x,y," + att + " \n")
     1116        for data_point, attribute in map(None, data_points, attributes):
     1117            row = (str(data_point[0]) + ',' +
     1118                   str(data_point[1]) + ',' +
     1119                   str(attribute))
     1120            file.write(row + "\n")
     1121        file.close()
     1122
     1123        # Check that values can be set from file
     1124        quantity.set_values(filename=ptsfile, attribute_name=att, alpha=0)
     1125        answer = linear_function(quantity.domain.get_vertex_coordinates())
     1126
     1127        assert num.allclose(quantity.vertex_values.flat, answer)
     1128
     1129        # Check that values can be set from file using default attribute
     1130        quantity.set_values(filename = ptsfile, alpha = 0)
     1131        assert num.allclose(quantity.vertex_values.flat, answer)       
    10561132       
    10571133       
Note: See TracChangeset for help on using the changeset viewer.