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

Orientation tensor of 6DoF solver

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

Like Tree6Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 13, 2016, 09:50
Default Orientation tensor of 6DoF solver
  #1
Member
 
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 12
manoj_nav is on a distinguished road
Hi All

I am trying to use interDyMfoam solver for doing dynamic trim and sinkage simulation of a ship. Following is an extract from the log.interDyMfoam file.

6-DoF rigid body motion

Centre of rotation: (2.59 0 0.296454)

Centre of mass: (2.59 0 0.296454)

Orientation: (0.99971 0 -0.02408 0 1 0 0.02408 0 0.99971)

Linear velocity: (0 0 -0.0128308)

Angular velocity: (0 0.00336935 0)



What is this orientation tensor? How do we get trim (rotation about y axis) and sinkage ( translation about z axis) information out of it?

Regards,

Manoj
chliu likes this.
manoj_nav is offline   Reply With Quote

Old   January 15, 2016, 13:41
Default
  #2
Member
 
Davi Barreira
Join Date: Apr 2014
Location: Fortaleza
Posts: 76
Rep Power: 12
davibarreira is on a distinguished road
When you run your simulation, save the log file. In the log file you will have the information that you want, so it's just a matter of writing a little script to extract it. Here is a little bash to get the center of mass.

Code:
#!/bin/bash
grep 'Centre of mass' $1 | cut -d '(' -f 2 | tr -d ")" > centreMass_Extract
grep -e "^Time = " $1 | cut -d " " -f 3 > times_Extract

paste times_Extract centreMass_Extract > cmMotion_parcial
sed -e 's/ [ ]*/\t/g' cmMotion_parcial > cmMotion
rm cmMotion_parcial
rm times_Extract
rm centreMass_Extract
davibarreira is offline   Reply With Quote

Old   January 19, 2016, 00:59
Default
  #3
Member
 
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 12
manoj_nav is on a distinguished road
Quote:
Originally Posted by davibarreira View Post
When you run your simulation, save the log file. In the log file you will have the information that you want, so it's just a matter of writing a little script to extract it. Here is a little bash to get the center of mass.

Code:
#!/bin/bash
grep 'Centre of mass' $1 | cut -d '(' -f 2 | tr -d ")" > centreMass_Extract
grep -e "^Time = " $1 | cut -d " " -f 3 > times_Extract

paste times_Extract centreMass_Extract > cmMotion_parcial
sed -e 's/ [ ]*/\t/g' cmMotion_parcial > cmMotion
rm cmMotion_parcial
rm times_Extract
rm centreMass_Extract
Thank you for the reply. It works very well.

But I am facing 2 issues .

1) Because I am having 3 nOuterCorrectors loops inside PIMPLE, so it seems 6DOF solvers also runs the same number of time for every time step. So in the cmmotion file, center of mass data is 3 times the time data. I am attaching the files with the message. If you can help me to correct it. I am new to writing these scripts.

2) What is the orientation tensor? There is 9 values in it. What are these values?

Thanks again.

Regards,

Manoj
Attached Files
File Type: gz cmMotion.tar.gz (9.8 KB, 48 views)
manoj_nav is offline   Reply With Quote

Old   January 19, 2016, 04:02
Default
  #4
Member
 
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 12
manoj_nav is on a distinguished road
Quote:
Originally Posted by manoj_nav View Post
1) Because I am having 3 nOuterCorrectors loops inside PIMPLE, so it seems 6DOF solvers also runs the same number of time for every time step. So in the cmmotion file, center of mass data is 3 times the time data. I am attaching the files with the message. If you can help me to correct it. I am new to writing these scripts.
Got this working by including,

awk 'NR == 1 || NR % 3 == 0' centreMass_Extract > centreMass_Extract1


But I still dont understand what are these 9 values of orientation tensor..
Richal Sun likes this.
manoj_nav is offline   Reply With Quote

Old   January 21, 2016, 11:38
Default
  #5
Member
 
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 12
manoj_nav is on a distinguished road
Quote:
Originally Posted by manoj_nav View Post
But I still dont understand what are these 9 values of orientation tensor..
Can anyone confirm if the orientation tensor is give by below matrix, where the rotations are about the , and axes with angles , and ?


manoj_nav is offline   Reply With Quote

Old   January 21, 2016, 14:05
Default
  #6
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 17
kmooney is on a distinguished road
Quote:
Originally Posted by manoj_nav View Post
Can anyone confirm if the orientation tensor is give by below matrix, where the rotations are about the , and axes with angles , and ?


Looking at this:
http://planning.cs.uiuc.edu/node102.html

and this:
http://foam.sourceforge.net/docs/cpp/a09729_source.html

It indeed appears that that is the correct summation of the Rx Ry and Rz tensors.
gautami, Isidoros and IFX21 like this.
kmooney is offline   Reply With Quote

Old   January 22, 2016, 09:15
Default
  #7
Member
 
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 12
manoj_nav is on a distinguished road
Thanks a lot for the reply.

Regards,

Manoj
manoj_nav is offline   Reply With Quote

Old   January 30, 2016, 02:56
Default
  #8
Senior Member
 
Join Date: Jul 2011
Posts: 120
Rep Power: 14
haze_1986 is on a distinguished road
For interDyMFoam, if you are using sixDoFRigidBodyMotionI.H:

Code:
inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorX
(
    scalar phi
) const
{
    return tensor
    (
        1, 0, 0,
        0, Foam::cos(phi), -Foam::sin(phi),
        0, Foam::sin(phi), Foam::cos(phi)
    );
}


inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorY
(
    scalar phi
) const
{
    return tensor
    (
        Foam::cos(phi), 0, Foam::sin(phi),
        0, 1, 0,
        -Foam::sin(phi), 0, Foam::cos(phi)
    );
}


inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorZ
(
    scalar phi
) const
{
    return tensor
    (
        Foam::cos(phi), -Foam::sin(phi), 0,
        Foam::sin(phi), Foam::cos(phi), 0,
        0, 0, 1
    );
}


inline Foam::Tuple2<Foam::tensor, Foam::vector>
Foam::sixDoFRigidBodyMotion::rotate
(
    const tensor& Q0,
    const vector& pi0,
    const scalar deltaT
) const
{
    Tuple2<tensor, vector> Qpi(Q0, pi0);
    tensor& Q = Qpi.first();
    vector& pi = Qpi.second();

    tensor R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorZ(deltaT*pi.z()/momentOfInertia_.zz());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
    pi = pi & R;
    Q = Q & R;

    return Qpi;
}
The rotation function below shows that it is actually
0.5*Rx*0.5*Ry*Rz*0.5*Ry*0.5*Rx
haze_1986 is offline   Reply With Quote

Old   January 31, 2016, 11:29
Default
  #9
Member
 
Manoj
Join Date: Jun 2013
Posts: 38
Rep Power: 12
manoj_nav is on a distinguished road
Hi Haze

If the orientation tensor is 0.5*Rx*0.5*Ry*Rz*0.5*Ry*0.5*Rx , then the 7th member of the tensor becomes zero for rotation about only y-axis. But in my simulations, I am getting this number non-zero. Can you confirm?



Thanks and Regards,

Manoj
manoj_nav is offline   Reply With Quote

Old   May 6, 2017, 05:04
Default Orientation adjustment from Q0() to Q()?
  #10
New Member
 
Join Date: Mar 2017
Posts: 4
Rep Power: 9
tmatrix is on a distinguished road
Do you know the orientation adjustment from Q0() to Q()?

Quote:
Originally Posted by haze_1986 View Post
For interDyMFoam, if you are using sixDoFRigidBodyMotionI.H:

Code:
inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorX
(
    scalar phi
) const
{
    return tensor
    (
        1, 0, 0,
        0, Foam::cos(phi), -Foam::sin(phi),
        0, Foam::sin(phi), Foam::cos(phi)
    );
}


inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorY
(
    scalar phi
) const
{
    return tensor
    (
        Foam::cos(phi), 0, Foam::sin(phi),
        0, 1, 0,
        -Foam::sin(phi), 0, Foam::cos(phi)
    );
}


inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorZ
(
    scalar phi
) const
{
    return tensor
    (
        Foam::cos(phi), -Foam::sin(phi), 0,
        Foam::sin(phi), Foam::cos(phi), 0,
        0, 0, 1
    );
}


inline Foam::Tuple2<Foam::tensor, Foam::vector>
Foam::sixDoFRigidBodyMotion::rotate
(
    const tensor& Q0,
    const vector& pi0,
    const scalar deltaT
) const
{
    Tuple2<tensor, vector> Qpi(Q0, pi0);
    tensor& Q = Qpi.first();
    vector& pi = Qpi.second();

    tensor R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorZ(deltaT*pi.z()/momentOfInertia_.zz());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
    pi = pi & R;
    Q = Q & R;

    return Qpi;
}
The rotation function below shows that it is actually
0.5*Rx*0.5*Ry*Rz*0.5*Ry*0.5*Rx
tmatrix is offline   Reply With Quote

Old   September 14, 2017, 01:57
Default
  #11
New Member
 
twinkle
Join Date: Aug 2017
Posts: 3
Rep Power: 8
lil_star is on a distinguished road
[QUOTE=manoj_nav;581507]Got this working by including,

awk 'NR == 1 || NR % 3 == 0' centreMass_Extract > centreMass_Extract1


But I still dont understand what are these 9 values of orientation tensor..


where did you add this after sed ?
lil_star is offline   Reply With Quote

Old   October 10, 2017, 05:48
Default scripts
  #12
Member
 
Antoni Alexander
Join Date: Nov 2009
Posts: 43
Rep Power: 16
zkdkeen is on a distinguished road
I think the script should be modified as below:

Code:
awk 'NR == 1 || (NR-1) % 3 == 0' centreMass_Extract > centreMass_Extract1
so that the coordinates of centre of mass will match the time correctly.

As to the orientation, I think if you fix your ship in y=0 plane, the orientation should be (cosθ 0 sinθ 0 1 0 −sinθ 0 cosθ).
Richal Sun likes this.
zkdkeen is offline   Reply With Quote

Old   October 11, 2017, 06:25
Default
  #13
New Member
 
twinkle
Join Date: Aug 2017
Posts: 3
Rep Power: 8
lil_star is on a distinguished road
In dynamicmeshdict if y-plane = 1 ; then that means the object is allowed to rotate about y-axis. it will have pitch. right?



constraints
{
zAxis
{
sixDoFRigidBodyMotionConstraint line;
direction (0 0 1);
}
yPlane
{
sixDoFRigidBodyMotionConstraint axis;
axis (0 1 0);
}
lil_star is offline   Reply With Quote

Old   January 23, 2020, 12:55
Default Yes it is pitch,but how do we extract the angle value for it from orientation tensor?
  #14
New Member
 
Ahsan
Join Date: Nov 2019
Location: Bologna, Italy
Posts: 27
Rep Power: 6
mahsankhan is on a distinguished road
Quote:
Originally Posted by lil_star View Post
In dynamicmeshdict if y-plane = 1 ; then that means the object is allowed to rotate about y-axis. it will have pitch. right?



constraints
{
zAxis
{
sixDoFRigidBodyMotionConstraint line;
direction (0 0 1);
}
yPlane
{
sixDoFRigidBodyMotionConstraint axis;
axis (0 1 0);
}
Yes according to this if x-axis is along the wave travel and z is your vertical axis, then the constraints that you have shown are for linear motion in heave and rotation about y in pitch.

But can you please tell me how can we get the values of the pitch in degrees (or even in radians) from the orientation tensor? There is a total of 9 values, I am not understanding it. Any help would be nice.
mahsankhan is offline   Reply With Quote

Old   July 23, 2020, 07:13
Default
  #15
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Quote:
Originally Posted by haze_1986 View Post
For interDyMFoam, if you are using sixDoFRigidBodyMotionI.H:

Code:
inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorX
(
    scalar phi
) const
{
    return tensor
    (
        1, 0, 0,
        0, Foam::cos(phi), -Foam::sin(phi),
        0, Foam::sin(phi), Foam::cos(phi)
    );
}


inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorY
(
    scalar phi
) const
{
    return tensor
    (
        Foam::cos(phi), 0, Foam::sin(phi),
        0, 1, 0,
        -Foam::sin(phi), 0, Foam::cos(phi)
    );
}


inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorZ
(
    scalar phi
) const
{
    return tensor
    (
        Foam::cos(phi), -Foam::sin(phi), 0,
        Foam::sin(phi), Foam::cos(phi), 0,
        0, 0, 1
    );
}


inline Foam::Tuple2<Foam::tensor, Foam::vector>
Foam::sixDoFRigidBodyMotion::rotate
(
    const tensor& Q0,
    const vector& pi0,
    const scalar deltaT
) const
{
    Tuple2<tensor, vector> Qpi(Q0, pi0);
    tensor& Q = Qpi.first();
    vector& pi = Qpi.second();

    tensor R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorZ(deltaT*pi.z()/momentOfInertia_.zz());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
    pi = pi & R;
    Q = Q & R;

    R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
    pi = pi & R;
    Q = Q & R;

    return Qpi;
}
The rotation function below shows that it is actually
0.5*Rx*0.5*Ry*Rz*0.5*Ry*0.5*Rx



Does someone know why the rotation Matrix is constructed like this? (0.5*Rx*0.5*Ry*Rz*0.5*Ry*0.5*Rx)


Best


Michael

Last edited by mAlletto; July 25, 2020 at 07:15.
mAlletto is offline   Reply With Quote

Old   July 4, 2021, 09:19
Default
  #16
New Member
 
umutcan
Join Date: May 2021
Posts: 2
Rep Power: 0
umutcaninal is on a distinguished road
could you find a solution to that problem?
I am also dealing with the same issue. I have an orientation tensor in the output file as;

(1 0 8.11758850564-22
0 1 0
-8.11758850564-22 0 1)
It's the Ry matrix that gives the pitch angle of the rigid body as it introduced in the link below;
http://planning.cs.uiuc.edu/node102.html

Please let me know if i am mistaken, best regards.
umutcaninal is offline   Reply With Quote

Old   March 18, 2022, 11:24
Default
  #17
Member
 
Tony Zhang
Join Date: Nov 2019
Location: soton
Posts: 45
Rep Power: 6
zyfsoton is on a distinguished road
Dear all,

I have the same question about this pitch and heave plot.

I think the sin(pitch) is the third component of the orientation vector but I have no idea how to derive the heave.

Please let me know if you have any idea.

Many thanks,
Tony
zyfsoton is offline   Reply With Quote

Old   March 28, 2022, 06:21
Default
  #18
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 137
Rep Power: 19
JNSN is on a distinguished road
since some years there is a function object available, which writes the motion state to file. No need for parsing log files and doing transformations on your own.


Best,
Jan
JNSN is offline   Reply With Quote

Old   May 14, 2022, 18:35
Default Which function?
  #19
New Member
 
Felipe Teixeira Duarte
Join Date: May 2022
Posts: 2
Rep Power: 0
Felipe.td is on a distinguished road
Quote:
Originally Posted by JNSN View Post
since some years there is a function object available, which writes the motion state to file. No need for parsing log files and doing transformations on your own.


Best,
Jan
Can you tell which one It is? And How it Works?
Thanks
Felipe.td is offline   Reply With Quote

Old   May 16, 2022, 04:43
Default
  #20
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 137
Rep Power: 19
JNSN is on a distinguished road
If you are using the rigidBodyDynamics library, then put folowing coding in the functions section of your controlDict:
Code:
  rigidBodyState
  {
    angleFormat degrees;
    functionObjectLibs
      (
        "librigidBodyState.so"
      );
    type rigidBodyState;
   }
For the sixDoFRigidBodyMotions lib, adjust the names accordingly.


Best,
Jan
JNSN is offline   Reply With Quote

Reply

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
Creating New Solver: For particle-laden compressible jets sankarv OpenFOAM Running, Solving & CFD 17 December 3, 2014 19:41
Quarter Burner mesh with periosic condition SamCanuck FLUENT 2 August 31, 2011 11:34
Working directory via command line Luiz CFX 4 March 6, 2011 20:02
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 14:08
Error during Solver cfd guy CFX 4 May 8, 2001 06:04


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