|
1 | 1 | from os import path |
2 | | -import sys |
3 | | -sys.path.append(path.dirname(path.dirname(__file__))) |
4 | 2 |
|
5 | 3 | from compas.datastructures import Mesh, mesh_subdivide |
6 | 4 | from compas_view2 import app |
7 | 5 |
|
8 | | -from nfd import nfd_ur_numpy |
| 6 | +from compas_fd.nfd_numpy import nfd_ur_numpy |
9 | 7 | from _helpers import mesh_update |
10 | 8 |
|
11 | 9 |
|
12 | 10 | # ================================================= |
13 | 11 | # IO |
14 | 12 | # ================================================= |
| 13 | + |
15 | 14 | HERE = path.dirname(__file__) |
16 | 15 | FILE_I = path.join(HERE, '..', 'data', 'in_hypar_mesh.json') |
17 | 16 | mesh = Mesh.from_json(FILE_I) |
|
20 | 19 | # ================================================= |
21 | 20 | # input mesh |
22 | 21 | # ================================================= |
| 22 | + |
23 | 23 | mesh.vertices_attribute('is_anchor', True, |
24 | 24 | mesh.vertices_where({'vertex_degree': 2})) |
25 | 25 |
|
26 | 26 | central_vertex = 3 |
27 | | -# nbrs = mesh.vertex_neighborhood(central_vertex, ring=2) |
28 | | -# for nbr in nbrs: |
29 | | -# mesh.delete_vertex(nbr) |
30 | 27 | mesh.delete_vertex(3) |
31 | 28 |
|
32 | 29 | mesh = mesh_subdivide(mesh, scheme='quad', k=3) |
|
50 | 47 | # ================================================= |
51 | 48 | # get mesh data |
52 | 49 | # ================================================= |
| 50 | + |
53 | 51 | P = mesh.vertices_attributes(['px', 'py', 'pz']) |
54 | 52 | S = mesh.faces_attribute('s_pre') |
55 | 53 | Q = mesh.edges_attribute('q_pre') |
|
58 | 56 | # ================================================= |
59 | 57 | # run solver |
60 | 58 | # ================================================= |
| 59 | + |
61 | 60 | xyz, r, s, f = nfd_ur_numpy(mesh, S, Q, vertex_loads=P, kmax=10, |
62 | 61 | s_calc=1, s_tol=.05, xyz_tol=.01) |
63 | 62 | mesh_update(mesh, xyz, r, s, f) |
|
66 | 65 | # ================================================= |
67 | 66 | # visualisation |
68 | 67 | # ================================================= |
| 68 | + |
69 | 69 | viewer = app.App() |
70 | 70 | viewer.add(mesh) |
71 | 71 | viewer.show() |
0 commit comments