Skip to content

Commit

Permalink
clean up basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Feb 29, 2024
1 parent dcd3f5e commit 80b68b4
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions docs/examples/example_mesh_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@
indata = InputData.from_mesh(mesh, fixed, loads, qpre)

# =============================================================================
# Solve
# Solve and Update
# =============================================================================

result = dr_numpy(indata=indata)

# =============================================================================
# Update
# =============================================================================

for vertex in mesh.vertices():
mesh.vertex_attributes(vertex, "xyz", result.xyz[vertex])
result.update_mesh(mesh)

# =============================================================================
# Visualize
# =============================================================================

forcecolor = Color.green().darkened(50)

viewer = App()
viewer.view.camera.position = [5, -5, 20]
viewer.view.camera.look_at([5, 5, 0])
Expand All @@ -49,14 +46,12 @@

for vertex in fixed:
point = Point(*mesh.vertex_coordinates(vertex))
residual = Vector(*result.residuals[vertex])
ball = Sphere(radius=0.1, point=point)

viewer.add(ball.to_brep(), facecolor=Color.red())
viewer.add(
Line(point, point - residual * 0.1),
linecolor=Color.green().darkened(50),
linewidth=3,
)
residual = Vector(*result.residuals[vertex]) * 0.1

ball = Sphere(radius=0.1, point=point).to_brep()
line = Line(point, point - residual)

viewer.add(ball, facecolor=Color.red())
viewer.add(line, linecolor=forcecolor, linewidth=3)

viewer.run()

0 comments on commit 80b68b4

Please sign in to comment.