コード例 #1
0

# Set initial condition
class Set_IC:
    """Set an initial condition with a constant value, for x0<x<x1
    """
    def __init__(self, x0=0.25, x1=0.5, h=1.0):
        self.x0 = x0
        self.x1 = x1
        self.h = h

    def __call__(self, x, y):
        return self.h * ((x > self.x0) & (x < self.x1))


domain.set_quantity('stage', Set_IC(200.0, 300.0, 5.0))

try:
    domain.initialise_visualiser()
except:
    print 'No visualiser'
else:
    domain.visualiser.scale_z['stage'] = 0.2
    domain.visualiser.scale_z['elevation'] = 0.05

#Boundaries
R = Reflective_boundary(domain)
domain.set_boundary({'left': R, 'right': R, 'top': R, 'bottom': R})

# Evolution
print 'Minimal allowed water height = ', domain.minimum_allowed_height
コード例 #2
0
log.critical('Number of elements=%d' % len(vertices))
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.smooth = False
domain.default_order = 2
domain.set_name('show_balanced_limiters')
domain.store = True
domain.format = 'sww'   #Native netcdf visualisation format

#Set bed-slope and friction
inflow_stage = 0.1
manning = 0.1
Z = Weir(inflow_stage)

log.critical('Field values')
domain.set_quantity('elevation', Z)
domain.set_quantity('friction', manning)


######################
# Boundary conditions
#
log.critical('Boundaries')
Br = Reflective_boundary(domain)
Bt = Transmissive_boundary(domain)

#Constant inflow
Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0])

#Time dependent inflow
from math import sin, pi
コード例 #3
0
log.critical('Number of elements=%d' % len(vertices))
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.smooth = False
domain.default_order = 2
domain.set_name('show_balanced_limiters')
domain.store = True
domain.format = 'sww'  #Native netcdf visualisation format

#Set bed-slope and friction
inflow_stage = 0.1
manning = 0.1
Z = Weir(inflow_stage)

log.critical('Field values')
domain.set_quantity('elevation', Z)
domain.set_quantity('friction', manning)

######################
# Boundary conditions
#
log.critical('Boundaries')
Br = Reflective_boundary(domain)
Bt = Transmissive_boundary(domain)

#Constant inflow
Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0])

#Time dependent inflow
from math import sin, pi
Bw = Time_boundary(domain=domain,
コード例 #4
0
# Set initial condition
class Set_IC:
    """Set an initial condition with a constant value, for x0<x<x1
    """

    def __init__(self, x0=0.25, x1=0.5, h=1.0):
        self.x0 = x0
        self.x1 = x1
        self.h  = h

    def __call__(self, x, y):
        return self.h*((x>self.x0)&(x<self.x1))


domain.set_quantity('stage', Set_IC(200.0,300.0,5.0))

try:
    domain.initialise_visualiser()
except:
    print 'No visualiser'
else:    
    domain.visualiser.scale_z['stage'] = 0.2
    domain.visualiser.scale_z['elevation'] = 0.05
    

#Boundaries
R = Reflective_boundary(domain)
domain.set_boundary( {'left': R, 'right': R, 'top':R, 'bottom': R} )

コード例 #5
0
            else:
                z[i] += 0.5 * (x[i] - 5.0)  # Sloping Segment  U/S Face
        if 10.0 < x[i] < 12.1:
            z[i] += 2.5  # Flat Crest of Embankment
        if 12.0 < x[i] < 14.5:
            if 2.0 - (x[i] - 12.0) / 2.5 < y[i] < 3.0 + (
                    x[i] - 12.0) / 2.5:  # Cut Out Segment for Culvert FACE
                z[i] = z[i]
            else:
                z[i] += 2.5 - 1.0 * (x[i] - 12.0)  # Sloping D/S Face

    return z


print 'Setting Quantities....'
domain.set_quantity('elevation', topography)  # Use function for elevation
domain.set_quantity('friction', 0.01)  # Constant friction
domain.set_quantity('stage', expression='elevation')  # Dry initial condition

#------------------------------------------------------------------------------
# Setup specialised forcing terms
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Setup CULVERT INLETS and OUTLETS in Current Topography
#------------------------------------------------------------------------------
print 'DEFINING any Structures if Required'

#  DEFINE CULVERT INLET AND OUTLETS

culvert_rating = Culvert_flow(
コード例 #6
0
from anuga_parallel.parallel_api import myid, numprocs, distribute

import project


#-------------------------
# Create Domain from mesh
#-------------------------
domain = Domain(project.mesh_filename, use_cache=True, verbose=True)
print domain.statistics()


#-------------------------
# Initial Conditions
#-------------------------
domain.set_quantity('friction', 0.0)
domain.set_quantity('stage', 0.0)

import time
t0 = time.time()
bathymetry_filename=project.bathymetry_filename
bathymetry_filename='Benchmark_2_Bathymetry_very_thin.pts'
print 'Starting domain.set_quantity.  Loading ', bathymetry_filename
s = "domain.set_quantity('elevation',filename=bathymetry_filename,alpha=0.02,verbose=True,use_cache=True)"


import profile, pstats
FN = 'profile.dat'

profile.run(s, FN)
コード例 #7
0
            else:
               z[i] +=  0.5*(x[i] -5.0)    # Sloping Segment  U/S Face
        if 10.0 < x[i] < 12.1:
           z[i] +=  2.5              # Flat Crest of Embankment
        if 12.0 < x[i] < 14.5:
            if  2.0-(x[i]-12.0)/2.5 <  y[i]  < 3.0 + (x[i]-12.0)/2.5: # Cut Out Segment for Culvert FACE
               z[i]=z[i]
            else:
               z[i] +=  2.5-1.0*(x[i] -12.0)       # Sloping D/S Face
        		   
        
		
    return z

print 'Setting Quantities....'
domain.set_quantity('elevation', topography)  # Use function for elevation
domain.set_quantity('friction', 0.01)         # Constant friction 
domain.set_quantity('stage',
                    expression='elevation')   # Dry initial condition




#------------------------------------------------------------------------------
# Setup specialised forcing terms
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Setup CULVERT INLETS and OUTLETS in Current Topography
#------------------------------------------------------------------------------
print 'DEFINING any Structures if Required'
コード例 #8
0
from anuga.abstract_2d_finite_volumes.util import file_function

from anuga_parallel.parallel_api import myid, numprocs, distribute

import project

#-------------------------
# Create Domain from mesh
#-------------------------
domain = Domain(project.mesh_filename, use_cache=True, verbose=True)
print domain.statistics()

#-------------------------
# Initial Conditions
#-------------------------
domain.set_quantity('friction', 0.0)
domain.set_quantity('stage', 0.0)

import time
t0 = time.time()
bathymetry_filename = project.bathymetry_filename
bathymetry_filename = 'Benchmark_2_Bathymetry_very_thin.pts'
print 'Starting domain.set_quantity.  Loading ', bathymetry_filename
s = "domain.set_quantity('elevation',filename=bathymetry_filename,alpha=0.02,verbose=True,use_cache=True)"

import profile, pstats
FN = 'profile.dat'

profile.run(s, FN)

print 'Set_quantity elevation took %.2f seconds' % (time.time() - t0)