Changeset 6045


Ignore:
Timestamp:
Dec 5, 2008, 11:35:49 AM (14 years ago)
Author:
ole
Message:

Implemented, tested and documunted new boundary condition:

Transmissive_stage_zero_momentum_boundary

Renamed two others according to style guide but retained backward compatibility

Location:
anuga_core
Files:
4 edited

Legend:

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

    r5976 r6045  
    23162316
    23172317%%%
    2318 \begin{classdesc}{Transmissive\_Momentum\_Set\_Stage\_boundary}{Boundary}
     2318%\begin{classdesc}{Transmissive\_Momentum\_Set\_Stage\_boundary}{Boundary}
     2319\begin{classdesc}{Transmissive\_momentum\_set\_stage\_boundary}{Boundary}
    23192320Module: \module{shallow\_water}
    23202321\label{pg: transmissive momentum set stage boundary}
     
    23352336
    23362337
    2337 \begin{classdesc}{Dirichlet\_Discharge\_boundary}{Boundary}
     2338\begin{classdesc}{Transmissive\_stage\_zero\_momentum\_boundary}{Boundary}
     2339Module: \module{shallow\_water}
     2340\label{pg: transmissive stage zero momentum boundary}
     2341
     2342This boundary returns same stage conserved quantities as
     2343those present in its neighbour volume but sets momentum to zero.
     2344The underlying domain must be specified when boundary is instantiated
     2345
     2346This type of boundary is useful when stage is known at the boundary as a
     2347function of time, but momentum should be set to zero. This is for example the case where a boundary is needed in the ocean on the two sides perpendicular to the coast to maintain the wave height of the incoming wave.
     2348
     2349This class is specific to the shallow water equation as it works with the
     2350momentum quantities assumed to be the second and third conserved quantities.
     2351
     2352This boundary condition should not cause the numerical instabilities seen with the transmissive momentum
     2353boundary conditions (see Page \pageref{pg: transmissive boundary} and Page \pageref{pg: transmissive momentum set stage boundary}).
     2354
     2355\end{classdesc}
     2356
     2357
     2358\begin{classdesc}{Dirichlet\_discharge\_boundary}{Boundary}
    23382359Module: \module{shallow\_water}
    23392360
  • anuga_core/source/anuga/shallow_water/__init__.py

    r4733 r6045  
    1010    Transmissive_boundary, Reflective_boundary,\
    1111    Dirichlet_boundary, Time_boundary, File_boundary,\
    12     Transmissive_Momentum_Set_Stage_boundary,\
    13     Dirichlet_Discharge_boundary,\
     12    Transmissive_momentum_set_stage_boundary,\
     13    Dirichlet_discharge_boundary,\
    1414    Field_boundary
    1515
    1616
     17# FIXME (Ole): Deprecate
     18from shallow_water_domain import Transmissive_Momentum_Set_Stage_boundary
     19from shallow_water_domain import Dirichlet_Discharge_boundary
     20 
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r6006 r6045  
    11081108
    11091109
    1110 class Transmissive_Momentum_Set_Stage_boundary(Boundary):
     1110
     1111class Transmissive_momentum_set_stage_boundary(Boundary):
    11111112    """Returns same momentum conserved quantities as
    11121113    those present in its neighbour volume.
     
    11191120        return sea_level + normalized_amplitude/cosh(t-25)**2
    11201121
    1121     Bts = Transmissive_Momentum_Set_Stage_boundary(domain, waveform)
     1122    Bts = Transmissive_momentum_set_stage_boundary(domain, waveform)
    11221123   
    11231124
     
    11401141
    11411142    def __repr__(self):
    1142         return 'Transmissive_Momentum_Set_Stage_boundary(%s)' %self.domain
     1143        return 'Transmissive_momentum_set_stage_boundary(%s)' %self.domain
    11431144
    11441145    def evaluate(self, vol_id, edge_id):
    1145         """Transmissive Momentum Set Stage boundaries return the edge momentum
     1146        """Transmissive momentum set stage boundaries return the edge momentum
    11461147        values of the volume they serve.
    11471148        """
     
    11821183
    11831184
    1184 
    1185 class Dirichlet_Discharge_boundary(Boundary):
     1185# Backward compatibility       
     1186# FIXME(Ole): Deprecate
     1187class Transmissive_Momentum_Set_Stage_boundary(Transmissive_momentum_set_stage_boundary):
     1188    pass
     1189
     1190     
     1191
     1192class Transmissive_stage_zero_momentum_boundary(Boundary):
     1193    """Return same stage as those present in its neighbour volume. Set momentum to zero.
     1194
     1195    Underlying domain must be specified when boundary is instantiated
     1196    """
     1197
     1198    def __init__(self, domain=None):
     1199        Boundary.__init__(self)
     1200
     1201        if domain is None:
     1202            msg = 'Domain must be specified for '
     1203            msg += 'Transmissive_stage_zero_momentum boundary'
     1204            raise Exception, msg
     1205
     1206        self.domain = domain
     1207
     1208    def __repr__(self):
     1209        return 'Transmissive_stage_zero_momentum_boundary(%s)' %self.domain
     1210
     1211    def evaluate(self, vol_id, edge_id):
     1212        """Transmissive boundaries return the edge values
     1213        of the volume they serve.
     1214        """
     1215
     1216        q = self.domain.get_conserved_quantities(vol_id, edge=edge_id)
     1217       
     1218        q[1] = q[2] = 0.0
     1219        return q
     1220
     1221
     1222       
     1223class Dirichlet_discharge_boundary(Boundary):
    11861224    """
    11871225    Sets stage (stage0)
     
    11911229    """
    11921230
    1193     def __init__(self, domain = None, stage0=None, wh0=None):
     1231    def __init__(self, domain=None, stage0=None, wh0=None):
    11941232        Boundary.__init__(self)
    11951233
     
    12291267
    12301268
     1269       
     1270# Backward compatibility       
     1271# FIXME(Ole): Deprecate
     1272class Dirichlet_Discharge_boundary(Dirichlet_discharge_boundary):
     1273    pass
     1274                                                   
     1275   
     1276
     1277       
     1278       
    12311279class Field_boundary(Boundary):
    12321280    """Set boundary from given field represented in an sww file containing values
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r6002 r6045  
    558558
    559559       
    560        
     560
     561       
     562    def test_boundary_conditionsIII(self):
     563        """test_boundary_conditionsIII
     564       
     565        Test Transmissive_stage_zero_momentum_boundary
     566        """
     567       
     568        a = [0.0, 0.0]
     569        b = [0.0, 2.0]
     570        c = [2.0,0.0]
     571        d = [0.0, 4.0]
     572        e = [2.0, 2.0]
     573        f = [4.0,0.0]
     574
     575        points = [a, b, c, d, e, f]
     576        #bac, bce, ecf, dbe
     577        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ]
     578        boundary = { (0, 0): 'Third',
     579                     (0, 2): 'First',
     580                     (2, 0): 'Second',
     581                     (2, 1): 'Second',
     582                     (3, 1): 'Second',
     583                     (3, 2): 'Third'}
     584
     585
     586        domain = Domain(points, vertices, boundary)
     587        domain.check_integrity()
     588
     589
     590        domain.set_quantity('stage', [[1,2,3], [5,5,5],
     591                                      [0,0,9], [-6, 3, 3]])
     592
     593        domain.set_quantity('xmomentum', [[1,1,1], [2,2,2],
     594                                          [3,3,3], [4, 4, 4]])
     595
     596        domain.set_quantity('ymomentum', [[10,10,10], [20,20,20],
     597                                          [30,30,30], [40, 40, 40]])
     598
     599
     600        D = Dirichlet_boundary([5,2,1])
     601        T = Transmissive_stage_zero_momentum_boundary(domain)
     602        R = Reflective_boundary(domain)
     603        domain.set_boundary( {'First': D, 'Second': T, 'Third': R})
     604
     605        domain.update_boundary()
     606
     607        # Stage
     608        assert domain.quantities['stage'].boundary_values[0] == 2.5
     609        assert domain.quantities['stage'].boundary_values[0] ==\
     610               domain.get_conserved_quantities(0, edge=0)[0] #Reflective (2.5)
     611        assert domain.quantities['stage'].boundary_values[1] == 5. #Dirichlet
     612        assert domain.quantities['stage'].boundary_values[2] ==\
     613               domain.get_conserved_quantities(2, edge=0)[0] #Transmissive (4.5)
     614        assert domain.quantities['stage'].boundary_values[3] ==\
     615               domain.get_conserved_quantities(2, edge=1)[0] #Transmissive (4.5)
     616        assert domain.quantities['stage'].boundary_values[4] ==\
     617               domain.get_conserved_quantities(3, edge=1)[0] #Transmissive (-1.5)
     618        assert domain.quantities['stage'].boundary_values[5] ==\
     619               domain.get_conserved_quantities(3, edge=2)[0] #Reflective (-1.5)
     620
     621        # Xmomentum
     622        assert domain.quantities['xmomentum'].boundary_values[0] == 1.0 #Reflective
     623        assert domain.quantities['xmomentum'].boundary_values[1] == 2. #Dirichlet
     624        assert domain.quantities['xmomentum'].boundary_values[2] == 0.0
     625        assert domain.quantities['xmomentum'].boundary_values[3] == 0.0
     626        assert domain.quantities['xmomentum'].boundary_values[4] == 0.0
     627        assert domain.quantities['xmomentum'].boundary_values[5] == -4.0  #Reflective
     628
     629        # Ymomentum
     630        assert domain.quantities['ymomentum'].boundary_values[0] == -10.0 #Reflective
     631        assert domain.quantities['ymomentum'].boundary_values[1] == 1.  #Dirichlet
     632        assert domain.quantities['ymomentum'].boundary_values[2] == 0.0
     633        assert domain.quantities['ymomentum'].boundary_values[3] == 0.0
     634        assert domain.quantities['ymomentum'].boundary_values[4] == 0.0
     635        assert domain.quantities['ymomentum'].boundary_values[5] == 40. #Reflective
     636
     637               
     638               
    561639       
    562640    def test_boundary_condition_time(self):
Note: See TracChangeset for help on using the changeset viewer.