#include "FluidSim/ScenarioCatalog.hpp" #include "FluidSim/DesktopScenario.hpp" #include #include #include #include #include using namespace fluidsim::port; int main() { std::set ids; for(const auto& example:scenario_examples()) { if(!ids.insert(example.id).second)throw std::runtime_error("duplicate example id"); DesktopScenario scenario(example.kind,example.two,example.exhaust,example.junctions,example.engine,example.title); scenario.set_audio_scene(OutdoorScene::Dry); const auto started=std::chrono::steady_clock::now(); float peak_power=0; for(int i=0;i<88200;++i) { scenario.set_controls(i<44100?.45f:0.f,0,1); const auto audio=scenario.process(); if(i%4410==0) peak_power=std::max(peak_power,scenario.snapshot().average_power); if(!std::isfinite(audio.left)||!std::isfinite(audio.right))throw std::runtime_error(example.id+" nonfinite audio"); } const auto snapshot=scenario.snapshot(); if(snapshot.pipe_positivity_repairs)throw std::runtime_error(example.id+" required positivity repairs"); if(example.id=="big-carb" && peak_power<10000)throw std::runtime_error("big carb V8 failed to produce power"); if(!std::isfinite(snapshot.rpm)||snapshot.rpm<=0)throw std::runtime_error(example.id+" invalid engine speed"); if(example.engine.cylinders && (snapshot.cylinder_count!=example.engine.cylinders || snapshot.layout!=example.engine.layout))throw std::runtime_error("custom cylinder layout lost"); const bool custom_v8=example.engine.american_headers(); if(custom_v8 && (!snapshot.v8_headers || snapshot.h_pipe!=example.junctions.h_pipe || snapshot.pipe_states[25].empty())) throw std::runtime_error("custom V8 lost American junction headers/crossover"); if(example.engine.staged_headers() && example.engine.layout==EngineLayout::Inline) { if(!snapshot.staged_headers || snapshot.dual_exhaust) throw std::runtime_error("inline engine lost staged junction collectors"); } if(example.engine.staged_headers() && example.engine.layout==EngineLayout::V && (!snapshot.dual_exhaust || !snapshot.staged_headers)) throw std::runtime_error("large V engine lost separate bank outlets"); if(snapshot.example_name!=example.title)throw std::runtime_error("example name lost"); if(example.engine.has_silenced_exhaust() && snapshot.silencers!=example.exhaust.enabled)throw std::runtime_error("example silencer selection lost"); std::cout<