@@ -36,12 +36,30 @@ int main(int argc, char* argv[]) {
3636 }
3737 }
3838
39- // Get model file names - use regression test data directory
40- std::filesystem::path DATADIR = std::filesystem::current_path ( );
39+ // Get model file names - use HydroChrono data directory
40+ std::filesystem::path DATADIR ( hydroc::getDataDir () );
4141
42- auto body1_meshfame = (DATADIR / " demos" / " geometry" / " float_cog.obj" ).lexically_normal ().generic_string ();
43- auto body2_meshfame = (DATADIR / " demos" / " geometry" / " plate_cog.obj" ).lexically_normal ().generic_string ();
44- auto h5fname = (DATADIR / " demos" / " hydroData" / " rm3.h5" ).lexically_normal ().generic_string ();
42+ std::filesystem::path body1_path = DATADIR / " demos" / " rm3" / " geometry" / " float_cog.obj" ;
43+ std::filesystem::path body2_path = DATADIR / " demos" / " rm3" / " geometry" / " plate_cog.obj" ;
44+ std::filesystem::path h5_path = DATADIR / " demos" / " rm3" / " hydroData" / " rm3.h5" ;
45+
46+ // Early sanity check so we fail with a clear message if assets are missing
47+ if (!std::filesystem::exists (body1_path)) {
48+ std::cerr << " ERROR: RM3 regular-waves test: float_cog mesh not found at " << body1_path << std::endl;
49+ return 1 ;
50+ }
51+ if (!std::filesystem::exists (body2_path)) {
52+ std::cerr << " ERROR: RM3 regular-waves test: plate_cog mesh not found at " << body2_path << std::endl;
53+ return 1 ;
54+ }
55+ if (!std::filesystem::exists (h5_path)) {
56+ std::cerr << " ERROR: RM3 regular-waves test: rm3.h5 not found at " << h5_path << std::endl;
57+ return 1 ;
58+ }
59+
60+ auto body1_meshfame = body1_path.lexically_normal ().generic_string ();
61+ auto body2_meshfame = body2_path.lexically_normal ().generic_string ();
62+ auto h5fname = h5_path.lexically_normal ().generic_string ();
4563
4664 std::cout << " Looking for mesh files in:" << std::endl;
4765 std::cout << " body1: " << body1_meshfame << std::endl;
@@ -60,11 +78,6 @@ int main(int argc, char* argv[]) {
6078 ChRealtimeStepTimer realtime_timer;
6179 double simulationDuration = 40.0 ;
6280
63- // Create user interface
64- std::shared_ptr<hydroc::gui::UI> pui = hydroc::gui::CreateUI (visualizationOn);
65-
66- hydroc::gui::UI& ui = *pui.get ();
67-
6881 // some io/viz options
6982 bool profilingOn = true ;
7083 bool saveDataOn = true ;
@@ -82,6 +95,7 @@ int main(int argc, char* argv[]) {
8295 true , // create visualization asset
8396 false // collisions
8497 );
98+ std::cout << " Created float_body1 from mesh." << std::endl;
8599
86100 // define the float's initial conditions
87101 system.Add (float_body1);
@@ -104,6 +118,7 @@ int main(int argc, char* argv[]) {
104118 true , // create visualization asset
105119 false // collisions
106120 );
121+ std::cout << " Created plate_body2 from mesh." << std::endl;
107122
108123 // Create a visualization material
109124 auto blue = chrono_types::make_shared<ChVisualMaterial>();
@@ -128,6 +143,7 @@ int main(int argc, char* argv[]) {
128143 prismatic_pto->Initialize (float_body1, plate_body2, false , ChVector3d (0 , 0 , -0.72 ), ChVector3d (0 , 0 , -21.29 ));
129144 prismatic_pto->SetDampingCoefficient (0.0 );
130145 system.AddLink (prismatic_pto);
146+ std::cout << " Added prismatic and PTO links." << std::endl;
131147
132148 // attach hydrodynamic forces to body
133149 std::vector<std::shared_ptr<ChBody>> bodies;
@@ -138,30 +154,41 @@ int main(int argc, char* argv[]) {
138154 auto my_hydro_inputs = std::make_shared<RegularWave>(static_cast <unsigned int >(bodies.size ()));
139155 my_hydro_inputs->regular_wave_amplitude_ = 1.0 ;
140156 my_hydro_inputs->regular_wave_omega_ = 2.10 ;
157+ std::cout << " Configured RegularWave inputs." << std::endl;
141158
159+ std::cout << " Constructing TestHydro..." << std::endl;
160+ // Use default NoWave; TestHydro will size it correctly for the number of bodies.
142161 TestHydro hydro_forces (bodies, h5fname);
143- hydro_forces. AddWaves (my_hydro_inputs) ;
162+ std::cout << " TestHydro constructed, adding waves... " << std::endl ;
144163
164+ try {
165+ hydro_forces.AddWaves (my_hydro_inputs);
166+ std::cout << " Waves added to TestHydro." << std::endl;
167+ } catch (const std::exception& e) {
168+ std::cerr << " Exception in TestHydro::AddWaves: " << e.what () << std::endl;
169+ return 1 ;
170+ }
145171 // for profiling
146172 auto start = std::chrono::high_resolution_clock::now ();
147173
148- // main simulation loop
149- ui.Init (&system, " RM3 - Regular Wave Test" );
150- ui.SetCamera (0 , -50 , -10 , 0 , 0 , -10 );
151-
174+ std::cout << " Entering simulation loop..." << std::endl;
175+ // main simulation loop (headless, no GUI)
176+ int step = 0 ;
152177 while (system.GetChTime () <= simulationDuration) {
153- if (ui.IsRunning (timestep) == false ) break ;
178+ if (step % 100 == 0 ) {
179+ std::cout << " Step " << step << " , t = " << system.GetChTime () << std::endl;
180+ }
154181
155- if (ui. simulationStarted ) {
156- system. DoStepDynamics (timestep) ;
182+ system. DoStepDynamics (timestep);
183+ ++step ;
157184
158- // append data to output vector
159- time_vector.push_back (system.GetChTime ());
160- float_heave_position.push_back (float_body1->GetPos ().z ());
161- float_drift_position.push_back (float_body1->GetPos ().x ());
162- plate_heave_position.push_back (plate_body2->GetPos ().z ());
163- }
185+ // append data to output vector
186+ time_vector.push_back (system.GetChTime ());
187+ float_heave_position.push_back (float_body1->GetPos ().z ());
188+ float_drift_position.push_back (float_body1->GetPos ().x ());
189+ plate_heave_position.push_back (plate_body2->GetPos ().z ());
164190 }
191+ std::cout << " Exited simulation loop at t = " << system.GetChTime () << std::endl;
165192
166193 // for profiling
167194 auto end = std::chrono::high_resolution_clock::now ();
0 commit comments