diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b66b8ec --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +build + +.git + +.gitignore + +.DS_Store + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f8d0206 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.16) +project(CMakeExercise LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# CRITICAL: Add link directories BEFORE creating executable +link_directories(/usr/local/lib) + +# ---------- Find Packages ---------- +# Boost (filesystem + header-only container) +find_package(Boost REQUIRED COMPONENTS filesystem system) + +# deal.II (FEM) +find_package(deal.II REQUIRED + HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR} +) + +# yaml-cpp (manually specify since it's in /usr/local) +find_library(YAML_CPP_LIBRARY + NAMES yaml-cpp + PATHS /usr/local/lib + REQUIRED +) + +# ---------- Sources ---------- +set(SOURCES + main.cpp + flatset/flatset.cpp + filesystem/filesystem.cpp + fem/fem.cpp + yamlParser/yamlParser.cpp +) + +# ---------- Create Executable ---------- +add_executable(main ${SOURCES}) + +# ---------- Include Directories ---------- +target_include_directories(main PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${Boost_INCLUDE_DIRS} + /usr/local/include +) + +# ---------- deal.II Setup (must come AFTER add_executable) ---------- +deal_ii_initialize_cached_variables() +deal_ii_setup_target(main) + +# ---------- Link Libraries ---------- +# CRITICAL: yaml-cpp must be linked AFTER deal.II setup +target_link_libraries(main + ${Boost_LIBRARIES} + ${YAML_CPP_LIBRARY} +) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..814b737 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +FROM ubuntu:24.04 + +# Avoid prompts from apt +ENV DEBIAN_FRONTEND=noninteractive + +# Base tools and dev packages +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + unzip \ + wget \ + vim \ + git \ + libboost-all-dev \ + libdeal.ii-dev \ + && rm -rf /var/lib/apt/lists/* + +# Build and install yaml-cpp v0.6.3 from source +WORKDIR /tmp +RUN wget --no-check-certificate https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.tar.gz \ + && tar -xzf yaml-cpp-0.6.3.tar.gz \ + && cd yaml-cpp-yaml-cpp-0.6.3 \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release -DYAML_BUILD_TESTS=OFF .. \ + && make -j"$(nproc)" \ + && make install \ + && cd /tmp \ + && rm -rf yaml-cpp-* + +# Make sure libraries in /usr/local/lib (yaml-cpp) are found +ENV LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-} + +# Workdir for the project +WORKDIR /workspace + +# Copy the repository contents +COPY . /workspace/cmake-exercise + +# Switch into the exercise folder by default +WORKDIR /workspace/cmake-exercise + +# Default command: drop into a shell +CMD ["/bin/bash"] diff --git a/main.cpp b/main.cpp index 7588360..c70927b 100644 --- a/main.cpp +++ b/main.cpp @@ -1,39 +1,40 @@ -//#include "fem/fem.hpp" -//#include "flatset/flatset.hpp" -//#include "filesystem/filesystem.hpp" -//#include "yamlParser/yamlParser.hpp" +#include "fem/fem.hpp" +#include "flatset/flatset.hpp" +#include "filesystem/filesystem.hpp" +#include "yamlParser/yamlParser.hpp" + #include +#include int main(int argc, char *argv[]) { std::cout << "Let's fight with CMake, Docker, and some dependencies!" << std::endl << std::endl; - //std::cout << "Solve Poisson problem with FEM using deal.II" << std::endl; - //Fem fem; - //fem.run(); - //std::cout << std::endl; + std::cout << "Solve Poisson problem with FEM using deal.II" << std::endl; + Fem fem; + fem.run(); + std::cout << std::endl; - //std::cout << "Modify a flat set using boost container" << std::endl; - //modifyAndPrintSets(); - //std::cout << std::endl; + std::cout << "Modify a flat set using boost container" << std::endl; + modifyAndPrintSets(); + std::cout << std::endl; - //std::cout << "Inspect the current directory using boost filesystem" << std::endl; - //inspectDirectory(); - //std::cout << std::endl; + std::cout << "Inspect the current directory using boost filesystem" << std::endl; + inspectDirectory(); + std::cout << std::endl; - - //if ( argc == 2 ) - //{ - // const std::string yamlFile( argv[1] ); - // std::cout << "Parse some yaml file with yaml-cpp" << std::endl; - // std::cout << " " << yamlFile << std::endl; - // parseConfig( yamlFile ); - //} - //else - //{ - // std::cout << "To parse a yaml file please specify file on command line" << std::endl; - // std::cout << " ./main YAMLFILE" << std::endl; - //} + if (argc == 2) + { + const std::string yamlFile(argv[1]); + std::cout << "Parse some yaml file with yaml-cpp" << std::endl; + std::cout << " " << yamlFile << std::endl; + parseConfig(yamlFile); + } + else + { + std::cout << "To parse a yaml file please specify file on command line" << std::endl; + std::cout << " ./main YAMLFILE" << std::endl; + } return 0; }