Reaching the shore


Grand Canal Bay, Dublin
It’s the 2nd of September now, and I am back in the Czech Republic again. I left Dublin 2 days ago, after finishing the work on my Summer of HPC project in ICHEC. So, let’s have a look back now at what happened during the last few weeks in Ireland, and how my project ended up in the end.
After I created some 3D images of the shallow water simulation output using ParaView, I was still left with some time. There were several paths I could take to continue my work. One was using ParaView Catalyst for in situ visualisation, i.e. integrating ParaView directly into the simulation code, so no data copy is required between the simulation and ParaView. This would probably speed up the whole process of visualisation, since IO operations can’t be very time expensive. But there was another thing that I was far tempted to do. Two years ago, I took a computer graphic course, focused on OpenGL programming in C++. Therefore I decided to create my own visualisation tool on OpenGL, and try to push the visualisation a bit further.
I was lucky that I could reuse most of my old code from that 2 years old course, which made my work a bit easier. But I still had to adjust it in many ways, and improve it so the application could load the simulation output, and renderer it as a water surface. One of the advantages was definitely the fact that unlike ParaView, my application could easily load the Fortran binary files, which is probably the fastest way of data transfer when using files. The problematic part was to construct a mesh from the height map, i.e. organise the vertices into triplets (triangle rendering) and calculate normals of the surface, which are necessary for shading. This part is quite time consuming, and could be yet optimised in the future.

Shallow water visualisation using OpenGL
After loading the simulation output and converting it into a mesh which can be rendered by OpenGL, I moved to shader programming. Shader is in general a C++ program, which is ran on gpu. There are two basic types of shaders in OpenGL pipeline – vertex and fragment shaders. Fragment shader receives one small part of the model mesh (called fragment), information about it’s position, surface normal, texture coordinates, and other attributes, and from those, the shader calculates the result colour of this fragment. This process is executed for each fragment in the scene (in parallel, using gpu), and the result colour field is displayed on screen.

The Temple Bar pub, one of the most popular pubs in Dublin centre
Water rendering has many specifics. They arise from the fact that water is transparent, and also that it has a different refractive index than air. That makes light rays passing through the water both reflect and pass through while changing their trajectory. The result effect is that we partially see the reflection of the object above the water surface, and partially we see a deformed version of what’s below the surface. How big the reflective and transparent parts are is depending on the angle of impact of the light ray on the water surface. There are two laws describing this behaviour – Snell’s law and Fresnel effect. So, it seems that there is no problem with water rendering since the physics around is well described. The problem comes with performance. If we want to render a water surface that keeps changing quickly over time, there is plenty of calculations involved and some compromises are required.

The Chapel Royal, and the Record Tower, the only part of the Dublin castle surviving from medieval times, built in 1228
In my application, I didn’t get particularly far with implementing effects mentioned above, due to some technical difficulties I encountered with OpenGL. I did manage to implement basic transparency and also use Fresnel effect to modify the level of transparency based on the angle of the water surface normal towards the view angle, which is already something that ParaView doesn’t support, at least not natively, and the result a bit more realistic thanks to this. I am also very enthusiastic about improving my application, and render nicer water, even though the Summer of HPC is already over. So, in the future, I might come up with a separate post somewhere on the internet to show my progress. Water rendering is definitely something very interesting and it offers many ways to experiment and play around with visualisation and gpu parallelisation.

The old graveyard in Glendalough, co. Wicklow
As my stay in Dublin quickly approached its end, even though being busy with finishing my work, I still dedicated some time to explore Ireland a bit more and enjoy its beauties while I could. I was lucky that I could meet up with my uncle, who has been living and working in Ireland for several years now, and who showed me around some of the most beautiful places in Dublin. We visited New Ross, a charming town to the south of Ireland. Then we drove up north, passing through Glendalough, where we visited an old Celtic cemetery. It’s difficult to describe the atmosphere at such places. The spirit of old times fills your soul with sacred astonishment, and together with gentle rain and mist covering tops of the surrounding hills makes you believe you are part of something mysterious and beautiful. It’s a completely different world compared to busy and cheerful city of Dublin. At places like this, you can find peace, balance, and lose yourself in the nature’s embrace.

Christ Church Cathedral, Dublin – one of the two main city cathedrals
Full of impressions, we drove further north. Soon we were crossing the Wicklow Mountains National Park. We drove through narrow roads bending between endless bald hills without a soul to meet. This was yet another amazing experience, as we were literally in the middle of nowhere, surrounded only by a pure and scenic nature. On top of all that, my uncle let me drive throughout the whole trip, giving me a chance to experience driving on the opposite side of the road than I am used to. To be honest, it was less of a challenge than I thought it would be, but definitely a huge fun.

Papal cross in Phoenix park, Dublin
During the last few days I had left, I walked a bit more around Dublin. I finally got an opportunity to enter the famous Temple Bar pub (it doesn’t require any kind of permission, but it’s totally crowded most of the time) and listen to a live band playing traditional irish music. I also visited the Dublin castle, which is located right in the center of Dublin, but still difficult to find surprisingly. One day a took a long walk through a massive Phoenix park, which, besides other things, has a massive (35m tall) cross, which was erected there in the 70s, when pope John Paul II. visited Dublin and served an outdoor mass together with about 1 million people there. This is one of the reminders that, despite having both of it’s main cathedrals belong to church of Ireland, the most expanded church in Ireland is roman catholic.
There are far more experiences and impressions I could include in this blog, but that would turn it into a small book. Those nearly two months I spent in Dublin were an amazing experience, I learned a lot, discovered even more, both work and holiday wise, and I will definitely consider visiting Ireland again.
Leave a Reply