Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SixDofOutFile

SixDofOutFile is an OpenFOAM runtime restraint module for exporting six-degree-of-freedom rigid-body motion data directly during a simulation.

It is designed as an output-only sixDoFRigidBodyMotionRestraint: it does not apply any additional force or moment to the body, but writes motion history to file for post-processing.

Features

  • Export rigid-body motion and velocity during runtime
  • Support both dat and csv output formats
  • Avoid duplicate writes within the same time step
  • Only write from the master process in parallel runs
  • Provide a Python plotting script for quick visualization

Output Data

The library writes two files:

  • BodyMotion.dat or BodyMotion.csv
  • BodyVelocity.dat or BodyVelocity.csv

BodyMotion columns

Time X Y Z Surge Sway Heave Roll Pitch Yaw

or in CSV:

Time,X,Y,Z,Surge,Sway,Heave,Roll,Pitch,Yaw

Meaning:

  • X Y Z: center of mass position
  • Surge Sway Heave: displacement relative to the initial center of mass
  • Roll Pitch Yaw: Euler angles in XYZ order

BodyVelocity columns

Time Ux Uy Uz OmegaX OmegaY OmegaZ

or in CSV:

Time,Ux,Uy,Uz,OmegaX,OmegaY,OmegaZ

Meaning:

  • Ux Uy Uz: translational velocity
  • OmegaX OmegaY OmegaZ: angular velocity

Build

Build the shared library in an OpenFOAM environment:

wmake libso

After compilation, the library is typically generated under:

$FOAM_USER_LIBBIN/libSixDofOutFile.so

Load the Library

In system/controlDict:

libs
(
    "libSixDofOutFile.so"
);

Usage in dynamicMeshDict

DAT output

restraints
{
    sixDofOutput
    {
        sixDoFRigidBodyMotionRestraint SixDofOutFile;
        outputFormat  dat;
        motionFile    "BodyMotion.dat";
        velocityFile  "BodyVelocity.dat";
        outputDegrees true;
    }
}

CSV output

restraints
{
    sixDofOutput
    {
        sixDoFRigidBodyMotionRestraint SixDofOutFile;
        outputFormat  csv;
        motionFile    "BodyMotion.csv";
        velocityFile  "BodyVelocity.csv";
        outputDegrees true;
    }
}

Notes:

  • outputFormat supports dat and csv
  • cvs is also accepted and normalized internally to csv
  • If file names are omitted, default names are selected automatically based on outputFormat
  • outputDegrees true; writes Euler angles in degrees
  • outputDegrees false; writes Euler angles in radians

Python Plotting

This repository also includes plot_sixdof.py, which can read both dat and csv output files and generate figures.

Examples:

python plot_sixdof.py
python plot_sixdof.py --group displacement --style separate
python plot_sixdof.py --group rotation --style overlay --name rotation_overlay
python plot_sixdof.py --fields Surge,Heave,Pitch --style subplots --name selected_dofs

Repository Files

  • SixDofOutFile.C: implementation
  • SixDofOutFile.H: class declaration
  • plot_sixdof.py: plotting helper
  • 说明书.md: detailed Chinese documentation
  • Make/: OpenFOAM build files

Notes

  • This module is an output utility, not a physical restraint model
  • Euler angles may show discontinuities near singular configurations
  • Output files are written relative to the solver working directory unless explicit paths are provided

License

This project is distributed under the GNU General Public License v3.0 or later. See LICENSE.

About

OpenFOAM sixDoFRigidBodyMotionRestraint module for exporting 6-DoF motion data with dat/csv output and Python plotting.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages