Changeset 2457


Ignore:
Timestamp:
Feb 28, 2006, 2:55:56 PM (18 years ago)
Author:
howard
Message:

Continuing update to the second example in Chapter 2. Added terms 'meshfile' and 'points file' to Glossary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentation/user_manual/anuga_user_manual.tex

    r2455 r2457  
    286286\begin{itemize}
    287287
    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$ 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
     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$ 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
    294294
    295295   \item a dictionary \code{boundary}, used to tag the triangle edges on
     
    492492the \code{bedslope.py} example and introduces a second example,
    493493\code{run_sydney_smf.py}, that follows the same basic outline, but
    494 incorporates many more complex features.
     494incorporates more complex features and refers to a real-life
     495scenario, rather than the artificial illustrative one used in
     496\code{bedslope.py}.
    495497
    496498\subsection{Overview}
     
    607609#-------------------------------------------------------------------------------
    608610
    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 #
     611interior_regions = [[project.harbour_polygon_2, interior_res],
    639612[project.botanybay_polygon_2, interior_res]]
    640613
     
    743716In its simplest form, the technique creates the mesh within a single
    744717polygon 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
     718the user. The user specifies the \emph{resolution}---that is, the
     719maximal area of a triangle used for triangulation---and mesh points
     720are created inside the polygon through a random process. Figure XXX
     721shows a simple example of this, in which the triangulation is
     722carried out within a pentagon.
     723
     724Boundary 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
     727appropriate to the configuration being modelled.
     728
     729While a mesh created inside a polygon offers more flexibility than
     730one based on a rectangular grid, the technique of mesh creation that
     731we have so far described doesn't provide a way to adapt to
    759732geographic or other features in the landscape, whose presence may
    760733require 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
     734features. To achieve more flexibility, an extension of the technique
     735is adopted, which allows the user to specify a number of interior
    763736polygons to be triangulated separately, possibly using different
    764737resolutions. See Figure XXX.
     
    766739The upshot is a general method that takes for its input a bounding
    767740polygon 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
     741triangular mesh inside the bounding polygon, using a user-specified
     742resolution, but then creates a separate triangulation inside each of
     743the interior polygons, according to the resolution specified for
     744that polygon.
     745
     746The function used to implement this process is
    774747\code{create_mesh_from_regions}. Its arguments include the bounding
    775748polygon and its resolution, a list of boundary tags, and a list of
     
    778751
    779752In practice, the details of the polygons used are read from a
    780 separate file \code{project.py}.
     753separate 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
     755the data specifying a mesh. (There are two formats for such a file:
     756it can either be a binary file, with extension \code{.msh}, or an
     757ASCII file, with extension \code{.tsh}. In the present case, the
     758binary file format \code{.msh} is used. See Section \ref{sec:file
     759formats} for more on file formats.) and assigned a name obtained by
     760appending the extension \code{.msh} to the name specified in the
     761input file \code{project.py}. This name is stored in the variable
     762\code{meshname}.
    781763
    782764
     
    784766
    785767As with \code{bedslope.py}, once we have created the mesh, the next
    786 step is to create the data structure \code{domain}.
     768step is to create the data structure \code{domain}. This is
     769accomplished through the following statements:
    787770
    788771{\scriptsize \begin{verbatim}
     
    793776\end{verbatim}}
    794777
     778The 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}
     781to set quantities and to apply other operations. In the case of
     782\code{bedslope.py},
     783
    795784\subsection{Specifying the Quantities}
     785
     786
    796787
    797788{\scriptsize \begin{verbatim}
     
    820811
    821812#-------------------------------------------------------------------------------
    822 # Setup initial conditions
     813# Set up initial conditions
    823814#-------------------------------------------------------------------------------
    824815
     
    13441335    \item \indexedbold{Mesh}    triangulation of domain
    13451336
     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
    13461343    \item \indexedbold{Grid} evenly spaced
    13471344
Note: See TracChangeset for help on using the changeset viewer.