CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   creating csv files (

cbarry October 1, 2009 09:14

creating csv files
Hi everyone,

this may sound very simple, but I am new to OpenFOAM and am struggling a little.
I am trying to get OpenFOAM to write out the wall shear stress into a simple csv file. For this I was going to modify the wallShearStress.C postprocessing application. However, I have not managed to get OpenFOAM to write the data out as a list in the following format:

x, y, z, wall shear stress in x, directionm wall shear stress in y direction, wall shear stress in z direction

I have tried using the following line:

Info << mesh.Cf().boundaryField()[patchi] << wallShearStress.boundaryField()[patchi] << endl

This however only resulted in a list of the coordinates written in brackets, followed by a seperate list underneath, which showd the wall shear stress vectors in brackets. There was also a bunch of information inbetween that I don't need.

Does anyone have any ideas how I could do this?

Best regards,


harishg October 1, 2009 18:22

You could use the sample postprocessing tool to write out the data in the format you required. I have used it for writing slices and I guess you can define cutting planes too. I am not sure if it has the capability to write a whole volume.

cbarry October 2, 2009 03:37

thank you for your reply. The problem with the sample tool is that, as I see it, you need to define a plane each time in the sampleDict, which is a bit tedious. Ideally I would like to just be able to select a wall and then get the coordinates of the points and the wall shear stresses written out into a nice csv list.

Do you reckon that's possible somehow by modifying the sample tool source code? It's a thought I've been playing with, but I can't see how to do it.

Best regards,


cbarry October 2, 2009 05:24

Never mind, problem solved. I just had to define a vector within the vectorField mesh.Gf().boundaryField() and then create a forAll loop, in which OpenFOAM writes each component of the new vector for each iteration of the forAll loop.

Thanks for the help though.

All times are GMT -4. The time now is 09:03.