Changeset 2457
- Timestamp:
- Feb 28, 2006, 2:55:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentation/user_manual/anuga_user_manual.tex
r2455 r2457 286 286 \begin{itemize} 287 287 288 \item a list \code{points} of length $N$, where $N = (m + 1)(n + 1)$,289 comprising the coordinates $(x, y)$ of each of the $N$ mesh290 points,291 292 \item a list \code{vertices} of length $2mn$ (each entry specifies the three293 vertices of one of the triangles used in the triangulation) , and288 \item a list \code{points} % of length $N$, where $N = (m + 1)(n + 1)$, 289 %comprising the coordinates $(x, y)$ of each of the $N$ mesh 290 %points, 291 292 \item a list \code{vertices} %of length $2mn$ (each entry specifies the three 293 %vertices of one of the triangles used in the triangulation) , and 294 294 295 295 \item a dictionary \code{boundary}, used to tag the triangle edges on … … 492 492 the \code{bedslope.py} example and introduces a second example, 493 493 \code{run_sydney_smf.py}, that follows the same basic outline, but 494 incorporates many more complex features. 494 incorporates more complex features and refers to a real-life 495 scenario, rather than the artificial illustrative one used in 496 \code{bedslope.py}. 495 497 496 498 \subsection{Overview} … … 607 609 #------------------------------------------------------------------------------- 608 610 609 #def get_polygon_from_file(filename): # fid = open(filename) # 610 lines = fid.readlines() # fid.close() 611 612 # polygon = [] # for line in lines[1:]: # fields = 613 line.split(',') # x = float(fields[3]) # y = 614 float(fields[4]) # polygon.append([x, y]) 615 616 # return interior_polygon 617 618 from pmesh.create_mesh import create_mesh_from_regions 619 \end{verbatim}} 620 621 622 {\scriptsize \begin{verbatim} 623 num_polygons = 1 filelist = [] fileext 624 = '.csv' filename = project.polygonptsfile interior_res = 50000 625 626 for p in range(1, num_polygons+1): 627 thefilename = filename + str(p) + fileext 628 interior_polygon = get_polygon_from_file(thefilename) 629 interior_regions.append([interior_polygon, interior_res]) 630 631 # test 632 #interior_regions = [[project.poly1, interior_res], 633 # 634 [project.poly2, interior_res]] 635 # original 636 #interior_regions = 637 [[project.harbour_polygon_2, interior_res], 638 # 611 interior_regions = [[project.harbour_polygon_2, interior_res], 639 612 [project.botanybay_polygon_2, interior_res]] 640 613 … … 743 716 In its simplest form, the technique creates the mesh within a single 744 717 polygon whose vertices are at geographical locations specified by 745 the user. A triangular mesh is created using points insidethe746 polygon selected through a random process, the user specifying the 747 \emph{resolution}---that is, the maximal area of a triangle used for 748 triangulation. 749 750 Figure XXX shows a simple example of this, in which the 751 triangulation is carried out within a pentagon. Instead of using the 752 four tags \code{`left'}, \code{`right'}, \code{`bottom'} and 753 \code{ `top'} that we used in the case of \code{bedslope.py} to754 distinguish boundary elements, the user can define tags appropriate 755 to the configuration being modelled. 756 757 While this simple version of the technique offers more flexibility 758 than the rectangular grid, itdoesn't provide a way to adapt to718 the user. The user specifies the \emph{resolution}---that is, the 719 maximal area of a triangle used for triangulation---and mesh points 720 are created inside the polygon through a random process. Figure XXX 721 shows a simple example of this, in which the triangulation is 722 carried out within a pentagon. 723 724 Boundary tags are not restricted to \code{`left'}, \code{`right'}, 725 \code{`bottom'} and \code{`top'}, as in the case of 726 \code{bedslope.py}. Instead the user specifies a list of tags 727 appropriate to the configuration being modelled. 728 729 While a mesh created inside a polygon offers more flexibility than 730 one based on a rectangular grid, the technique of mesh creation that 731 we have so far described doesn't provide a way to adapt to 759 732 geographic or other features in the landscape, whose presence may 760 733 require us to vary the resolution in the neighbourhood of the 761 features. To achieve more flexibility we therefore extend the762 technique, allowingthe user to specify a number of interior734 features. To achieve more flexibility, an extension of the technique 735 is adopted, which allows the user to specify a number of interior 763 736 polygons to be triangulated separately, possibly using different 764 737 resolutions. See Figure XXX. … … 766 739 The upshot is a general method that takes for its input a bounding 767 740 polygon and (optionally) a list of interior polygons. It creates a 768 triangular mesh inside the bounding polygon, using a specified769 resolution, but initially leaves the regions inside the interior770 polygons alone. It then triangulates each of these regions 771 separately, using a separately specified resolution.772 773 The function used to implement this process is the function741 triangular mesh inside the bounding polygon, using a user-specified 742 resolution, but then creates a separate triangulation inside each of 743 the interior polygons, according to the resolution specified for 744 that polygon. 745 746 The function used to implement this process is 774 747 \code{create_mesh_from_regions}. Its arguments include the bounding 775 748 polygon and its resolution, a list of boundary tags, and a list of … … 778 751 779 752 In practice, the details of the polygons used are read from a 780 separate file \code{project.py}. 753 separate file \code{project.py}. The resulting mesh is output to a 754 \emph{meshfile}, which is a file of a specific format used to store 755 the data specifying a mesh. (There are two formats for such a file: 756 it can either be a binary file, with extension \code{.msh}, or an 757 ASCII file, with extension \code{.tsh}. In the present case, the 758 binary file format \code{.msh} is used. See Section \ref{sec:file 759 formats} for more on file formats.) and assigned a name obtained by 760 appending the extension \code{.msh} to the name specified in the 761 input file \code{project.py}. This name is stored in the variable 762 \code{meshname}. 781 763 782 764 … … 784 766 785 767 As with \code{bedslope.py}, once we have created the mesh, the next 786 step is to create the data structure \code{domain}. 768 step is to create the data structure \code{domain}. This is 769 accomplished through the following statements: 787 770 788 771 {\scriptsize \begin{verbatim} … … 793 776 \end{verbatim}} 794 777 778 The function \code{pmesh_to_domain_instance} converts a meshfile 779 \code{meshname} into an instance of the data structure 780 \code{domain}, allowing us to use methods like \code{set\_quantity} 781 to set quantities and to apply other operations. In the case of 782 \code{bedslope.py}, 783 795 784 \subsection{Specifying the Quantities} 785 786 796 787 797 788 {\scriptsize \begin{verbatim} … … 820 811 821 812 #------------------------------------------------------------------------------- 822 # Set up initial conditions813 # Set up initial conditions 823 814 #------------------------------------------------------------------------------- 824 815 … … 1344 1335 \item \indexedbold{Mesh} triangulation of domain 1345 1336 1337 \item \indexedbold{meshfile} [generic word for either .tsh or 1338 .msh file] 1339 1340 \item \indexedbold{points file} [generic word for either .pts or 1341 .xya file] 1342 1346 1343 \item \indexedbold{Grid} evenly spaced 1347 1344
Note: See TracChangeset
for help on using the changeset viewer.