Skip to content

Commit 0741e77

Browse files
committed
Consolidate config/YAML under src/hydro/config
move all YAML/config logic into a dedicated config module. src/hydro/io/hydro_config_types.h -> include/hydroc/config/hydro_config.h Moved YAML implementation into src/hydro/config/ Updated includes in runner and tests to use the new paths Updated CMakeLists to build src/hydro/config/*.cpp and removed old paths
1 parent d1cd0ab commit 0741e77

14 files changed

Lines changed: 87 additions & 49 deletions

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,16 @@ set(HYDROCHRONO_SOURCES
339339
src/hydro/io/h5_reader.cpp
340340
src/hydro/io/h5_writer.cpp
341341
src/hydro/io/simulation_export.cpp
342-
src/hydro/io/hydro_config_loader.cpp
342+
# Config/YAML module (consolidated under src/hydro/config/)
343+
src/hydro/config/yaml_parser.cpp
344+
src/hydro/config/config_loader.cpp
345+
src/hydro/config/setup_from_yaml.cpp
346+
src/hydro/config/yaml_discovery.cpp
343347
# Core library sources
344348
src/chloadaddedmass.cpp
345349
src/hydro_forces.cpp
346350
src/helper.cpp
347351
src/wave_types.cpp
348-
src/hydro_yaml_parser.cpp
349-
src/setup_hydro_from_yaml.cpp
350352
# Hydro modules
351353
src/hydro/waves/wave_base.cpp
352354
src/hydro/waves/wave_utilities.cpp
@@ -471,7 +473,6 @@ if(HYDROCHRONO_ENABLE_YAML_RUNNER)
471473
app/run_hydrochrono.cpp
472474
src/hydrochrono_runner/run_hydrochrono_from_yaml.cpp
473475
src/utils/misc_options.cpp
474-
src/utils/setup_parser.cpp
475476
)
476477

477478
target_link_libraries(run_hydrochrono
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
// TODO: This file will move to src/hydrochrono_hydro/ in a future refactor.
2-
3-
#ifndef HYDRO_CONFIG_TYPES_H
4-
#define HYDRO_CONFIG_TYPES_H
5-
61
/*********************************************************************
7-
* @file hydro_config_types.h
2+
* @file hydro_config.h
3+
*
4+
* @brief Public configuration types for HydroChrono YAML configuration.
85
*
9-
* @brief Data structures for parsed hydro.yaml content.
6+
* This header defines the data structures used to represent parsed
7+
* hydro.yaml configuration files. Users and library consumers should
8+
* include this header to work with hydrodynamic configuration data.
9+
*
10+
* MAIN TYPES:
11+
* - HydroBody: Configuration for a single hydrodynamic body
12+
* - WaveSettings: Configuration for wave conditions
13+
* - YAMLHydroData: Top-level container for all configuration
14+
*
15+
* USAGE:
16+
* Include <hydroc/config/hydro_config.h> to access these types.
17+
* Use hydrochrono::hydro::LoadHydroConfigFromYaml() to parse YAML files.
1018
*********************************************************************/
1119

20+
#ifndef HYDROC_CONFIG_HYDRO_CONFIG_H
21+
#define HYDROC_CONFIG_HYDRO_CONFIG_H
22+
1223
#include <string>
1324
#include <vector>
1425
#include <array>
@@ -71,5 +82,5 @@ struct YAMLHydroData {
7182
bool td_export_plot_csv = false; // dump before/after CSV summaries (false by default)
7283
};
7384

74-
#endif // HYDRO_CONFIG_TYPES_H
85+
#endif // HYDROC_CONFIG_HYDRO_CONFIG_H
7586

include/hydroc/hydro_forces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*********************************************************************/
4545

4646
// Include hydro_types.h FIRST to ensure BodyForces and GeneralizedForce are available
47-
// before any other includes that might conflict (e.g., hydro_config_types.h)
47+
// before any other includes that might conflict (e.g., config/hydro_config.h)
4848
#include <hydroc/hydro_types.h>
4949

5050
// Standard includes
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*********************************************************************
2-
* @file hydro_config_loader.cpp
2+
* @file config_loader.cpp
33
*
44
* @brief Implementation of the simple hydrodynamics config loader.
55
*********************************************************************/
66

7-
#include "hydro_config_loader.h"
8-
#include "../../hydro_yaml_parser.h"
7+
#include "config_loader.h"
8+
#include "yaml_parser.h"
99

1010
namespace hydrochrono {
1111
namespace hydro {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*********************************************************************
2-
* @file hydro_config_loader.h
2+
* @file config_loader.h
33
*
44
* @brief Simple helper to load hydrodynamics config from YAML.
55
*
66
* This wrapper keeps the handwritten parser in one place and gives
77
* callers a stable, easy-to-read entry point.
88
*********************************************************************/
99

10-
#ifndef HYDRO_IO_HYDRO_CONFIG_LOADER_H
11-
#define HYDRO_IO_HYDRO_CONFIG_LOADER_H
10+
#ifndef HYDRO_CONFIG_CONFIG_LOADER_H
11+
#define HYDRO_CONFIG_CONFIG_LOADER_H
1212

13-
#include "hydro_config_types.h"
13+
#include <hydroc/config/hydro_config.h>
1414
#include <string>
1515

1616
namespace hydrochrono {
@@ -31,5 +31,5 @@ YAMLHydroData LoadHydroConfigFromYaml(const std::string& yaml_path);
3131
} // namespace hydro
3232
} // namespace hydrochrono
3333

34-
#endif // HYDRO_IO_HYDRO_CONFIG_LOADER_H
34+
#endif // HYDRO_CONFIG_CONFIG_LOADER_H
3535

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*********************************************************************
2-
* @file setup_hydro_from_yaml.cpp
2+
* @file setup_from_yaml.cpp
33
*
44
* @brief Implementation of hydrodynamic setup from YAML data.
55
*
@@ -32,8 +32,8 @@
3232
* - No validation that matched body count matches H5 file structure
3333
*********************************************************************/
3434

35-
#include "setup_hydro_from_yaml.h"
36-
#include "hydro/io/hydro_config_loader.h"
35+
#include "setup_from_yaml.h"
36+
#include "config_loader.h"
3737
#include <hydroc/hydro_forces.h> // For TestHydro
3838
#include <hydroc/wave_types.h> // For WaveBase, RegularWave, IrregularWaves, NoWave
3939
#include <hydroc/logging.h> // For Logger
@@ -252,4 +252,5 @@ std::unique_ptr<TestHydro> SetupHydroFromYAMLFile(
252252
double ramp_duration) {
253253
const YAMLHydroData hydro_data = hydrochrono::hydro::LoadHydroConfigFromYaml(hydro_yaml_path);
254254
return SetupHydroFromYAML(hydro_data, bodies, timestep, sim_duration, ramp_duration);
255-
}
255+
}
256+
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#ifndef SETUP_HYDRO_FROM_YAML_H
2-
#define SETUP_HYDRO_FROM_YAML_H
3-
41
/*********************************************************************
5-
* @file setup_hydro_from_yaml.h
2+
* @file setup_from_yaml.h
63
*
74
* @brief Setup hydrodynamic forces from parsed YAML data.
85
*
@@ -18,7 +15,7 @@
1815
* - Configure radiation convolution options (Baseline/TaperedDirect)
1916
*
2017
* INTERACTIONS:
21-
* - Takes parsed YAMLHydroData from hydro_yaml_parser
18+
* - Takes parsed YAMLHydroData from yaml_parser
2219
* - Takes Chrono bodies from the simulation system
2320
* - Returns configured TestHydro instance ready for simulation
2421
* - Uses wave_types.h for wave model creation
@@ -36,7 +33,10 @@
3633
* - Body matching is simple string equality (no fuzzy matching)
3734
*********************************************************************/
3835

39-
#include "hydro/io/hydro_config_types.h"
36+
#ifndef HYDRO_CONFIG_SETUP_FROM_YAML_H
37+
#define HYDRO_CONFIG_SETUP_FROM_YAML_H
38+
39+
#include <hydroc/config/hydro_config.h>
4040
#include <chrono/physics/ChBody.h>
4141
#include <memory>
4242
#include <vector>
@@ -88,4 +88,5 @@ std::unique_ptr<TestHydro> SetupHydroFromYAMLFile(
8888
double ramp_duration
8989
);
9090

91-
#endif // SETUP_HYDRO_FROM_YAML_H
91+
#endif // HYDRO_CONFIG_SETUP_FROM_YAML_H
92+
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
#include "setup_parser.h"
1+
/*********************************************************************
2+
* @file yaml_discovery.cpp
3+
*
4+
* @brief Implementation of setup file discovery and parsing.
5+
*********************************************************************/
6+
7+
#include "yaml_discovery.h"
28
#include <hydroc/logging.h>
39
#include <fstream>
410
#include <sstream>
@@ -99,4 +105,5 @@ SetupConfig ParseSetupFile(const std::filesystem::path& setup_path) {
99105
return config;
100106
}
101107

102-
} // namespace hydroc
108+
} // namespace hydroc
109+
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
#pragma once
1+
/*********************************************************************
2+
* @file yaml_discovery.h
3+
*
4+
* @brief Discovery and parsing of model.setup.yaml files.
5+
*
6+
* This module handles finding and parsing setup files that point to
7+
* other configuration files (model, simulation, hydro, output).
8+
*********************************************************************/
9+
10+
#ifndef HYDRO_CONFIG_YAML_DISCOVERY_H
11+
#define HYDRO_CONFIG_YAML_DISCOVERY_H
212

313
#include <filesystem>
414
#include <string>
@@ -29,4 +39,7 @@ SetupConfig ParseSetupFile(const std::filesystem::path& setup_path);
2939
/// @return Path to setup file if it exists, empty path otherwise
3040
std::filesystem::path FindSetupFile(const std::filesystem::path& directory);
3141

32-
} // namespace hydroc
42+
} // namespace hydroc
43+
44+
#endif // HYDRO_CONFIG_YAML_DISCOVERY_H
45+
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*********************************************************************
2-
* @file hydro_yaml_parser.cpp
2+
* @file yaml_parser.cpp
33
*
44
* @brief Implementation of YAML parser for hydro.yaml files.
55
*********************************************************************/
66

7-
#include "hydro_yaml_parser.h"
7+
#include "yaml_parser.h"
88
#include <fstream>
99
#include <sstream>
1010
#include <stdexcept>
@@ -608,3 +608,4 @@ YAMLHydroData ReadHydroYAML(const std::string& hydro_file_path) {
608608

609609
return data;
610610
}
611+

0 commit comments

Comments
 (0)