Skip to content

Commit e0b8821

Browse files
committed
Move chrono_state_utils into chrono coupling layer
1 parent 9814b00 commit e0b8821

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ set(HYDROCHRONO_SOURCES
356356
src/hydro/waves/irregular_wave.cpp
357357
src/hydro/radiation/radiation_rirf_processing.cpp
358358
src/hydro/radiation/radiation_rirf_convolution.cpp
359-
src/hydro/core/chrono_state_utils.cpp
360359
src/hydro/core/hydro_system.cpp
360+
# Chrono coupling layer (bridges Chrono physics with Chrono-free core)
361+
src/hydro/chrono/chrono_state_utils.cpp
361362
src/hydro/chrono/chrono_hydro_coupler.cpp
362363
src/hydro/force_components/hydrostatics_component.cpp
363364
src/hydro/force_components/radiation_component.cpp

src/hydro/chrono/chrono_hydro_coupler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*********************************************************************/
55

66
#include <hydroc/coupling/chrono_coupler.h>
7-
#include "../core/chrono_state_utils.h"
7+
#include "chrono_state_utils.h"
88

99
#include <cassert>
1010

@@ -22,7 +22,7 @@ ChronoHydroCoupler::ChronoHydroCoupler(
2222
BodyForces ChronoHydroCoupler::Evaluate(double time) {
2323
// Build SystemState from Chrono bodies
2424
SystemState system_state;
25-
BuildSystemStateFromChronoBodies(bodies_, system_state);
25+
chrono_coupling::BuildSystemStateFromChronoBodies(bodies_, system_state);
2626

2727
// Evaluate forces via HydroSystem
2828
return hydro_system_->Evaluate(system_state, time);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*********************************************************************
22
* @file chrono_state_utils.cpp
33
* @brief Implementation of Chrono-SystemState conversion utilities.
4+
*
5+
* Part of the Chrono coupling layer (src/hydro/chrono/).
46
*********************************************************************/
57

68
#include "chrono_state_utils.h"
79

8-
namespace hydrochrono::hydro {
10+
namespace hydrochrono::hydro::chrono_coupling {
911

1012
void BuildSystemStateFromChronoBodies(
1113
const std::vector<std::shared_ptr<chrono::ChBody>>& bodies,
@@ -44,5 +46,5 @@ void BuildSystemStateFromChronoBodies(
4446
}
4547
}
4648

47-
} // namespace hydrochrono::hydro
49+
} // namespace hydrochrono::hydro::chrono_coupling
4850

Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
/*********************************************************************
22
* @file chrono_state_utils.h
33
* @brief Utilities for converting between Chrono and SystemState representations.
4+
*
5+
* This file is part of the Chrono coupling layer (src/hydro/chrono/).
6+
* It provides the bridge between Chrono physics types (ChBody) and the
7+
* Chrono-free core hydrodynamics types (SystemState).
8+
*
9+
* ARCHITECTURE NOTE:
10+
* - Core hydrodynamics (src/hydro/core/) remains Chrono-free.
11+
* - This utility lives in the coupling layer because it depends on Chrono types.
12+
* - The core SystemState types are defined in include/hydroc/core/system_state.h.
413
*********************************************************************/
514

6-
#ifndef HYDRO_CORE_CHRONO_STATE_UTILS_H
7-
#define HYDRO_CORE_CHRONO_STATE_UTILS_H
15+
#ifndef HYDRO_CHRONO_CHRONO_STATE_UTILS_H
16+
#define HYDRO_CHRONO_CHRONO_STATE_UTILS_H
817

918
#include <hydroc/core/system_state.h>
1019
#include <chrono/physics/ChBody.h>
1120
#include <memory>
1221
#include <vector>
1322

14-
namespace hydrochrono::hydro {
23+
namespace hydrochrono::hydro::chrono_coupling {
1524

1625
/**
1726
* @brief Build SystemState from Chrono bodies.
1827
*
1928
* Extracts pose and velocity data from Chrono bodies into the SystemState structure.
29+
* This function bridges the Chrono physics layer with the Chrono-free core.
2030
*
2131
* @param bodies Vector of Chrono body pointers
2232
* @param out_state Output SystemState (will be populated)
@@ -25,7 +35,7 @@ void BuildSystemStateFromChronoBodies(
2535
const std::vector<std::shared_ptr<chrono::ChBody>>& bodies,
2636
SystemState& out_state);
2737

28-
} // namespace hydrochrono::hydro
38+
} // namespace hydrochrono::hydro::chrono_coupling
2939

30-
#endif // HYDRO_CORE_CHRONO_STATE_UTILS_H
40+
#endif // HYDRO_CHRONO_CHRONO_STATE_UTILS_H
3141

src/hydro/hydro_forces.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include <hydroc/waves/irregular_wave.h>
6060
#include <hydroc/logging.h>
6161
#include <hydroc/core/system_state.h>
62-
#include "core/chrono_state_utils.h"
62+
#include "chrono/chrono_state_utils.h"
6363
#include "force_components/hydrostatics_component.h"
6464
#include "force_components/radiation_component.h"
6565
#include "force_components/excitation_component.h"
@@ -349,7 +349,7 @@ const hydrochrono::hydro::SystemState& TestHydro::GetCachedSystemState(double ti
349349
}
350350

351351
// Fallback: build state now (should not happen in normal flow)
352-
hydrochrono::hydro::BuildSystemStateFromChronoBodies(bodies_, cached_state_);
352+
hydrochrono::hydro::chrono_coupling::BuildSystemStateFromChronoBodies(bodies_, cached_state_);
353353
cached_state_time_ = time;
354354
return cached_state_;
355355
}
@@ -714,7 +714,7 @@ double TestHydro::CoordinateFuncForBody(int b, int dof_index) {
714714
prev_time = bodies_[0]->GetChTime();
715715

716716
// Build SystemState once for this timestep
717-
hydrochrono::hydro::BuildSystemStateFromChronoBodies(bodies_, cached_state_);
717+
hydrochrono::hydro::chrono_coupling::BuildSystemStateFromChronoBodies(bodies_, cached_state_);
718718
cached_state_time_ = prev_time;
719719

720720
// Ensure HydroSystem + ChronoHydroCoupler are initialized

0 commit comments

Comments
 (0)