Skip to content

Commit 978727f

Browse files
committed
Merge branch 'main' into feature/vsg-visualization
2 parents 5b97897 + b341418 commit 978727f

18 files changed

Lines changed: 250 additions & 161 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,11 @@ target_include_directories(HydroChronoGUI
443443
"$<INSTALL_INTERFACE:include>"
444444
)
445445

446+
if(MSVC)
447+
target_compile_options(HydroChronoGUI PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/wd4996>) # deprecated function or class member
448+
target_compile_options(HydroChronoGUI PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/wd4458>) # declaration hides class member
449+
endif()
450+
446451
set_target_properties(HydroChronoGUI PROPERTIES POSITION_INDEPENDENT_CODE ON)
447452
target_link_libraries(HydroChronoGUI
448453
PUBLIC

data/reference_data/rm3/hc_ref_rm3_decay.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Time (s) Float Heave (m) Plate Heave (m)
1+
Time(s) Float_Heave(m) Plate_Heave(m)
22
0.01 -0.62000515 -21.29000007
33
0.02 -0.62002233 -21.29000032
44
0.03 -0.62005382 -21.29000078

include/hydroc/core/hydro_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace hydrochrono::hydro {
2323
* Force vector [Fx, Fy, Fz, Mx, My, Mz] for surge, sway, heave,
2424
* roll, pitch, yaw degrees of freedom.
2525
*/
26-
using GeneralizedForce = Eigen::VectorXd;
26+
using GeneralizedForce = Eigen::VectorXd; //// RADU - why is this not an Eigen vector of fixed size 6, or better yet 2 vectors?
2727

2828
/**
2929
* @brief Forces for all bodies in the system.

include/hydroc/helper.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,20 @@
33

44
#pragma once
55

6-
#include <Eigen/Dense> // Need for the container function
76
#include <fstream>
87
#include <iostream>
9-
#include <hydroc/logging.h>
108
#include <string>
119
#include <filesystem> // C++17
1210

11+
#include <Eigen/Dense> // Need for the container function
12+
13+
#include <hydroc/logging.h>
14+
15+
//// RADU - why not use constants from Chrono?
1316
#ifndef M_PI
1417
#define M_PI 3.14159265358979323846
1518
#endif
1619

17-
/**@brief Returns last index of vector element below value.
18-
*
19-
* @param value Input value
20-
* @param ticks Array of ticks from which to find lower-bound index (assuming ascending order)
21-
*
22-
*/
23-
size_t get_lower_index(double value, const std::vector<double>& ticks);
24-
2520
/**@brief Base namespace for HydroChrono library
2621
*
2722
*/

include/hydroc/io/h5_reader.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class H5File;
3030

3131
class H5FileInfo;
3232

33+
//// RADU - these should not be in the global namespace!
34+
3335
// contains "chunked" data from the h5 file, generated from H5FileInfo class
3436
class HydroData {
3537
public:
@@ -78,9 +80,10 @@ class HydroData {
7880
std::vector<IrregularWaveInfo> irreg_wave_data_;
7981
friend H5FileInfo;
8082
void resize(int num_bodies);
81-
HydroData() = default;
8283

8384
public:
85+
HydroData() = default;
86+
8487
// getter function naming conventions: put Matrix, Vector, or Val at end to denote return type, always put body_num
8588
// argument first, body_num is always 0 indexed, one line return types can be defined here and not in cpp
8689

include/hydroc/logging.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
1313
*/
1414

15+
//// RADU - does this need to be public?
16+
1517
#pragma once
1618

1719
#include <cstddef>

include/hydroc/waves/irregular_wave.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,8 @@ class IrregularWaves : public WaveBase {
4848
void AddH5Data(std::vector<HydroData::IrregularWaveInfo>& irreg_h5_data, HydroData::SimulationParameters& sim_data);
4949

5050
double GetElevation(const Eigen::Vector3d& position, double time) override;
51-
Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time) override;
52-
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time) override;
53-
Eigen::Vector2d GetElevationGradientXY(const Eigen::Vector3d& position, double time) const override;
54-
55-
/// @brief Compute elevation using only the first N frequency components (for visualization).
56-
///
57-
/// This method is optimized for real-time visualization where visual quality can be
58-
/// traded for performance. Using fewer components (e.g., 50-100 instead of 1000)
59-
/// provides a significant speedup while maintaining a visually acceptable wave surface.
60-
///
61-
/// @param position World coordinates [m]. Only x-coordinate is used (waves propagate in +X).
62-
/// @param time Simulation time [s].
63-
/// @param max_components Maximum number of frequency components to use.
64-
/// If <= 0 or >= num_components, all components are used.
65-
/// @return Free-surface elevation [m] above mean water level.
66-
///
67-
/// @note Physics calculations should use GetElevation() which uses all components.
68-
double GetElevationForVisualization(const Eigen::Vector3d& position, double time, int max_components) const;
51+
Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time, double elevation) override;
52+
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time, double elevation) override;
6953

7054
private:
7155
IrregularWaveParams params_;

include/hydroc/waves/regular_wave.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,34 @@
1414
// Forward declaration for internal utilities (not exposed in public API)
1515
// Wave utilities are internal implementation details
1616

17+
struct RegularWaveParams {
18+
unsigned int num_bodies_;
19+
double regular_wave_amplitude_;
20+
double regular_wave_omega_;
21+
double regular_wave_phase_ = 0.0;
22+
bool wave_stretching_ = true;
23+
};
24+
1725
class RegularWave : public WaveBase {
1826
public:
1927
RegularWave();
2028
explicit RegularWave(unsigned int num_b);
29+
explicit RegularWave(const RegularWaveParams& params);
2130

2231
void Initialize() override;
2332
Eigen::VectorXd GetForceAtTime(double t) override;
2433
WaveMode GetWaveMode() override { return mode_; }
2534

26-
double regular_wave_amplitude_ = 0.0;
27-
double regular_wave_omega_ = 0.0;
28-
double regular_wave_phase_ = 0.0;
29-
bool wave_stretching_ = true;
35+
//// RADU - eliminate these and use a RegularWaveParams struct (consistent with IrregularWaves)
36+
double regular_wave_amplitude_;
37+
double regular_wave_omega_;
38+
double regular_wave_phase_ = 0.0;
3039

3140
void AddH5Data(std::vector<HydroData::RegularWaveInfo>& reg_h5_data, HydroData::SimulationParameters& sim_data);
3241

3342
double GetElevation(const Eigen::Vector3d& position, double time) override;
34-
Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time) override;
35-
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time) override;
36-
Eigen::Vector2d GetElevationGradientXY(const Eigen::Vector3d& position, double time) const override;
43+
Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time, double elevation) override;
44+
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time, double elevation) override;
3745

3846
private:
3947
unsigned int num_bodies_ = 0;

include/hydroc/waves/wave_base.h

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
#include <Eigen/Dense>
1010

11+
//// RADU - why is this not in some namespace?
12+
//// - should these classes be DLL-exported (e.g., to allow AddWave(NoWave))?
13+
//// if not, why is this a public headers?
14+
1115
enum class WaveMode {
1216
noWaveCIC = 0,
1317
regular = 1,
@@ -34,48 +38,38 @@ class WaveBase {
3438
public:
3539
virtual ~WaveBase() = default;
3640

37-
virtual void Initialize() = 0;
38-
virtual Eigen::VectorXd GetForceAtTime(double t) = 0;
39-
virtual WaveMode GetWaveMode() = 0;
40-
virtual double GetElevation(const Eigen::Vector3d& position, double time) = 0;
41-
virtual Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time) = 0;
42-
virtual Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time) = 0;
41+
virtual void Initialize() = 0;
42+
virtual Eigen::VectorXd GetForceAtTime(double t) = 0;
43+
virtual WaveMode GetWaveMode() = 0;
44+
virtual double GetElevation(const Eigen::Vector3d& position, double time) = 0;
45+
virtual Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time, double elevation) = 0;
46+
virtual Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time, double elevation) = 0;
47+
48+
Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time);
49+
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d& position, double time);
4350

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-
}
51+
double mwl_ = 0.0;
52+
double g_ = 9.81;
53+
double water_depth_ = 0.0;
54+
bool wave_stretching_ = true;
55+
};
6256

63-
double mwl_ = 0.0;
64-
double g_ = 9.81;
65-
double water_depth_ = 0.0;
57+
struct NoWaveParams {
58+
unsigned int num_bodies_;
6659
};
6760

6861
class NoWave : public WaveBase {
6962
public:
7063
NoWave();
7164
explicit NoWave(unsigned int num_b);
65+
explicit NoWave(const NoWaveParams& params);
7266

7367
void Initialize() override {}
7468
Eigen::VectorXd GetForceAtTime(double t) override;
7569
WaveMode GetWaveMode() override { return mode_; }
7670
double GetElevation(const Eigen::Vector3d&, double) override { return 0.0; }
77-
Eigen::Vector3d GetVelocity(const Eigen::Vector3d&, double) override { return Eigen::Vector3d(0.0, 0.0, 0.0); }
78-
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d&, double) override { return Eigen::Vector3d(0.0, 0.0, 0.0); }
71+
Eigen::Vector3d GetVelocity(const Eigen::Vector3d&, double, double) override { return Eigen::Vector3d(0.0, 0.0, 0.0); }
72+
Eigen::Vector3d GetAcceleration(const Eigen::Vector3d&, double, double) override { return Eigen::Vector3d(0.0, 0.0, 0.0); }
7973

8074
private:
8175
unsigned int num_bodies_ = 0;

src/hydro/chrono/chrono_state_utils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ void BuildSystemStateFromChronoBodies(
1818
for (const auto& body : bodies) {
1919
BodyState body_state;
2020

21+
//// RADU - why not simply do:
22+
////body_state.position = body->GetPos().eigen();
23+
////body_state.orientation_rpy = body->GetRot().GetCardanAnglesXYZ().eigen();
24+
////body_state.linear_velocity = body->GetPosDt().eigen();
25+
////body_state.angular_velocity = body->GetAngVelParent().eigen();
26+
2127
// Extract position and orientation
2228
const chrono::ChVector3d position_world = body->GetPos();
2329
const chrono::ChVector3d rotation_rpy = body->GetRot().GetCardanAnglesXYZ();

0 commit comments

Comments
 (0)