38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include "FluidSim/Engine.hpp"
|
|
|
|
namespace fluidsim::port {
|
|
|
|
// Fixed thermodynamic boundary matching the C# Atmosphere component.
|
|
class Atmosphere final : public Component {
|
|
public:
|
|
float pressure{101325.0f};
|
|
float temperature{300.0f};
|
|
float gas_constant_value{gas_constant};
|
|
float gamma_value{gamma};
|
|
Port port{};
|
|
|
|
Atmosphere() { update_port(); }
|
|
|
|
float density() const { return pressure / (gas_constant_value * temperature); }
|
|
float specific_enthalpy() const {
|
|
return gamma_value / (gamma_value - 1.0f) * pressure / density();
|
|
}
|
|
std::vector<Port*> ports() override { return {&port}; }
|
|
void update_state(float /*dt*/) override { update_port(); }
|
|
|
|
private:
|
|
void update_port() {
|
|
port.gamma_value = gamma_value;
|
|
port.gas_constant_value = gas_constant_value;
|
|
port.pressure = pressure;
|
|
port.density = density();
|
|
port.temperature = temperature;
|
|
port.enthalpy = specific_enthalpy();
|
|
port.air_fraction = 1.0f;
|
|
}
|
|
};
|
|
|
|
} // namespace fluidsim::port
|