一种可能性是通过我的一个项目smoothfit 来实现。您首先创建一个四边形网格(meshzoo 可能会有所帮助),然后使用值 y0 定义目标位置 x0,然后使用 smoothfit 求解。
import meshzoo
import smoothfit
points, cells = meshzoo.rectangle_quad((0.0, 0.0), (7.0, 7.0), n=7)
x0 = [
[0.5, 0.5],
[1.5, 0.5],
[2.5, 0.5],
[3.5, 0.5],
[4.5, 0.5],
[5.5, 0.5],
# ...
[0.5, 5.5],
# ...
[5.5, 5.5],
]
y0 = [8.0, 8.0, 9.0, 8.0, 7.0, 6.0, 10.0, 9.0]
basis, u = smoothfit.fit(x0, y0, points, cells, lmbda=1.0e-4, solver="dense-direct")
# Write the function to a file
basis.mesh.save("out.vtu", point_data={"u": u})
这将为您提供整个域上的函数,该函数平滑且大致满足您的目标值。