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

Inertia in rigidBodyMotion

Register Blogs Community New Posts Updated Threads Search

Like Tree14Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 18, 2022, 12:21
Default
  #21
Member
 
Tony Zhang
Join Date: Nov 2019
Location: soton
Posts: 45
Rep Power: 7
zyfsoton is on a distinguished road
Quote:
Originally Posted by Bloerb View Post
You are using rhoInf=1. This is the density of air. It's been a long time since i used these solvers. It is likely that it isn't read and the density field of interFoam is used....RhoInf used to calculate the forces on the patch. Since many OpenFOAM solvers use a density normalized pressure p/rho. Hence to calculate the Force on the patch F=p*n you'd need to multiply it by a density. F=rhoInf*p*n. Please make sure this isn't the case. Otherwise there is basically 1000 times less force on the patch as realisitc (density of water=1000). From looking into the code it seems that it isn't used. It is basically a forces function object that calculates the forces on the patch which are given to the rigidbody solver. Hence removing that line altogether should work.


For plotting you have to keep in mind that you are only saving your result every so often. Hence if you need something for plotting over time make sure to use functionObjects to output the needed values. I am not familiar with RAOs what quantity do you need to calculate it?




Try this for starters in your controlDict:
Code:
functions 
{
      sixDoFRigidBodyState
    {
        type           sixDoFRigidBodyState;
        libs           ("libsixDoFRigidBodyState.so");
        angleFormat    degrees;
    }
}
Dear Bloerb,

Many thanks for your reply.

Basically, I want to plot the hull pitch angle and heave along with the simulation time. So from the logfile I have the following information:

Code:
Courant Number mean: 0.00587552 max: 0.999287
Interface Courant Number mean: 2.52283e-05 max: 0.554831
deltaT = 0.000732041
Time = 11.5344

PIMPLE: Iteration 1
forces forces:
    Not including porosity effects
Restraint translationDamper:  force (-0 -0 -6.68788)
Restraint rotationDamper:  moment (-0 7.0894 -0)
6-DoF rigid body motion
    Centre of rotation: (1.86617 -4.84309e-07 0.15847)
    Centre of mass: (1.86617 -4.84309e-07 0.15847)
    Orientation: (0.999954 0 0.00954438 0 1 0 -0.00954438 0 0.999954)
    Linear velocity: (0 0 0.000927669)
    Angular velocity: (0 -0.000730012 0)
GAMG:  Solving for pcorr, Initial residual = 1, Final residual = 0.000796647, No Iterations 5
time step continuity errors : sum local = 1.35111e-11, global = 3.33221e-12, cumulative = 1.80929e-08
smoothSolver:  Solving for alpha.water, Initial residual = 1.44068e-06, Final residual = 8.86336e-12, No Iterations 2
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -7.72742e-21  Max(alpha.water) = 1
Applying the previous iteration compression flux
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -1.177e-09  Max(alpha.water) = 1
GAMG:  Solving for p_rgh, Initial residual = 0.000313061, Final residual = 2.24666e-08, No Iterations 3
time step continuity errors : sum local = 5.17601e-11, global = -9.04222e-12, cumulative = 1.80839e-08
PIMPLE: Iteration 2
forces forces:
    Not including porosity effects
Restraint translationDamper:  force (-0 -0 -6.69499)
Restraint rotationDamper:  moment (-0 7.10083 -0)
6-DoF rigid body motion
    Centre of rotation: (1.86617 -4.84309e-07 0.15847)
    Centre of mass: (1.86617 -4.84309e-07 0.15847)
    Orientation: (0.999954 0 0.00954438 0 1 0 -0.00954438 0 0.999954)
    Linear velocity: (0 0 0.000927761)
    Angular velocity: (0 -0.000730041 0)
GAMG:  Solving for pcorr, Initial residual = 1, Final residual = 0.000546164, No Iterations 5
time step continuity errors : sum local = 9.445e-12, global = -3.36602e-12, cumulative = 1.80805e-08
smoothSolver:  Solving for alpha.water, Initial residual = 1.43412e-06, Final residual = 8.81716e-12, No Iterations 2
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -7.72727e-21  Max(alpha.water) = 1
Applying the previous iteration compression flux
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -1.32948e-09  Max(alpha.water) = 1
GAMG:  Solving for p_rgh, Initial residual = 1.42924e-06, Final residual = 1.78075e-08, No Iterations 2
time step continuity errors : sum local = 4.10253e-11, global = 4.71189e-13, cumulative = 1.8081e-08
PIMPLE: Iteration 3
forces forces:
    Not including porosity effects
Restraint translationDamper:  force (-0 -0 -6.69565)
Restraint rotationDamper:  moment (-0 7.10111 -0)
6-DoF rigid body motion
    Centre of rotation: (1.86617 -4.84309e-07 0.15847)
    Centre of mass: (1.86617 -4.84309e-07 0.15847)
    Orientation: (0.999954 0 0.00954438 0 1 0 -0.00954438 0 0.999954)
    Linear velocity: (0 0 0.000927775)
    Angular velocity: (0 -0.000730046 0)
GAMG:  Solving for pcorr, Initial residual = 1, Final residual = 0.000765161, No Iterations 5
time step continuity errors : sum local = 1.29848e-11, global = 2.79613e-12, cumulative = 1.80838e-08
smoothSolver:  Solving for alpha.water, Initial residual = 1.43408e-06, Final residual = 8.8173e-12, No Iterations 2
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -7.72725e-21  Max(alpha.water) = 1
Applying the previous iteration compression flux
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -1.32747e-09  Max(alpha.water) = 1
GAMG:  Solving for p_rgh, Initial residual = 1.32453e-07, Final residual = 2.10085e-08, No Iterations 1
time step continuity errors : sum local = 4.83998e-11, global = -9.64363e-12, cumulative = 1.80741e-08
PIMPLE: Iteration 4
forces forces:
    Not including porosity effects
Restraint translationDamper:  force (-0 -0 -6.69575)
Restraint rotationDamper:  moment (-0 7.10116 -0)
6-DoF rigid body motion
    Centre of rotation: (1.86617 -4.84309e-07 0.15847)
    Centre of mass: (1.86617 -4.84309e-07 0.15847)
    Orientation: (0.999954 0 0.00954438 0 1 0 -0.00954438 0 0.999954)
    Linear velocity: (0 0 0.000927777)
    Angular velocity: (0 -0.000730045 0)
GAMG:  Solving for pcorr, Initial residual = 1, Final residual = 0.000555095, No Iterations 5
time step continuity errors : sum local = 9.39265e-12, global = -3.4139e-12, cumulative = 1.80707e-08
smoothSolver:  Solving for alpha.water, Initial residual = 1.43408e-06, Final residual = 8.81732e-12, No Iterations 2
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -7.72725e-21  Max(alpha.water) = 1
Applying the previous iteration compression flux
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -1.32894e-09  Max(alpha.water) = 1
GAMG:  Solving for p_rgh, Initial residual = 3.92688e-08, Final residual = 3.92688e-08, No Iterations 0
time step continuity errors : sum local = 9.04682e-11, global = -2.86723e-11, cumulative = 1.8042e-08
PIMPLE: Iteration 5
forces forces:
    Not including porosity effects
Restraint translationDamper:  force (-0 -0 -6.69576)
Restraint rotationDamper:  moment (-0 7.10115 -0)
6-DoF rigid body motion
    Centre of rotation: (1.86617 -4.84309e-07 0.15847)
    Centre of mass: (1.86617 -4.84309e-07 0.15847)
    Orientation: (0.999954 0 0.00954438 0 1 0 -0.00954438 0 0.999954)
    Linear velocity: (0 0 0.000927777)
    Angular velocity: (0 -0.000730045 0)
GAMG:  Solving for pcorr, Initial residual = 1, Final residual = 0.000764826, No Iterations 5
time step continuity errors : sum local = 1.29589e-11, global = 2.72512e-12, cumulative = 1.80448e-08
smoothSolver:  Solving for alpha.water, Initial residual = 1.43408e-06, Final residual = 8.81733e-12, No Iterations 2
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -7.72725e-21  Max(alpha.water) = 1
Applying the previous iteration compression flux
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.536594  Min(alpha.water) = -1.33009e-09  Max(alpha.water) = 1
GAMG:  Solving for p_rgh, Initial residual = 4.06946e-08, Final residual = 4.06946e-08, No Iterations 0
time step continuity errors : sum local = 9.37529e-11, global = -2.87026e-11, cumulative = 1.80161e-08
smoothSolver:  Solving for omega, Initial residual = 4.60429e-06, Final residual = 1.6717e-09, No Iterations 1
smoothSolver:  Solving for k, Initial residual = 0.000148782, Final residual = 2.15968e-08, No Iterations 1
ExecutionTime = 114820 s  ClockTime = 115202 s

forces totForce write:
    sum of forces:
        pressure : (-4.81482 -0.0370846 2258.52)
        viscous  : (-7.34272 0.00989957 -0.0580179)
        porous   : (0 0 0)
    sum of moments:
        pressure : (0.00511215 3.71011 -0.115732)
        viscous  : (0.00273009 1.46312 -0.0146114)
        porous   : (0 0 0)
How can I get trim (rotation about y-axis) and sinkage ( translation about z-axis) information out of it?

I can use the script to extract the linear, angular velocities and orientation from the logfile, but since I have 3 nOuterCorrectors loops inside PIMPLE, so for each timestep, I have 3 linear, angular velocities and orientations, I am confused how to plot the pitch and heave along the simulation time.

And for pitch angle, I think it should be the sin(pitch_angle) value from the third component of orientation (Orientation: (0.999954 0 0.00954438 0 1 0 -0.00954438 0 0.999954)). But for heave, I have no idea how to derive it.

I have attached the pitch angle variation plot along the simulation time, please correct me if I am wrong.

I will try your suggestion of adding function of sixDoFRigidBodyState in controlDict file.

Many thanks and have a good weekend
Tony
Attached Images
File Type: png pitch.png (32.2 KB, 19 views)
zyfsoton is offline   Reply With Quote

Old   March 18, 2022, 13:43
Default
  #22
Senior Member
 
Join Date: Sep 2013
Posts: 353
Rep Power: 21
Bloerb will become famous soon enough
The function object i listed should do just that. But learning awk is extremly helpful for linux and OpenFOAM postProcessing in general.

Hence this is extremly long and not the cleanest implementation, but hopefully readable und learnable.


Put this inside an createPlot.sh file and execute it.
Code:
#!/bin/sh

awk '{
gsub(/[()]/,"");
if ($0 ~ "Centre of rotation:") {corx=$4;cory=$5;corz=$6};
if ($0 ~ "Centre of mass:")     {comx=$4;comy=$5;comz=$6};
if ($0 ~ "Linear velocity:")    {velx=$3;vely=$4;velz=$5};
if ($1 == "Time") {currentTime=$3};




if ($0 ~ "ExecutionTime")
  {
  print currentTime,comy*sin(velz)
  }
  

}' log.dat > resultForPlotting.dat
Awk goes through a file line by line and executes the code while it is in that line. First part is gsub. This replaces ( and ) with "". So it removes all brackets inside that line. Next part checks if the line contains "Centre of rotation" and if it does sets variables like corx to the x value of the rotation which is the 4th column of that line. And if the first column of a line is "Time" we set the third column to the time value.



And currently it prints those variables if it s in a line that has ExecutionTime in it. Hence at the end of a time step into a file resultForPlotting.dat. I'll leave it to you to figure out your formula. Awk can use sin cos etc (not in degrees but radians before you are searching for errors). Shouldn't the heave just be the centre of mass?
Bloerb is offline   Reply With Quote

Old   September 19, 2022, 04:27
Default
  #23
New Member
 
Zhang zf.
Join Date: May 2022
Posts: 2
Rep Power: 0
Zhang zf. is on a distinguished road
hey guys,
I just wonder when the density = 1, if the value of mass is just the volume?
Zhang zf. is offline   Reply With Quote

Old   September 19, 2022, 04:34
Default
  #24
New Member
 
Zhang zf.
Join Date: May 2022
Posts: 2
Rep Power: 0
Zhang zf. is on a distinguished road
Quote:
Originally Posted by vava10 View Post
Thank you so much for the reply I have been stuck soooooo hard

I was finding the moment of inertia of the ship from the stl (MeshLab, Solidworks and surfaceInertia) and using it for the calculation. My kayak was sinking

what I have is a kayak and it does not have any additions cargo or engines.
and I have 77 kg as the weight of the kayak. I obtained the volume of the mesh using MeshLAb and used this volume and given mass to find the density.

This density was used for the calculation of the moment of inertia

If the inertia from the STL file is not used for the calculation, that probably can be the reason for sinking?

How exactly should I proceed for finding the moment of inertia for the calculation purpose?

Should I just use the moment of inertia for the bounding box? if so I need mass for that. should I use 77kg for the mass??



Again thank you

hey guys,
I just wonder when the density = 1, if the value of mass is just the volume?
Zhang zf. is offline   Reply With Quote

Old   September 14, 2023, 01:23
Default
  #25
New Member
 
Aero_Cats!
Join Date: Jul 2021
Location: Indonesia
Posts: 7
Rep Power: 5
IFX21 is on a distinguished road
Quote:
Originally Posted by Bloerb View Post
1) snappyHexMesh uses the stl file of the ship and cuts this out of the mesh block. Since the mesh block covers only half the rest isn't used. You could use half, but it is easier to use the full ship, since this makes it easier to detect edges in the meshing run. E.g if your half ship stl file has one point at x=1e-15 and your mesh goes to x=0 you might get artifacts during meshing.


2) rhoInf is there because you are using basically two solvers. One for the rigid body and one for the flow simulation. Coupled together on a patch. Incompressible openfoam solvers do not use a density. They instead solve for p/rho. Hence you need to add rhoInf so that the rigid body solver can calculate the fluid forces correctly. rhoInf is hence the density of the fluid. I haven't looked in the code, but this is probably not read for solvers which use a density field. Like interFoam etc.


3) no 3 question asked


4) There is one moment of inertia. You can however transform it into a different coordinate system. Which basically means rotating your part until x y z align with principle axis. You obviously need to calculate it here using the coordinate system you are calculating in. And around the centre of mass.



surfaceInertia -density 1 file.stl calculates the moment of inertia of the stl file around it's centre of mass with density 1.

surfaceInertia -density 1 -referencePoint '(0 0 1)' file.stl calculates the moment of inertia of the stl file around this point

Hello I would like to ask to clarify my understanding. Suppose we want to simulate ship motion in heave and pitch movement for towing tank test validation. In towing tank experiment, the centre of rotation for pitch movement is being fixed at a point (not in ship's CG).

Can the moment inertia resulted from surfaceInertia file.stl being used directly in the dynamicMeshDict.sixDoF or should the moment inertia transformed first from ship's CG to the rotation point?
IFX21 is offline   Reply With Quote

Reply


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
Fatal error with rho in rigidBodyMotion! monnda OpenFOAM Running, Solving & CFD 1 November 3, 2023 10:39
Defining centre of mass/rotation in rigidBodyMotion solver tok3rat0r OpenFOAM Running, Solving & CFD 1 November 26, 2018 10:44
linearAxialAngularSpring restraint in rigidBodyMotion solver jiadongw OpenFOAM Running, Solving & CFD 4 August 13, 2018 22:33
Inertia in 6DOF pabsandoval FLUENT 0 March 13, 2013 19:06
Mass moment of inertia Cluain CFX 4 July 18, 2012 10:36


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