本文整理汇总了Python中anuga.shallow_water.shallow_water_domain.Domain.set_tag_region方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.set_tag_region方法的具体用法?Python Domain.set_tag_region怎么用?Python Domain.set_tag_region使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anuga.shallow_water.shallow_water_domain.Domain
的用法示例。
在下文中一共展示了Domain.set_tag_region方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unique_vertices_average_loc_unique_vert
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import set_tag_region [as 别名]
def test_unique_vertices_average_loc_unique_vert(self):
"""
get values based on triangle lists.
"""
#Create basic mesh
points, vertices, boundary = rectangular(1, 3)
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.build_tagged_elements_dictionary({'bottom':[0,1],
'top':[4,5],
'not_bottom':[2,3,4,5]})
#Set friction
domain.set_quantity('friction', add_x_y)
av_bottom = 2.0/3.0
add = 60.0
calc_frict = av_bottom + add
domain.set_tag_region(Add_value_to_region('bottom', 'friction', add,
initial_quantity='friction',
location='unique vertices',
average=True
))
#print domain.quantities['friction'].get_values()
frict_points = domain.quantities['friction'].get_values()
assert num.allclose(frict_points[0],\
[ calc_frict, calc_frict, calc_frict])
assert num.allclose(frict_points[1],\
[ calc_frict, calc_frict, calc_frict])
assert num.allclose(frict_points[2],\
[ calc_frict, 1.0 + 2.0/3.0, calc_frict])
assert num.allclose(frict_points[3],\
[ 2.0/3.0,calc_frict, 1.0 + 2.0/3.0])
示例2: test_unique_verticesII
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import set_tag_region [as 别名]
def test_unique_verticesII(self):
"""
get values based on triangle lists.
"""
#Create basic mesh
points, vertices, boundary = rectangular(1, 3)
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.build_tagged_elements_dictionary({'bottom':[0,1],
'top':[4,5],
'all':[0,1,2,3,4,5]})
#Set friction
manning = 0.07
domain.set_quantity('friction', manning)
domain.set_tag_region(Add_value_to_region('bottom', 'friction', 1.0,initial_quantity='friction', location = 'unique vertices'))
#print domain.quantities['friction'].get_values()
assert num.allclose(domain.quantities['friction'].get_values(),\
[[ 1.07, 1.07, 1.07],
[ 1.07, 1.07, 1.07],
[ 1.07, 0.07, 1.07],
[ 0.07, 1.07, 0.07],
[ 0.07, 0.07, 0.07],
[ 0.07, 0.07, 0.07]])
示例3: test_region_tags
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import set_tag_region [as 别名]
def test_region_tags(self):
"""get values based on triangle lists."""
#Create basic mesh
points, vertices, boundary = rectangular(1, 3)
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.build_tagged_elements_dictionary({'bottom': [0,1],
'top': [4,5],
'all': [0,1,2,3,4,5]})
#Set friction
manning = 0.07
domain.set_quantity('friction', manning)
a = Set_tag_region('bottom', 'friction', 0.09)
b = Set_tag_region('top', 'friction', 1.0)
domain.set_tag_region([a, b])
expected = [[ 0.09, 0.09, 0.09],
[ 0.09, 0.09, 0.09],
[ 0.07, 0.07, 0.07],
[ 0.07, 0.07, 0.07],
[ 1.0, 1.0, 1.0],
[ 1.0, 1.0, 1.0]]
msg = ("\ndomain.quantities['friction']=%s\nexpected value=%s"
% (str(domain.quantities['friction'].get_values()),
str(expected)))
assert num.allclose(domain.quantities['friction'].get_values(),
expected), msg
#c = Add_Value_To_region('all', 'friction', 10.0)
domain.set_tag_region(Add_value_to_region('all', 'friction', 10.0))
#print domain.quantities['friction'].get_values()
assert num.allclose(domain.quantities['friction'].get_values(),
[[ 10.09, 10.09, 10.09],
[ 10.09, 10.09, 10.09],
[ 10.07, 10.07, 10.07],
[ 10.07, 10.07, 10.07],
[ 11.0, 11.0, 11.0],
[ 11.0, 11.0, 11.0]])
# trying a function
domain.set_tag_region(Set_tag_region('top', 'friction', add_x_y))
#print domain.quantities['friction'].get_values()
assert num.allclose(domain.quantities['friction'].get_values(),
[[ 10.09, 10.09, 10.09],
[ 10.09, 10.09, 10.09],
[ 10.07, 10.07, 10.07],
[ 10.07, 10.07, 10.07],
[ 5./3, 2.0, 2./3],
[ 1.0, 2./3, 2.0]])
domain.set_quantity('elevation', 10.0)
domain.set_quantity('stage', 10.0)
domain.set_tag_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation'))
#print domain.quantities['stage'].get_values()
assert num.allclose(domain.quantities['stage'].get_values(),
[[ 10., 10., 10.],
[ 10., 10., 10.],
[ 10., 10., 10.],
[ 10., 10., 10.],
[ 11.0, 11.0, 11.0],
[ 11.0, 11.0, 11.0]])
domain.set_quantity('elevation', 10.0)
domain.set_quantity('stage', give_me_23)
#this works as well, (is cleaner, but doesn't work for regions)
#domain.set_quantity('stage',
# domain.quantities['stage'].vertex_values+ \
# domain.quantities['elevation'].vertex_values)
domain.set_tag_region(Add_quantities('top', 'elevation','stage'))
#print domain.quantities['stage'].get_values()
assert num.allclose(domain.quantities['elevation'].get_values(),
[[ 10., 10., 10.],
[ 10., 10., 10.],
[ 10., 10., 10.],
[ 10., 10., 10.],
[ 33., 33.0, 33.],
[ 33.0, 33., 33.]])