Changeset 7804


Ignore:
Timestamp:
Jun 7, 2010, 4:19:31 PM (10 years ago)
Author:
hudson
Message:

Fixed up failing tests, updated user guide with new API (first few chapters only).

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/classroom/ripcurrent.py

    r7589 r7804  
    1616# Import necessary modules
    1717#------------------------------------------------------------------------------
    18 from anuga.interface import create_domain_from_regions
    19 from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
    20 from anuga.shallow_water.shallow_water_domain import Reflective_boundary
    21 from anuga.shallow_water.shallow_water_domain import Time_boundary
    22 from anuga.shallow_water.data_manager import get_mesh_and_quantities_from_file
     18import anuga
    2319from pylab import figure, plot, axis, quiver, quiverkey, show, title, axhline
    2420from pylab import cos, sin, pi
     
    4137halfchannelwidth = 5
    4238bank_slope = 0.1
    43 simulation_length = 1
     39simulation_length = 60
    4440timestep = 1
    4541
     
    5046length = 120
    5147width = 170
    52 seafloor_resolution = 60.0 # Resolution: Max area of triangles in the mesh
     48seafloor_resolution = 20.0 # Resolution: Max area of triangles in the mesh
    5349feature_resolution = 1.0
    5450beach_resolution = 10.0
    5551
    5652sea_boundary_polygon = [[0,0],[length,0],[length,width],[0,width]]
    57 feature_boundary_polygon = [[0,100],[length,100],[length,150],[0,150]]
     53feature_boundary_polygon = [[19,99],[length/2+1,99],[length/2+1,151],[0,151]]
     54hole_boundary_polygon = [[20,100],[length/2,100],[length/2,150],[20,150]]
    5855beach_interior_polygon = [[0,150],[length,150],[length,width],[0,width]]
    5956
     
    6461                   [beach_interior_polygon, beach_resolution]]
    6562
    66 domain = create_domain_from_regions(sea_boundary_polygon,
     63domain = anuga.create_domain_from_regions(sea_boundary_polygon,
    6764                                    boundary_tags={'bottom': [0],
    6865                                                   'right' : [1],
     
    7269                                    mesh_filename=meshname,
    7370                                    interior_regions=feature_regions,
     71                                    interior_holes=[hole_boundary_polygon],
    7472                                    use_cache=True,
    7573                                    verbose=True)
     
    149147# Setup boundary conditions
    150148#------------------------------------------------------------------------------
    151 Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
    152 Br = Reflective_boundary(domain)              # Solid reflective wall
    153 Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
     149Bi = anuga.Dirichlet_boundary([0.4, 0, 0])          # Inflow
     150Br = anuga.Reflective_boundary(domain)              # Solid reflective wall
     151Bo = anuga.Dirichlet_boundary([-5, 0, 0])           # Outflow
    154152
    155153def wave(t):
     
    158156   
    159157    A = 0.4  # Amplitude of wave [m] (wave height)
    160     T = 5    # Wave period [s]
     158    T = 1    # Wave period [s]
    161159
    162160    if t < 30000000000:
     
    165163        return [0.0, 0, 0]
    166164
    167 Bt = Time_boundary(domain, f=wave)
    168 
    169 
    170 domain.set_boundary({'left': Br, 'right': Br, 'top': Bo, 'bottom': Bt})
     165Bt = anuga.Time_boundary(domain, f=wave)
     166
     167
     168domain.set_boundary({'left': Br, 'right': Br, 'top': Bo, 'bottom': Bt, 'exterior': Br})
    171169
    172170
  • trunk/anuga_core/documentation/user_manual/anuga_user_manual.tex

    r7631 r7804  
    7272                % will be used.
    7373
    74 %\release{1.0}   % release version; this is used to define the
     74%\release{1.2}   % release version; this is used to define the
    7575%                % \version macro
    7676
     
    147147where the more adventurous reader might like to go.
    148148
    149 This manual describes \anuga version 1.0. To check for later versions of this manual
     149This manual describes \anuga version 1.2. To check for later versions of this manual
    150150go to \url{https://datamining.anu.edu.au/anuga}.
    151151
     
    335335
    336336\begin{verbatim}
    337 points, vertices, boundary = rectangular_cross(10, 10)
     337points, vertices, boundary = anuga.rectangular_cross(10, 10)
    338338\end{verbatim}
    339339
     
    345345
    346346\begin{verbatim}
    347 points, vertices, boundary = rectangular_cross(m, n)
     347points, vertices, boundary = anuga.rectangular_cross(m, n)
    348348\end{verbatim}
    349349
     
    372372
    373373\begin{verbatim}
    374 domain = Domain(points, vertices, boundary)
     374domain = anuga.Domain(points, vertices, boundary)
    375375\end{verbatim}
    376376
     
    499499
    500500\begin{verbatim}
    501 Br = Reflective_boundary(domain)
    502 Bt = Transmissive_boundary(domain)
    503 Bd = Dirichlet_boundary([0.2, 0.0, 0.0])
    504 Bw = Time_boundary(domain=domain,
     501Br = anuga.Reflective_boundary(domain)
     502Bt = anuga.Transmissive_boundary(domain)
     503Bd = anuga.Dirichlet_boundary([0.2, 0.0, 0.0])
     504Bw = anuga.Time_boundary(domain=domain,
    505505                   f=lambda t: [(0.1*sin(t*2*pi)-0.3)*exp(-t), 0.0, 0.0])
    506506\end{verbatim}
     
    609609
    610610\begin{verbatim}
    611 Bw = Time_boundary(domain=domain, f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0])
     611Bw = anuga.Time_boundary(domain=domain, f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0])
    612612\end{verbatim}
    613613
     
    726726
    727727\begin{verbatim}
    728 points, vertices, boundary = rectangular_cross(m, n, len1=length, len2=width)
     728points, vertices, boundary = anuga.rectangular_cross(m, n, len1=length, len2=width)
    729729\end{verbatim}
    730730
     
    742742dx = dy = 1           # Resolution: Length of subdivisions on both axes
    743743
    744 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     744points, vertices, boundary = anuga.rectangular_cross(int(length/dx), int(width/dy),
    745745                                               len1=length, len2=width)
    746746\end{verbatim}
     
    780780
    781781\begin{verbatim}
    782 Bo = Dirichlet_boundary([-5, 0, 0])    # Outflow
     782Bo = anuga.Dirichlet_boundary([-5, 0, 0])    # Outflow
    783783\end{verbatim}
    784784
     
    10241024\begin{verbatim}
    10251025remainder_res = 10000000
    1026 domain = create_domain_from_regions(project.bounding_polygon,
     1026domain = anuga.create_domain_from_regions(project.bounding_polygon,
    10271027                                    boundary_tags={'top': [0],
    10281028                                                   'ocean_east': [1],
     
    11451145
    11461146\begin{verbatim}
    1147 Bd = Dirichlet_boundary([tide,0,0]) # Mean water level
    1148 Bs = Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
     1147Bd = anuga.Dirichlet_boundary([tide,0,0]) # Mean water level
     1148Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
    11491149
    11501150if project.scenario == 'fixed_wave':
    11511151    # Huge 50m wave starting after 60 seconds and lasting 1 hour.
    1152     Bw = Time_boundary(domain=domain,
     1152    Bw = anuga.Time_boundary(domain=domain,
    11531153                       function=lambda t: [(60<t<3660)*50, 0, 0])
    11541154    domain.set_boundary({'ocean_east': Bw,
  • trunk/anuga_core/documentation/user_manual/version.tex

    r6055 r7804  
    77% release version; this is used to define the
    88% \version macro
    9 \release{1.0beta\_6051}
     9\release{1.2beta\_6051}
  • trunk/anuga_core/source/anuga/file_conversion/asc2dem.py

    r7758 r7804  
    11# external modules
    22import numpy as num
     3import anuga.utilities.log as log
    34
    45# ANUGA modules
  • trunk/anuga_core/source/anuga/file_conversion/dem2pts.py

    r7742 r7804  
    33
    44# ANUGA modules
     5import anuga.utilities.log as log
    56from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a, \
    67                            netcdf_float
  • trunk/anuga_core/source/anuga/file_conversion/test_urs2sww.py

    r7800 r7804  
    1616from anuga.coordinate_transforms.redfearn import redfearn     
    1717
    18 from urs2sww import urs2sww
     18from urs2sww import urs2sww, urs_ungridded2sww
    1919import urs
    2020
     
    163163        #Latitude:   -21  0 ' 0.00000 ''  Longitude: 115  0 ' 0.00000 ''
    164164
    165         'hole_points_UTM(base_name, mean_stage=-240992.0,
     165        hole_points_UTM(base_name, mean_stage=-240992.0,
    166166                          hole_points_UTM=[ 292110.784, 7676551.710 ])
    167167       
  • trunk/anuga_core/source/anuga/fit_interpolate/fit.py

    r7751 r7804  
    299299                assert flag is True, msg               
    300300               
    301                 # FIXME(Ole): This is the message referred to in ticket:314
    302                 minx = min(self.mesh_boundary_polygon[:,0])
    303                 maxx = max(self.mesh_boundary_polygon[:,0])               
    304                 miny = min(self.mesh_boundary_polygon[:,1])
    305                 maxy = max(self.mesh_boundary_polygon[:,1])
    306                 msg = 'Could not find triangle for point %s. ' % str(x)
    307                 msg += 'Mesh boundary extent is (%.f, %.f), (%.f, %.f)'\
    308                     % (minx, maxx, miny, maxy)
    309                 raise RuntimeError, msg
    310 
     301                # data point has fallen within a hole - so ignore it.
    311302               
    312303        self.AtA = AtA
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r7780 r7804  
    53435343        os.remove(ptsfile)
    53445344
     5345
     5346    def test_fitting_in_hole(self):
     5347        '''
     5348            Make sure we can fit a mesh that has a hole in it.
     5349            This is a regression test for ticket:234
     5350           
     5351        '''
     5352        verbose = False
     5353       
     5354        from anuga.shallow_water.shallow_water_domain import Domain
     5355        from anuga.pmesh.mesh_interface import create_mesh_from_regions
     5356        from anuga.geospatial_data.geospatial_data import Geospatial_data
     5357
     5358       
     5359        # Get path where this test is run
     5360        path = get_pathname_from_package('anuga.shallow_water')       
     5361       
     5362       
     5363        #----------------------------------------------------------------------
     5364        # Create domain
     5365        #--------------------------------------------------------------------
     5366        W = 303400
     5367        N = 6195800
     5368        E = 308640
     5369        S = 6193120
     5370        border = 2000
     5371        bounding_polygon = [[W, S], [E, S], [E, N], [W, N]]
     5372        hole_polygon = [[W+border, S+border], [E-border, S+border], \
     5373                        [E-border, N-border], [W+border, N-border]]       
     5374
     5375        meshname = os.path.join(path, 'offending_mesh.msh')
     5376        create_mesh_from_regions(bounding_polygon,
     5377                                 boundary_tags={'south': [0], 'east': [1],
     5378                                                'north': [2], 'west': [3]},
     5379                                 maximum_triangle_area=1000000,
     5380                                 filename=meshname,
     5381                                 interior_holes=[hole_polygon],
     5382                                 use_cache=False,
     5383                                 verbose=verbose)
     5384
     5385        domain = Domain(meshname, use_cache=False, verbose=verbose)
     5386
     5387        #----------------------------------------------------------------------
     5388        # Fit data point inside hole to mesh
     5389        #----------------------------------------------------------------------
     5390
     5391        points_file = os.path.join(path, 'offending_point.pts')
     5392
     5393        # Offending point
     5394        G = Geospatial_data(data_points=[[(E+W)/2, (N+S)/2]],
     5395                            attributes=[1])
     5396        G.export_points_file(points_file)
     5397
     5398        # fit data using the point within the hole.
     5399        domain.set_quantity('elevation', filename=points_file,
     5400                            use_cache=False, verbose=verbose, alpha=0.01)
     5401        os.remove(meshname)
     5402        os.remove(points_file)           
     5403       
     5404
    53455405    def test_fitting_example_that_crashed(self):
    53465406        """This unit test has been derived from a real world example
Note: See TracChangeset for help on using the changeset viewer.