Port FluidSim core and scenarios to C++20
This commit is contained in:
35
include/FluidSim/Atmosphere.hpp
Normal file
35
include/FluidSim/Atmosphere.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#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.pressure = pressure;
|
||||
port.density = density();
|
||||
port.temperature = temperature;
|
||||
port.enthalpy = specific_enthalpy();
|
||||
port.air_fraction = 1.0f;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace fluidsim::port
|
||||
Reference in New Issue
Block a user