Changeset 5673


Ignore:
Timestamp:
Aug 22, 2008, 11:56:30 AM (16 years ago)
Author:
duncan
Message:

update to add_points_and_segments

Location:
anuga_core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/anuga_user_manual.tex

    r5672 r5673  
    14681468
    14691469
    1470 The variables \code{points}, \code{vertices} and \code{boundary}
     1470The variables \code{points}, \code{triangles} and \code{boundary}
    14711471represent the data displayed in Figure \ref{fig:simplemesh} as
    14721472follows. The list \code{points} stores the coordinates of the
     
    14981498\end{table}
    14991499
    1500 The list \code{vertices} specifies the triangles that make up the
     1500The list \code{triangles} specifies the triangles that make up the
    15011501mesh. It does this by specifying, for each triangle, the indices
    15021502(the numbers shown in the first column above) that correspond to the
    1503 three points at its vertices, taken in an anti-clockwise order
     1503three points at the triangles vertices, taken in an anti-clockwise order
    15041504around the triangle. Thus, in the example shown in Figure
    1505 \ref{fig:simplemesh}, the variable \code{vertices} contains the
    1506 entries shown in Table \ref{tab:vertices}. The starting point is
     1505\ref{fig:simplemesh}, the variable \code{triangles} contains the
     1506entries shown in Table \ref{tab:triangles}. The starting point is
    15071507arbitrary so triangle $(0,1,3)$ is considered the same as $(1,3,0)$
    15081508and $(3,0,1)$.
     
    15121512  \begin{center}
    15131513    \begin{tabular}{|c|ccc|} \hline
    1514       index & \multicolumn{3}{c|}{\code{vertices}}\\ \hline
     1514      index & \multicolumn{3}{c|}{\code{points}}\\ \hline
    15151515      0 & 0 & 1 & 3\\
    15161516      1 & 1 & 2 & 4\\
     
    15261526  \end{center}
    15271527
    1528   \caption{Vertices for mesh in Figure \protect \ref{fig:simplemesh}}
    1529   \label{tab:vertices}
     1528  \caption{Triangles for mesh in Figure \protect \ref{fig:simplemesh}}
     1529  \label{tab:triangles}
    15301530\end{table}
    15311531
     
    16261626
    16271627This method is used to build the mesh outline. It adds points and
    1628 segments connecting the points.  A tag for each segment can optionally
    1629 be added.
     1628segments connecting the points.  Points is a list of points. Segments
     1629is a list of segments.  Each segment is defined by the start and end
     1630of the line by it's point index, e.g. use \code{segments =
     1631[[0,1],[1,2]]} to make a polyline between points 0, 1 and 2. A tag for
     1632each segment can optionally be added.
    16301633
    16311634\end{methoddesc}
  • anuga_core/source/anuga/pmesh/mesh.py

    r5209 r5673  
    872872
    873873    def add_points_and_segments(self, points,
    874                                   segments, segment_tags = None):
     874                                  segments=None, segment_tags = None):
    875875        """
    876876        Add an outline of the mesh.
    877         Vertices is a list of points/ a standard representation of points.
     877        Points is a list of points a standard representation of points.
    878878        Segments is a list of tuples of integers.  Each tuple defines the
    879            start and end of the segment by it's vertex index, in relation to
    880            the list of vertices.
     879           start and end of the segment by it's point index.
    881880        segment_tags is an optional dictionary which is used to add tags to
    882881           the segments.  The key is the tag name, value is the list of segment
     
    887886        #make sure the points are absolute
    888887        points = ensure_absolute(points)
    889        
     888
     889        if segments is None:
     890            segments = []
     891            for i in range(len(points)-1):
     892                segments.append([i, i+1])
     893           
    890894        #create points, segs and tags
    891895        region_dict = {}
  • anuga_core/source/anuga/pmesh/test_mesh.py

    r5207 r5673  
    15001500        points =  [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
    15011501        segments = [[0, 1], [1, 2]]
    1502         segment_tags = {'do-op':[1]}
     1502        segment_tags = {'hair':[1]}
    15031503        m.add_points_and_segments(points,
    15041504                                    segments, segment_tags)
     
    15131513        self.failUnless(m.userSegments[0].tag =='food',
    15141514                        'Wrong segment tag length.')
    1515         self.failUnless(m.userSegments[1].tag =='do-op',
     1515        self.failUnless(m.userSegments[1].tag =='hair',
     1516                        'Wrong segment tag.')
     1517       
     1518    def test_add_points_and_segmentsII(self):
     1519        m = Mesh()
     1520        Segment.set_default_tag("food")
     1521        dict = {}
     1522        points =  [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
     1523        segments = None #[[0, 1], [1, 2]]
     1524        segment_tags = {'hair':[1]}
     1525        m.add_points_and_segments(points,
     1526                                    segments, segment_tags)
     1527        # have to reset this , since it's a class attribute
     1528        Segment.set_default_tag("")
     1529
     1530       
     1531        self.failUnless(len(m.userSegments) ==2,
     1532                        'Wrong segment list length.')
     1533        self.failUnless(len(m.userVertices) == 3,
     1534                        'Wrong vertex list length.')
     1535        self.failUnless(m.userSegments[0].tag =='food',
     1536                        'Wrong segment tag length.')
     1537        self.failUnless(m.userSegments[1].tag =='hair',
    15161538                        'Wrong segment tag.')
    15171539       
     
    18421864         
    18431865        self.failUnless(segs[2].tag=='bom',
    1844                         'FAILED!') 
     1866                        'FAILED!')
    18451867        self.failUnless(segs[3].tag=='',
    18461868                        'FAILED!')
     
    22872309    #suite = unittest.makeSuite(meshTestCase,'test_asciiFile')
    22882310    #suite = unittest.makeSuite(meshTestCase,'test_mesh2IO')
    2289     #suite = unittest.makeSuite(meshTestCase,'test_import_ungenerate_file')
     2311    #suite = unittest.makeSuite(meshTestCase,'test_add_points_and_segmentsII')
    22902312    runner = unittest.TextTestRunner() #verbosity=2)
    22912313    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.