Changeset 4144


Ignore:
Timestamp:
Jan 8, 2007, 3:20:41 PM (18 years ago)
Author:
duncan
Message:

Changing the mesh generator and triangle interface to work with Numeric arrys, as input. Fixed to work on Linux

Location:
anuga_core/source/anuga
Files:
5 deleted
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/alpha_shape/alpha_shape.py

    r4142 r4144  
    179179
    180180        ## Build Delaunay triangulation
    181         import anuga.mesh_engine.triang as triang
     181        from anuga.mesh_engine.mesh_engine import generate_mesh
    182182        points = []
    183183        seglist = []
     
    186186        pointattlist = []
    187187        segattlist = []
    188         trilist = []
    189188
    190189        points = [(pt[0], pt[1]) for pt in self.points]
     
    192191        mode = "Qzcn"
    193192        #print "computing delaunay triangulation ... \n"
    194         tridata = triang.genMesh(points,seglist,holelist,regionlist,
    195                                  pointattlist,segattlist,trilist,mode)
     193        tridata = generate_mesh(points,seglist,holelist,regionlist,
     194                                 pointattlist,segattlist,mode)
    196195        #print tridata
    197196        #print "point attlist: ", tridata['generatedpointattributelist'],"\n"
  • anuga_core/source/anuga/fit_interpolate/test_fit.py

    r4135 r4144  
    271271       
    272272        f = fit_to_mesh(vertices, triangles,fileName,
    273                                 alpha=0.0, max_read_lines=2)
     273                                alpha=0.0, max_read_lines=2)#, verbose=True)
    274274        answer = linear_function(vertices)
    275275        #print "f\n",f
  • anuga_core/source/anuga/mesh_engine/compile.py

    r4142 r4144  
    319319              print "********** Manually doing dependencies **************"
    320320              compile(['triang.c','triangle.c'])
    321             elif  filename == 'mesh_engine.c': # not part of ANUGA
    322               continue
     321            elif  filename == 'mesh_engine_c_layer.c':
    323322              #print "********** Manually doing dependencies **************"
    324               #compile(['mesh_engine.c','triangle.c'])
     323              compile(['mesh_engine_c_layer.c','triangle.c'])
    325324             
    326325            else:
  • anuga_core/source/anuga/mesh_engine/me_compile.py

    r4142 r4144  
    315315          print '--------------- Trying to compile c-extension %s' %filename
    316316          try:
    317             if filename == 'mesh_engine.c':
     317            if filename == 'mesh_engine_c_layer.c':
    318318              print "********** Manually doing dependencies **************"
    319               compile(['mesh_engine.c','triangle.c'])
     319              compile(['mesh_engine_c_layer.c','triangle.c'])
    320320            else:
    321321              compile(filename)
  • anuga_core/source/anuga/mesh_engine/test_generate_mesh.py

    r4139 r4144  
    522522    suite = unittest.makeSuite(triangTestCase,'test')
    523523    #suite = unittest.makeSuite(triangTestCase,'test_lone_verts4')
    524     ###suite = unittest.makeSuite(triangTestCase,'testrectangleII')
     524    #suite = unittest.makeSuite(triangTestCase,'testrectangleIIb')
    525525    runner = unittest.TextTestRunner() #verbosity=2)
    526526    runner.run(suite)
  • anuga_core/source/anuga/pmesh/mesh.py

    r4142 r4144  
    55   Note: A .index attribute is added to objects such as vertices and
    66   segments, often when reading and writing to files.  This information
    7    should not be used as percistant information.  It is not the 'index' of
     7   should not be used as persistant information.  It is not the 'index' of
    88   an element in a list.
    99
     
    1616import sys
    1717import math
    18 import anuga.mesh_engine.triang as triang
    1918import re
    2019import os
     
    2322import types
    2423import exceptions
    25 
    26 import load_mesh
     24from Numeric import array, Float, Int
     25
     26
     27#import load_mesh
    2728from anuga.coordinate_transforms.geo_reference import Geo_reference,DEFAULT_ZONE
    2829from anuga.utilities.polygon import point_in_polygon
    2930import load_mesh.loadASCII
    3031import anuga.alpha_shape.alpha_shape
    31 from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_geospatial, ensure_absolute
     32from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_geospatial, ensure_absolute, ensure_numeric
     33from anuga.mesh_engine.mesh_engine import generate_mesh
     34
     35#import anuga.mesh_engine_b.mesh_engine as triang
    3236
    3337try: 
     
    467471Segment.set_default_tag("")       
    468472
     473class Rigid_triangulation:
     474    """
     475    This is a triangulation that can't have triangles added or taken away.
     476
     477    It just represents the triangulation, not the mesh outline needed to
     478    build the triangulation.
     479
     480      This is the guts of the data structure;
     481        generated vertex list: [(x1,y1),(x2,y2),...] (Tuples of doubles)
     482        generated segment list: [(point1,point2),(p3,p4),...]
     483            (Tuples of integers)
     484        generated segment tag list: [tag,tag,...] list of strings
     485
     486        generated triangle list: [(p1,p2,p3), (p4,p5,p6),....] tuple of points
     487
     488        generated triangle attribute list: [s1,s2,...] list of strings
     489
     490        generated triangle neighbor list: [(t1,t2,t3), (t4,t5,t6),....]
     491            tuple of triangles
     492
     493            Should I do the basic structure like triangle, general
     494            mesh or something else? How about like triangle, since
     495            that's where the info is from, and it'll fit easier into
     496            this file..
     497
     498             Removing the loners is difficult, since all the vert's
     499             after it must be removed.
     500
     501             This happens in set_triangulation.
     502           
     503    """
     504
     505    def __init__(self,
     506                 triangles,
     507                 segments,
     508                 vertices,
     509                 triangle_tags,
     510                 triangle_neighbor,
     511                 segment_tags,
     512                 ):
     513       
     514        self.triangles=ensure_numeric(triangles)
     515        self.triangle_neighbor=ensure_numeric(triangle_neighbor)
     516        self.triangle_tags=triangle_tags
     517        self.segments=ensure_numeric(segments)
     518       
     519        self.segment_tags=segment_tags # string
     520        self.vertices=ensure_numeric(vertices)
     521
     522       
     523       
    469524class Mesh:
    470525    """
     
    10541109        #print "mesh#generateMesh# self.mode",self.mode 
    10551110        meshDict = self.Mesh2triangList()
     1111
     1112        #FIXME (DSG-DSG)  move below section into generate_mesh.py
     1113        #                  & 4 functions eg segment_strings2ints
    10561114        #print "*************************!@!@ This is going to triangle   !@!@"
    10571115        #print meshDict
     
    10671125        #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%regionlist",meshDict['regionlist']
    10681126        #print "meshDict['segmenttaglist']", meshDict['segmenttaglist'
    1069         generatedMesh = triang.genMesh(
     1127        generatedMesh = generate_mesh(
    10701128                              meshDict['pointlist'],
    10711129                              meshDict['segmentlist'],
     
    10741132                              meshDict['pointattributelist'],
    10751133                              meshDict['segmenttaglist'],
    1076                               [],  # since the trianglelist isn't used
    1077                               self.mode)
     1134                              self.mode,
     1135                              meshDict['pointlist'])
    10781136        #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%generated",generatedMesh
    10791137        generatedMesh['generatedsegmentmarkerlist'] = \
     
    10811139                                  segconverter)
    10821140        #print "processed gen",generatedMesh['generatedsegmentmarkerlist']
     1141        #print "generatedtriangleattributelist",generatedMesh['generatedtriangleattributelist']
    10831142        generatedMesh['generatedtriangleattributelist'] = \
    10841143         region_ints2strings(generatedMesh['generatedtriangleattributelist'],
    10851144                                  regionconverter)
    10861145
     1146        #FIXME (DSG-DSG)  move above section into generate_mesh.py
    10871147
    10881148        if len(generatedMesh['generatedpointattributelist'][0])==0:
     
    14001460            -1 means there's no triangle neighbor
    14011461        triangle attribute list: [(T1att), (T2att), ...]
     1462
     1463
    14021464            (list of a list of strings)
    14031465        lone point list:[point1, ...] (list of integers)
  • anuga_core/source/anuga/pmesh/test_mesh.py

    r4142 r4144  
    10681068                        ,
    10691069                        'exported Ascii xya file is wrong')
    1070            
     1070     
     1071    def test_lone_vert_in_mesh_gen_c_layer(self):
     1072        # currently just a copy of the above test
     1073        a = Vertex (0,0)
     1074        b = Vertex (0,3)
     1075        c = Vertex (3,3)
     1076        d = Vertex (1,2)
     1077        e = Vertex (3,1)
     1078        #f = Vertex (3,1)
     1079     
     1080        s1 = Segment(a,b, tag = 50)
     1081        s2 = Segment(b,c, tag = 40)
     1082        s3 = Segment(c,a, tag = 30)
     1083     
     1084        r1 = Region(2, 1,tag = 1.3)
     1085        h1 = Hole(1,4)
     1086        # Warning mesh can't produce this type of data structure its self
     1087        m = Mesh(userVertices=[a,b,c,d,e],
     1088                 userSegments=[s1,s2,s3],
     1089                 regions=[r1],
     1090                 holes = [h1])
     1091       
     1092        fileName = tempfile.mktemp(".xya")
     1093        #fileName = 't.xya'
     1094        #os.remove(fileName)
     1095        m.exportPointsFile(fileName)
     1096        file = open(fileName)
     1097        lFile = file.read().split('\n')
     1098        file.close()
     1099
     1100        os.remove(fileName)
     1101        self.failUnless(lFile[0] == "" and
     1102                        lFile[1] == "0,0" and
     1103                        lFile[2] == "0,3" and
     1104                        lFile[3] == "3,3"
     1105                        ,
     1106                        'exported Ascii xya file is wrong')
     1107        self.failUnless(lFile[4] == "1,2" and
     1108                        lFile[5] == "3,1"
     1109                        ,
     1110                        'exported Ascii xya file is wrong')
     1111       
     1112        # vertex e is outside of the outline, so
     1113        # it is a loner and it is removed.
     1114        m.generateMesh("Q", maxArea = 2.1)
     1115        fileName = tempfile.mktemp(".xya")
     1116        #fileName = 't.xya'
     1117        #m.export_mesh_file('m.tsh')
     1118        m.exportPointsFile(fileName)
     1119        file = open(fileName)
     1120        lFile = file.read().split('\n')
     1121        file.close()
     1122        os.remove(fileName)
     1123       
     1124        self.failUnless(lFile[0] == "" and
     1125                        lFile[1] == "0.0,0.0" and
     1126                        lFile[2] == "0.0,3.0" and
     1127                        lFile[3] == "3.0,3.0" and
     1128                        lFile[4] == "1.0,2.0"
     1129                        ,
     1130                        'exported Ascii xya file is wrong')
     1131       
    10711132    def test_exportPointsFilefile2(self):
    10721133        m = Mesh()
     
    22762337if __name__ == "__main__":
    22772338    suite = unittest.makeSuite(meshTestCase,'test')
    2278     #suite = unittest.makeSuite(meshTestCase,'test_add_points_and_segments')
     2339    #suite = unittest.makeSuite(meshTestCase,'test_exportASCIIsegmentoutlinefile')
     2340    #suite = unittest.makeSuite(meshTestCase,'test_e')
    22792341    runner = unittest.TextTestRunner() #verbosity=2)
    22802342    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.