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

27
src/solver.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "FluidSim/Solver.hpp"
#include <algorithm>
namespace fluidsim::port {
Solver::Solver(std::vector<Pipe1D>& pipes, BoundarySystem& boundaries)
: pipes_(pipes), boundaries_(boundaries) {}
void Solver::add_component(Component& component) {
components_.push_back(&component);
}
void Solver::step(float dt) {
if (dt <= 0.0f) return;
int substeps = std::max(minimum_substeps, 1);
for (const auto& pipe : pipes_) substeps = std::max(substeps, pipe.required_substeps(dt, 0.8f));
const float sub_dt = dt / static_cast<float>(substeps);
for (int i = 0; i < substeps; ++i) {
boundaries_.resolve(sub_dt);
for (auto& pipe : pipes_) pipe.advance(sub_dt);
}
for (Component* component : components_) component->update_state(dt);
++step_count_;
}
} // namespace fluidsim::port