三维笛卡尔网格到球面剖分网格的转换

2024-09-27 17:57:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用有限元法模拟球形截面的对流。我尝试将三维笛卡尔网格变形为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. 我使用了一些变换函数来变形网格,但无法达到最终目标。我正在寻找一些关于算法或变换函数的建议,以将网格变形为球形截面。你知道吗


Tags: the函数lt网格is半径side角度
1条回答
网友
1楼 · 发布于 2024-09-27 17:57:14

不确定这是否真的是一样的,但用肉眼看它看起来足够近了:

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()

enter image description here

相关问题 更多 >

    热门问题