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
181 stars 30 forks source link

Visualize compression and tension members through colors (red and blue) in Julia #143

Closed pitipatw closed 1 year ago

pitipatw commented 1 year ago

I'm currently using the truss optimization to generate truss structure. Currently I can't find options in the visualize component to set the color according to the result stress or the stress in each element.

My current solution is to send the vector of element areas to post process outside of TopOpt.jl

yijiangh commented 1 year ago

@pitipatw PR #140 starts to support visualize(problem; cell_colors=color_per_cell) where color_per_cell is a vector of dimension length(x). You can also change the color scheme to make sure it matches red for compression and blue for tension scheme by changing the default colormap=ColorSchemes.Spectral_10.

The only caveat is that you have to compute the per-cell stress from the FEA solver, and pass it into cell_colors.

pitipatw commented 1 year ago

Im currently using TopOpt 0.7.0 but still getting "got unsupported keywords "cell_color", "colormap".

I saw these keywords written in the visualization.jl file too. I merged #140 to my local machine. Is there any other possible version conflict I could look for?

pitipatw commented 1 year ago

update, after I merged #140, the same script cant find the "visualize"

yijiangh commented 1 year ago

Can you try ] add Example#master?

Also, you have to open a new Julia session after you pull a new version to trigger compilation for the visualization module.

pitipatw commented 1 year ago

I tried ] add Example#master , still cant find the "visualize". I also notice an error about CUDA.jl outdated, so I updated it and now it seems that either Julia or Visual Studio can't find my CUDA runtime library.

I will keep using ver0.6.0 for now.

yijiangh commented 1 year ago

@pitipatw the visualize module is only loaded when Makie is imported as well. Try this:

using Makie, GLMakie, TopOpt
using TopOpt.TrussTopOptProblems.TrussVisualization: visualize

Also, what julia version you are using?

For the CUDA problem, I have never encountered this before. @mohamed82008 I thought we've got rid of all CUDA dependencies?

pitipatw commented 1 year ago

@yijiangh Thank you for the help I already have the using Makie, GLMakie, TopOpt TopOpt.TrussTopOptProblems.Trussvisualization:visualize on top of the script. The script I'm using is basically the truss 3d example with some adjustments for input from GH through JSON. The second line is the one that throws the error of can't find visualize

pitipatw commented 1 year ago

I'm on Julia 1.8.5

mohamed82008 commented 1 year ago

For the CUDA problem, I have never encountered this before. @mohamed82008 I thought we've got rid of all CUDA dependencies?

I think that may be GLMakie's fault.