Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export velocity field as vector such that one can use the Paraview streamtracer function #77

Open
DanielDoehring opened this issue Nov 7, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@DanielDoehring
Copy link

Currently, the velocity field is exported as three scalars. If you want to use Paraview to compute e.g. the streamlines a vector-valued velocity field is required.

Exporting the velocities (and maybe also the magnetic field) as a vector-field would be a nice feature/change.

@DanielDoehring DanielDoehring added the enhancement New feature or request label Nov 7, 2023
@ranocha ranocha added the good first issue Good for newcomers label Nov 8, 2023
@DanielDoehring
Copy link
Author

DanielDoehring commented Nov 16, 2023

The goal would be putting the funcitonality provided by this code

pd = PlotData2D(sol)

using Printf

mkpath("out")  # Create output directory automatically

Velocities_String = "out/Velocities.vtk"
Velocities = open(Velocities_String, "w")

write(Velocities, "# vtk DataFile Version 3.0\n")
write(Velocities, "vtk output\n")
write(Velocities, "ASCII\n")
write(Velocities, "DATASET STRUCTURED_GRID\n")

Nx = length(pd.x)
Ny = length(pd.y)
NumPoints = Int(Nx * Ny)
NumPointsString = string(Int(Nx * Ny))

write(Velocities, "DIMENSIONS ", string(Nx), " ", string(Ny), " 1\n")
write(Velocities, "POINTS ", NumPointsString, " float\n")
for i in 1:Nx
  for j in 1:Ny
    write(Velocities, "$(pd.x[i]) $(pd.y[j]) 0\n")
  end
end

write(Velocities, "\n")
write(Velocities, "POINT_DATA ", NumPointsString, "\n")

write(Velocities, "\n")
write(Velocities, "VECTORS U float\n")
v1 = pd.data[2]
v2 = pd.data[3]
for i in 1:Nx
  for j in 1:Ny
    # Need to transpose back (note interchanged `j, i`), see l. 528 of src/visualization/utilities.jl
    write(Velocities, string(v1[j,i]), " ", string(v2[j,i]), " 0\n")
  end
end

close(Velocities)

in Trixi.jl/Trixi2Vtk.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants