Skip to content

Commit 185e4b7

Browse files
committed
Merge branch 'main' into feature/chrono-fsi-interface
2 parents ef6a741 + 314f1e2 commit 185e4b7

90 files changed

Lines changed: 4835 additions & 5630 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020
# ===============================================================================
2121

2222
project(HydroChrono
23-
VERSION 0.3.2
23+
VERSION 0.4.0
2424
DESCRIPTION "Hydrodynamics for Project Chrono."
2525
LANGUAGES CXX
2626
)
@@ -319,29 +319,58 @@ list(APPEND HC_INCLUDES_BUILD ${PROJECT_BINARY_DIR})
319319

320320
# -- Main HydroChrono Library --
321321
set(HC_SOURCES
322-
src/h5fileinfo.cpp
323-
src/chloadaddedmass.cpp
324-
src/hydro_forces.cpp
325-
src/helper.cpp
326-
src/wave_types.cpp
327-
# src/simulation_logging.cpp # removed in streamlined logging
328-
src/hydro_yaml_parser.cpp
329-
src/setup_hydro_from_yaml.cpp
330-
# logging consolidated: coordinator + CLI (logging.cpp), backend (logger_backend.cpp)
331-
src/utils/logger_backend.cpp
332-
src/utils/logging.cpp
333-
src/h5_writer.cpp
334-
src/simulation_exporter.cpp
322+
# IO module (consolidated under src/hydro/io/)
323+
src/hydro/io/h5_reader.cpp
324+
src/hydro/io/h5_writer.cpp
325+
src/hydro/io/simulation_export.cpp
326+
# Config/YAML module (consolidated under src/hydro/config/)
327+
src/hydro/config/yaml_parser.cpp
328+
src/hydro/config/config_loader.cpp
329+
src/hydro/config/setup_from_yaml.cpp
330+
src/hydro/config/yaml_discovery.cpp
331+
# Core facade and utilities
332+
src/hydro/hydro_system.cpp
333+
src/hydro/utils/helper.cpp
334+
# Hydro modules
335+
src/hydro/waves/wave_base.cpp
336+
src/hydro/waves/wave_utilities.cpp
337+
src/hydro/waves/regular_wave.cpp
338+
src/hydro/waves/irregular_wave.cpp
339+
src/hydro/radiation/radiation_rirf_processing.cpp
340+
src/hydro/radiation/radiation_rirf_convolution.cpp
341+
src/hydro/core/hydro_forces.cpp
342+
# Chrono coupling layer (bridges Chrono physics with Chrono-free core)
343+
src/hydro/chrono/chrono_state_utils.cpp
344+
src/hydro/chrono/chrono_hydro_coupler.cpp
345+
src/hydro/chrono/added_mass.cpp
346+
src/hydro/force_components/hydrostatics_component.cpp
347+
src/hydro/force_components/radiation_component.cpp
348+
src/hydro/force_components/excitation_component.cpp
349+
# Logging module (consolidated under src/hydro/logging/)
350+
src/hydro/logging/logger_backend.cpp
351+
src/hydro/logging/logging.cpp
335352
)
336353

337354
set(HC_HEADERS
338355
${PROJECT_BINARY_DIR}/hydroc/config.h
339356
${PROJECT_BINARY_DIR}/hydroc/version.h
340-
include/hydroc/h5_writer.h
341-
include/hydroc/h5fileinfo.h
342357
include/hydroc/helper.h
343358
include/hydroc/hydro_forces.h
344359
include/hydroc/logging.h
360+
include/hydroc/config/hydro_config.h
361+
include/hydroc/core/force_component.h
362+
include/hydroc/core/hydro_forces.h
363+
include/hydroc/core/hydro_types.h
364+
include/hydroc/core/system_state.h
365+
include/hydroc/coupling/added_mass.h
366+
include/hydroc/coupling/chrono_coupler.h
367+
include/hydroc/io/h5_reader.h
368+
include/hydroc/io/h5_writer.h
369+
include/hydroc/io/simulation_export.h
370+
include/hydroc/radiation/radiation_types.h
371+
include/hydroc/waves/irregular_wave.h
372+
include/hydroc/waves/regular_wave.h
373+
include/hydroc/waves/wave_base.h
345374
)
346375

347376
# Create the library target and configure it

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<p align="center">
33
<img src="docs/assets/img/hydrochrono_banner.png" />
44
<br/>
5-
<a href="https://github.com/NREL/HydroChrono/releases"><img src="https://img.shields.io/badge/version-v0.3-blue.svg" /></a>
5+
<a href="https://github.com/NREL/HydroChrono/releases"><img src="https://img.shields.io/badge/version-v0.4-blue.svg" /></a>
66
<a href="#"><img src="https://img.shields.io/badge/status-Prototype-orange.svg" /></a>
77
</p>
88

9-
> ⚠️ HydroChrono is under active development (`v0.3` prototype). This early release focuses on a YAML‑driven CLI and portable HDF5 outputs so you can try the code and share feedback. Expect rapid iteration over the coming year (inc. more advanced PTO, control, mooring & hydrodynamics) — please get in touch if you have any issues or feature requests.
9+
> ⚠️ HydroChrono is under active development (`v0.4` prototype). This early release focuses on a YAML‑driven CLI and portable HDF5 outputs so you can try the code and share feedback. Expect rapid iteration over the coming year (inc. more advanced PTO, control, mooring & hydrodynamics) — please get in touch if you have any issues or feature requests.
1010
1111

1212
HydroChrono (Hydrodynamics for Project Chrono) is a hydrodynamics simulation toolkit built on [Project Chrono](https://projectchrono.org/). It is designed for simulating wave energy converters (WECs) and other complex ocean systems, and is **100% free and open‑source** end‑to‑end — no proprietary dependencies required. This repo ships a prototype, YAML‑driven CLI app for running simulations and exporting portable results.

app/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ message(STATUS "Add run_hydrochrono program")
22

33
add_executable(run_hydrochrono
44
run_hydrochrono.cpp
5-
../src/hydrochrono_runner/run_hydrochrono_from_yaml.cpp
5+
../include/hydroc/runner/run_from_yaml.h
6+
../src/hydro/runner/run_from_yaml.cpp
67
../src/utils/misc_options.cpp
7-
../src/utils/setup_parser.cpp
88
)
99

1010
# Set C++ standard

app/run_hydrochrono.cpp

Lines changed: 55 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* @brief CLI entrypoint for the HydroChrono YAML-based runner
44
*/
55

6-
#include <hydroc/hydrochrono_runner/run_hydrochrono_from_yaml.h>
6+
#include <hydroc/runner/run_from_yaml.h>
77
#include <hydroc/config.h>
88
#include <hydroc/version.h>
99
#include "../src/utils/misc_options.h"
1010
#include <hydroc/logging.h>
1111
#include <string>
1212
#include <filesystem>
13+
#include <iostream>
1314

1415
#ifdef _WIN32
1516
#include <windows.h>
@@ -76,15 +77,15 @@ struct CLIArgs {
7677
std::string sim_file;
7778
bool nogui = false;
7879
bool log = false;
79-
bool nobanner = false; // NEW: Disable banner display
80-
bool quiet = false; // NEW: Quiet mode (minimal output)
81-
bool debug = false; // NEW: Enable detailed simulation diagnostics
82-
bool trace = false; // NEW: Enable step-by-step simulation tracing
83-
std::string output_h5; // NEW: Export HDF5 results path
84-
bool h5_verbose = false; // NEW: HDF5 verbose diagnostics
85-
std::string h5_tag; // NEW: Optional tag appended to filename
86-
bool fail_fast = false; // NEW: Stop on first failure during sweep
87-
bool profile = false; // NEW: Enable runtime profiling summary
80+
bool nobanner = false; // Disable banner display
81+
bool quiet = false; // Quiet mode (minimal output)
82+
bool debug = false; // Enable detailed simulation diagnostics
83+
bool trace = false; // Enable step-by-step simulation tracing
84+
std::string output_h5; // Export HDF5 results path
85+
bool h5_verbose = false; // HDF5 verbose diagnostics
86+
std::string h5_tag; // Optional tag appended to filename
87+
bool fail_fast = false; // Stop on first failure during sweep
88+
bool profile = false; // Enable runtime profiling summary
8889
};
8990

9091
static CLIArgs ParseArguments(int argc, char* argv[]) {
@@ -165,51 +166,60 @@ int main(int argc, char* argv[]) {
165166
// Configure UTF-8 console output on Windows (must be first!)
166167
// ---------------------------------------------------------------------
167168
#ifdef _WIN32
168-
// Enable UTF-8 console output on Windows
169169
SetConsoleOutputCP(CP_UTF8);
170-
std::ios_base::sync_with_stdio(false);
171170
#endif
172171

173172
// Check for hidden options first (before any other processing)
174173
if (hydroc::misc::HandleHiddenOptions(argc, argv)) {
175174
return 0;
176175
}
177176

177+
// -------------------------------------------------------------------------
178+
// Initialize logging early so all CLI output uses the nice formatting
179+
// Wrapped in try/catch to report initialization failures clearly
180+
// -------------------------------------------------------------------------
181+
try {
182+
hydroc::LoggingConfig cfg;
183+
cfg.enable_cli_output = true;
184+
cfg.enable_file_output = false;
185+
cfg.console_level = hydroc::LogLevel::Info;
186+
cfg.file_level = hydroc::LogLevel::Info;
187+
(void)hydroc::Initialize(cfg); // Ignore return value; failures throw
188+
} catch (const std::exception& e) {
189+
std::cerr << "FATAL: Exception during logging initialization: " << e.what() << std::endl;
190+
return 1;
191+
} catch (...) {
192+
std::cerr << "FATAL: Unknown exception during logging initialization" << std::endl;
193+
return 1;
194+
}
195+
178196
// Check for help/version/info flags first (before requiring input directory)
179197
for (int i = 1; i < argc; i++) {
180198
std::string arg = argv[i];
181199
if (arg == "--help" || arg == "-h") {
182-
hydroc::LoggingConfig cfg;
183-
cfg.enable_cli_output = true;
184-
cfg.enable_file_output = false;
185-
cfg.console_level = hydroc::LogLevel::Info;
186-
cfg.file_level = hydroc::LogLevel::Info;
187-
hydroc::Initialize(cfg);
188200
PrintHelp(argv[0]);
189201
hydroc::Shutdown();
190202
return 0;
191203
} else if (arg == "--version" || arg == "-v") {
192-
hydroc::LoggingConfig cfg;
193-
cfg.enable_cli_output = true;
194-
cfg.enable_file_output = false;
195-
cfg.console_level = hydroc::LogLevel::Info;
196-
cfg.file_level = hydroc::LogLevel::Info;
197-
hydroc::Initialize(cfg);
198204
PrintVersion();
199205
hydroc::Shutdown();
200206
return 0;
201207
} else if (arg == "--info" || arg == "-i") {
202-
hydroc::LoggingConfig cfg;
203-
cfg.enable_cli_output = true;
204-
cfg.enable_file_output = false;
205-
cfg.console_level = hydroc::LogLevel::Info;
206-
cfg.file_level = hydroc::LogLevel::Info;
207-
hydroc::Initialize(cfg);
208208
PrintInfo();
209209
hydroc::Shutdown();
210210
return 0;
211211
}
212212
}
213+
214+
// Handle "no arguments" case
215+
if (argc == 1) {
216+
hydroc::cli::LogError("ERROR: Input directory or setup file is required");
217+
hydroc::cli::ShowEmptyLine();
218+
hydroc::cli::LogInfo(std::string("Usage: ") + argv[0] + " [options] <input_directory_or_setup_file>");
219+
hydroc::cli::LogInfo("Use --help for more information.");
220+
hydroc::Shutdown();
221+
return 1;
222+
}
213223

214224
// Parse command line arguments
215225
CLIArgs args = ParseArguments(argc, argv);
@@ -220,85 +230,61 @@ int main(int argc, char* argv[]) {
220230
hydroc::cli::ShowEmptyLine();
221231
hydroc::cli::LogInfo(std::string("Usage: ") + argv[0] + " [options] <input_directory_or_setup_file>");
222232
hydroc::cli::LogInfo("Use --help for more information.");
233+
hydroc::Shutdown();
223234
return 1;
224235
}
225236

226237
// Check if input is a setup file or directory
227238
std::filesystem::path input_path(args.input_directory);
228239
if (std::filesystem::exists(input_path)) {
229240
if (std::filesystem::is_regular_file(input_path)) {
230-
// Check if it's a setup file
231241
if (input_path.extension() == ".yaml") {
232242
const std::string filename = input_path.filename().string();
233243
const std::string suffix = ".setup.yaml";
234244
if (filename.length() >= suffix.length() &&
235245
filename.compare(filename.length() - suffix.length(), suffix.length(), suffix) == 0) {
236-
// Convert setup file path to directory path
237246
args.input_directory = input_path.parent_path().string();
238247
hydroc::cli::LogInfo(std::string("Loaded setup file: ") + input_path.string());
239248
} else {
240249
hydroc::cli::LogError("ERROR: File provided is not a valid .setup.yaml file");
241250
hydroc::cli::LogInfo(std::string(" Path: ") + args.input_directory);
242251
hydroc::cli::LogInfo(" Expected: Directory or any file ending in '.setup.yaml'");
252+
hydroc::Shutdown();
243253
return 1;
244254
}
245255
}
246256
} else if (!std::filesystem::is_directory(input_path)) {
247257
hydroc::cli::LogError("ERROR: Path is neither a directory nor a regular file");
248258
hydroc::cli::LogInfo(std::string(" Path: ") + args.input_directory);
259+
hydroc::Shutdown();
249260
return 1;
250261
}
251262
} else {
252263
hydroc::cli::LogError("ERROR: Input path does not exist");
253264
hydroc::cli::LogInfo(std::string(" Path: ") + args.input_directory);
265+
hydroc::Shutdown();
254266
return 1;
255267
}
256268

257-
// Note: Banner will be rendered by the YAML runner
269+
// Shutdown logging - the runner will reinitialize it
270+
hydroc::Shutdown();
258271

259272
// Prepare arguments for the YAML runner
260273
std::vector<std::string> runner_args;
261-
runner_args.push_back(argv[0]); // program name
262-
263-
// Add input directory
274+
runner_args.push_back(argv[0]);
264275
runner_args.push_back(args.input_directory);
265276

266-
// Add optional flags
267-
if (args.nogui) {
268-
runner_args.push_back("--nogui");
269-
}
270-
271-
// Add logging flag if requested
272-
if (args.log) {
273-
runner_args.push_back("--log");
274-
}
275-
276-
// Add new CLI options
277-
if (args.nobanner) {
278-
runner_args.push_back("--nobanner");
279-
}
280-
281-
if (args.quiet) {
282-
runner_args.push_back("--quiet");
283-
}
284-
285-
if (args.debug) {
286-
runner_args.push_back("--debug");
287-
}
288-
289-
if (args.trace) {
290-
runner_args.push_back("--trace");
291-
}
292-
293-
if (args.profile) {
294-
runner_args.push_back("--profile");
295-
}
296-
277+
if (args.nogui) runner_args.push_back("--nogui");
278+
if (args.log) runner_args.push_back("--log");
279+
if (args.nobanner) runner_args.push_back("--nobanner");
280+
if (args.quiet) runner_args.push_back("--quiet");
281+
if (args.debug) runner_args.push_back("--debug");
282+
if (args.trace) runner_args.push_back("--trace");
283+
if (args.profile) runner_args.push_back("--profile");
297284
if (!args.model_file.empty()) {
298285
runner_args.push_back("--model_file");
299286
runner_args.push_back(args.model_file);
300287
}
301-
302288
if (!args.sim_file.empty()) {
303289
runner_args.push_back("--sim_file");
304290
runner_args.push_back(args.sim_file);
@@ -307,9 +293,7 @@ int main(int argc, char* argv[]) {
307293
runner_args.push_back("--output-h5");
308294
runner_args.push_back(args.output_h5);
309295
}
310-
if (args.fail_fast) {
311-
runner_args.push_back("--fail-fast");
312-
}
296+
if (args.fail_fast) runner_args.push_back("--fail-fast");
313297

314298
// Convert to argc/argv format for the runner
315299
std::vector<char*> runner_argv;

demos/DeepCWind/demo_DeepCWind_decay.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6+
#include <chrono/physics/ChSystemSMC.h>
7+
#include <chrono/physics/ChBodyEasy.h>
68

79
#include <chrono> // std::chrono::high_resolution_clock::now
810
#include <iomanip> // std::setprecision

demos/f3of/demo_F3OF_DT1.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6+
#include <chrono/physics/ChSystemSMC.h>
7+
#include <chrono/physics/ChBodyEasy.h>
68

79
#include <chrono> // std::chrono::high_resolution_clock::now
810
#include <iomanip> // std::setprecision

demos/f3of/demo_F3OF_DT2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6+
#include <chrono/physics/ChSystemSMC.h>
7+
#include <chrono/physics/ChBodyEasy.h>
68

79
#include <chrono> // std::chrono::high_resolution_clock::now
810
#include <iomanip> // std::setprecision

demos/f3of/demo_F3OF_DT3.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6-
#include <chrono/physics/ChLinkMate.h> // fixed body uses link
6+
#include <chrono/physics/ChSystemSMC.h>
7+
#include <chrono/physics/ChBodyEasy.h>
78

89
#include <chrono> // std::chrono::high_resolution_clock::now
910
#include <iomanip> // std::setprecision

demos/oswec/demo_oswec_decay.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6-
#include <chrono/physics/ChLinkMate.h> // fixed body uses link
6+
#include <chrono/physics/ChSystemNSC.h>
7+
#include <chrono/physics/ChBodyEasy.h>
78

89
#include <chrono> // std::chrono::high_resolution_clock::now
910
#include <iomanip> // std::setprecision

demos/oswec/demo_oswec_reg_waves.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <hydroc/hydro_forces.h>
44

55
#include <chrono/core/ChRealtimeStep.h>
6-
#include <chrono/physics/ChLinkMate.h> // fixed body uses link
6+
#include <chrono/physics/ChSystemNSC.h>
7+
#include <chrono/physics/ChBodyEasy.h>
78

89
#include <chrono> // std::chrono::high_resolution_clock::now
910
#include <iomanip> // std::setprecision

0 commit comments

Comments
 (0)