CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   How to extract roll angles of 2D floating object? (

CKH February 14, 2012 12:46

How to extract roll angles of 2D floating object?
Hi Foamers,

I'm trying to figure out how to extract / sample the roll angle of a floating box constrained to roll only (1 DoF). It seems like a simple problem but I can't seemed to find anyway of doing it!

The case I'm running is based on: Jung, K.H., Chang, K.A., Jo, H.J., Viscous Effect on the Roll Motion of a Rectangular Structure, J. of Engineering Mechanics, 2006. This was mentioned in the Eric Paterson's slides for 3rd OF workshop and seems to have been used as a demo case a few times. If anyone has ran the case before please do share some hints.

Thanks in advance.

CKH February 16, 2012 00:05

Get sixDoFRigidBodyMoton functionObject to output "Orientation"
Posting my work-around if it's of help to anyone else:

Go to $FOAM_SRC/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion

Open sixDoFRigidBodyMotion.C file with your favourite editor.

Near the bottom of the file:


<< "Angular velocity: " << omega()

" << nl"
to get std IO to jump to the next line

After the angular velocity line (but before the line that says

<< endl;

<< "Orientation: " << Q()
Save and close the file and rerun Allwmake. The next time interDyMFoam is run, the IO will show the values of the Orientation tensor at each time step. The entire stream can be saved in a log file (e.g. log.interDyMFoam).

A bash script (e.g. extractData script found in the simple harmonic motion tutorial) can subsequently be used to extract time step and Orientation tensor value for further post-processing.

I think the orientation (Q) tensor is a rotational matrix generated by rotating in X, Y, Z sequence (still figuring this out at the moment......). If this is the case, then roll (i.e. rotation about Y axis) will be given by asin of the 3,1 element which should be the #7 of the 9 values of the Q tensor.

All times are GMT -4. The time now is 19:27.