Skip to content

Commit d968e4b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into enable-linux-build
2 parents 4645ffd + 23cb81d commit d968e4b

23 files changed

Lines changed: 1641 additions & 120 deletions

app/run_hydrochrono.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct CLIArgs {
8383
bool h5_verbose = false; // NEW: HDF5 verbose diagnostics
8484
std::string h5_tag; // NEW: Optional tag appended to filename
8585
bool fail_fast = false; // NEW: Stop on first failure during sweep
86+
bool profile = false; // NEW: Enable runtime profiling summary
8687
};
8788

8889
static CLIArgs ParseArguments(int argc, char* argv[]) {
@@ -136,6 +137,8 @@ static CLIArgs ParseArguments(int argc, char* argv[]) {
136137
}
137138
} else if (arg == "--fail-fast") {
138139
args.fail_fast = true;
140+
} else if (arg == "--profile") {
141+
args.profile = true;
139142
} else if (arg.substr(0, 1) != "-") {
140143
// This is a positional argument (input directory)
141144
if (args.input_directory.empty()) {
@@ -286,6 +289,10 @@ int main(int argc, char* argv[]) {
286289
runner_args.push_back("--trace");
287290
}
288291

292+
if (args.profile) {
293+
runner_args.push_back("--profile");
294+
}
295+
289296
if (!args.model_file.empty()) {
290297
runner_args.push_back("--model_file");
291298
runner_args.push_back(args.model_file);

build.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,20 @@ function Get-BuildArguments {
603603
$irrlicht = ($Config.IrrlichtDir -replace '\\','/')
604604
$irrlichtDllWin = Join-Path $Config.IrrlichtDir "bin\Win64-VisualStudio\Irrlicht.dll"
605605
$irrlichtDll = ($irrlichtDllWin -replace '\\','/')
606+
$irrlichtFlag = if ($Config.IrrlichtDir -and (Test-Path $Config.IrrlichtDir)) { "ON" } else { "OFF" }
606607

607608
# Deterministic prefix path so our roots win over ambient environment
608609
$prefixParts = @()
609610
foreach ($p in @($Config.ChronoDir, $Config.Hdf5Dir, $Config.EigenDir, $Config.IrrlichtDir, $Config.PythonRoot)) {
610-
if ($p -and (Test-Path $p)) { $prefixParts += ($p -replace '\\','/') }
611+
if ($p) {
612+
$isValid = $false
613+
try { $null = [System.IO.Path]::GetFullPath($p); $isValid = $true } catch { $isValid = $false }
614+
if ($isValid) {
615+
try {
616+
if (Test-Path -LiteralPath $p) { $prefixParts += ($p -replace '\\','/') }
617+
} catch { }
618+
}
619+
}
611620
}
612621
$prefixPath = ($prefixParts -join ';')
613622
$testsFlag = if ($NoTests) { "OFF" } else { "ON" }
@@ -623,6 +632,7 @@ function Get-BuildArguments {
623632
"-DEIGEN3_INCLUDE_DIR=`"$eigenDir`"",
624633
"-DIrrlicht_ROOT=`"$irrlicht`"",
625634
"-DIRRLICHT_DLL_PATH=`"$irrlichtDll`"",
635+
"-DHYDROCHRONO_ENABLE_IRRLICHT=`"$irrlichtFlag`"",
626636
"-DCMAKE_PREFIX_PATH=`"$prefixPath`"",
627637
"-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON",
628638
"-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF",

include/hydroc/hydro_forces.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ class ForceFunc6d {
149149

150150
class ChLoadAddedMass;
151151

152+
// Lightweight hydrodynamics profiling stats
153+
struct HydroProfileStats {
154+
double hydrostatics_seconds = 0.0;
155+
double radiation_seconds = 0.0;
156+
double waves_seconds = 0.0;
157+
int hydrostatics_calls = 0;
158+
int radiation_calls = 0;
159+
int waves_calls = 0;
160+
};
161+
152162
// TODO: Rename TestHydro for clarity, perhaps to HydroForces?
153163
// TODO: Split TestHydro class from its helper classes for clearer code structure.
154164
class TestHydro {
@@ -220,6 +230,42 @@ class TestHydro {
220230
*/
221231
double GetRIRFval(int row, int col, int st);
222232

233+
// Convolution mode selection
234+
enum class RadiationConvolutionMode {
235+
Baseline,
236+
TaperedDirect
237+
};
238+
239+
/**
240+
* @brief Set the radiation convolution mode. Default is Baseline.
241+
*/
242+
void SetRadiationConvolutionMode(RadiationConvolutionMode mode) { convolution_mode_ = mode; }
243+
244+
struct TaperedDirectOptions {
245+
// smoothing: "sg" (Savitzky–Golay) or "moving_average"
246+
std::string smoothing = "sg";
247+
int window_length = 5; // odd, >= 3
248+
249+
// RIRF truncation
250+
double rirf_end_time = -1.0; // end RIRF at this time (seconds), -1.0 = use full length
251+
252+
// Simple taper control - sensible defaults for improved stability
253+
double taper_start_percent = 0.8; // start taper at 80% (taper last 20%)
254+
double taper_end_percent = 1.0; // end taper at 100% of total time series
255+
double taper_final_amplitude = 0.0; // final amplitude as fraction of original (0.0 = zero, 1.0 = no change)
256+
bool export_plot_csv = false; // dump before/after CSV summaries (false by default)
257+
};
258+
259+
/**
260+
* @brief Set options for TaperedDirect preprocessing.
261+
*/
262+
void SetTaperedDirectOptions(const TaperedDirectOptions& opts) { tapered_opts_ = opts; }
263+
264+
/**
265+
* @brief Set the directory where diagnostics (e.g., CSVs) should be written.
266+
*/
267+
void SetDiagnosticsOutputDirectory(const std::string& dir) { diagnostics_output_dir_ = dir; }
268+
223269
/**
224270
* @brief Calculates or retrieves the total force on a specific body in a particular degree of freedom.
225271
*
@@ -233,6 +279,9 @@ class TestHydro {
233279
*/
234280
double CoordinateFuncForBody(int b, int i);
235281

282+
// Hydrodynamics profiling accessors
283+
HydroProfileStats GetProfileStats() const { return profile_stats_; }
284+
236285
private:
237286
// Class properties related to the body and hydrodynamics
238287
std::vector<std::shared_ptr<ChBody>> bodies_;
@@ -281,6 +330,18 @@ class TestHydro {
281330
* @param index The DOF index, ranging from [0,1,...,5].
282331
*/
283332
double SetVelHistory(double val, int step, int b_num, int index);
333+
334+
// Hydrodynamics profiling data (accumulated over run)
335+
HydroProfileStats profile_stats_;
336+
337+
// Convolution kernel preprocessing (optional)
338+
RadiationConvolutionMode convolution_mode_ = RadiationConvolutionMode::Baseline;
339+
bool rirf_processed_ready_ = false;
340+
std::vector<Eigen::Tensor<double, 3>> rirf_processed_; // per body [dof x col x step]
341+
TaperedDirectOptions tapered_opts_;
342+
std::string diagnostics_output_dir_;
343+
344+
void EnsureProcessedRIRF();
284345
};
285346

286347
#endif

include/hydroc/utils/profiler.h

Whitespace-only changes.

0 commit comments

Comments
 (0)