Changeset 5673
- Timestamp:
- Aug 22, 2008, 11:56:30 AM (15 years ago)
- Location:
- anuga_core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/anuga_user_manual.tex
r5672 r5673 1468 1468 1469 1469 1470 The variables \code{points}, \code{ vertices} and \code{boundary}1470 The variables \code{points}, \code{triangles} and \code{boundary} 1471 1471 represent the data displayed in Figure \ref{fig:simplemesh} as 1472 1472 follows. The list \code{points} stores the coordinates of the … … 1498 1498 \end{table} 1499 1499 1500 The list \code{ vertices} specifies the triangles that make up the1500 The list \code{triangles} specifies the triangles that make up the 1501 1501 mesh. It does this by specifying, for each triangle, the indices 1502 1502 (the numbers shown in the first column above) that correspond to the 1503 three points at its vertices, taken in an anti-clockwise order1503 three points at the triangles vertices, taken in an anti-clockwise order 1504 1504 around the triangle. Thus, in the example shown in Figure 1505 \ref{fig:simplemesh}, the variable \code{ vertices} contains the1506 entries shown in Table \ref{tab: vertices}. The starting point is1505 \ref{fig:simplemesh}, the variable \code{triangles} contains the 1506 entries shown in Table \ref{tab:triangles}. The starting point is 1507 1507 arbitrary so triangle $(0,1,3)$ is considered the same as $(1,3,0)$ 1508 1508 and $(3,0,1)$. … … 1512 1512 \begin{center} 1513 1513 \begin{tabular}{|c|ccc|} \hline 1514 index & \multicolumn{3}{c|}{\code{ vertices}}\\ \hline1514 index & \multicolumn{3}{c|}{\code{points}}\\ \hline 1515 1515 0 & 0 & 1 & 3\\ 1516 1516 1 & 1 & 2 & 4\\ … … 1526 1526 \end{center} 1527 1527 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} 1530 1530 \end{table} 1531 1531 … … 1626 1626 1627 1627 This 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. 1628 segments connecting the points. Points is a list of points. Segments 1629 is a list of segments. Each segment is defined by the start and end 1630 of 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 1632 each segment can optionally be added. 1630 1633 1631 1634 \end{methoddesc} -
anuga_core/source/anuga/pmesh/mesh.py
r5209 r5673 872 872 873 873 def add_points_and_segments(self, points, 874 segments , segment_tags = None):874 segments=None, segment_tags = None): 875 875 """ 876 876 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. 878 878 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. 881 880 segment_tags is an optional dictionary which is used to add tags to 882 881 the segments. The key is the tag name, value is the list of segment … … 887 886 #make sure the points are absolute 888 887 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 890 894 #create points, segs and tags 891 895 region_dict = {} -
anuga_core/source/anuga/pmesh/test_mesh.py
r5207 r5673 1500 1500 points = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]] 1501 1501 segments = [[0, 1], [1, 2]] 1502 segment_tags = {' do-op':[1]}1502 segment_tags = {'hair':[1]} 1503 1503 m.add_points_and_segments(points, 1504 1504 segments, segment_tags) … … 1513 1513 self.failUnless(m.userSegments[0].tag =='food', 1514 1514 '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', 1516 1538 'Wrong segment tag.') 1517 1539 … … 1842 1864 1843 1865 self.failUnless(segs[2].tag=='bom', 1844 'FAILED!') 1866 'FAILED!') 1845 1867 self.failUnless(segs[3].tag=='', 1846 1868 'FAILED!') … … 2287 2309 #suite = unittest.makeSuite(meshTestCase,'test_asciiFile') 2288 2310 #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') 2290 2312 runner = unittest.TextTestRunner() #verbosity=2) 2291 2313 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.