本文整理汇总了Python中dolfin.Mesh.coordinates()[:,:]方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.coordinates()[:,:]方法的具体用法?Python Mesh.coordinates()[:,:]怎么用?Python Mesh.coordinates()[:,:]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dolfin.Mesh
的用法示例。
在下文中一共展示了Mesh.coordinates()[:,:]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cyclic3D
# 需要导入模块: from dolfin import Mesh [as 别名]
# 或者: from dolfin.Mesh import coordinates()[:,:] [as 别名]
def cyclic3D(u):
""" Symmetrize with respect to (xyz) cycle. """
try:
nrm = np.linalg.norm(u.vector())
V = u.function_space()
assert V.mesh().topology().dim() == 3
mesh1 = Mesh(V.mesh())
mesh1.coordinates()[:, :] = mesh1.coordinates()[:, [1, 2, 0]]
W1 = FunctionSpace(mesh1, 'CG', 1)
# testing if symmetric
bc = DirichletBC(V, 1, DomainBoundary())
test = Function(V)
bc.apply(test.vector())
test = interpolate(Function(W1, test.vector()), V)
assert max(test.vector()) - min(test.vector()) < 1.1
v1 = interpolate(Function(W1, u.vector()), V)
mesh2 = Mesh(mesh1)
mesh2.coordinates()[:, :] = mesh2.coordinates()[:, [1, 2, 0]]
W2 = FunctionSpace(mesh2, 'CG', 1)
v2 = interpolate(Function(W2, u.vector()), V)
pr = project(u+v1+v2)
assert np.linalg.norm(pr.vector())/nrm > 0.01
return pr
except:
print "Cyclic symmetrization failed!"
return u
示例2: rotational
# 需要导入模块: from dolfin import Mesh [as 别名]
# 或者: from dolfin.Mesh import coordinates()[:,:] [as 别名]
def rotational(u, n):
""" Symmetrize with respect to n-fold symmetry. """
# TODO: test one rotation only
V = u.function_space()
if V.mesh().topology().dim() > 2 or n < 2:
return u
mesh = V.mesh()
sum = u
nrm = np.linalg.norm(u.vector())
rotation = np.array([[np.cos(2*np.pi/n), np.sin(2*np.pi/n)],
[-np.sin(2*np.pi/n), np.cos(2*np.pi/n)]])
for i in range(1, n):
mesh = Mesh(mesh)
mesh.coordinates()[:, :] = np.dot(mesh.coordinates(), rotation)
W = FunctionSpace(mesh, 'CG', 1)
v = interpolate(Function(W, u.vector()), V)
sum += v
pr = project(sum)
if np.linalg.norm(pr.vector())/nrm > 0.01:
return pr
else:
return u