aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt43
-rw-r--r--shell.nix4
-rw-r--r--src/fluid_buffer.cc4
-rw-r--r--src/fluid_buffer.h3
4 files changed, 37 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5cbd03..29ad827 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,31 +1,48 @@
cmake_minimum_required(VERSION 3.10)
-project(boltzbub)
+project(boltzbub LANGUAGES CXX)
-set(
- CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -std=c++1z -W -Wall -Wextra -Winline -pedantic"
+add_library(
+ boltzbub
+ src/lbm.cc
+ src/fluid_buffer.cc
+ src/boundary_conditions.cc
)
-include_directories(
- src/
+target_compile_features(
+ boltzbub
+ PUBLIC
+ cxx_std_17
)
-set(
- BASE
- src/lbm.cc
- src/fluid_buffer.cc
- src/boundary_conditions.cc
+target_include_directories(
+ boltzbub
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+)
+
+target_link_libraries(
+ boltzbub
+ PRIVATE
+ stdc++fs
)
add_executable(
cavity2d
cavity2d.cc
- ${BASE}
+)
+
+target_link_libraries(
+ cavity2d
+ boltzbub
)
add_executable(
cavity2d_with_obstacles
cavity2d_with_obstacles.cc
- ${BASE}
src/box_obstacle.cc
)
+
+target_link_libraries(
+ cavity2d_with_obstacles
+ boltzbub
+)
diff --git a/shell.nix b/shell.nix
index 087712a..dabe8b5 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,12 +1,12 @@
with import <nixpkgs> {};
-stdenv.mkDerivation rec {
+stdenvNoCC.mkDerivation rec {
name = "boltzbub-env";
env = buildEnv { name = name; paths = buildInputs; };
buildInputs = [
git
- gcc
+ gcc8
cmake
];
diff --git a/src/fluid_buffer.cc b/src/fluid_buffer.cc
index 1f40d2f..9291fdd 100644
--- a/src/fluid_buffer.cc
+++ b/src/fluid_buffer.cc
@@ -32,7 +32,9 @@ Velocity& FluidBuffer::velocity(Vector<std::size_t> pos) {
return velocity(pos[0], pos[1]);
}
-void FluidBuffer::writeAsVTK(const std::string& path) {
+void FluidBuffer::writeAsVTK(const std::filesystem::path& path) {
+ std::filesystem::create_directories(path.parent_path());
+
std::ofstream fout;
fout.open(path.c_str());
diff --git a/src/fluid_buffer.h b/src/fluid_buffer.h
index 72518bb..b0e0936 100644
--- a/src/fluid_buffer.h
+++ b/src/fluid_buffer.h
@@ -2,6 +2,7 @@
#include <memory>
#include <string>
+#include <filesystem>
#include "vector.h"
@@ -28,5 +29,5 @@ public:
Velocity& velocity(std::size_t x, std::size_t y);
Velocity& velocity(Vector<std::size_t> pos);
- void writeAsVTK(const std::string& path);
+ void writeAsVTK(const std::filesystem::path& path);
};