Port FluidSim core and scenarios to C++20
This commit is contained in:
37
include/FluidSim/Crankcase.hpp
Normal file
37
include/FluidSim/Crankcase.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "FluidSim/Component.hpp"
|
||||
#include "FluidSim/Engine.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace fluidsim::port {
|
||||
|
||||
class Crankcase final : public Component {
|
||||
public:
|
||||
Crankcase(Crankshaft& crankshaft, float crank_radius, float connecting_rod_length,
|
||||
float bore, float clearance_volume, float initial_pressure = 101325.0f,
|
||||
float initial_temperature = 300.0f);
|
||||
|
||||
Port intake_port{}, transfer_port{};
|
||||
float pressure() const { return pressure_; }
|
||||
float temperature() const { return temperature_; }
|
||||
float density() const { return mass_ / (volume_ > 1e-12f ? volume_ : 1e-12f); }
|
||||
float volume() const { return volume_; }
|
||||
float mass() const { return mass_; }
|
||||
float air_fraction() const { return air_fraction_; }
|
||||
|
||||
std::vector<Port*> ports() override { return {&intake_port, &transfer_port}; }
|
||||
void pre_step(float dt);
|
||||
void update_state(float dt) override;
|
||||
|
||||
private:
|
||||
Crankshaft& crankshaft_;
|
||||
float crank_radius_{}, connecting_rod_length_{}, piston_area_{};
|
||||
float clearance_volume_{}, obliquity_{};
|
||||
float mass_{}, energy_{}, air_fraction_{1.0f};
|
||||
float pressure_{101325.0f}, temperature_{300.0f}, volume_{}, previous_volume_{};
|
||||
|
||||
void sync_ports();
|
||||
};
|
||||
|
||||
} // namespace fluidsim::port
|
||||
Reference in New Issue
Block a user