#include "MachineBench.hpp" #include "FluidSim/Machine.hpp" #include "FluidSim/Scenario.hpp" #include "FluidSim/ScenarioCatalog.hpp" #include #include #include #include #include using namespace fluidsim::port; template double measure(Step step,int frames){ const auto begin=std::chrono::steady_clock::now(); for(int i=0;i(std::chrono::steady_clock::now()-begin).count(); } int main(int argc,char** argv)try{ const int frames=argc>1?std::stoi(argv[1]):32768;const float rpm=argc>2?std::stof(argv[2]):3000,pedal=argc>3?std::stof(argv[3]):.35f; if(frames<1||!std::isfinite(rpm)||rpm<0||rpm>50000||!std::isfinite(pedal)||pedal<0||pedal>1)throw std::invalid_argument("Usage: fluidsim_machine_benchmark [frames>0] [rpm 0..50000] [pedal 0..1]"); std::cout<<"scenario,runtime,frames,rpm,pedal,cells,min_cell_mm,substeps_per_frame,us_per_frame,wall_per_sim,positivity_repairs\n"; for(const char* id:{"single-450","twin","flat6","v8-h"}){ const auto& preset=scenario_example(id);FourStrokeScenario native(44100,preset);native.set_controls(pedal,0,1); const auto step=[&]{native.crankshaft.omega=rpm*2*pi/60;return native.process();}; for(int i=0;i<512;++i)step();const auto before=native.snapshot().solver_substeps;const double elapsed=measure(step,frames);const auto after=native.snapshot(); float shortest=1e9f;unsigned cells=0;for(auto& p:native.pipes){cells+=unsigned(p.cells.size());shortest=std::min(shortest,p.minimum_cell_length());} std::cout<