Trixi.jl icon indicating copy to clipboard operation
Trixi.jl copied to clipboard

Examples visualization !

Open Nour-Touil opened this issue 8 months ago • 14 comments

hello ! I'm new in Julia and i would like to visualize examples like the conical island to see the surface reaction , honestly i have to visualize the example because i'm short on time and Trixi.jl is the best way to progress on my project . So i'll be thankful if i get instractions to how to use Makie.jl to do that thank you .

Nour-Touil avatar Apr 02 '25 12:04 Nour-Touil

Hi @Nour-Touil! We have some documentation on how to use Makie.jl to visualize simulation results: https://trixi-framework.github.io/Trixi.jl/stable/visualization/#Makie.jl This requires to actually produce some results using Trixi.jl (the sol object). Can you give some more details about what you have tried so far?

benegee avatar Apr 02 '25 12:04 benegee

I already tried the instructions in the documentation but what i need is an animation of the examples not just a simple plots because it's not enough to analyse it So the question is how to make something like the photo

Image

Nour-Touil avatar Apr 02 '25 13:04 Nour-Touil

You could use the Visualization Callback to write out files at a specified interval. They can be converted to VTK using Trixi2Vtk and you could then use e.g. Paraview to further inspect and visualize. This is the most flexible approach.

If you would like to use Makie as linked above you would have to use the integrator interface (https://docs.sciml.ai/DiffEqDocs/dev/basics/integrator/), i.e. use init instead of solve and advance to the time steps you want to visualize.

benegee avatar Apr 02 '25 13:04 benegee

You can use the SaveSolutionCallback and Trixi2Vtkj.l together with something like Paraview.

ranocha avatar Apr 02 '25 13:04 ranocha

hello again I’m encountering an error while visualizing with TrixiVTK.jl and SaveSolutionCallback. Could you please explain what might be causing this? ERROR: MethodError: no method matching axes(::String, ::Int64) The function axes exists, but no method is defined for this combination of argument types.

Nour-Touil avatar Apr 02 '25 22:04 Nour-Touil

Hi @Nour-Touil - can you provide a MWE (minimum working example) so we can reproduce the error?

jlchan avatar Apr 03 '25 01:04 jlchan

If you go the ParaView route then the "Warp by scalar" filter is what you need to create a figure / video like the one posted above. If you use Makie then the iplot command is what you need. After your simulation is complete you can write something like the following in the REPL (here I assume you are solving the shallow water equations)

julia> pd = PlotData2D(sol);

julia> fig_ax_plt = iplot(pd["b"], plot_mesh=true, colormap=:viridis);

julia> fig_ax_plt2 = iplot!(pd["H"], plot_mesh=true, colormap=:blues)

andrewwinters5000 avatar Apr 03 '25 03:04 andrewwinters5000

Hi @jlchan - so I’m trying to visualize results from a TrixiShallowWater.jl simulation using SaveSolutionCallback + Trixi2Vtk.jl, as recommended. However, I encounter an error when converting .h5 files to VTK: MWE :

using Trixi, TrixiShallowWater, Trixi2Vtk  

Run the conical_island.jl example (standard setup)  
output_dir = "trixi_output_exp"  
save_solution = SaveSolutionCallback(interval=100, output_directory=output_dir)  
sol = solve(ode, SSPRK43(); callback=save_solution)

Error occurs here:

trixi2vtk(joinpath(output_dir, "solution_000000.h5"), output_directory=output_dir)  

ERROR: MethodError: no method matching axes(::String, ::Int64)  
Closest candidates:  
  axes(::HDF5.Dataset, ::Integer) at ... 

What is the correct way to pass the HDF5 file to trixi2vtk?

Should I specify a dataset name ?

i'm very thankfull for your help

Nour-Touil avatar Apr 03 '25 21:04 Nour-Touil

I cannot reproduce the error locally. Please provide the full code and the complete stacktrace of the output you get.

ranocha avatar Apr 07 '25 06:04 ranocha

I just want to know the file's name of the simulation in the photo below , and if I can do the 3D visualization directly with Trixi2vtk.jl and ParaView or if there are some steps to follow before.

Le lun. 7 avr. 2025 à 08:53, Hendrik Ranocha @.***> a écrit :

I cannot reproduce the error locally. Please provide the full code and the complete stacktrace of the output you get.

— Reply to this email directly, view it on GitHub https://github.com/trixi-framework/Trixi.jl/issues/2345#issuecomment-2782205174, or unsubscribe https://github.com/notifications/unsubscribe-auth/BQIKAW6IOIQCGDHYI3BIA5D2YIOGRAVCNFSM6AAAAAB2JPPJYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBSGIYDKMJXGQ . You are receiving this because you were mentioned.Message ID: @.***> [image: ranocha]ranocha left a comment (trixi-framework/Trixi.jl#2345) https://github.com/trixi-framework/Trixi.jl/issues/2345#issuecomment-2782205174

I cannot reproduce the error locally. Please provide the full code and the complete stacktrace of the output you get.

— Reply to this email directly, view it on GitHub https://github.com/trixi-framework/Trixi.jl/issues/2345#issuecomment-2782205174, or unsubscribe https://github.com/notifications/unsubscribe-auth/BQIKAW6IOIQCGDHYI3BIA5D2YIOGRAVCNFSM6AAAAAB2JPPJYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBSGIYDKMJXGQ . You are receiving this because you were mentioned.Message ID: @.***>

Nour-Touil avatar Apr 09 '25 10:04 Nour-Touil

So far we cannot reproduce the error you got. And the photo did not go through.

I just did the following:

  • cloned TrixiShallowWater.jl
  • created a subdirectory run
  • launched Julia from there: julia --project=.
  • added packages: `(run) pkg> add Trixi Trixi2Vtk OrdinaryDiffEqLowStorageRK OrdinaryDiffEqSSPRK
  • julia> using Trixi
  • julia> trixi_include("../examples/tree_2d_dgsem/elixir_shallowwater_conical_island.jl")
  • simulation runs
  • output by default is written to out subdirectory
  • julia> using Trixi2Vtk
  • julia> trixi2vtk("out/solution*.h5")
  • converted files are written to current directory by default
  • launched ParaView and loaded vtu files, e.g. solution_000000100.vtu

benegee avatar Apr 09 '25 10:04 benegee

@benegee ,

Thank you for the guidance. I followed the steps you provided, However, the output remains nonsensical:

retcode: Success Interpolation: 1st order linear t: 2-element Vector{Float64}: 0.0 10.0 u: 2-element Vector{Vector{Float64}}: [1.1102230246251565e-13, 0.0, 0.0, 0.1, 1.1102230246251565e-13, 0.0, 0.0, 0.1, 1.1102230246251565e-13, 0.0 … 0.0, 0.1, 1.1102230246251565e-13, 0.0, 0.0, 0.1, 1.1102230246251565e-13, 0.0, 0.0, 0.1] [3.523381496870724e-7, -1.3312172324815831e-8, -1.3156460196412207e-8, 0.09999999999999998, 1.9891558193217423e-7, -5.7330117742263835e-9, -5.6857214302115585e-9, 0.09999999999999998, 2.2261456381640867e-7, -6.508871969061457e-9 … 1.001054193685207e-7, 0.10000000000000002, 9.96119991718485e-6, 1.5321369450614548e-7, 1.4750485327312413e-7, 0.10000000000000002, 1.0437937031948472e-5, 1.605144662992031e-7, 1.5003905403723654e-7, 0.10000000000000002]

The captured times are only at 0.0 and 10.0, and many water height values are close to zero, indicating a potential issue.

Nour-Touil avatar Apr 10 '25 11:04 Nour-Touil

Don't worry about the console output (https://github.com/trixi-framework/Trixi.jl/issues/2349).

Your simulation was successful and you should be able to run trixi2vtk next.

benegee avatar Apr 10 '25 11:04 benegee

Just to expand a little bit about why there are only 0.0 and 10.0 as output times: This is because save_everystep = false is set in the call to solve (it's part of the ode_default_options). This is for performance reasons. Saving every intermediate time step allocates a lot, which means it costs a lot of time. If you save the solution to .hdf5 files using the SaveSolutionCallback, you will get the output also at intermediate time steps (controlled by the interval keyword). These intermediate time steps are only printed to the file and not saved in the Julia session and therefore not visible in the output. As @benegee said, you should be able to call trixi2vtk and view the result in Paraview.

JoshuaLampert avatar Apr 10 '25 11:04 JoshuaLampert