Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build

.git

.gitignore

.DS_Store

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
54 changes: 54 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
)
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
55 changes: 28 additions & 27 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -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 <iostream>
#include <string>

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;
}