JuliaTopOpt / TopOpt.jl

A package for binary and continuous, single and multi-material, truss and continuum, 2D and 3D topology optimization on unstructured meshes using automatic differentiation in Julia.
https://juliatopopt.github.io/TopOpt.jl/
Other
185 stars 30 forks source link

Visualization of first documentation example #99

Closed LucasMSpereira closed 1 year ago

LucasMSpereira commented 2 years ago

The first example on the documentation ("SIMP example: Point Load Cantilever") has some small issues. When trying to visualize the final topology, I first had problems with GLMakie and had to add import GLMakie to the beginning of the file.

The other problem is in fig = visualize(problem; topology = result.topology, problem; topology = result.topology, default_exagg_scale = 0.07, scale_range = 10.0, vector_linewidth = 3, vector_arrowsize = 0.5, ). The repetition of problem; topology = result.topology introduces two semicolons on the call of a function.

Lastly, when the GLMakie window shows up with the final topology, the first slider ("deformation exaggeration") doesn't seem to affect the plot. I'd expect the structure to move a bit.

yijiangh commented 2 years ago

Good catch! By default, we need the user to pass in the deformation vector u and then the deformation exaggeration slider is actually doing something. I think we will try to keep this assumption to make the API simple, but you are right that an ineffective slider is misleading and we should hide this slider if no u is passed in.

And until recently, Makie did not assume GLMakie as its default and required the users to specify the backend explicitly. We should update the documentation and the @require stuff in the visualization module.

I will push a PR on the visualizer soon.

For now, if you want to visualize the optimized design's deformation under load, you can do the following:

solver.vars = result.minimizer
solver()

visualize(problem, solver.u, topology=result.minimizer)