Changeset 2455
- Timestamp:
- Feb 27, 2006, 4:52:42 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentation/user_manual/anuga_user_manual.tex
r2450 r2455 146 146 many of the ideas, and the second is a real-life example. 147 147 148 \section{First Example: Overview} 148 \section{A Simple Example} 149 150 \subsection{Overview} 149 151 150 152 What follows … … 181 183 %\emph{[More details of the problem background]} 182 184 183 \s ection{Outline of the Program}185 \subsection{Outline of the Program} 184 186 185 187 In outline, \code{bedslope.py} performs the following steps: … … 203 205 \end{enumerate} 204 206 205 \s ection{The Code}207 \subsection{The Code} 206 208 207 209 %FIXME: we are using the \code function here. … … 257 259 for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0): 258 260 domain.write_time() 259 260 261 \end{verbatim}} 262 263 264 \section{Establishing the Mesh} 261 \end{verbatim}} 262 263 264 \subsection{Establishing the Mesh} 265 265 266 266 The first task is to set up the triangular mesh to be used for the … … 302 302 303 303 304 \s ection{Initialising the Domain}304 \subsection{Initialising the Domain} 305 305 306 306 These variables are then used to set up a data structure … … 323 323 324 324 325 \s ection{Specifying the Quantities}325 \subsection{Specifying the Quantities} 326 326 327 327 The next task is to specify a number of quantities that we wish to set … … 340 340 341 341 342 \subs ection{Elevation}342 \subsubsection{Elevation} 343 343 344 344 The elevation is set using a function, defined through the … … 365 365 366 366 367 \subs ection{Friction}367 \subsubsection{Friction} 368 368 369 369 The assignment of the friction quantity demonstrates another way … … 378 378 to 0.1 at every mesh point. 379 379 380 \subs ection{Depth}380 \subsubsection{Depth} 381 381 382 382 Assigning depth illustrates a more complex way to use … … 395 395 elevation of the bed. 396 396 397 \subs ection{Boundary Conditions}397 \subsubsection{Boundary Conditions} 398 398 399 399 The boundary conditions are specified as follows: … … 446 446 447 447 448 \s ection{Evolution}448 \subsection{Evolution} 449 449 450 450 The final statement \nopagebreak[3] … … 462 462 463 463 464 \s ection{Output}464 \subsection{Output} 465 465 466 466 %Give details here of the form of the output and explain how it can … … 493 493 \code{run_sydney_smf.py}, that follows the same basic outline, but 494 494 incorporates many more complex features. 495 496 \subsection{Overview} 497 As in the case of \code{bedslope.py}, the actions carried out by the 498 program can be organised according to this outline: 499 500 \begin{enumerate} 501 502 \item Set up a triangular mesh. 503 504 \item Set certain parameters governing the mode of 505 operation of the model-specifying, for instance, where to store the 506 model output. 507 508 \item Input various quantities describing physical measurements, such 509 as the elevation, to be specified at each mesh point (vertex). 510 511 \item Set up the boundary conditions. 512 513 \item Carry out the evolution of the model through a series of time 514 steps and outputs the results, providing a results file that can be 515 visualised. 516 517 \end{enumerate} 518 519 520 521 \subsection{The Code} 495 522 496 523 Here is the code for \code{run_sydney_smf.py}: … … 535 562 from smf import slump_tsunami 536 563 # Function for submarine mudslide 537 538 539 #------------------------------------------------------------------------------- 540 # Preparation of topographic data # 541 # Convert ASC 2 DEM 2 PTS using542 source data and store result in source data 543 # Do for coarse and fine564 \end{verbatim}} 565 566 567 {\scriptsize \begin{verbatim} 568 #------------------------------------------------------------------------------- 569 # Preparation of topographic data # # Convert ASC 2 DEM 2 PTS using 570 source data and store result in source data # Do for coarse and fine 544 571 data 545 572 … … 590 617 591 618 from pmesh.create_mesh import create_mesh_from_regions 592 593 num_polygons = 1 filelist = [] fileext = '.csv' filename = 594 project.polygonptsfile interior_res = 50000 619 \end{verbatim}} 620 621 622 {\scriptsize \begin{verbatim} 623 num_polygons = 1 filelist = [] fileext 624 = '.csv' filename = project.polygonptsfile interior_res = 50000 595 625 596 626 for p in range(1, num_polygons+1): … … 599 629 interior_regions.append([interior_polygon, interior_res]) 600 630 601 # test #interior_regions = [[project.poly1, interior_res], # 602 [project.poly2, interior_res]] # original #interior_regions = 603 [[project.harbour_polygon_2, interior_res], # 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 # 604 639 [project.botanybay_polygon_2, interior_res]] 605 640 606 641 #FIXME: Fix caching of this one once the mesh_interface is ready 607 from caching import cache _ = cache(create_mesh_from_regions, 642 from caching import cache 643 _ = cache(create_mesh_from_regions, 608 644 project.diffpolygonall, 609 645 {'boundary_tags': {'bottom': [0], … … 620 656 621 657 #------------------------------------------------------------------------------- 622 # Set up computational domain658 # Set up computational domain 623 659 #------------------------------------------------------------------------------- 624 660 … … 694 730 high-level perspective of the various tasks it undertakes. 695 731 696 If we compare this example with \code{bedslope.py}, the most 697 noticeable difference is that data is taken from a file. This is to 698 be expected, since the example now represents an actual physical 699 scenario rather than an illustrative example. 700 701 However, another important difference is that this example uses a 702 different method to create the mesh---one more suited to use for a 703 physical scenario. Instead of imposing a mesh structure on a 732 \subsection{Establishing the Mesh} 733 734 Comparing the present example with \code{bedslope.py}, we note that 735 one important difference is the use of a more complex method to 736 create the mesh. Instead of imposing a mesh structure on a 704 737 rectangular grid, the technique used for this example involves 705 738 building mesh structures inside polygons specified by the user. 706 739 707 In its simplest form, this technique creates the mesh within a 708 single polygon whose vertices are at geographical locations 709 specified by the user. A triangular mesh is created using points 710 inside the polygon selected through a random process, the user 711 specifying the \emph{resolution}---that is, the maximal area of a 712 triangle used for triangulation. 713 714 Figure XXX shows a simple example, in which the triangulation is 715 carried out within a pentagon. Instead of using the four tags 716 \code{`left'}, \code{`right'}, \code{`bottom'} and 717 \code{`top'} to distinguish boundary elements, the user can define 718 tags appropriate to the configuration being modelled. 719 720 While this offers more flexibility than the rectangular grid, it 721 doesn't provide a way to adapt to geographic or other features in the 722 landscape, for which we may require to vary the resolution. We achieve 723 more flexibility by extending this method, allowing the user to 724 specify a number of interior polygons which are triangulated 725 separately, possibly using different resolutions. See Figure XXX. 726 727 As before, we start by including 728 729 730 731 732 733 740 The following remarks may help the reader understand the basic ideas 741 behind the mesh-creation technique used in this program. 742 743 In its simplest form, the technique creates the mesh within a single 744 polygon whose vertices are at geographical locations specified by 745 the user. A triangular mesh is created using points inside the 746 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} to 754 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, it doesn't provide a way to adapt to 759 geographic or other features in the landscape, whose presence may 760 require us to vary the resolution in the neighbourhood of the 761 features. To achieve more flexibility we therefore extend the 762 technique, allowing the user to specify a number of interior 763 polygons to be triangulated separately, possibly using different 764 resolutions. See Figure XXX. 765 766 The upshot is a general method that takes for its input a bounding 767 polygon and (optionally) a list of interior polygons. It creates a 768 triangular mesh inside the bounding polygon, using a specified 769 resolution, but initially leaves the regions inside the interior 770 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 function 774 \code{create_mesh_from_regions}. Its arguments include the bounding 775 polygon and its resolution, a list of boundary tags, and a list of 776 pairs \code{[polygon, resolution]}, specifying the interior polygons 777 and their resolutions. 778 779 In practice, the details of the polygons used are read from a 780 separate file \code{project.py}. 781 782 783 \subsection{Initialising the Domain} 784 785 As with \code{bedslope.py}, once we have created the mesh, the next 786 step is to create the data structure \code{domain}. 787 788 {\scriptsize \begin{verbatim} 789 domain = 790 pmesh_to_domain_instance(meshname, Domain, 791 use_cache = True, 792 verbose = True) 793 \end{verbatim}} 794 795 \subsection{Specifying the Quantities} 796 797 {\scriptsize \begin{verbatim} 798 domain.set_name(project.basename) 799 domain.set_datadir(project.outputdir) 800 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 801 'ymomentum']) 802 803 804 #------------------------------------------------------------------------------- 805 # Set up scenario (tsunami_source is a callable object used with 806 set_quantity) 807 #------------------------------------------------------------------------------- 808 809 tsunami_source = slump_tsunami(length=30000.0, 810 depth=400.0, 811 slope=6.0, 812 thickness=176.0, 813 radius=3330, 814 dphi=0.23, 815 x0=project.slump_origin[0], 816 y0=project.slump_origin[1], 817 alpha=0.0, 818 domain=domain) 819 820 821 #------------------------------------------------------------------------------- 822 # Setup initial conditions 823 #------------------------------------------------------------------------------- 824 825 domain.set_quantity('stage', tsunami_source) 826 domain.set_quantity('friction', 0.03) # supplied by Benfield 827 domain.set_quantity('elevation', 828 filename = project.combineddemname + '.pts', 829 use_cache = True, 830 verbose = True) 831 \end{verbatim}} 832 833 \subsection{Boundary Conditions} 834 835 {\scriptsize \begin{verbatim} 836 Br = Reflective_boundary(domain) 837 domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br, 838 'right2': Br, 'top': Br, 'left1': Br, 839 'left2': Br, 'left3': Br} ) 840 \end{verbatim}} 734 841 735 842 \chapter{\anuga Public Interface}
Note: See TracChangeset
for help on using the changeset viewer.