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

How to plot pitch motion for free decay test?

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

Sponsored Links

Like Tree1Likes
  • 1 Post By mo_na

Reply
 
LinkBack Thread Tools Display Modes
Old   May 2, 2016, 06: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: 3
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
Sponsored Links

Old   May 23, 2016, 04: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, 04:40
Default
  #3
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 3
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, 06:45
Unhappy Ideas
  #4
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 3
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, 10:51
Thumbs up Solved
  #5
Member
 
mo_na's Avatar
 
Mona
Join Date: Mar 2016
Location: Berlin
Posts: 49
Rep Power: 3
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
havref likes this.
mo_na is offline   Reply With Quote

Old   November 23, 2016, 06:04
Default
  #6
New Member
 
Håvard
Join Date: Jun 2015
Location: Norway
Posts: 3
Rep Power: 4
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

Reply

Tags
dynamic mesh, pitching

Thread Tools
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 On
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 17:07
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03: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 08:21

Sponsored Links


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