CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

How to plot pitch motion for free decay test?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree6Likes
  • 6 Post By mo_na

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 2, 2016, 07:15
Question How to plot pitch motion for free decay test?
  #1
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 5
mo_na is on a distinguished road
Hi all,

I am simulating a floating body in pitch motion and I would like to do a free decay test to compare with experimental results.
I am using a moving mesh and the log file contains information like this:
Code:
6-DoF rigid body motion
    Centre of rotation: (0 0 0)
    Centre of mass: (0.58783434026 0 -0.181372871211)
    Orientation: (0.995632340385 0 0.0933608203665 0 1 0 -0.0933608203665 0 0.995632340385)
    Linear velocity: (0 0 0)
    Angular velocity: (0 0.0586546346079 0)
Is there a way to write the orientation of the body in a separate file to plot the pitch motion after? Or is there maybe another way?

Cheers,
Mona
mo_na is offline   Reply With Quote

Old   May 23, 2016, 05:27
Default
  #2
Member
 
Hao Chen
Join Date: Aug 2014
Posts: 66
Rep Power: 0
hchen is on a distinguished road
Hi Mona:

Did you manage to do it?

Best regards
Hao


Quote:
Originally Posted by mo_na View Post
Hi all,

I am simulating a floating body in pitch motion and I would like to do a free decay test to compare with experimental results.
I am using a moving mesh and the log file contains information like this:
Code:
6-DoF rigid body motion
    Centre of rotation: (0 0 0)
    Centre of mass: (0.58783434026 0 -0.181372871211)
    Orientation: (0.995632340385 0 0.0933608203665 0 1 0 -0.0933608203665 0 0.995632340385)
    Linear velocity: (0 0 0)
    Angular velocity: (0 0.0586546346079 0)
Is there a way to write the orientation of the body in a separate file to plot the pitch motion after? Or is there maybe another way?

Cheers,
Mona
hchen is offline   Reply With Quote

Old   May 24, 2016, 05:40
Default
  #3
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 5
mo_na is on a distinguished road
Hi Hao,

no I havn't managed yet. Do you have an idea how to do it or do you want me to tell you as soon as I figured it out?

Cheers,
Mona
mo_na is offline   Reply With Quote

Old   May 27, 2016, 07:45
Unhappy Ideas
  #4
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 5
mo_na is on a distinguished road
Hi all,

I have some ideas now how to do it but I am not quite there yet.
In this thread simon-2 describes a way to obtain sixDoFRigidBodyMotionState files for each timestep:
http://www.cfd-online.com/Forums/ope...tml#post601930
He said it was just a matter of batch processing to write all the information into one file so you obtain a file like this:
Code:
#time centreOfMass orientation velocity acceleration angularMomentum Torque 
80.0199 ( 3.3 0 0.1386375 ) ( 0.99807619 0 0.061999301 0 1 0 -0.061999301 0 0.99807619 ) ( 0 0 0.0045163445 ) ( 1.3211615 -2.6233042 0.84606626 ) ( 0 -0.2529557 0 ) ( 1109.8274 99.511973 -24.488035 ) 
80.0298 ( ... ... ... ) (.. ... ... .. .. .. .. .. ..) (.. .. ..) (.. .. ..) (... .. ..) 
80.0398 ( ... ... ... ) (.. ... ... .. .. .. .. .. ..) (.. .. ..) (.. .. ..) (... .. ..) 
80.0497 ( ... ... ... ) (.. ... ... .. .. .. .. .. ..) (.. .. ..) (.. .. ..) (... .. ..)
But I havn't figured out how to do it.
I also found this python-script: https://github.com/kodejak/openfoam-data-extractor
This script extracts searched datas from the OpenFOAM project generated files e.g. gravity, centreOfMass etc. The datas will be stored as a CSV file located at the directory of the script, named like the command line search pattern.
But then I still need to do this for every single sixDoFRigidBodyMotionState file and thats a lot.
Any ideas?

Cheers,
Mona
mo_na is offline   Reply With Quote

Old   June 1, 2016, 11:51
Thumbs up Solved
  #5
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 5
mo_na is on a distinguished road
Hey,

for everyone struggling with the same issue: I found a shell script that writes out data from the logfile and modified it a little bit to match my needs:
Code:
#!/bin/bash

PFAD=log
EXCL=10

# cat   list a files content on a screen / in a pipeline (using "|")
# grep  returns all lines matching a certain string
# cut   cuts out e.g. fields "-f" (here 3rd until END [-]) specified through delminiter "-d' '" (here blanks)
# sed   remove complete lines containing a certain string (here "ClockTime")
# sed-i includes Header
# head  deletes last 10 lines (for scaling reasons, as last lines are often already diverged)
# tr    remove certain strings (here "(" and ")")
#paste  merge two files line by line

################ CLEAR OLD DATA ################
rm -r data

##################### TIME #####################
cat $PFAD | grep 'Time = ' | cut -d' ' -f3- | sed '/ClockTime/d' > Time.dat

############### ORIENTATION  ###############
cat $PFAD | grep 'Orientation' | cut -d' ' -f3- | tr -d '(' | tr -d ')'| tr -d 'Orientation:' | sed -e 's/[\\ \\]/      /g' > orientationTemp.dat

############### LINEAR VELOCITY ################
cat $PFAD | grep 'Linear velocity' | cut -d' ' -f3- | tr -d '(' | tr -d ')' | sed -e 's/[\\ \\]/        /g' > linearVelocityTemp.dat

############### ANGULAR VELOCITY ###############
cat $PFAD | grep 'Angular velocity' | cut -d' ' -f3- | tr -d '(' | tr -d ')' | sed -e 's/[\\ \\]/       /g' > angularVelocityTemp.dat

########## MERGE FILES & ADD HEADER ############
mkdir data
paste Time.dat orientationTemp.dat > data/orientationTemp.dat
sed -i '1i#Time, cos, 0, sin, 0, 1, 0, -sin, 0, cos' data/orientationTemp.dat
head -n -$EXCL data/orientationTemp.dat > data/orientation.dat
paste Time.dat linearVelocityTemp.dat > data/linearVelocityTemp.dat
sed -i '1i#Time, u, v, w' data/linearVelocityTemp.dat
head -n -$EXCL data/linearVelocityTemp.dat > data/linearVelocity.dat
paste Time.dat angularVelocityTemp.dat > data/angularVelocityTemp.dat
sed -i '1i#Time, p, q, r' data/angularVelocityTemp.dat
head -n -$EXCL data/angularVelocityTemp.dat > data/angularVelocity.dat
rm Time.dat
rm orientationTemp.dat
rm data/orientationTemp.dat
rm linearVelocityTemp.dat
rm data/linearVelocityTemp.dat
rm angularVelocityTemp.dat
rm data/angularVelocityTemp.dat
rm plot/*.png
So copy this code into a file called data.sh and execute after running simulation with
Code:
bash data.sh
This will write you some .dat files, that you can open/plot with matlab/ocatve/excel/whatever

I hoped this will help someone!
Cheers,
Mona
chivaee, havref, dupeng and 3 others like this.
mo_na is offline   Reply With Quote

Old   November 23, 2016, 06:04
Default
  #6
New Member
 
Håvard B. Refvik
Join Date: Jun 2015
Location: Norway
Posts: 17
Rep Power: 6
havref is on a distinguished road
Exactly what I have been searching for. Thanks!

Last edited by havref; November 24, 2016 at 07:10.
havref is offline   Reply With Quote

Old   October 16, 2018, 13:09
Default
  #7
New Member
 
Adri
Join Date: Sep 2017
Posts: 24
Rep Power: 4
Adri_12 is on a distinguished road
Hi Mona,

I am using the new rigidBodyDynamics library instead of the classical sixDofRigidBodyMotion ?

The problem is that I do not understand how to explore the log file info since the CoG is not logged out anymore. What we have instead is a "center of rotation" but it is not the kind of point I am looking for, a CoG or a manually point to follow would be better. Here you have an example :

Code:
Courant Number mean: 0.000365065 max: 0.934088
Interface Courant Number mean: 1.39805e-05 max: 0.301043
deltaT = 0.00981865
Time = 2.43733

PIMPLE: iteration 1
forces forces:
    Not including porosity effects
Rigid-body motion of the BOAT
    Centre of rotation: (0.148519 -3.25435e-06 -0.00757061)
    Orientation: (0.999997 2.91458e-07 0.0022597 -2.91323e-07 1 -6.00382e-08 -0.0022597 5.93798e-08 0.999997)
    Linear velocity: (0.0538253 3.10699e-06 0.0702008)
Moreover, a "q" 6 dimension vector is automatically copied in the folder /uniform/rigidBodyState that seems to match with the log point info.

If you have some info about the way to extract CoG info, please share it

Adri
Adri_12 is offline   Reply With Quote

Old   December 22, 2018, 09:38
Default
  #8
New Member
 
Luo_Bingjun
Join Date: Oct 2018
Location: CHINA
Posts: 14
Rep Power: 3
Robin86 is on a distinguished road
Quote:
Originally Posted by mo_na View Post
Hey,

for everyone struggling with the same issue: I found a shell script that writes out data from the logfile and modified it a little bit to match my needs:
Code:
#!/bin/bash

PFAD=log
EXCL=10

# cat   list a files content on a screen / in a pipeline (using "|")
# grep  returns all lines matching a certain string
# cut   cuts out e.g. fields "-f" (here 3rd until END [-]) specified through delminiter "-d' '" (here blanks)
# sed   remove complete lines containing a certain string (here "ClockTime")
# sed-i includes Header
# head  deletes last 10 lines (for scaling reasons, as last lines are often already diverged)
# tr    remove certain strings (here "(" and ")")
#paste  merge two files line by line

################ CLEAR OLD DATA ################
rm -r data

##################### TIME #####################
cat $PFAD | grep 'Time = ' | cut -d' ' -f3- | sed '/ClockTime/d' > Time.dat

############### ORIENTATION  ###############
cat $PFAD | grep 'Orientation' | cut -d' ' -f3- | tr -d '(' | tr -d ')'| tr -d 'Orientation:' | sed -e 's/[\\ \\]/      /g' > orientationTemp.dat

############### LINEAR VELOCITY ################
cat $PFAD | grep 'Linear velocity' | cut -d' ' -f3- | tr -d '(' | tr -d ')' | sed -e 's/[\\ \\]/        /g' > linearVelocityTemp.dat

############### ANGULAR VELOCITY ###############
cat $PFAD | grep 'Angular velocity' | cut -d' ' -f3- | tr -d '(' | tr -d ')' | sed -e 's/[\\ \\]/       /g' > angularVelocityTemp.dat

########## MERGE FILES & ADD HEADER ############
mkdir data
paste Time.dat orientationTemp.dat > data/orientationTemp.dat
sed -i '1i#Time, cos, 0, sin, 0, 1, 0, -sin, 0, cos' data/orientationTemp.dat
head -n -$EXCL data/orientationTemp.dat > data/orientation.dat
paste Time.dat linearVelocityTemp.dat > data/linearVelocityTemp.dat
sed -i '1i#Time, u, v, w' data/linearVelocityTemp.dat
head -n -$EXCL data/linearVelocityTemp.dat > data/linearVelocity.dat
paste Time.dat angularVelocityTemp.dat > data/angularVelocityTemp.dat
sed -i '1i#Time, p, q, r' data/angularVelocityTemp.dat
head -n -$EXCL data/angularVelocityTemp.dat > data/angularVelocity.dat
rm Time.dat
rm orientationTemp.dat
rm data/orientationTemp.dat
rm linearVelocityTemp.dat
rm data/linearVelocityTemp.dat
rm angularVelocityTemp.dat
rm data/angularVelocityTemp.dat
rm plot/*.png
So copy this code into a file called data.sh and execute after running simulation with
Code:
bash data.sh
This will write you some .dat files, that you can open/plot with matlab/ocatve/excel/whatever

I hoped this will help someone!
Cheers,
Mona

Hi, Mona!
I also try to plot the heave motion of a floating body. I follow your ideas above. After running the case, I creat a file named data.sh and copy the script into the this file. Then I run the command bash data.sh in the terminal. However, some errors happen and I get three .dat files without nothong in these files. I don't know if I am right to do so. Did I do someting wrong so that I can't get the data.
I am new here. I wish your rely, thank you!
Robin86 is offline   Reply With Quote

Old   February 27, 2019, 11:27
Default
  #9
New Member
 
Laurent Fieschi
Join Date: Aug 2017
Posts: 6
Rep Power: 4
Fieschi is on a distinguished road
Hi Robin86,

Quote:
Originally Posted by Robin86 View Post
I get three .dat files without nothong in these files.
Try to personalise the data file by modifying the following line :
Code:
PFAD=log
For example, if your data are written in a file called log.interFoam you have to write :
Code:
PFAD=log.interFoam
Regards,
Laurent.
Fieschi is offline   Reply With Quote

Old   March 19, 2019, 21:28
Default
  #10
New Member
 
Luo_Bingjun
Join Date: Oct 2018
Location: CHINA
Posts: 14
Rep Power: 3
Robin86 is on a distinguished road
Thank you for your reply. I already fix the problem.
Robin86 is offline   Reply With Quote

Old   September 30, 2019, 08:01
Default
  #11
New Member
 
Arun Kumar
Join Date: Sep 2019
Posts: 1
Rep Power: 0
AR91 is on a distinguished road
Quote:
Originally Posted by mo_na View Post
Hey,

for everyone struggling with the same issue: I found a shell script that writes out data from the logfile and modified it a little bit to match my needs:
Code:
#!/bin/bash

PFAD=log
EXCL=10

# cat   list a files content on a screen / in a pipeline (using "|")
# grep  returns all lines matching a certain string
# cut   cuts out e.g. fields "-f" (here 3rd until END [-]) specified through delminiter "-d' '" (here blanks)
# sed   remove complete lines containing a certain string (here "ClockTime")
# sed-i includes Header
# head  deletes last 10 lines (for scaling reasons, as last lines are often already diverged)
# tr    remove certain strings (here "(" and ")")
#paste  merge two files line by line

################ CLEAR OLD DATA ################
rm -r data

##################### TIME #####################
cat $PFAD | grep 'Time = ' | cut -d' ' -f3- | sed '/ClockTime/d' > Time.dat

############### ORIENTATION  ###############
cat $PFAD | grep 'Orientation' | cut -d' ' -f3- | tr -d '(' | tr -d ')'| tr -d 'Orientation:' | sed -e 's/[\\ \\]/      /g' > orientationTemp.dat

############### LINEAR VELOCITY ################
cat $PFAD | grep 'Linear velocity' | cut -d' ' -f3- | tr -d '(' | tr -d ')' | sed -e 's/[\\ \\]/        /g' > linearVelocityTemp.dat

############### ANGULAR VELOCITY ###############
cat $PFAD | grep 'Angular velocity' | cut -d' ' -f3- | tr -d '(' | tr -d ')' | sed -e 's/[\\ \\]/       /g' > angularVelocityTemp.dat

########## MERGE FILES & ADD HEADER ############
mkdir data
paste Time.dat orientationTemp.dat > data/orientationTemp.dat
sed -i '1i#Time, cos, 0, sin, 0, 1, 0, -sin, 0, cos' data/orientationTemp.dat
head -n -$EXCL data/orientationTemp.dat > data/orientation.dat
paste Time.dat linearVelocityTemp.dat > data/linearVelocityTemp.dat
sed -i '1i#Time, u, v, w' data/linearVelocityTemp.dat
head -n -$EXCL data/linearVelocityTemp.dat > data/linearVelocity.dat
paste Time.dat angularVelocityTemp.dat > data/angularVelocityTemp.dat
sed -i '1i#Time, p, q, r' data/angularVelocityTemp.dat
head -n -$EXCL data/angularVelocityTemp.dat > data/angularVelocity.dat
rm Time.dat
rm orientationTemp.dat
rm data/orientationTemp.dat
rm linearVelocityTemp.dat
rm data/linearVelocityTemp.dat
rm angularVelocityTemp.dat
rm data/angularVelocityTemp.dat
rm plot/*.png
So copy this code into a file called data.sh and execute after running simulation with
Code:
bash data.sh
This will write you some .dat files, that you can open/plot with matlab/ocatve/excel/whatever

I hoped this will help someone!
Cheers,
Mona
There seems to be an issue when this script copies exponents from the log file to the .dat file.
For instance: 1.34587e-18 becomes 1.34587-18.
Any help would be greatly appreciated in this regard.
Thanks,
Arun.
AR91 is offline   Reply With Quote

Reply

Tags
dynamic mesh, pitching

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with p_rgh with interDyMFoam in a ship roll decay test karmo OpenFOAM Running, Solving & CFD 1 August 23, 2012 18:07
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 04:01
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 14:43
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 08:21
Automatic Mesh Motion solver michele OpenFOAM Running, Solving & CFD 10 September 26, 2005 09:21


All times are GMT -4. The time now is 08:11.