From 884882872ee3ba7a3745eee9904495a5a35767d6 Mon Sep 17 00:00:00 2001 From: DanielWit Date: Tue, 14 Nov 2023 12:25:39 +0000 Subject: [PATCH] reverse --- CMakeLists.txt | 4 ++-- Dockerfile | 4 ++-- simulation/simulation.py | 14 +++++++------- src/gs/gs.cpp | 5 +---- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8afa84d..1bc0bdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.14) project(MiscadaProjectGp12Tests) -# GoogleTest requires at least C++17 -set(CMAKE_CXX_STANDARD 17) +# GoogleTest requires at least C++14 +set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) enable_testing() diff --git a/Dockerfile b/Dockerfile index 7dc2abf..b6e398e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,10 +14,10 @@ COPY ./build ./build # Copy the simulation script and run script into the Docker image COPY ./simulation/simulation.py ./run.sh ./ -RUN chmod +x run.sh +RUN chmod +x ./run.sh # Expose the port 5050 for serving animation EXPOSE 5050 # Run the output executable -ENTRYPOINT ["sh","/app/run.sh"] +CMD ["./run.sh"] \ No newline at end of file diff --git a/simulation/simulation.py b/simulation/simulation.py index e765843..110cc1e 100644 --- a/simulation/simulation.py +++ b/simulation/simulation.py @@ -6,19 +6,19 @@ pv.start_xvfb() # Get a list of all files in the directory -BASE_DIR = os.path.join( os.path.dirname('__file__'), '..' ) -directory = BASE_DIR + '/build/src/app/data/' +directory = '/app/data/' files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))] -files.sort(key = len) + # Create a plotter object to plot and animate print("creating animation ...") plotter = pv.Plotter() -mesh = pv.read(directory + 'output_0.vtk') +plotter.set_movie_delay(200) +mesh = pv.read('/app/data/output_0.vtk') plotter.add_mesh(mesh) -plotter.open_gif(BASE_DIR + '/simulation/animation.gif') +plotter.open_gif('/app/data/animation.gif') # Loop over all frames for file in files: - mesh = pv.read(BASE_DIR + file) + mesh = pv.read(f'/app/data/{file}') plotter.clear() plotter.add_mesh(mesh) @@ -29,7 +29,7 @@ class CustomHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): def translate_path(self, path): - base_dir = directory + base_dir = '/app/data/' requested_path = path[1:] # Remove the leading '/' return os.path.join(base_dir, requested_path) diff --git a/src/gs/gs.cpp b/src/gs/gs.cpp index f5dff33..4a89b68 100644 --- a/src/gs/gs.cpp +++ b/src/gs/gs.cpp @@ -6,7 +6,6 @@ #include #include #include -#include // Define simulation parameters const int width = 256; // Width of the grid @@ -42,10 +41,8 @@ void init() { // Function to write the u array to a VTK file void writeVTKFile(int iteration) { - std::stringstream ss; - std::filesystem::create_directories("app/data/"); - ss << "app/data/output_" << iteration << ".vtk"; + ss << "/app/data/output_" << iteration << ".vtk"; std::ofstream vtkFile(ss.str()); vtkFile << "# vtk DataFile Version 3.0\n";