Skip to content

Commit 086ceef

Browse files
committed
Rename TestHydro facade to HydroForces with back-compat alias
1 parent 3fa8886 commit 086ceef

16 files changed

Lines changed: 114 additions & 117 deletions

include/hydroc/hydro_forces.h

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
/*********************************************************************
55
* @file hydro_forces.h
66
*
7-
* @brief Header file of TestHydro main class and helper classes
7+
* @brief Header file of HydroForces main class and helper classes
88
* ComponentFunc and ForceFunc6d.
99
*
1010
* ARCHITECTURE:
11-
* TestHydro is a thin adapter over HydroSystem + ChronoHydroCoupler.
11+
* HydroForces is a thin adapter over HydroSystem + ChronoHydroCoupler.
1212
* Force computation is handled internally by HydroSystem, which owns:
1313
* - HydrostaticsComponent (restoring forces + buoyancy)
1414
* - RadiationComponent (RIRF convolution, owns velocity history)
@@ -19,7 +19,7 @@
1919
* opposes motion.)
2020
*
2121
* MAIN RESPONSIBILITIES:
22-
* - TestHydro: Façade over HydroSystem; provides Chrono force callbacks
22+
* - HydroForces: Façade over HydroSystem; provides Chrono force callbacks
2323
* - ForceFunc6d: Wraps 6-DOF force/torque callbacks for Chrono bodies
2424
* - ComponentFunc: Per-DOF force function for Chrono's ChForce system
2525
*
@@ -31,7 +31,7 @@
3131
* These are the single source of truth for component configuration.
3232
*
3333
* INTERACTIONS:
34-
* - Used by setup_hydro_from_yaml to create and configure TestHydro instances
34+
* - Used by setup_hydro_from_yaml to create and configure HydroForces instances
3535
* - Called by Chrono during simulation via ChForce callbacks
3636
* - Reads HDF5 data through H5FileInfo (not directly exposed here)
3737
* - Uses WaveBase hierarchy for wave excitation (passed in constructor)
@@ -88,7 +88,7 @@ class ChronoHydroCoupler;
8888
}
8989

9090
class ForceFunc6d;
91-
class TestHydro;
91+
class HydroForces;
9292

9393
// ─────────────────────────────────────────────────────────────────────────────
9494
// Degrees of Freedom Constant
@@ -159,9 +159,9 @@ class ForceFunc6d {
159159
* @brief Initializes hydro force info from H5FileInfo and the ChBody this force will be applied to.
160160
*
161161
* @param object The body in the system to which this 6-dimensional force is being applied.
162-
* @param all_hydro_forces_user The TestHydro class where the total force on all bodies is calculated.
162+
* @param all_hydro_forces_user The HydroForces class where the total force on all bodies is calculated.
163163
*/
164-
ForceFunc6d(std::shared_ptr<chrono::ChBody> object, TestHydro* all_hydro_forces_user);
164+
ForceFunc6d(std::shared_ptr<chrono::ChBody> object, HydroForces* all_hydro_forces_user);
165165

166166
/**
167167
* @brief Copy constructor that ensures the force is only added to a body once.
@@ -208,7 +208,7 @@ class ForceFunc6d {
208208
std::shared_ptr<ComponentFunc> force_ptrs_[kDofPerBody]; ///< Pointers to the forces.
209209
std::shared_ptr<chrono::ChForce> chrono_force_; ///< Chrono force for the body.
210210
std::shared_ptr<chrono::ChForce> chrono_torque_; ///< Chrono torque for the body.
211-
TestHydro* all_hydro_forces_; ///< Pointer to TestHydro for calculations.
211+
HydroForces* all_hydro_forces_; ///< Pointer to HydroForces for calculations.
212212
};
213213

214214
// Forward declaration of ChLoadAddedMass (defined in added_mass.h, included in .cpp)
@@ -226,22 +226,21 @@ struct HydroProfileStats {
226226

227227
// ═══════════════════════════════════════════════════════════════════════════════
228228
//
229-
// TestHydro — Primary Hydrodynamics Façade / Adapter
229+
// HydroForces — Primary Hydrodynamics Façade / Adapter
230230
//
231231
// ═══════════════════════════════════════════════════════════════════════════════
232232
/**
233233
* @brief Primary hydrodynamics façade for HydroChrono applications.
234234
*
235-
* TestHydro is the main user-facing object for attaching hydrodynamic forces to
236-
* Chrono bodies. Despite its name (a historical artifact), it is NOT a test-only
237-
* class — it is the production hydrodynamics adapter used by all workflows.
235+
* HydroForces is the main user-facing object for attaching hydrodynamic forces to
236+
* Chrono bodies. This is the production hydrodynamics adapter used by all workflows.
238237
*
239-
* @note The name "TestHydro" is retained for backward compatibility. New code
240-
* may use the alias `HydroForces` for clarity (see below).
238+
* @note The historical name "TestHydro" is retained as an alias for backward
239+
* compatibility. New code should use `HydroForces`.
241240
*
242241
* ## What It Does
243242
*
244-
* TestHydro bridges three layers:
243+
* HydroForces bridges three layers:
245244
* 1. **Chrono bodies** — The physical bodies in the Chrono simulation.
246245
* 2. **HydroSystem (core)** — Chrono-free hydrodynamic force computation.
247246
* 3. **Chrono force callbacks** — ChForce functions that Chrono calls each timestep.
@@ -256,16 +255,16 @@ struct HydroProfileStats {
256255
*
257256
* // Attach hydrodynamic forces (with or without waves)
258257
* std::vector<std::shared_ptr<ChBody>> bodies = {body1};
259-
* TestHydro hydro(bodies, "path/to/hydro_data.h5");
258+
* HydroForces hydro(bodies, "path/to/hydro_data.h5");
260259
* hydro.AddWaves(std::make_shared<RegularWave>(...));
261260
*
262-
* // Run simulation — Chrono automatically queries TestHydro for forces
261+
* // Run simulation — Chrono automatically queries HydroForces for forces
263262
* @endcode
264263
*
265264
* ## Used By
266265
*
267-
* - **C++ tests and demos** — Directly instantiate TestHydro with bodies and H5 file.
268-
* - **YAML runner (hydrochrono.exe)** — SetupHydroFromYAML creates TestHydro internally.
266+
* - **C++ tests and demos** — Directly instantiate HydroForces with bodies and H5 file.
267+
* - **YAML runner (hydrochrono.exe)** — SetupHydroFromYAML creates HydroForces internally.
269268
*
270269
* ## Architecture Notes
271270
*
@@ -279,16 +278,16 @@ struct HydroProfileStats {
279278
* to determine body order. Internally, body indices are **1-based** in the callback
280279
* interface (CoordinateFuncForBody) to match this naming convention.
281280
*
282-
* @see HydroForces (alias below)
281+
* @see TestHydro (backwards-compatibility alias)
283282
* @see HydroSystem (Chrono-free hydrodynamic core)
284283
* @see ChronoHydroCoupler (extracts state from Chrono bodies)
285284
*/
286-
class TestHydro {
285+
class HydroForces {
287286
public:
288-
TestHydro() = delete;
287+
HydroForces() = delete;
289288

290289
/**
291-
* @brief Main constructor for initializing the TestHydro class.
290+
* @brief Main constructor for initializing the HydroForces class.
292291
*
293292
* Sets up vector of bodies, h5 file info, and hydro inputs. If no waves are given,
294293
* this constructor defaults to using NoWave.
@@ -297,16 +296,16 @@ class TestHydro {
297296
* @param h5_file_name Name of the h5 file where hydro data is stored.
298297
* @param waves WaveBase object. Defaults to NoWave if not provided.
299298
*/
300-
TestHydro(std::vector<std::shared_ptr<chrono::ChBody>> user_bodies,
301-
std::string h5_file_name,
302-
std::shared_ptr<WaveBase> waves = std::make_shared<NoWave>());
299+
HydroForces(std::vector<std::shared_ptr<chrono::ChBody>> user_bodies,
300+
std::string h5_file_name,
301+
std::shared_ptr<WaveBase> waves = std::make_shared<NoWave>());
303302

304303
// Destructor (defined in .cpp to allow unique_ptr to incomplete type)
305-
~TestHydro();
304+
~HydroForces();
306305

307306
// Deleted copy constructor and assignment operator for safety.
308-
TestHydro(const TestHydro& old) = delete;
309-
TestHydro& operator=(const TestHydro& rhs) = delete;
307+
HydroForces(const HydroForces& old) = delete;
308+
HydroForces& operator=(const HydroForces& rhs) = delete;
310309

311310
/**
312311
* @brief Adds waves class to force calculations depending on if regular or irregular waves.
@@ -518,7 +517,7 @@ class TestHydro {
518517
std::unique_ptr<hydrochrono::hydro::ExcitationComponent> CreateExcitationComponent() const;
519518

520519
// Factory: creates HydrostaticsComponent with current equilibrium/stiffness data.
521-
// Used by both the TestHydro constructor and EnsureHydroSystemAndCoupler()
520+
// Used by both the HydroForces constructor and EnsureHydroSystemAndCoupler()
522521
// to ensure consistent construction.
523522
std::unique_ptr<hydrochrono::hydro::HydrostaticsComponent> CreateHydrostaticsComponent() const;
524523

@@ -534,20 +533,18 @@ class TestHydro {
534533
};
535534

536535
// ─────────────────────────────────────────────────────────────────────────────
537-
// Public Alias for Clarity
536+
// Backwards-Compatibility Alias
538537
// ─────────────────────────────────────────────────────────────────────────────
539538
/**
540-
* @brief Alias for TestHydro — the primary hydrodynamics façade.
539+
* @brief Backwards-compatibility alias for HydroForces.
541540
*
542-
* HydroForces is the recommended name for new code. The underlying class
543-
* is TestHydro (historical name retained for backward compatibility).
541+
* TestHydro is the historical name for the main hydrodynamics façade.
542+
* It is retained as an alias for backward compatibility with existing code.
544543
*
545-
* Usage:
546-
* @code{.cpp}
547-
* HydroForces hydro(bodies, "hydro_data.h5");
548-
* hydro.AddWaves(my_waves);
549-
* @endcode
544+
* @note Prefer `HydroForces` for new code.
545+
*
546+
* @deprecated Use HydroForces instead.
550547
*/
551-
using HydroForces = TestHydro;
548+
using TestHydro = HydroForces;
552549

553550
#endif

src/hydro/config/setup_from_yaml.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
*
66
* OVERVIEW:
77
* Implements the SetupHydroFromYAML function that connects YAML configuration
8-
* to Chrono bodies and creates a configured TestHydro instance. Handles body
8+
* to Chrono bodies and creates a configured HydroForces instance. Handles body
99
* matching, wave model creation, and convolution mode setup.
1010
*
1111
* MAIN RESPONSIBILITIES:
1212
* - Match bodies by name between YAML config and Chrono system
1313
* - Factory function for WaveBase implementations (RegularWave, IrregularWaves, NoWave)
14-
* - TestHydro initialization with matched bodies and H5 file path
14+
* - HydroForces initialization with matched bodies and H5 file path
1515
* - Configuration of radiation convolution options from YAML
1616
*
1717
* INTERACTIONS:
1818
* - Reads hydro_data (YAMLHydroData) from parser
1919
* - Accesses Chrono bodies from simulation system
2020
* - Creates WaveBase instances via factory pattern
21-
* - Configures TestHydro with convolution settings
21+
* - Configures HydroForces with convolution settings
2222
*
2323
* KEY ASSUMPTIONS:
2424
* - All bodies use same H5 file (takes first body's h5_file)
@@ -34,7 +34,7 @@
3434

3535
#include "setup_from_yaml.h"
3636
#include "config_loader.h"
37-
#include <hydroc/hydro_forces.h> // For TestHydro
37+
#include <hydroc/hydro_forces.h> // For HydroForces
3838
#include <hydroc/waves/wave_base.h>
3939
#include <hydroc/waves/regular_wave.h>
4040
#include <hydroc/waves/irregular_wave.h>
@@ -171,9 +171,9 @@ std::vector<std::shared_ptr<ChBody>> MatchBodiesByName(
171171
// ------------------------------------------------------------
172172
// SECTION: Main setup function
173173
// ------------------------------------------------------------
174-
// Orchestrates body matching, wave creation, and TestHydro initialization.
174+
// Orchestrates body matching, wave creation, and HydroForces initialization.
175175

176-
std::unique_ptr<TestHydro> SetupHydroFromYAML(
176+
std::unique_ptr<HydroForces> SetupHydroFromYAML(
177177
const YAMLHydroData& hydro_data,
178178
const std::vector<std::shared_ptr<ChBody>>& bodies,
179179
double timestep,
@@ -192,18 +192,18 @@ std::unique_ptr<TestHydro> SetupHydroFromYAML(
192192
auto wave = CreateWaveFromSettings(hydro_data.waves, matched_bodies.size(),
193193
timestep, sim_duration, ramp_duration);
194194

195-
// Create and initialize TestHydro (multibody: all matched bodies passed in)
196-
auto test_hydro = std::make_unique<TestHydro>(matched_bodies, h5_file_path, wave);
195+
// Create and initialize HydroForces (multibody: all matched bodies passed in)
196+
auto hydro_forces = std::make_unique<HydroForces>(matched_bodies, h5_file_path, wave);
197197

198-
hydroc::debug::LogDebug(std::string("Initialized TestHydro with ") + std::to_string(matched_bodies.size()) + " bodies");
198+
hydroc::debug::LogDebug(std::string("Initialized HydroForces with ") + std::to_string(matched_bodies.size()) + " bodies");
199199

200200
// System-wide convolution settings (applies to all bodies)
201201
std::string mode = hydro_data.radiation_convolution_mode;
202202
hydroc::debug::LogDebug("Parsed convolution mode: '" + mode + "'");
203203
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
204204
hydroc::debug::LogDebug("Lowercase mode: '" + mode + "'");
205205
if (mode == "tapereddirect") {
206-
test_hydro->SetRadiationConvolutionMode(hydrochrono::hydro::RadiationConvolutionMode::TaperedDirect);
206+
hydro_forces->SetRadiationConvolutionMode(hydrochrono::hydro::RadiationConvolutionMode::TaperedDirect);
207207
hydroc::debug::LogDebug("Radiation convolution mode: TaperedDirect");
208208
hydrochrono::hydro::TaperedDirectOptions opts;
209209
opts.smoothing = !hydro_data.td_smoothing.empty() ? hydro_data.td_smoothing : opts.smoothing;
@@ -218,7 +218,7 @@ std::unique_ptr<TestHydro> SetupHydroFromYAML(
218218
opts.taper_end_percent = hydro_data.td_taper_end_percent;
219219
opts.taper_final_amplitude = hydro_data.td_taper_final_amplitude;
220220
opts.export_plot_csv = hydro_data.td_export_plot_csv;
221-
test_hydro->SetTaperedDirectOptions(opts);
221+
hydro_forces->SetTaperedDirectOptions(opts);
222222

223223
// CLI inline bullets near main summary
224224
hydroc::cli::LogInfo(hydroc::cli::CreateAlignedLine("", "Convolution Mode", "TaperedDirect"));
@@ -234,12 +234,12 @@ std::unique_ptr<TestHydro> SetupHydroFromYAML(
234234
hydroc::cli::LogInfo(hydroc::cli::CreateAlignedLine("", "Conv Export CSV", (opts.export_plot_csv ? "true" : "false")));
235235
}
236236
} else {
237-
test_hydro->SetRadiationConvolutionMode(hydrochrono::hydro::RadiationConvolutionMode::Baseline);
237+
hydro_forces->SetRadiationConvolutionMode(hydrochrono::hydro::RadiationConvolutionMode::Baseline);
238238
hydroc::debug::LogDebug("Radiation convolution mode: Baseline");
239239
hydroc::cli::LogInfo(hydroc::cli::CreateAlignedLine("", "Convolution Mode", "Baseline"));
240240
}
241241

242-
return test_hydro;
242+
return hydro_forces;
243243
}
244244

245245
// ------------------------------------------------------------
@@ -248,7 +248,7 @@ std::unique_ptr<TestHydro> SetupHydroFromYAML(
248248
// Keeps file parsing and setup logic together for callers that
249249
// only know the YAML path.
250250

251-
std::unique_ptr<TestHydro> SetupHydroFromYAMLFile(
251+
std::unique_ptr<HydroForces> SetupHydroFromYAMLFile(
252252
const std::string& hydro_yaml_path,
253253
const std::vector<std::shared_ptr<ChBody>>& bodies,
254254
double timestep,

src/hydro/config/setup_from_yaml.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
* OVERVIEW:
77
* This file provides the main entry point for configuring hydrodynamic
88
* forces from YAML configuration files. It bridges parsed configuration
9-
* data to the TestHydro force computation system.
9+
* data to the HydroForces force computation system.
1010
*
1111
* MAIN RESPONSIBILITIES:
1212
* - Match Chrono bodies with YAML body configurations by name
1313
* - Create appropriate WaveBase implementations from wave settings
14-
* - Initialize TestHydro with matched bodies and wave models
14+
* - Initialize HydroForces with matched bodies and wave models
1515
* - Configure radiation convolution options (Baseline/TaperedDirect)
1616
*
1717
* INTERACTIONS:
1818
* - Takes parsed YAMLHydroData from yaml_parser
1919
* - Takes Chrono bodies from the simulation system
20-
* - Returns configured TestHydro instance ready for simulation
20+
* - Returns configured HydroForces instance ready for simulation
2121
* - Uses wave_types.h for wave model creation
2222
*
2323
* KEY ASSUMPTIONS:
@@ -43,24 +43,24 @@
4343
#include <string>
4444

4545
// Forward declarations
46-
class TestHydro;
46+
class HydroForces;
4747

4848
/**
4949
* @brief Setup hydrodynamic forces from parsed YAML data.
5050
*
5151
* This function connects parsed YAML data (from hydro.yaml) to actual hydrodynamic forces.
5252
* It builds the appropriate WaveBase subclass from hydro_data.waves, matches body names
53-
* with their corresponding HDF5 files, and initializes TestHydro with the matched bodies.
53+
* with their corresponding HDF5 files, and initializes HydroForces with the matched bodies.
5454
*
5555
* @param hydro_data Parsed hydrodynamic configuration from hydro.yaml
5656
* @param bodies Vector of Chrono bodies that may have hydrodynamic forces
5757
* @param timestep Simulation timestep (used for irregular wave setup)
5858
* @param sim_duration Simulation duration (used for irregular wave setup)
5959
* @param ramp_duration Wave ramp duration (used for irregular wave setup)
60-
* @return Unique pointer to initialized TestHydro object
60+
* @return Unique pointer to initialized HydroForces object
6161
* @throws std::runtime_error on configuration errors
6262
*/
63-
std::unique_ptr<TestHydro> SetupHydroFromYAML(
63+
std::unique_ptr<HydroForces> SetupHydroFromYAML(
6464
const YAMLHydroData& hydro_data,
6565
const std::vector<std::shared_ptr<chrono::ChBody>>& bodies,
6666
double timestep,
@@ -69,7 +69,7 @@ std::unique_ptr<TestHydro> SetupHydroFromYAML(
6969
);
7070

7171
/**
72-
* @brief Convenience overload that loads the YAML file and then sets up TestHydro.
72+
* @brief Convenience overload that loads the YAML file and then sets up HydroForces.
7373
*
7474
* Behaviour matches calling LoadHydroConfigFromYaml followed by SetupHydroFromYAML.
7575
*
@@ -78,9 +78,9 @@ std::unique_ptr<TestHydro> SetupHydroFromYAML(
7878
* @param timestep Simulation time step (used for irregular waves).
7979
* @param sim_duration Simulation duration (irregular waves).
8080
* @param ramp_duration Wave ramp duration.
81-
* @return Initialized TestHydro object.
81+
* @return Initialized HydroForces object.
8282
*/
83-
std::unique_ptr<TestHydro> SetupHydroFromYAMLFile(
83+
std::unique_ptr<HydroForces> SetupHydroFromYAMLFile(
8484
const std::string& hydro_yaml_path,
8585
const std::vector<std::shared_ptr<chrono::ChBody>>& bodies,
8686
double timestep,

0 commit comments

Comments
 (0)