From 996916a493fb55437208e50a3a9fda7c04423747 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 9 Sep 2018 12:15:07 +0200 Subject: Extract result path generation --- boltz.cc | 3 ++- src/fluid_buffer.cc | 4 ++-- src/fluid_buffer.h | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/boltz.cc b/boltz.cc index 6f8788e..092814e 100644 --- a/boltz.cc +++ b/boltz.cc @@ -1,5 +1,6 @@ #include #include +#include #include #include "lbm.h" @@ -106,7 +107,7 @@ int main() { if ( t % 100 == 0 ) { std::cout << "."; std::cout.flush(); - fluid.writeAsVTK(t); + fluid.writeAsVTK("result/data_t" + std::to_string(t) + ".vtk"); } } diff --git a/src/fluid_buffer.cc b/src/fluid_buffer.cc index e73c818..1f40d2f 100644 --- a/src/fluid_buffer.cc +++ b/src/fluid_buffer.cc @@ -32,9 +32,9 @@ Velocity& FluidBuffer::velocity(Vector pos) { return velocity(pos[0], pos[1]); } -void FluidBuffer::writeAsVTK(int time) { +void FluidBuffer::writeAsVTK(const std::string& path) { std::ofstream fout; - fout.open(("result/data_t" + std::to_string(time) + ".vtk").c_str()); + fout.open(path.c_str()); fout << "# vtk DataFile Version 3.0\n"; fout << "lbm_output\n"; diff --git a/src/fluid_buffer.h b/src/fluid_buffer.h index 1d802c0..72518bb 100644 --- a/src/fluid_buffer.h +++ b/src/fluid_buffer.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "vector.h" @@ -27,5 +28,5 @@ public: Velocity& velocity(std::size_t x, std::size_t y); Velocity& velocity(Vector pos); - void writeAsVTK(int time); + void writeAsVTK(const std::string& path); }; -- cgit v1.2.3