本文整理汇总了Python中anuga.Domain.tri_full_flag[1]方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.tri_full_flag[1]方法的具体用法?Python Domain.tri_full_flag[1]怎么用?Python Domain.tri_full_flag[1]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anuga.Domain
的用法示例。
在下文中一共展示了Domain.tri_full_flag[1]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rate_operator_functions_spatial_with_ghost
# 需要导入模块: from anuga import Domain [as 别名]
# 或者: from anuga.Domain import tri_full_flag[1] [as 别名]
def test_rate_operator_functions_spatial_with_ghost(self):
from anuga.config import rho_a, rho_w, eta_w
from math import pi, cos, sin
a = [0.0, 0.0]
b = [0.0, 2.0]
c = [2.0, 0.0]
d = [0.0, 4.0]
e = [2.0, 2.0]
f = [4.0, 0.0]
points = [a, b, c, d, e, f]
# bac, bce, ecf, dbe
vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
domain = Domain(points, vertices)
area = numpy.sum(domain.areas)
#Flat surface with 1m of water
domain.set_quantity('elevation', 0.0)
domain.set_quantity('stage', 1.0)
domain.set_quantity('friction', 0.0)
Br = Reflective_boundary(domain)
domain.set_boundary({'exterior': Br})
verbose = False
if verbose:
print domain.quantities['elevation'].centroid_values
print domain.quantities['stage'].centroid_values
print domain.quantities['xmomentum'].centroid_values
print domain.quantities['ymomentum'].centroid_values
# Apply operator to these triangles
factor = 10.0
def main_spatial_rate(x,y,t):
# x and y should be an n by 1 array
return x + y
default_rate = 0.0
# kludge to make a ghost cell
domain.tri_full_flag[1] = 0
operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
default_rate = default_rate)
# Apply Operator
domain.timestep = 2.0
operator()
t = operator.get_time()
Q_all = operator.get_Q(full_only=False)
Q_full = operator.get_Q()
x = operator.coord_c[:,0]
y = operator.coord_c[:,1]
rate = main_spatial_rate(x,y,t)*factor
Q_ex_all = num.sum(domain.areas*rate)
Q_ex_full = num.sum(num.where(domain.tri_full_flag==1,domain.areas*rate,0.0))
d = operator.get_timestep()*rate + 1
#print "d"
#print d
#print Q_ex_full, Q_ex_all
stage_ex = num.array([ 1.0, 1.0, 1.0, 1.0])
stage_ex[:] = d
if verbose:
print domain.quantities['elevation'].centroid_values
print domain.quantities['stage'].centroid_values
print domain.quantities['xmomentum'].centroid_values
print domain.quantities['ymomentum'].centroid_values
assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
assert num.allclose(Q_ex_all, Q_all)
assert num.allclose(Q_ex_full, Q_full)
assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas*domain.tri_full_flag).sum())