Skip to content

Commit

Permalink
reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielWit committed Nov 14, 2023
1 parent 27fcd42 commit 8848828
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
14 changes: 7 additions & 7 deletions simulation/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions src/gs/gs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <fstream>
#include <sstream>
#include <cmath>
#include <filesystem>

// Define simulation parameters
const int width = 256; // Width of the grid
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 8848828

Please sign in to comment.