Changeset 5638
- Timestamp:
- Aug 11, 2008, 12:41:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/pmesh/test_mesh_interface.py
r5193 r5638 800 800 m.generate_mesh(maximum_triangle_area=max_area,verbose=False) 801 801 m.export_mesh_file('b_test_mesh_iknterface.tsh') 802 803 def concept_ungenerateII(self): 804 805 from anuga.shallow_water import Domain, Reflective_boundary, \ 806 Dirichlet_boundary 807 x=0 808 y=0 809 mesh_geo = geo_reference=Geo_reference(56,x,y) 810 811 # These are the absolute values 812 polygon_absolute = [[0,0],[100,0],[100,100],[0,100]] 813 814 x_p = -10 815 y_p = -40 816 geo_ref_poly = Geo_reference(56, x_p, y_p) 817 polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute) 818 819 boundary_tags = {'wall':[0,1,3],'wave':[2]} 820 821 inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]] 822 inner1_polygon = geo_ref_poly. \ 823 change_points_geo_ref(inner1_polygon_absolute) 824 825 inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]] 826 inner2_polygon = geo_ref_poly. \ 827 change_points_geo_ref(inner2_polygon_absolute) 828 829 max_area = 1 830 interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)] 831 m = create_mesh_from_regions(polygon, 832 boundary_tags, 833 max_area, 834 interior_regions=interior_regions, 835 poly_geo_reference=geo_ref_poly, 836 mesh_geo_reference=mesh_geo) 837 838 m.export_mesh_file('a_test_mesh_iknterface.tsh') 839 840 fileName = tempfile.mktemp(".txt") 841 file = open(fileName,"w") 842 file.write(" 1 ?? ??\n\ 843 90.0 90.0\n\ 844 81.0 90.0\n\ 845 81.0 81.0\n\ 846 90.0 81.0\n\ 847 90.0 90.0\n\ 848 END\n\ 849 2 ?? ??\n\ 850 10.0 80.0\n\ 851 10.0 90.0\n\ 852 20.0 90.0\n\ 853 10.0 80.0\n\ 854 END\n\ 855 END\n") 856 file.close() 857 858 m.import_ungenerate_file(fileName) #, tag='wall') 859 os.remove(fileName) 860 m.generate_mesh(maximum_triangle_area=max_area,verbose=False) 861 mesh_filename = "bento_b.tsh" 862 m.export_mesh_file(mesh_filename) 863 864 domain = Domain(mesh_filename, use_cache = False) 865 866 Br = Reflective_boundary(domain) 867 Bd = Dirichlet_boundary([3,0,0]) 868 domain.set_boundary( {'wall': Br, 'wave': Bd} ) 869 yieldstep = 0.1 870 finaltime = 10 871 for t in domain.evolve(yieldstep, finaltime): 872 domain.write_time() 873 874 def concept_ungenerateIII(self): 875 876 from anuga.shallow_water import Domain, Reflective_boundary, \ 877 Dirichlet_boundary 878 879 from anuga.pmesh.mesh_interface import create_mesh_from_regions 880 881 # These are the absolute values 882 polygon = [[0,0],[100,0],[100,100],[0,100]] 883 884 boundary_tags = {'wall':[0,1,3],'wave':[2]} 885 886 inner1_polygon = [[10,10],[20,10],[20,20],[10,20]] 887 888 889 inner2_polygon = [[30,30],[40,30],[40,40],[30,40]] 890 891 892 max_area = 1 893 interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)] 894 m = create_mesh_from_regions(polygon, 895 boundary_tags, 896 max_area, 897 interior_regions=interior_regions) 898 899 fileName = tempfile.mktemp(".txt") 900 file = open(fileName,"w") 901 file.write(" 1 ?? ??\n\ 902 90.0 90.0\n\ 903 81.0 90.0\n\ 904 81.0 81.0\n\ 905 90.0 81.0\n\ 906 90.0 90.0\n\ 907 END\n\ 908 2 ?? ??\n\ 909 10.0 80.0\n\ 910 10.0 90.0\n\ 911 20.0 90.0\n\ 912 10.0 80.0\n\ 913 END\n\ 914 END\n") 915 file.close() 916 917 m.import_ungenerate_file(fileName) 918 os.remove(fileName) 919 m.generate_mesh(maximum_triangle_area=max_area,verbose=False) 920 mesh_filename = "mesh.tsh" 921 m.export_mesh_file(mesh_filename) 922 923 domain = Domain(mesh_filename, use_cache = False) 924 925 Br = Reflective_boundary(domain) 926 Bd = Dirichlet_boundary([3,0,0]) 927 domain.set_boundary( {'wall': Br, 'wave': Bd} ) 928 yieldstep = 0.1 929 finaltime = 10 930 for t in domain.evolve(yieldstep, finaltime): 931 domain.write_time() 802 932 #------------------------------------------------------------- 803 933 if __name__ == "__main__": 804 934 suite = unittest.makeSuite(TestCase,'test') 805 #suite = unittest.makeSuite(TestCase,' test_create_mesh_from_regions_with_ungenerate')935 #suite = unittest.makeSuite(TestCase,'concept_ungenerateIII') 806 936 runner = unittest.TextTestRunner() #verbosity=2) 807 937 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.