Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/in_hypar_mesh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"compas": "1.7.1", "datatype": "compas.datastructures/Mesh", "data": {"facedata": {"5": {"path": [1, 0]}, "6": {"path": [1, 1]}, "7": {"path": [1, 2]}, "8": {"path": [1, 3]}, "9": {"path": [2, 0]}, "10": {"path": [2, 1]}, "11": {"path": [2, 2]}, "12": {"path": [2, 3]}, "13": {"path": [3, 0]}, "14": {"path": [3, 1]}, "15": {"path": [3, 2]}, "16": {"path": [3, 3]}, "17": {"path": [4, 0]}, "18": {"path": [4, 1]}, "19": {"path": [4, 2]}, "20": {"path": [4, 3]}}, "dva": {"y": 0.0, "x": 0.0, "z": 0.0}, "face": {"5": [9, 0, 10, 21], "6": [10, 2, 13, 21], "7": [13, 3, 15, 21], "8": [15, 7, 9, 21], "9": [12, 1, 11, 22], "10": [11, 8, 16, 22], "11": [16, 3, 17, 22], "12": [17, 4, 12, 22], "13": [17, 3, 13, 23], "14": [13, 2, 14, 23], "15": [14, 5, 18, 23], "16": [18, 4, 17, 23], "17": [15, 3, 16, 24], "18": [16, 8, 20, 24], "19": [20, 6, 19, 24], "20": [19, 7, 15, 24]}, "edgedata": {}, "dfa": {}, "max_vertex": 24, "dea": {}, "attributes": {"name": "Mesh"}, "max_face": 20, "vertex": {"0": {"z": 20.0, "y": -46.983559137412122, "x": -44.487094537112114}, "1": {"z": 20.0, "y": 43.016440862587885, "x": 45.512905462887865}, "2": {"z": 10.0, "y": -46.983559137412122, "x": 0.51290546288787808}, "3": {"z": 0.0, "y": -1.9835591374121182, "x": 0.51290546288788419}, "4": {"z": 10.0, "y": -1.9835591374121213, "x": 45.512905462887865}, "5": {"z": 0.0, "y": -46.983559137412122, "x": 45.512905462887865}, "6": {"z": 0.0, "y": 43.016440862587885, "x": -44.487094537112114}, "7": {"z": 10.0, "y": -1.9835591374121186, "x": -44.487094537112114}, "8": {"z": 10.0, "y": 43.016440862587885, "x": 0.51290546288789052}, "9": {"z": 15.0, "y": -24.483559137412122, "x": -44.487094537112114}, "10": {"z": 15.0, "y": -46.983559137412122, "x": -21.987094537112117}, "11": {"z": 15.0, "y": 43.016440862587885, "x": 23.012905462887879}, "12": {"z": 15.0, "y": 20.516440862587881, "x": 45.512905462887865}, "13": {"z": 5.0, "y": -24.483559137412119, "x": 0.51290546288788108}, "14": {"z": 5.0, "y": -46.983559137412122, "x": 23.012905462887872}, "15": {"z": 5.0, "y": -1.9835591374121184, "x": -21.987094537112117}, "16": {"z": 5.0, "y": 20.516440862587881, "x": 0.5129054628878873}, "17": {"z": 5.0, "y": -1.9835591374121198, "x": 23.012905462887872}, "18": {"z": 5.0, "y": -24.483559137412122, "x": 45.512905462887865}, "19": {"z": 5.0, "y": 20.516440862587885, "x": -44.487094537112114}, "20": {"z": 5.0, "y": 43.016440862587885, "x": -21.98709453711211}, "21": {"z": 10.0, "y": -24.483559137412119, "x": -21.987094537112114}, "22": {"z": 10.0, "y": 20.516440862587885, "x": 23.012905462887879}, "23": {"z": 5.0, "y": -24.483559137412119, "x": 23.012905462887872}, "24": {"z": 5.0, "y": 20.516440862587885, "x": -21.987094537112114}}}}
68 changes: 68 additions & 0 deletions scripts/91_nfd_hypar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from os import path

from compas.datastructures import Mesh, mesh_subdivide
from compas_view2 import app

from compas_fd.nfd import nfd_ur_numpy
from _nfd_helpers import mesh_update


# =================================================
# IO
# =================================================

HERE = path.dirname(__file__)
FILE_I = path.join(HERE, '..', 'data', 'in_hypar_mesh.json')
mesh = Mesh.from_json(FILE_I)


# =================================================
# input mesh
# =================================================

mesh.vertices_attribute('is_anchor', True,
mesh.vertices_where({'vertex_degree': 2}))

mesh = mesh_subdivide(mesh, scheme='quad', k=2)
mesh.quads_to_triangles()

bounds = mesh.edges_on_boundaries()[0]
mesh.edges_attribute('q_pre', 20, bounds)

dva = {'rx': .0, 'ry': .0, 'rz': .0,
'px': .0, 'py': .0, 'pz': .0,
'is_anchor': False}
dea = {'q_pre': .0}
dfa = {'s_pre': [1.0, 1.0, 0.0]}

mesh.update_default_vertex_attributes(dva)
mesh.update_default_edge_attributes(dea)
mesh.update_default_face_attributes(dfa)


# =================================================
# get mesh data
# =================================================

fixed = [mesh.key_index()[v] for v in mesh.vertices_where({'is_anchor': True})]
P = mesh.vertices_attributes(['px', 'py', 'pz'])
S = mesh.faces_attribute('s_pre')
Q = mesh.edges_attribute('q_pre')


# =================================================
# solver
# =================================================

xyz, r, f, _, s = nfd_ur_numpy(mesh, fixed, S, force_density_goals=Q,
vertex_loads=P, kmax=10, stress_flag=1)
mesh_update(mesh, xyz, r, s, f)


# =================================================
# viz
# =================================================

viewer = app.App()
viewer.add(mesh)
viewer.show()
72 changes: 72 additions & 0 deletions scripts/92_nfd_hypar_opening.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from os import path

from compas.datastructures import Mesh, mesh_subdivide
from compas_view2 import app

from compas_fd.nfd import nfd_ur_numpy
from _nfd_helpers import mesh_update


# =================================================
# IO
# =================================================

HERE = path.dirname(__file__)
FILE_I = path.join(HERE, '..', 'data', 'in_hypar_mesh.json')
mesh = Mesh.from_json(FILE_I)


# =================================================
# input mesh
# =================================================

mesh.vertices_attribute('is_anchor', True,
mesh.vertices_where({'vertex_degree': 2}))

central_vertex = 3
mesh.delete_vertex(3)

mesh = mesh_subdivide(mesh, scheme='quad', k=3)
mesh.quads_to_triangles()

in_bounds, out_bounds = sorted(mesh.edges_on_boundaries(), key=len)
mesh.edges_attribute('q_pre', 11, in_bounds)
mesh.edges_attribute('q_pre', 30, out_bounds)

dva = {'rx': .0, 'ry': .0, 'rz': .0,
'px': .0, 'py': .0, 'pz': .0,
'is_anchor': False}
dea = {'q_pre': .0}
dfa = {'s_pre': [1.0, 1.0, 0.0]}

mesh.update_default_vertex_attributes(dva)
mesh.update_default_edge_attributes(dea)
mesh.update_default_face_attributes(dfa)


# =================================================
# get mesh data
# =================================================

fixed = [mesh.key_index()[v] for v in mesh.vertices_where({'is_anchor': True})]
P = mesh.vertices_attributes(['px', 'py', 'pz'])
S = mesh.faces_attribute('s_pre')
Q = mesh.edges_attribute('q_pre')


# =================================================
# solver
# =================================================

xyz, r, f, _, s = nfd_ur_numpy(mesh, fixed, S, force_density_goals=Q, vertex_loads=P,
kmax=10, stress_flag=1, stress_tol=.05, xyz_tol=.01)
mesh_update(mesh, xyz, r, s, f)


# =================================================
# viz
# =================================================

viewer = app.App()
viewer.add(mesh)
viewer.show()
67 changes: 67 additions & 0 deletions scripts/93_nfd_hypar_quads.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from os import path

from compas.datastructures import Mesh, mesh_subdivide
from compas_view2 import app

from compas_fd.nfd import nfd_ur_numpy
from _nfd_helpers import mesh_update


# =================================================
# IO
# =================================================

HERE = path.dirname(__file__)
FILE_I = path.join(HERE, '..', 'data', 'in_hypar_mesh.json')
mesh = Mesh.from_json(FILE_I)


# =================================================
# input mesh
# =================================================

mesh.vertices_attribute('is_anchor', True,
mesh.vertices_where({'vertex_degree': 2}))

mesh = mesh_subdivide(mesh, scheme='quad', k=3)

bounds = mesh.edges_on_boundaries()[0]
mesh.edges_attribute('q_pre', 30, bounds)

dva = {'rx': .0, 'ry': .0, 'rz': .0,
'px': .0, 'py': .0, 'pz': .0,
'is_anchor': False}
dea = {'q_pre': .0}
dfa = {'s_pre': [1.0, 1.0, 0.0]}

mesh.update_default_vertex_attributes(dva)
mesh.update_default_edge_attributes(dea)
mesh.update_default_face_attributes(dfa)


# =================================================
# get mesh data
# =================================================

fixed = [mesh.key_index()[v] for v in mesh.vertices_where({'is_anchor': True})]
P = mesh.vertices_attributes(['px', 'py', 'pz'])
S = mesh.faces_attribute('s_pre')
Q = mesh.edges_attribute('q_pre')


# =================================================
# solver
# =================================================

xyz, r, f, _, s = nfd_ur_numpy(mesh, fixed, S, force_density_goals=Q, vertex_loads=P,
kmax=10, stress_flag=1, stress_tol=.05, xyz_tol=.01)
mesh_update(mesh, xyz, r, s, f)


# =================================================
# viz
# =================================================

viewer = app.App()
viewer.add(mesh)
viewer.show()
71 changes: 71 additions & 0 deletions scripts/94_nfd_hypar_quads_tris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from os import path

from compas.datastructures import Mesh, mesh_subdivide
from compas_view2 import app

from compas_fd.nfd import nfd_ur_numpy
from _nfd_helpers import mesh_update


# =================================================
# IO
# =================================================

HERE = path.dirname(__file__)
FILE_I = path.join(HERE, '..', 'data', 'in_hypar_mesh.json')
mesh = Mesh.from_json(FILE_I)


# =================================================
# input mesh
# =================================================

mesh.vertices_attribute('is_anchor', True,
mesh.vertices_where({'vertex_degree': 2}))

mesh = mesh_subdivide(mesh, scheme='quad', k=2)
faces_to_split = (mesh.get_any_face() for _ in range(200))
for face in faces_to_split:
v = mesh.face_vertices(face)
mesh.split_face(face, v[0], v[2])

bounds = mesh.edges_on_boundaries()[0]
mesh.edges_attribute('q_pre', 15, bounds)

dva = {'rx': .0, 'ry': .0, 'rz': .0,
'px': .0, 'py': .0, 'pz': .0,
'is_anchor': False}
dea = {'q_pre': .0}
dfa = {'s_pre': [1.0, 1.0, 0.0]}

mesh.update_default_vertex_attributes(dva)
mesh.update_default_edge_attributes(dea)
mesh.update_default_face_attributes(dfa)


# =================================================
# get mesh data
# =================================================

fixed = [mesh.key_index()[v] for v in mesh.vertices_where({'is_anchor': True})]
P = mesh.vertices_attributes(['px', 'py', 'pz'])
S = mesh.faces_attribute('s_pre')
Q = mesh.edges_attribute('q_pre')


# =================================================
# solver
# =================================================

xyz, r, f, _, s = nfd_ur_numpy(mesh, fixed, S, force_density_goals=Q, vertex_loads=P,
kmax=10, stress_flag=1, stress_tol=.05, xyz_tol=.01)
mesh_update(mesh, xyz, r, s, f)


# =================================================
# viz
# =================================================

viewer = app.App()
viewer.add(mesh)
viewer.show()
95 changes: 95 additions & 0 deletions scripts/95_nfd_hypar_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from os import path

from compas.datastructures import Mesh, mesh_subdivide
from compas_view2 import app

from compas_fd.nfd import nfd_ur_numpy
from _nfd_helpers import mesh_update


# =================================================
# IO
# =================================================

HERE = path.dirname(__file__)
FILE_I = path.join(HERE, '..', 'data', 'in_hypar_mesh.json')
mesh = Mesh.from_json(FILE_I)


# =================================================
# input mesh
# =================================================

mesh.vertices_attribute('is_anchor', True,
mesh.vertices_where({'vertex_degree': 2}))

mesh = mesh_subdivide(mesh, scheme='quad', k=3)
mesh.quads_to_triangles()

# get ring of vertices around central vertex
central_vertex = 3
ring_size = 3
ring_all = mesh.vertex_neighborhood(central_vertex, ring=ring_size)
ring_in = mesh.vertex_neighborhood(central_vertex, ring=ring_size - 1)
ring = set(ring_all) - set(ring_in)
mesh.vertices_attributes(['z', 'is_anchor'], [25, True], ring)

# triangulate top faces at supports
fva = mesh.face_vertex_after
for v in ring:
faces = mesh.vertex_faces(v)

for face in faces:
vts = mesh.face_vertices(face)
v_count = len(vts)
if v_count != 4:
continue
w = fva(face, fva(face, v))
if not mesh.vertex_attribute(w, 'is_anchor'):
continue
mesh.split_face(face, v, w)

# delete vertices inside support ring
for v in ring_in:
mesh.delete_vertex(v)

bounds = mesh.edges_on_boundaries()[0]
mesh.edges_attribute('q_pre', 30, bounds)

dva = {'rx': .0, 'ry': .0, 'rz': .0,
'px': .0, 'py': .0, 'pz': .0,
'is_anchor': False}
dea = {'q_pre': .0}
dfa = {'s_pre': [1.0, 1.0, 0.0]}

mesh.update_default_vertex_attributes(dva)
mesh.update_default_edge_attributes(dea)
mesh.update_default_face_attributes(dfa)


# =================================================
# get mesh data
# =================================================

fixed = [mesh.key_index()[v] for v in mesh.vertices_where({'is_anchor': True})]
P = mesh.vertices_attributes(['px', 'py', 'pz'])
S = mesh.faces_attribute('s_pre')
Q = mesh.edges_attribute('q_pre')


# =================================================
# solver
# =================================================

xyz, r, f, _, s = nfd_ur_numpy(mesh, fixed, S, force_density_goals=Q, vertex_loads=P,
kmax=10, stress_flag=1, stress_tol=.01, xyz_tol=.01)
mesh_update(mesh, xyz, r, s, f)


# =================================================
# viz
# =================================================

viewer = app.App()
viewer.add(mesh)
viewer.show()
Loading