Changeset 5672


Ignore:
Timestamp:
Aug 21, 2008, 4:32:14 PM (16 years ago)
Author:
ole
Message:

Tested for bug where default_boundry was repeatedly added to by Field_boundary.
Fixed bug and updated manual accordingly.

This closes ticket:293

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/anuga_user_manual.tex

    r5657 r5672  
    22542254appropriate segments for each conserved quantity.
    22552255
    2256 Optional argument \code{default_boundary} can be used to specify another boundary object to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}.
    2257 The default_boundary could be a simple Dirichlet condition or even another File\_boundary
     2256Optional argument \code{default\_boundary} can be used to specify another boundary object to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}.
     2257The \code{default\_boundary} could be a simple Dirichlet condition or
     2258even another \code{File\_boundary}
    22582259typically using data pertaining to another time interval. 
    22592260\end{classdesc}
    22602261
    2261 
     2262\begin{classdesc}{Field\_boundary}{Boundary}
     2263Module: \module{shallow\_water.shallow\_water\_domain}
     2264
     2265This method works in the same way as \code{File\_boundary} except that it
     2266allows for the value of stage to be offset by a constant specified in the
     2267keyword argument \code{mean\_stage}.
     2268
     2269This functionality allows for models to be run for a range of tides using
     2270the same boundary information (from .sts, .sww or .tms files). The tidal value
     2271for each run would then be specified in the keyword argument
     2272\code{mean\_stage}.
     2273If \code{mean\_stage} = 0.0, \code{Field\_boundary} and \code{File\_boundary}
     2274behave identically.
     2275
     2276
     2277Note that if the optional argument \code{default\_boundary} is specified
     2278it's stage value will be adjusted by \code{mean\_stage} just like the values
     2279obtained from the file.
     2280
     2281See \code{File\_boundary} for further details.
     2282\end{classdesc}
    22622283
    22632284%%%
  • anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r5666 r5672  
    332332                    # Pass control to default boundary
    333333                    res = self.default_boundary.evaluate(vol_id, edge_id)
    334                                    
     334                   
     335                    # Ensure that result cannot be manipulated
     336                    # This is a real danger in case the
     337                    # default_boundary is a Dirichlet type
     338                    # for instance.
     339                    res = res.copy()
     340                   
    335341                    if self.default_boundary_invoked is False:
    336342                        # Issue warning the first time
     
    347353                   
    348354
    349                    
    350                
    351355            if res == NAN:
    352356                x,y=self.midpoint_coordinates[i,:]
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r5657 r5672  
    11451145        vol_id and edge_id are ignored
    11461146        """
    1147 
     1147       
    11481148        # Evaluate file boundary
    11491149        q = self.file_boundary.evaluate(vol_id, edge_id)
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r5657 r5672  
    78017801        from anuga.pmesh.mesh_interface import create_mesh_from_regions
    78027802
    7803         bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02]]
     7803        bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],
     7804                          [6.02,97.02],[6.00,97.02]]
    78047805        tide = 0.37
    78057806        time_step_count = 5
    78067807        time_step = 2
    7807         lat_long_points =bounding_polygon[0:3]
     7808        lat_long_points = bounding_polygon[0:3]
    78087809        n=len(lat_long_points)
    78097810        first_tstep=ones(n,Int)
     
    79367937        os.remove(meshname)
    79377938
    7938        
     7939
     7940       
     7941               
     7942       
     7943    def test_field_boundary_stsI_beyond_model_time(self):
     7944        """test_field_boundary(self):
     7945       
     7946        Test that field_boundary can work when model time
     7947        exceeds available data whilst adjusting mean_stage.
     7948       
     7949        """
     7950       
     7951        # Don't do warnings in unit test
     7952        import warnings
     7953        warnings.simplefilter('ignore')
     7954       
     7955        from anuga.shallow_water import Domain
     7956        from anuga.shallow_water import Reflective_boundary
     7957        from anuga.shallow_water import Dirichlet_boundary
     7958        from anuga.shallow_water import File_boundary
     7959        from anuga.pmesh.mesh_interface import create_mesh_from_regions
     7960
     7961        bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],
     7962                          [6.02,97.02],[6.00,97.02]]
     7963        tide = 0.37
     7964        time_step_count = 5
     7965        time_step = 2
     7966        lat_long_points = bounding_polygon[0:3]
     7967        n=len(lat_long_points)
     7968        first_tstep=ones(n,Int)
     7969        last_tstep=(time_step_count)*ones(n,Int)
     7970
     7971        h = 20       
     7972        w = 2
     7973        u = 10
     7974        v = -10
     7975        gauge_depth=h*ones(n,Float)
     7976        ha=w*ones((n,time_step_count),Float)
     7977        ua=u*ones((n,time_step_count),Float)
     7978        va=v*ones((n,time_step_count),Float)
     7979        base_name, files = self.write_mux2(lat_long_points,
     7980                                           time_step_count, time_step,
     7981                                           first_tstep, last_tstep,
     7982                                           depth=gauge_depth,
     7983                                           ha=ha,
     7984                                           ua=ua,
     7985                                           va=va)
     7986
     7987        sts_file=base_name
     7988        urs2sts(base_name,
     7989                sts_file,
     7990                mean_stage=0.0, # Deliberately let Field_boundary do the adjustment
     7991                verbose=False)
     7992        self.delete_mux(files)
     7993
     7994        #print 'start create mesh from regions'
     7995        for i in range(len(bounding_polygon)):
     7996            zone,\
     7997            bounding_polygon[i][0],\
     7998            bounding_polygon[i][1]=redfearn(bounding_polygon[i][0],
     7999                                            bounding_polygon[i][1])
     8000                                           
     8001        extent_res=1000000
     8002        meshname = 'urs_test_mesh' + '.tsh'
     8003        interior_regions=None
     8004        boundary_tags={'ocean': [0,1], 'otherocean': [2,3,4]}
     8005        create_mesh_from_regions(bounding_polygon,
     8006                                 boundary_tags=boundary_tags,
     8007                                 maximum_triangle_area=extent_res,
     8008                                 filename=meshname,
     8009                                 interior_regions=interior_regions,
     8010                                 verbose=False)
     8011       
     8012        domain_fbound = Domain(meshname)
     8013        domain_fbound.set_quantity('stage', tide)
     8014       
     8015        Br = Reflective_boundary(domain_fbound)
     8016        Bd = Dirichlet_boundary([w+tide, u*(w+h), v*(w+h)])
     8017        Bdefault = Dirichlet_boundary([w, u*(w+h), v*(w+h)])       
     8018               
     8019        Bf = Field_boundary(sts_file+'.sts',
     8020                           domain_fbound,
     8021                           mean_stage=tide, # Field boundary to adjust for tide
     8022                           boundary_polygon=bounding_polygon,
     8023                           default_boundary=Bdefault) # Condition to be used
     8024                                                      # if model time exceeds
     8025                                                      # available data
     8026
     8027        domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br})
     8028       
     8029        # Check boundary object evaluates as it should
     8030        for i, ((vol_id, edge_id), B) in enumerate(domain_fbound.boundary_objects):
     8031            if B is Bf:
     8032           
     8033                qf = B.evaluate(vol_id, edge_id)  # Field boundary
     8034                qd = Bd.evaluate(vol_id, edge_id) # Dirichlet boundary
     8035               
     8036                msg = 'Got %s, should have been %s' %(qf, qd)
     8037                assert allclose(qf, qd), msg
     8038               
     8039        # Evolve
     8040        data_finaltime = time_step*(time_step_count-1)
     8041        finaltime = data_finaltime + 10 # Let model time exceed available data
     8042        yieldstep = time_step
     8043        temp_fbound=zeros(int(finaltime/yieldstep)+1, Float)
     8044
     8045        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     8046                                                   finaltime=finaltime,
     8047                                                   skip_initial_step=False)):
     8048                                                   
     8049            D = domain_fbound
     8050            temp_fbound[i]=D.quantities['stage'].centroid_values[2]
     8051
     8052            # Check that file boundary object has populated
     8053            # boundary array correctly 
     8054            # FIXME (Ole): Do this for the other tests too!
     8055            for j, val in enumerate(D.get_quantity('stage').boundary_values):
     8056           
     8057                (vol_id, edge_id), B = D.boundary_objects[j]
     8058                if isinstance(B, Field_boundary):
     8059                    msg = 'Got %f should have been %f' %(val, w+tide)
     8060                    assert allclose(val, w + tide), msg
     8061
    79398062
    79408063    def test_file_boundary_stsII(self):
  • anuga_work/development/boxingday08/project.py

    r5573 r5672  
    9999patong_bay_polygon = read_polygon(dir+sep+'patong_bay_polygon.csv')
    100100   
    101 tide=0.45
     101tide=0.15
    102102
    103103######################################
  • anuga_work/development/boxingday08/run_boxingday_polyline.py

    r5601 r5672  
    5454timestamp = strftime('%Y%m%d_%H%M%S',localtime())
    5555basename = scenario[:4] + '_polyline'
     56tide = project.tide
    5657
    5758
     
    130131print domain.statistics()
    131132
    132 domain.set_name(basename+timestamp)
     133domain.set_name(basename+timestamp+'_'+str(tide))
    133134#domain.set_name(basename)
    134135domain.set_datadir(scenario)
     
    146147#------------------------------------------------------------------------------
    147148     
    148 tide = project.tide
    149149domain.set_quantity('stage', tide)
    150150domain.set_quantity('friction', 0.01)
Note: See TracChangeset for help on using the changeset viewer.