This commit is contained in:
2026-10-23 03:00:20 +02:00
parent 589d22aa5e
commit 7a5c77c1c8
31 changed files with 1196 additions and 44 deletions

View File

@@ -1,20 +1,37 @@
#include "FluidSim/Fluid.hpp"
#include "FluidSim/Scenario.hpp"
#include "FluidSim/TwoStrokeScenario.hpp"
#include "FluidSim/HelmholtzScenario.hpp"
#include "FluidSim/PulseTestScenario.hpp"
#include <barrier>
#include <chrono>
#include <iostream>
#include <thread>
using namespace fluidsim::port;
int main() {
for (auto size : {std::pair{6, 10}, std::pair{64, 256}}) {
const int steps = 1000;
for (std::string name : {"twin", "turbo", "b205", "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);
} else if (name == "helmholtz") {
HelmholtzScenario s; geometry.push_back(s.neck());
} else if (name == "pulse") {
PulseTestScenario s; geometry.push_back(s.pipe());
} else if (name.starts_with("two-stroke")) {
TwoStrokeConfig config;
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");
geometry = s.pipes;
}
const int steps = 4000;
for (int workers : {1, 2, 4}) {
std::vector<Pipe1D> p;
for (int i = 0; i < size.first; i++)
p.emplace_back(.001f, 2, size.second);
auto p = geometry;
auto advance = [&](int worker) {
for (int k = worker; k < size.first; k += workers) {
for (int k = worker; k < static_cast<int>(p.size()); k += workers) {
auto &a = p[k];
auto l = a.state(0), r = a.state(size.second - 1);
auto l = a.state(0), r = a.state(static_cast<int>(a.cells.size()) - 1);
l.velocity = -l.velocity;
r.velocity = -r.velocity;
a.left_ghost = l;
@@ -47,7 +64,7 @@ int main() {
double sum = 0;
for (auto &q : p)
sum += q.state(0).pressure;
std::cout << "pipes=" << size.first << " cells/pipe=" << size.second << " workers=" << workers
std::cout << "scenario=" << name << " pipes=" << p.size() << " workers=" << workers
<< " steps=" << steps << " seconds=" << sec << " checksum=" << sum << '\n';
}
}