Skip to content

Commit 207f3c1

Browse files
committed
Fix compilation errors and clean up stale files
Fix missing declarations and struct definitions needed for state-space radiation feature to compile. Remove stale demo duplicate and move analysis/comparison tools to simocean-labs.
1 parent fcb9865 commit 207f3c1

9 files changed

Lines changed: 91 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ set(HC_HEADERS
322322
${PROJECT_BINARY_DIR}/hydroc/version.h
323323
include/hydroc/hydro_system.h
324324
include/hydroc/helper.h
325-
include/hydroc/hydro_forces.h
326325
include/hydroc/logging.h
327326
include/hydroc/config/hydro_config.h
328327
include/hydroc/core/force_component.h

include/hydroc/config/hydro_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ struct YAMLHydroData {
8888
double td_taper_end_percent = 1.0; // end taper at 100% of total time series
8989
double td_taper_final_amplitude = 0.0; // final amplitude as fraction of original (0.0 = zero, 1.0 = no change)
9090
bool td_export_plot_csv = false; // dump before/after CSV summaries (false by default)
91+
92+
// ─────────────────────────────────────────────────────────────────────────
93+
// Diagnostics
94+
// ─────────────────────────────────────────────────────────────────────────
95+
bool output_kernel_fit = false; // write kernel fit diagnostics to HDF5
9196
};
9297

9398
#endif // HYDROC_CONFIG_HYDRO_CONFIG_H

include/hydroc/core/hydro_forces.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ class HydroForces {
110110
*/
111111
bool ProfilingEnabled() const { return profiling_enabled_; }
112112

113+
/**
114+
* @brief Access the internal force components (read-only).
115+
* @return Const reference to the vector of force components
116+
*/
117+
const std::vector<std::unique_ptr<IHydroForceComponent>>& GetComponents() const {
118+
return components_;
119+
}
120+
113121
private:
114122
int num_bodies_;
115123
std::vector<std::unique_ptr<IHydroForceComponent>> components_;

include/hydroc/hydro_system.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,28 @@ class HydroSystem {
409409
*/
410410
void SetTaperedDirectOptions(const hydrochrono::hydro::TaperedDirectOptions& opts);
411411

412+
/**
413+
* @brief Enable or disable kernel fit diagnostic output.
414+
*
415+
* When enabled and using state-space radiation, kernel fit quality data
416+
* can be retrieved after the first force evaluation and exported to HDF5.
417+
*
418+
* @param enabled True to enable kernel fit diagnostics
419+
*/
420+
void SetOutputKernelFit(bool enabled);
421+
422+
/**
423+
* @brief Check if kernel fit diagnostics are available.
424+
* @return True if state-space radiation is active and diagnostics are ready
425+
*/
426+
bool HasKernelFitDiagnostics() const;
427+
428+
/**
429+
* @brief Get kernel fit diagnostics for all bodies.
430+
* @return Vector of KernelFitDiagnostics (one per body)
431+
*/
432+
std::vector<hydrochrono::hydro::KernelFitDiagnostics> GetKernelFitDiagnostics() const;
433+
412434
/**
413435
* @brief Set the directory where diagnostics (e.g., CSVs) should be written.
414436
*/
@@ -532,10 +554,11 @@ class HydroSystem {
532554
// Radiation configuration (uses canonical types from radiation module)
533555
// ─────────────────────────────────────────────────────────────────────────
534556

535-
// Top-level method selection (state-space not yet implemented)
557+
// Top-level method selection
536558
hydrochrono::hydro::RadiationMethod radiation_method_ =
537559
hydrochrono::hydro::RadiationMethod::kRirfConvolution;
538560
hydrochrono::hydro::StateSpaceOptions state_space_opts_;
561+
bool output_kernel_fit_ = false;
539562

540563
// Convolution kernel preprocessing (only applies when method == kRirfConvolution)
541564
hydrochrono::hydro::RadiationConvolutionMode convolution_mode_;

include/hydroc/io/simulation_export.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <vector>
1818
#include <string>
1919

20+
namespace hydrochrono::hydro { struct KernelFitDiagnostics; }
21+
2022
namespace chrono { class ChSystem; class ChBody; class ChLink; }
2123

2224
namespace hydroc {
@@ -162,6 +164,13 @@ class SimulationExporter {
162164
double dt_s,
163165
double time_final_s);
164166

167+
/**
168+
* @brief Write radiation kernel fit diagnostics to HDF5.
169+
* @param diagnostics Vector of per-body kernel fit diagnostics
170+
*/
171+
void WriteRadiationDiagnostics(
172+
const std::vector<hydrochrono::hydro::KernelFitDiagnostics>& diagnostics);
173+
165174
private:
166175
struct Impl;
167176
std::unique_ptr<Impl> impl_;

include/hydroc/radiation/radiation_types.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,42 @@ struct StateSpaceOptions {
124124
int r2_num_samples = 50;
125125
};
126126

127+
// ─────────────────────────────────────────────────────────────────────────────
128+
// Kernel Fit Diagnostics (for state-space radiation)
129+
// ─────────────────────────────────────────────────────────────────────────────
130+
131+
struct DofPairInfo {
132+
int dof_i = 0;
133+
int dof_j = 0;
134+
double r_squared = 0.0;
135+
int state_order = 0;
136+
int num_exp_modes = 0;
137+
int num_osc_modes = 0;
138+
};
139+
140+
} // namespace hydrochrono::hydro
141+
142+
// KernelFitDiagnostics is defined outside the namespace to avoid Eigen
143+
// dependency in radiation_types.h when only forward-declared.
144+
#include <Eigen/Dense>
145+
#include <vector>
146+
147+
namespace hydrochrono::hydro {
148+
149+
struct KernelFitDiagnostics {
150+
std::string body_name;
151+
int body_index = 0;
152+
int num_dofs = 0;
153+
double min_r2 = 0.0;
154+
double max_r2 = 0.0;
155+
double mean_r2 = 0.0;
156+
int total_modes = 0;
157+
Eigen::VectorXd time;
158+
Eigen::MatrixXd K_actual;
159+
Eigen::MatrixXd K_fit;
160+
std::vector<DofPairInfo> dof_pairs;
161+
};
162+
127163
} // namespace hydrochrono::hydro
128164

129165
#endif // HYDROC_RADIATION_TYPES_H

src/hydro/force_components/radiation_ss_component.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class RadiationStateSpaceComponent : public IHydroForceComponent {
115115
double min_r2() const;
116116
double max_r2() const;
117117

118+
bool HasDiagnostics() const { return false; }
119+
std::vector<KernelFitDiagnostics> GetDiagnostics() const { return {}; }
120+
118121
private:
119122
int num_bodies_;
120123
int num_dofs_; ///< Total DOFs = 6 * num_bodies

src/hydro/hydro_system.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ void HydroSystem::SetTaperedDirectOptions(const hydrochrono::hydro::TaperedDirec
476476
InvalidateRadiationComponent(); // Invalidate component to recreate with new settings
477477
}
478478

479+
void HydroSystem::SetOutputKernelFit(bool enabled) {
480+
output_kernel_fit_ = enabled;
481+
}
482+
479483
void HydroSystem::EnsureRadiationComponent() {
480484
if (radiation_component_) {
481485
return; // Already created
@@ -527,7 +531,7 @@ std::unique_ptr<hydrochrono::hydro::IHydroForceComponent> HydroSystem::CreateRad
527531
if (radiation_method_ == hydrochrono::hydro::RadiationMethod::kStateSpace) {
528532
// State-space approximation: O(1) per timestep
529533
return std::make_unique<hydrochrono::hydro::RadiationStateSpaceComponent>(
530-
file_info_, num_bodies_, state_space_opts_, output_kernel_fit_);
534+
file_info_, num_bodies_, state_space_opts_);
531535
}
532536

533537
// Default: RIRF convolution

tests/regression/sphere/test_sphere_irreg_waves_eta_consistency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <chrono/physics/ChSystemNSC.h>
2323

2424
#include <hydroc/helper.h>
25-
#include <hydroc/hydro_forces.h>
25+
#include <hydroc/hydro_system.h>
2626

2727
using namespace chrono;
2828

0 commit comments

Comments
 (0)