diff --git a/run_2d.sh b/run_2d.sh index d6340b5..a6350a1 100755 --- a/run_2d.sh +++ b/run_2d.sh @@ -10,7 +10,7 @@ engine_exe="$root_dir/$build_dir/src/cpp/main_2d/pffdtd_2d" sim_name="Diffusor" sim_dir="$root_dir/data/sim_data/$sim_name/cpu" -fmax=1600 +fmax=1000 duration=0.06 # Delete old sim diff --git a/src/cpp/main_2d/engine.cpp b/src/cpp/main_2d/engine.cpp index 9f9932f..afad03c 100644 --- a/src/cpp/main_2d/engine.cpp +++ b/src/cpp/main_2d/engine.cpp @@ -9,7 +9,8 @@ namespace pffdtd { auto run(Simulation2D const& sim) -> std::vector { - auto video = VideoWriter{"out.avi", 30.0, 1000, 1000}; + auto videoFile = sim.file.parent_path() / "out.avi"; + auto video = VideoWriter{videoFile, 30.0, 1000, 1000}; auto const Nx = sim.Nx; auto const Ny = sim.Ny; @@ -41,6 +42,8 @@ auto run(Simulation2D const& sim) -> std::vector { auto out_ixy_buf = sycl::buffer{sim.out_ixy}; auto src_sig_buf = sycl::buffer{sim.src_sig}; + auto frame = std::vector(sim.Nx * sim.Ny); + fmt::print(stdout, "111111111"); for (auto i{0UL}; i < sim.Nt; ++i) { fmt::print(stdout, "\r\r\r\r\r\r\r\r\r"); @@ -112,7 +115,15 @@ auto run(Simulation2D const& sim) -> std::vector { ); }); - queue.wait_and_throw(); + auto host = sycl::host_accessor{u0, sycl::read_only}; + for (auto i{0UL}; i < frame.size(); ++i) { + frame[i] = std::abs(double(host.get_pointer()[i])); + // if (sim.in_mask[i] == 0) { + // frame[i] = 1.0; + // } + } + + video.write(frame, Ny, Nx); } auto save = std::vector(Nt * Nr); diff --git a/src/cpp/pffdtd/simulation_2d.cpp b/src/cpp/pffdtd/simulation_2d.cpp index 9761cd9..58c7f23 100644 --- a/src/cpp/pffdtd/simulation_2d.cpp +++ b/src/cpp/pffdtd/simulation_2d.cpp @@ -10,6 +10,8 @@ namespace pffdtd { auto loadSimulation2D(std::filesystem::path const& path) -> Simulation2D { auto file = H5FReader{path.string().c_str()}; return Simulation2D{ + .file = path, + .Nx = file.read("Nx"), .Ny = file.read("Ny"), .Nt = file.read("Nt"), diff --git a/src/cpp/pffdtd/simulation_2d.hpp b/src/cpp/pffdtd/simulation_2d.hpp index 8988789..82e7367 100644 --- a/src/cpp/pffdtd/simulation_2d.hpp +++ b/src/cpp/pffdtd/simulation_2d.hpp @@ -7,6 +7,8 @@ namespace pffdtd { struct Simulation2D { + std::filesystem::path file; + int64_t Nx; // Number of x sample nodes int64_t Ny; // Number of y sample nodes int64_t Nt; // Number of time steps diff --git a/src/cpp/pffdtd/video.cpp b/src/cpp/pffdtd/video.cpp index 693c7be..364d9cf 100644 --- a/src/cpp/pffdtd/video.cpp +++ b/src/cpp/pffdtd/video.cpp @@ -34,9 +34,12 @@ auto VideoWriter::write(std::span buf, size_t width, size_t height) normalized.convertTo(normalized, CV_8U); auto resized = cv::Mat{}; - cv::resize(input, resized, _size); + cv::resize(normalized, resized, _size); - _writer.write(resized); + auto rotated = cv::Mat{}; + cv::rotate(resized, rotated, cv::ROTATE_90_COUNTERCLOCKWISE); + + _writer.write(rotated); } } // namespace pffdtd