-
Notifications
You must be signed in to change notification settings - Fork 169
Expand file tree
/
Copy pathpython_geometry.py
More file actions
40 lines (30 loc) · 1.05 KB
/
Copy pathpython_geometry.py
File metadata and controls
40 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from netgen.occ import *
from netgen.meshing import NetgenGeometry, Mesh as NGMesh
import numpy as np
class UnitSphereGeometry(NetgenGeometry):
def midpoint(self, newp, p1, p2, secpoint=0.5):
p1 = np.array([p1[0], p1[1], p1[2]])
p2 = np.array([p2[0], p2[1], p2[2]])
p = p1 + secpoint * (p2 - p1)
self.project(newp, p)
def project(self, newp, p):
pt = np.array([p[0], p[1], p[2]])
pt /= np.linalg.norm(pt)
newp[0] = pt[0]
newp[1] = pt[1]
newp[2] = pt[2]
def PointBetweenEdge(self, p1, p2, secpoint, surfi1, surfi2, ep1, ep2, newp, newgi):
self.midpoint(newp, p1, p2, secpoint)
def PointBetween(self, p1, p2, secpoint, surfi, gi1, gi2, newp, newgi):
self.midpoint(newp, p1, p2, secpoint)
def ProjectPointGI(self, surfind, p, gi):
self.project(p, p)
return True
m = OCCGeometry(Sphere(Pnt(0, 0, 0), 1)).GenerateMesh()
my_geo = UnitSphereGeometry()
m.SetGeometry(my_geo)
m.Refine()
m.Curve(3)
from ngsolve import *
mesh = Mesh(m)
Draw(mesh)