@@ -14,6 +14,22 @@ enum class WaveMode {
1414 irregular = 2
1515};
1616
17+ /* *
18+ * @brief Abstract base class for all wave models.
19+ *
20+ * Coordinate conventions:
21+ * - Waves propagate in the +X direction (unidirectional).
22+ * - Z is vertical (positive upward), with z = mwl_ at mean water level.
23+ * - Y is horizontal, perpendicular to wave propagation.
24+ *
25+ * Units:
26+ * - Positions: meters [m]
27+ * - Time: seconds [s]
28+ * - Elevation η: meters [m]
29+ * - Gradients ∂η/∂x, ∂η/∂y: dimensionless [m/m]
30+ * - Velocities: meters per second [m/s]
31+ * - Accelerations: meters per second squared [m/s²]
32+ */
1733class WaveBase {
1834 public:
1935 virtual ~WaveBase () = default ;
@@ -25,6 +41,25 @@ class WaveBase {
2541 virtual Eigen::Vector3d GetVelocity (const Eigen::Vector3d& position, double time) = 0;
2642 virtual Eigen::Vector3d GetAcceleration (const Eigen::Vector3d& position, double time) = 0;
2743
44+ /* *
45+ * @brief Returns the free-surface gradient (∂η/∂x, ∂η/∂y) at the given position and time.
46+ *
47+ * Used for computing surface normals in visualization. The normal vector can be
48+ * constructed as: n = normalize(−∂η/∂x, −∂η/∂y, 1).
49+ *
50+ * @param position World coordinates (x, y, z) in meters. Only x, y are used.
51+ * @param time Simulation time in seconds.
52+ * @return Eigen::Vector2d containing (∂η/∂x, ∂η/∂y), dimensionless.
53+ *
54+ * @note Default implementation returns (0, 0) for flat surface (NoWave).
55+ * @note Current wave models are unidirectional (+X), so ∂η/∂y = 0.
56+ */
57+ virtual Eigen::Vector2d GetElevationGradientXY (const Eigen::Vector3d& position, double time) const {
58+ (void )position;
59+ (void )time;
60+ return Eigen::Vector2d::Zero ();
61+ }
62+
2863 double mwl_ = 0.0 ;
2964 double g_ = 9.81 ;
3065 double water_depth_ = 0.0 ;
0 commit comments