本文整理汇总了Python中anuga.shallow_water.shallow_water_domain.Domain.store方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.store方法的具体用法?Python Domain.store怎么用?Python Domain.store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anuga.shallow_water.shallow_water_domain.Domain
的用法示例。
在下文中一共展示了Domain.store方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sww2domain1
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import store [as 别名]
def test_sww2domain1(self):
################################################
#Create a test domain, and evolve and save it.
################################################
#from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
#Create basic mesh
yiel=0.01
points, vertices, boundary = rectangular(10,10)
#print "=============== boundary rect ======================="
#print boundary
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.geo_reference = Geo_reference(56,11,11)
domain.smooth = False
domain.store = True
domain.set_name('bedslope')
domain.default_order=2
#Bed-slope and friction
domain.set_quantity('elevation', lambda x,y: -x/3)
domain.set_quantity('friction', 0.1)
# Boundary conditions
from math import sin, pi
Br = Reflective_boundary(domain)
Bt = Transmissive_boundary(domain)
Bd = Dirichlet_boundary([0.2,0.,0.])
Bw = Time_boundary(domain=domain,function=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
#domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd})
domain.quantities_to_be_stored['xmomentum'] = 2
domain.quantities_to_be_stored['ymomentum'] = 2
#Initial condition
h = 0.05
elevation = domain.quantities['elevation'].vertex_values
domain.set_quantity('stage', elevation + h)
domain.check_integrity()
#Evolution
#domain.tight_slope_limiters = 1
for t in domain.evolve(yieldstep = yiel, finaltime = 0.05):
#domain.write_time()
pass
#print boundary
filename = domain.datadir + os.sep + domain.get_name() + '.sww'
domain2 = load_sww_as_domain(filename, None, fail_if_NaN=False,
verbose=self.verbose)
# Unfortunately we loss the boundaries top, bottom, left and right,
# they are now all lumped into "exterior"
#print "=============== boundary domain2 ======================="
#print domain2.boundary
#print domain2.get_boundary_tags()
#points, vertices, boundary = rectangular(15,15)
#domain2.boundary = boundary
###################
##NOW TEST IT!!!
###################
os.remove(filename)
bits = ['vertex_coordinates']
for quantity in ['stage']:
bits.append('get_quantity("%s").get_integral()' % quantity)
bits.append('get_quantity("%s").get_values()' % quantity)
for bit in bits:
#print 'testing that domain.'+bit+' has been restored'
#print bit
#print 'done'
#print eval('domain.'+bit)
#print eval('domain2.'+bit)
assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit))
######################################
#Now evolve them both, just to be sure
######################################x
from time import sleep
final = .1
domain.set_quantity('friction', 0.1)
domain.store = False
domain.set_boundary({'exterior': Bd, 'left' : Bd, 'right': Bd, 'top': Bd, 'bottom': Bd})
for t in domain.evolve(yieldstep = yiel, finaltime = final):
#domain.write_time()
pass
#.........这里部分代码省略.........