all of the changes

This commit is contained in:
2026-10-23 18:29:51 +02:00
parent 4c435fdd76
commit 5607dcf2b5
73 changed files with 4365 additions and 2059 deletions

View File

@@ -3,13 +3,31 @@
#include "FluidSim/TwoStrokeScenario.hpp"
#include "FluidSim/HelmholtzScenario.hpp"
#include "FluidSim/PulseTestScenario.hpp"
#include <algorithm>
#include <barrier>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <stdexcept>
#include <thread>
#include <vector>
using namespace fluidsim::port;
int main() {
for (std::string name : {"twin", "turbo", "b205", "two-stroke-racing", "two-stroke-straight", "helmholtz", "pulse", "large"}) {
static void set_uniform_resolution(std::vector<Pipe1D>& pipes, int cells_per_meter) {
if (cells_per_meter <= 0) throw std::invalid_argument("cells per meter must be positive");
for (auto& pipe : pipes) {
const float length = std::accumulate(pipe.cell_lengths.begin(), pipe.cell_lengths.end(), 0.0f);
const int count = std::max(1, static_cast<int>(std::ceil(length * cells_per_meter)));
const float damping = pipe.damping_multiplier;
const float relaxation = pipe.energy_relaxation_rate;
pipe = Pipe1D(pipe.area, length, count);
pipe.damping_multiplier = damping;
pipe.energy_relaxation_rate = relaxation;
}
}
int main(int argc, char** argv) {
const int uniform_cells_per_meter = argc > 1 ? std::stoi(argv[1]) : 0;
for (std::string name : {"twin", "b205", "v8", "two-stroke-racing", "two-stroke-straight", "helmholtz", "pulse", "large"}) {
std::vector<Pipe1D> geometry;
if (name == "large") {
for (int i=0; i<64; ++i) geometry.emplace_back(.001f, 2, 256);
@@ -22,9 +40,11 @@ int main() {
config.exhaust = name == "two-stroke-straight" ? TwoStrokeExhaust::Straight : TwoStrokeExhaust::Racing;
TwoStrokeScenario s(44100, config); geometry = s.pipes;
} else {
FourStrokeScenario s(44100, name == "b205" ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin, name == "turbo");
FourStrokeScenario s(44100, name == "v8" ? FourStrokePreset::AmericanV8 : name == "b205" ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin);
geometry = s.pipes;
}
if (name == "v8" && uniform_cells_per_meter > 0)
set_uniform_resolution(geometry, uniform_cells_per_meter);
const int steps = 4000;
for (int workers : {1, 2, 4}) {
auto p = geometry;