A C++ header-first library for simulating and analyzing ocean surface waves across deterministic and spectral models.
The project includes:
- Wave model implementations (trochoidal/Gerstner, cnoidal, Fenton, JONSWAP, Pierson–Moskowitz, and helpers).
- Simulation and plotting utilities for generating CSV outputs and figures.
- Test and validation executables for model behavior and spectrum checks.
src/— core wave model headers and shared utilities.tests/— simple executable-based validation suite.data-sim/— simulation executable for generating data.plots/— plotting helpers (C++ and Python scripts).doc/— LaTeX documentation and model notes.
g++(tested with modern C++ compilers)Eigenheaders (expected at/usr/include/eigen3)
- Python 3
- Matplotlib / NumPy (for Python plotting scripts)
cd tests
make
./testsTest entry points are configured in tests/tests.cpp by preprocessor switches (FENTON_TEST, JONSWAP_TEST, PM_STOKES_TEST).
cd data-sim
make
./waves_simThis target is useful for generating wave field/spectrum CSV output for further analysis.
cd plots
make
./fenton_plotsPython plotting utilities are also available in plots/ (for example wave_sim_plots.py and wave_spectrum_plots.py).
Core headers in src/ include:
TrochoidalWave.hCnoidalWave.hFentonWaveVectorized.hJonswap3dStokesWaves.hPiersonMoskowitzStokes3D_Waves.hDirectionalSpread.hSeaMetrics.hWavesCategories.h
These headers expose utilities for:
- Surface elevation and derivatives
- Particle kinematics (velocity/acceleration)
- Spectral wave generation and diagnostics
- Sea state and derived wave metrics
#include <iostream>
#include "TrochoidalWave.h"
int main() {
TrochoidalWave<double> wave(1.0, 8.0); // amplitude [m], period [s]
double t = 1.5;
std::cout << "eta(t) = " << wave.surfaceElevation(t) << "\n";
std::cout << "u(x0,z0,t) = " << wave.horizontalVelocity(0.0, -2.0, t) << "\n";
}Compile (example):
g++ -O3 -I./src -I/usr/include/eigen3 your_file.cpp -o your_program- Most of the library is header-based, so linking is typically straightforward.
- For reproducible experiments, keep generated CSV and plots versioned separately from source.
- Mathematical derivations and additional background are provided in the
doc/LaTeX sources.
This project is distributed under the terms of the LICENSE file in the repository root.