Changeset 9405


Ignore:
Timestamp:
Jan 15, 2015, 1:07:49 PM (10 years ago)
Author:
steve
Message:

Adding in some upper directories to allow anuga_core to be smaller size

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/__init__.py

    r9379 r9405  
    162162from anuga.file_conversion.esri2sww import esri2sww   
    163163from anuga.file_conversion.sww2dem import sww2dem, sww2dem_batch
    164 from anuga.file_conversion.asc2dem import asc2dem     
     164from anuga.file_conversion.asc2dem import asc2dem
     165from anuga.file_conversion.xya2pts import xya2pts     
    165166from anuga.file_conversion.ferret2sww import ferret2sww     
    166167from anuga.file_conversion.dem2dem import dem2dem
  • trunk/anuga_core/source/anuga/file_conversion/xya2pts.py

    r9324 r9405  
    11
    22
    3 def xya2pts(filename, verbose=False):
     3def xya2pts(name_in, name_out=None, verbose=False):
    44    """Convert a file with xy and elevation data to NetCDF pts file.
    55    """
    66   
    77    from anuga.geospatial_data import Geospatial_data
     8
     9    root = name_in[:-4]
     10
     11    if name_out is None: name_out = root + '.pts'
    812   
    9     if verbose: print 'Creating', filename
     13    if verbose: print 'Creating', name_out
    1014   
    1115    # Read the ascii (.xya) version of this file,
    1216    # make it comma separated and invert the bathymetry
    1317    # (Below mean sea level should be negative)
    14     infile = open(filename[:-4] + '.xya')
    15     out_filename = filename[:-4] + '.pts'
     18    infile = open(name_in)
    1619
    1720    points = []
    1821    attribute = []
     22
    1923    for line in infile.readlines()[1:]: #Skip first line (the header)
    2024        fields = line.strip().split(',')
     
    3135    G = Geospatial_data(data_points=points,
    3236                        attributes=attribute)
    33     G.export_points_file(out_filename)
     37    G.export_points_file(name_out)
    3438   
    3539   
  • trunk/anuga_core/validation_tests/experimental_data/okushiri/create_okushiri.py

    r9403 r9405  
    185185
    186186        if verbose: print 'Reading pts from xya'
    187         anuga.xya2pts(project.bathymetry_filename_stem+'.pts', verbose = verbose)
     187        anuga.xya2pts(project.bathymetry_filename_stem+'.xya',\
     188                      verbose = verbose)
    188189       
    189190        fit_to_mesh_file(project.mesh_filename, project.bathymetry_filename,
  • trunk/anuga_user_manual/source/anuga_user_manual.tex

    r9402 r9405  
    344344
    345345\label{ref:runup_py_code}
    346 \verbatiminput{../../demos/runup.py}
     346\verbatiminputunderscore{../../anuga_core/demos/runup.py}
    347347
    348348
     
    656656when this example is run:
    657657
    658 \verbatiminput{examples/runupoutput.txt}
     658\verbatiminputunderscore{examples/runupoutput.txt}
    659659
    660660
     
    731731Here is the code for the first version of the channel flow \file{channel1.py}:
    732732
    733 \verbatiminput{demos/channel1.py}
     733\verbatiminputunderscore{demos/channel1.py}
    734734
    735735In discussing the details of this example, we follow the outline
     
    774774%\end{verbatim}
    775775
    776 
     776%=========================================
    777777\section{Model Output}
    778778
     
    787787\end{figure}
    788788
    789 \subsection{Changing boundary conditions on the fly}
     789
     790
     791%=========================================
     792\section{Changing boundary conditions on the fly}
    790793\label{sec:change boundary}
    791794
    792795Here is the code for the second version of the channel flow \file{channel2.py}:
    793796
    794 \verbatiminput{demos/channel2.py}
     797\verbatiminputunderscore{demos/channel2.py}
    795798
    796799This example differs from the first version in that a constant outflow boundary condition has
     
    845848Here is the code for the third version of the channel flow \file{channel3.py}:
    846849
    847 \verbatiminput{demos/channel3.py}
     850\verbatiminputunderscore{demos/channel3.py}
    848851
    849852This example differs from the first two versions in that the topography
     
    886889
    887890
    888 \section{An Example with Real Data}
     891%==========================================================
     892\chapter{An Example with Real Data}
    889893
    890894\label{sec:realdataexample} The following discussion builds on the
     
    905909}
    906910
    907 \subsection{Overview}
     911\section{Overview}
    908912As in the case of \file{runup.py}, the actions carried
    909913out by the program can be organised according to this outline:
     
    925929\end{enumerate}
    926930
    927 \subsection{The Code}
     931\section{The Code}
    928932
    929933Here is the code for \file{runcairns.py}:
    930934
    931 \verbatiminput{../../demos/cairns/runcairns.py}
     935\verbatiminputunderscore{../../anuga_core/demos/cairns/runcairns.py}
    932936
    933937In discussing the details of this example, we follow the outline
    934938given above, discussing each major step of the code in turn.
    935939
    936 \subsection{Establishing the Mesh}\index{mesh, establishing}
     940\section{Establishing the Mesh}\index{mesh, establishing}
    937941
    938942One obvious way that the present example differs from
     
    990994\file{project.py}:
    991995
    992 \verbatiminput{../../demos/cairns/project.py}
     996\verbatiminputunderscore{../../anuga_core/demos/cairns/project.py}
    993997
    994998Figure \ref{fig:cairns3d} illustrates the landscape of the region
     
    10741078Make sure points on polygons are spaced to be no closer than the smallest resolution requested.
    10751079
    1076 \subsection{Initialising the Domain}
     1080\section{Initialising the Domain}
    10771081
    10781082Since we used \code{create_domain_from_regions} to create the mesh file, we do not need to
     
    10891093\end{verbatim}
    10901094
    1091 \subsection{Initial Conditions}
     1095\section{Initial Conditions}
    10921096
    10931097Quantities for \file{runcairns.py} are set
     
    10971101auxiliary points file.
    10981102
    1099 \subsubsection{Stage}
     1103\subsection{Stage}
    11001104
    11011105The stage is initially set to 0.0 (i.e.\ Mean Sea Level) by the following statements:
     
    11231127%large amplitude tsunami which would inundate the Cairns region.}
    11241128
    1125 \subsubsection{Friction}
     1129\subsection{Friction}
    11261130
    11271131We assign the friction exactly as we did for \file{runup.py}:
     
    11311135\end{verbatim}
    11321136
    1133 \subsubsection{Elevation}
     1137\subsection{Elevation}
    11341138
    11351139The elevation is specified by reading data from a file with a name derived from
     
    11531157the screen.
    11541158
    1155 \subsection{Boundary Conditions}\index{boundary conditions}
     1159\section{Boundary Conditions}\index{boundary conditions}
    11561160
    11571161Setting boundaries follows a similar pattern to the one used for
     
    11901194how the script can take different actions depending on a variable.
    11911195
    1192 \subsection{Evolution}
     1196\section{Evolution}
    11931197
    11941198With the basics established, the running of the 'evolve' step is
     
    12531257\file{ExportResults.py} demonstrates how this function can be used:
    12541258
    1255 \verbatiminput{demos/cairns/ExportResults.py}
     1259\verbatiminputunderscore{demos/cairns/ExportResults.py}
    12561260
    12571261The script generates a maximum water depth ASCII grid at a defined
     
    13081312the gauges shown in Figure \ref{fig:cairnsgauges} is \file{gauges.csv}:
    13091313
    1310 \verbatiminput{demos/cairns/gauges.csv}
     1314\verbatiminputunderscore{demos/cairns/gauges.csv}
    13111315
    13121316Header information has been included to identify the location in terms of eastings and
     
    13181322of the standard \code{anuga} release, however it can be downloaded and installed from \code{http://matplotlib.sourceforge.net/}
    13191323
    1320 \verbatiminput{demos/cairns/GetTimeseries.py}
     1324\verbatiminputunderscore{demos/cairns/GetTimeseries.py}
    13211325
    13221326Here, the time series for the quantities stage, depth and speed will be generated for
     
    13471351
    13481352%=================================
    1349 \section{A Parallel Simulation}
    1350 
    1351 The previous examples were run just using one processor. \anuga also has the option of running in parallel using \mpi.
     1353\chapter{Parallel Simulation}
     1354
     1355The examples from the previous chapters were run just using one processor. As you will have noticed, the simulations can take a long time to run, especially if you are using a fine mesh. Indeed as you halve the spacing of the mesh, the number of triangles goes up by a factor of 4 and the timestep halves, so generally halving the spacing of the mesh increases the run time by approximately a factor of 8.
     1356
     1357One way to alleviate this is to run your simulation in parallel and use more processors to spread the computational cost.
     1358
     1359
     1360\anuga has the option of running in parallel using \mpi. A description of the method used to parallelize \anuga is given in section~\ref{theory:parallel}.
    13521361
    13531362Such jobs are run using the command
    13541363
    13551364\begin{verbatim}
    1356 mpirun -np n python runParallelCairns.py
     1365mpirun -np n python runscript.py
    13571366\end{verbatim}
    13581367where \code{n} is the total number of processors being used for the parallel run.
    13591368
    1360 Essentially we can expect speedups comparable to the number of cores available. This is measured via scalablity. We can expect scalability of 70\% when using up to the number of processors so that the local partitioned domains contain around 2000 triangles.
    1361 
    1362 \subsection{The Code}
    1363 
    1364 Here is the code for \file{runParallelCairns.py}:
     1369Essentially we can expect speedups comparable to the number of cores available. This is measured via scalability. Our current experiments have demonstrated a scalability of 70\% or above when the number of processors are chosen so that the local partitioned meshes contain around 2000 triangles.
     1370
     1371For instance, suppose we have a problem with a mesh of 500,000 triangles, and use 250 processors. Then the mesh will be partitioned into sub meshes of approximately 2000 triangles.
     1372We would expect 70\% scalability, and so expect a speedup of $250 \times 0.7 = 175$.
     1373
     1374\section{The Code}
     1375
     1376Here is the code for \file{runParallelCairns.py} which is found in the \file{demos/cairns} directory:
    13651377
    13661378\verbatiminputunderscore{../../anuga_core/demos/cairns/runParallelCairns.py}
    13671379
    13681380
    1369 \subsection{Structure of the Code}
     1381\section{Structure of the Code}
    13701382
    13711383The code is very similar to the sequential code. The same procedures are used to setup the domain, setup the inital conditions, boundary conditions and evolve.
    13721384
    13731385
    1374 We first import a few procedures  need forthe parallel code.
     1386We first import a few procedures  need for the parallel code.
    13751387\begin{verbatim}
    13761388from anuga import distribute, myid, numprocs, finalize, barrier
     
    14361448
    14371449
    1438 
    1439 \section{Checkpointing}
    1440 
    1441 When running large and long running simulations, it is useful to provide a mechanism to allow the simulation to restarted if it is interupted mid simulation. Maybe there is a power cut, or when using batch queues there may be a time restriction on the length of any one running job. Then the use of checkpointing becomes useful.
    1442 
    1443 The idea is that at regular intervals the system makes a copy of the current state of the computation. Then if there is an interruption the computation can be started from the last checkpoint time and not orginal start time.
    1444 
    1445 \subsection{The Code}
     1450%=================================
     1451\chapter{Checkpointing}
     1452
     1453When running large and long running simulations, it is useful to provide a mechanism to allow the simulation to restarted if it is interrupted mid simulation. Maybe there is a power cut, or when using batch queues there may be a time restriction on the length of any one running job. Then the use of checkpointing becomes useful.
     1454
     1455The idea is that at regular intervals the system makes a copy of the current state of the computation. Then if there is an interruption the computation can be started from the last checkpoint time and not original start time.
     1456
     1457\section{The Code}
    14461458
    14471459Here is the code for \file{runCheckpoint.py}:
    14481460
    1449 \verbatiminput{../../anuga_core/demos/checkpointing/runCheckpoint.py}
    1450 
    1451 \subsection{Structure of the Code}
     1461\verbatiminputunderscore{../../anuga_core/demos/checkpointing/runCheckpoint.py}
     1462
     1463\section{Structure of the Code}
    14521464
    14531465As usual the code needs to import the required modules, and setup parameters and in this case procedures for setting up the stage and elevation.
     
    14891501will run the tests in verbose mode (produces output) and in parallel using 6 processors (if parallel version of anuga has been setup).
    14901502
    1491 A subset of these validation tests can be run using \code{run_auto_validatoin_tests.py} from the \module{anuga_core} directory.
     1503A subset of these validation tests can be run using \code{run_auto_validation_tests.py} from the \module{anuga_core} directory.
    14921504
    14931505
     
    37673779
    37683780%FIXME (Ole): Should put in example with nonzero xllcorner, yllcorner
    3769 \verbatiminput{examples/bedslopeexcerpt.cdl}
     3781\verbatiminputunderscore{examples/bedslopeexcerpt.cdl}
    37703782
    37713783The SWW format is used not only for output but also serves as input
     
    38203832\subsection{Formats for Storing Arbitrary Points and Attributes}
    38213833
    3822 A CSV/TXT file is used to store data representing
     3834A CSV/TXT/XYA file is used to store data representing
    38233835arbitrary numerical attributes associated with a set of points.
    38243836
    3825 The format for an CSV/TXT file is:\\
     3837The format for an CSV/TXT/XYA file is:\\
    38263838 \\
    38273839first line:   \code{[column names]}\\
     
    42424254%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    42434255\section{Parallel Implementation}
     4256\label{theory:parallel}
    42444257
    42454258
     
    59135926%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    59145927
    5915 \chapter{Frequently Asked Questions}
    5916 
    5917 The Frequently Asked Questions have been move to the online FAQ at: \\
    5918 \url{https://anuga.anu.edu.au/wiki/FrequentlyAskedQuestions}
     5928%\chapter{Frequently Asked Questions}
     5929%
     5930%The Frequently Asked Questions have been move to the online FAQ at: \\
     5931%\url{https://anuga.anu.edu.au/wiki/FrequentlyAskedQuestions}
    59195932
    59205933%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.