问题描述
我对空间中表面积分的数值计算感兴趣,二次约束由非对角矩阵 g 确定,它有效地限制了椭球表面上的积分。到目前为止,我尝试通过狄拉克 delta 函数的高斯近似包含积分符号下的约束,但这显着减慢了收敛速度。
是否有一个最佳库可以有效地实现这种集成?可能在 Python 中?
解决方法
一个好的方法是首先生成域的三角剖分,例如,使用 pygalmesh
import pygalmesh
import numpy as np
class Surface(pygalmesh.DomainBase):
def __init__(self):
self.G = np.array([
[1.0,3.0,-1.0],[2.0,1.0,2.0],[0.0,0.0,1.0],])
super().__init__()
def eval(self,x):
return np.dot(x,self.G @ x) - 1.0
def get_bounding_sphere_squared_radius(self):
return 10.0
d = Surface()
mesh = pygalmesh.generate_surface_mesh(d,max_radius_surface_delaunay_ball=0.1)
mesh.write("out.vtk")
然后您可以使用 quadpy 对三角剖分上的任何函数进行积分。