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.
- Export rigid-body motion and velocity during runtime
- Support both
datandcsvoutput 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
The library writes two files:
BodyMotion.datorBodyMotion.csvBodyVelocity.datorBodyVelocity.csv
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 positionSurge Sway Heave: displacement relative to the initial center of massRoll Pitch Yaw: Euler angles inXYZorder
Time Ux Uy Uz OmegaX OmegaY OmegaZ
or in CSV:
Time,Ux,Uy,Uz,OmegaX,OmegaY,OmegaZ
Meaning:
Ux Uy Uz: translational velocityOmegaX OmegaY OmegaZ: angular velocity
Build the shared library in an OpenFOAM environment:
wmake libsoAfter compilation, the library is typically generated under:
$FOAM_USER_LIBBIN/libSixDofOutFile.soIn system/controlDict:
libs
(
"libSixDofOutFile.so"
);
restraints
{
sixDofOutput
{
sixDoFRigidBodyMotionRestraint SixDofOutFile;
outputFormat dat;
motionFile "BodyMotion.dat";
velocityFile "BodyVelocity.dat";
outputDegrees true;
}
}
restraints
{
sixDofOutput
{
sixDoFRigidBodyMotionRestraint SixDofOutFile;
outputFormat csv;
motionFile "BodyMotion.csv";
velocityFile "BodyVelocity.csv";
outputDegrees true;
}
}
Notes:
outputFormatsupportsdatandcsvcvsis also accepted and normalized internally tocsv- If file names are omitted, default names are selected automatically based on
outputFormat outputDegrees true;writes Euler angles in degreesoutputDegrees false;writes Euler angles in radians
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_dofsSixDofOutFile.C: implementationSixDofOutFile.H: class declarationplot_sixdof.py: plotting helper说明书.md: detailed Chinese documentationMake/: OpenFOAM build files
- 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
This project is distributed under the GNU General Public License v3.0 or later. See LICENSE.