我使用有限元方法在球形截面中建模对流。我试图将3D笛卡尔网格变形为3480 <=半径<= 6371 km的球形截面,并且θ和φ的角度范围是80度。 Please check this image, left side figure is the 3D cartesian mesh which I have and right side is the required deformed geometry of the mesh. 我使用了一些变换函数来变形网格但无法达到最终目标。我正在寻找关于算法或变换函数的一些建议,以将网格变形为球形截面。
答案 0 :(得分:0)
不确定这是否真的相同,但通过眼睛看起来足够接近:
import numpy as np
phi, theta, R = np.ogrid[-40:40:21j, -40:40:21j, 3480:6371:21j]
y, x = np.tan(phi*np.pi/180), np.tan(theta*np.pi/180)
z = R / np.sqrt(x*x + y*y + 1)
y, x = y*z, x*z
from mpl_toolkits.mplot3d import Axes3D
import pylab
fig = pylab.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(x[..., 20], y[..., 20], z[..., 20])
ax.plot_wireframe(0.01*x[..., 20], 0.01*y[..., 20], 0.01*z[..., 20]) # hack to scale z axis
ax.plot_wireframe(x[:, 20, :], y[:, 20, :], z[:, 20, :])
ax.plot_wireframe(x[0, ...], y[0, ...], z[0, ...])
fig.show()