Visualisation postprocessor for spherical velocities

Hi all,
Standard velocity visualisation output for paraview give results in full vectors (arrows) and separated in x,y,z-directions. However, regarding a spherical set-up (eg. spherical shell, chunk or sphere) I would like to visualise the velocity field also in separate radial and tangential velocities.

I was wondering if someone already has written a postprocessor that creates vtu-files containing these spherical velocities and is willing to share it?

Or if anyone could give me a heads-up regarding an existing postprocessor which I could try to modify to make it myself and, of course, any tips in how to do so.

Thanks in advance,
Erik

Hi Erik,
I do not have such a postprocessor, but you are right it would be very useful to have one. If nobody has one available and if you want to create one on your own I would start with a copy of one of the existing postprocessors that creates a vector or tensor quantity, e.g. source/postprocess/visualization/gravity.cc or source/postprocess/visualization/shear_stress.cc. The function evaluate_vector_field in these postprocessors is called once per cell whenever output is written, and the input parameter input_data contains the positions and velocities at every location we want to write output for in this cell. E.g. you can do input_data.solution_values[q][this->introspection().component_indices.velocities[d]] to access the velocity (as Tensor<1,dim>) at the q’th output vertex of that cell. Correspondingly input_data.evaluation_points[q] accesses the related positions (as Point<dim> in cartesian coordinates). You would then need to convert the velocities using the position into radius/longitude/latitude components and write those into the computed_quantities parameter. I think this would make a fine addition to the main code so please let us know if you do this or need any help.

Best,
Rene

Actually, if you’ve already extracted the velocity as in

  const Tensor<1,dim> velocity = ...

and assuming that you have also gotten the gravity vector somehow (there are examples for both of these things)

  const Tensor<1,dim> gravity = ...

then you can get the vertical (scalar) component of the velocity via

  const double vertical_velocity = (velocity * gravity) / gravity.norm();

and then the horizontal part of the velocity vector is simply

  const Tensor<1,dim> horizontal_velocity
    = velocity - vertical_velocity * gravity/gravity.norm();

This has the advantage that you don’t have to convert between different coordinate systems. It also works in 2d/3d, and in spherical/Cartesian coordinate systems. The only assumption is that the gravity vector indicates a good vertical direction – which is generally true.

Best
W.

The file source/postprocess/visualization/vertical_heat_flux.cc shows how to work around the issue if the gravity vector is zero.