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
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# General
cmake_minimum_required(VERSION 3.16.2)
project(sse_cmake_exercise)

# Packages
find_package(Boost REQUIRED COMPONENTS filesystem)
find_package(deal.II REQUIRED)
find_package(yaml-cpp REQUIRED)

# Source files
set(SOURCE_FILES
fem/fem.cpp
flatset/flatset.cpp
filesystem/filesystem.cpp
yamlParser/yamlParser.cpp
)

# Header files
set(HEADER_FILES
fem/fem.hpp
flatset/flatset.hpp
filesystem/filesystem.hpp
yamlParser/yamlParser.hpp
)

# Executable
add_executable(${PROJECT_NAME} main.cpp ${SOURCE_FILES} ${HEADER_FILES})

# deal.II
deal_ii_initialize_cached_variables()
deal_ii_setup_target(${PROJECT_NAME})

# Linking
target_link_libraries(${PROJECT_NAME} ${Boost_FILESYSTEM_LIBRARY} yaml-cpp)
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ubuntu:24.04

RUN mkdir yaml
COPY yaml.sh /yaml/yaml.sh

RUN apt-get update && apt-get install -y build-essential cmake libdeal.ii-dev libboost-all-dev wget
RUN ./yaml/yaml.sh
4 changes: 2 additions & 2 deletions build_and_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
./main ../yamlParser/config.yml
make -j
./sse_cmake_exercise ../yamlParser/config.yml
53 changes: 26 additions & 27 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
//#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>

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 << "Inspect the current directory using boost filesystem" << std::endl;
//inspectDirectory();
//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;

//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;
}
28 changes: 28 additions & 0 deletions yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

mkdir yaml && cd yaml

# config yamlcpp

YAMLCPP_VERSION="0.6.3"
YAMLCPP_TAR_GZ="yaml-cpp-${YAMLCPP_VERSION}.tar.gz"
YAMLCPP_URL="https://github.com/jbeder/yaml-cpp/archive/refs/tags/${YAMLCPP_TAR_GZ}"
PREFIX_DIR="$(pwd)/yaml-cpp-${YAMLCPP_VERSION}"

# download yamlcpp
mkdir -p build
wget -O "build/${YAMLCPP_TAR_GZ}" "${YAMLCPP_URL}"
tar -xzf "build/${YAMLCPP_TAR_GZ}" -C build

# build yamlcpp
mkdir -p "build/yaml-cpp-build-${YAMLCPP_VERSION}" "${PREFIX_DIR}"

cmake -S "build/yaml-cpp-yaml-cpp-${YAMLCPP_VERSION}" -B "build/yaml-cpp-build-${YAMLCPP_VERSION}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${PREFIX_DIR}" \
-DYAML_BUILD_SHARED_LIBS=ON \
-DYAML_BUILD_TESTS=OFF \
-DYAML_BUILD_TOOLS=OFF
cmake --build "build/yaml-cpp-build-${YAMLCPP_VERSION}" --target install -j

echo "Installed yaml-cpp at ${PREFIX_DIR}"