Port FluidSim core and scenarios to C++20

This commit is contained in:
maxwes08
2026-10-22 23:52:20 +02:00
commit a859740a95
47 changed files with 3851 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#pragma once
#include "FluidSim/Crankcase.hpp"
namespace fluidsim::port {
// Two-stroke variant of the reciprocating cylinder model. The shared four-
// stroke implementation supplies geometry, state balance, and combustion
// parameters; cycle events and pumping torque are specialized here.
class TwoStrokeCylinder final : public EngineCylinder {
public:
TwoStrokeCylinder(float bore, float stroke, float connecting_rod_length,
float compression_ratio, float transfer_duration_degrees,
float exhaust_duration_degrees);
float transfer_open() const { return 180.0f - transfer_duration_ * 0.5f; }
float transfer_close() const { return 180.0f + transfer_duration_ * 0.5f; }
float exhaust_open() const { return 180.0f - exhaust_duration_ * 0.5f; }
float exhaust_close() const { return 180.0f + exhaust_duration_ * 0.5f; }
void set_crankcase(Crankcase& crankcase) { crankcase_ = &crankcase; }
float valve_area(float cycle_degrees, bool inlet) const override;
void pre_step(Crankshaft& crank, float dt, float throttle) override;
private:
float transfer_duration_{}, exhaust_duration_{};
Crankcase* crankcase_{};
static float lift(float angle, float opens, float closes, float peak_lift);
void handle_cycle_events(float previous_degrees, float current_degrees);
};
} // namespace fluidsim::port