77 * @brief Header file of TestHydro main class and helper classes
88 * ComponentFunc and ForceFunc6d.
99 *
10- * OVERVIEW:
11- * This header defines the public interface for hydrodynamic force computation
12- * in multibody marine systems. It provides Chrono-compatible force callbacks
13- * that integrate hydrostatics, radiation damping, and wave excitation.
10+ * ARCHITECTURE:
11+ * TestHydro is a thin adapter over HydroSystem + ChronoHydroCoupler.
12+ * Force computation is handled internally by HydroSystem, which owns:
13+ * - HydrostaticsComponent (restoring forces + buoyancy)
14+ * - RadiationComponent (RIRF convolution, owns velocity history)
15+ * - ExcitationComponent (wave forcing)
16+ *
17+ * The sign convention is: total = hydrostatics - radiation + waves.
18+ * (RadiationComponent applies the negative sign internally since damping
19+ * opposes motion.)
1420 *
1521 * MAIN RESPONSIBILITIES:
16- * - TestHydro: Main orchestrator class for all hydrodynamic force components
22+ * - TestHydro: Façade over HydroSystem; provides Chrono force callbacks
1723 * - ForceFunc6d: Wraps 6-DOF force/torque callbacks for Chrono bodies
1824 * - ComponentFunc: Per-DOF force function for Chrono's ChForce system
1925 *
26+ * COMPONENT CONSTRUCTION:
27+ * Force components are constructed via factory methods:
28+ * - CreateHydrostaticsComponent()
29+ * - CreateRadiationComponent()
30+ * - CreateExcitationComponent()
31+ * These are the single source of truth for component configuration.
32+ *
2033 * INTERACTIONS:
2134 * - Used by setup_hydro_from_yaml to create and configure TestHydro instances
2235 * - Called by Chrono during simulation via ChForce callbacks
2740 * - Bodies are 1-indexed in CoordinateFuncForBody (legacy, from ForceFunc6d)
2841 * - All bodies share same H5 file (multibody data in single file)
2942 * - 6 DOF per body (surge, sway, heave, roll, pitch, yaw)
30- * - Forces computed once per time step and cached
31- *
32- * KNOWN LIMITATIONS:
33- * - Monolithic design: all physics components mixed in TestHydro
34- * - Tight coupling to Chrono types (hard to test in isolation)
35- * - Body indexing inconsistency (1-indexed vs 0-indexed)
36- * - No per-body enable/disable of force components
37- *
38- * FUTURE REFACTORING:
39- * This class will be replaced by HydroSystem + ChronoHydroCoupler.
40- * TestHydro will become a thin legacy adapter for API stability.
43+ * - Forces computed once per time step and cached via prev_time check
4144 *********************************************************************/
4245
43- // TODO: clean up include statements
44-
4546// Include hydro_types.h FIRST to ensure BodyForces and GeneralizedForce are available
4647// before any other includes that might conflict (e.g., hydro_config_types.h)
4748#include < hydroc/hydro_types.h>
@@ -252,29 +253,35 @@ class TestHydro {
252253 void AddWaves (std::shared_ptr<WaveBase> waves);
253254
254255 /* *
255- * @brief Computes the Hydrostatic stiffness force plus buoyancy force for a 6N dimensional system.
256+ * @brief Legacy API: Computes hydrostatic forces for a 6N dimensional system.
257+ *
258+ * NOTE: Retained for backward compatibility. The main force path now uses HydroSystem
259+ * (via CoordinateFuncForBody). This method is not called during normal simulation.
256260 *
257261 * @return 6N dimensional force for 6 DOF and N bodies in system.
258262 */
259263 std::vector<double > ComputeForceHydrostatics ();
260264
261265 /* *
262- * @brief Computes the Radiation Damping force with convolution history for a 6N dimensional system.
266+ * @brief Legacy API: Computes radiation damping forces for a 6N dimensional system.
263267 *
264- * The discretization uses the time series of the the RIRF relative to the current step.
265- * Linear interpolation is done on the velocity history if time_sim-time_rirf is between two values of the time
266- * history. Trapezoidal integration is used to compute the force.
268+ * NOTE: Retained for backward compatibility. The main force path now uses HydroSystem
269+ * (via CoordinateFuncForBody). This method is not called during normal simulation.
267270 *
268- * Time history is automatically added in this function (so it should only be called once per time step), and
269- * history that is older than the maximum RIRF time value is automatically removed .
271+ * Returns positive damping magnitudes (legacy convention); the main path applies
272+ * the correct sign internally via RadiationComponent .
270273 *
271274 * @return 6N dimensional force for 6 DOF and N bodies in system.
272275 */
273276 std::vector<double > ComputeForceRadiationDampingConv ();
274277
275278 /* *
276- * @brief Computes the 6N dimensional force from any waves applied to the system.
277- * @return 6N dimensional force for 6 DOF and N bodies in system (already Eigen type).
279+ * @brief Legacy API: Computes wave excitation forces for a 6N dimensional system.
280+ *
281+ * NOTE: Retained for backward compatibility. The main force path now uses HydroSystem
282+ * (via CoordinateFuncForBody). This method is not called during normal simulation.
283+ *
284+ * @return 6N dimensional force for 6 DOF and N bodies in system.
278285 */
279286 Eigen::VectorXd ComputeForceWaves ();
280287 // Expose the wave object (read-only) so callers can query inputs if needed
@@ -352,8 +359,8 @@ class TestHydro {
352359 // Hydrodynamics profiling accessors
353360 HydroProfileStats GetProfileStats () const { return profile_stats_; }
354361
355- // Compare mode: when enabled, compares legacy force path vs HydroSystem path
356- // and logs any discrepancies. Default is off .
362+ // Compare mode: legacy debugging feature, retained for API compatibility.
363+ // No longer affects behavior since the main path now uses HydroSystem exclusively .
357364 void SetCompareMode (bool enable) { compare_mode_ = enable; }
358365 bool GetCompareMode () const { return compare_mode_; }
359366
@@ -416,7 +423,7 @@ class TestHydro {
416423 std::unique_ptr<hydrochrono::hydro::HydroSystem> hydro_system_;
417424 std::unique_ptr<hydrochrono::hydro::ChronoHydroCoupler> chrono_coupler_;
418425
419- // Compare mode flag: when true, compares legacy vs HydroSystem forces
426+ // Legacy compare mode flag: retained for API compatibility; no longer used.
420427 bool compare_mode_ = false ;
421428
422429 // Convolution kernel preprocessing (optional)
@@ -451,15 +458,9 @@ class TestHydro {
451458 // Note: Each instance owns its own velocity history (they are independent).
452459 std::unique_ptr<hydrochrono::hydro::RadiationComponent> CreateRadiationComponent () const ;
453460
454- // Internal helpers for HydroSystem + ChronoHydroCoupler path
455- // Constructs hydro_system_ and chrono_coupler_ once; subsequent calls are no-ops.
461+ // Internal helper: constructs hydro_system_ and chrono_coupler_ once.
462+ // Subsequent calls are no-ops. Called automatically by CoordinateFuncForBody() .
456463 void EnsureHydroSystemAndCoupler ();
457- // Evaluate forces via HydroSystem (used by comparison harness)
458- hydrochrono::hydro::BodyForces EvaluateHydroSystem (double time);
459-
460- // Comparison harness: compares legacy forces vs HydroSystem forces and logs discrepancies.
461- // Only called when compare_mode_ is true.
462- void CompareWithHydroSystem (double time, int total_dofs);
463464};
464465
465466#endif
0 commit comments