Skip to content

Commit 4b6eac8

Browse files
Add building and container recipes
1 parent 42a78b7 commit 4b6eac8

3 files changed

Lines changed: 107 additions & 26 deletions

File tree

CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(cmake_exercise)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
7+
# --- Find Dependencies ---
8+
find_package(Boost REQUIRED COMPONENTS filesystem)
9+
find_package(deal.II REQUIRED)
10+
find_package(yaml-cpp REQUIRED)
11+
find_package(MPI REQUIRED)
12+
find_package(OpenMP REQUIRED)
13+
14+
# --- Define the Executable ---
15+
add_executable(main
16+
main.cpp
17+
flatset/flatset.cpp
18+
filesystem/filesystem.cpp
19+
fem/fem.cpp
20+
yamlParser/yamlParser.cpp
21+
)
22+
23+
# --- Link Libraries ---
24+
# 1. Setup deal.II (Handles Trilinos, PETSc, TBB, etc.)
25+
deal_ii_setup_target(main)
26+
27+
# 2. Link other libraries (Using plain style to match deal.II)
28+
target_link_libraries(main
29+
Boost::filesystem
30+
yaml-cpp
31+
MPI::MPI_CXX
32+
OpenMP::OpenMP_CXX
33+
)
34+
35+
# --- Include Directories ---
36+
target_include_directories(main PRIVATE
37+
${CMAKE_CURRENT_SOURCE_DIR}
38+
/usr/include/trilinos
39+
/usr/include/petsc
40+
)

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM ubuntu:24.04
2+
3+
# Prevent interactive prompts during installation
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
# Install all dependencies including the tricky ones (Trilinos, PETSc, TBB, MPI, Kokkos)
7+
RUN apt-get update && apt-get install -y \
8+
build-essential \
9+
cmake \
10+
git \
11+
wget \
12+
unzip \
13+
vim \
14+
libboost-all-dev \
15+
libdeal.ii-dev \
16+
mpi-default-dev \
17+
libkokkos-dev \
18+
libtrilinos-epetra-dev \
19+
libtrilinos-epetraext-dev \
20+
libtrilinos-teuchos-dev \
21+
libtrilinos-aztecoo-dev \
22+
libtrilinos-amesos-dev \
23+
libtrilinos-ifpack-dev \
24+
libtrilinos-ml-dev \
25+
libpetsc-real-dev \
26+
libtbb-dev \
27+
&& rm -rf /var/lib/apt/lists/*
28+
29+
# Manual install of yaml-cpp 0.6.3
30+
WORKDIR /tmp
31+
RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.zip
32+
RUN unzip yaml-cpp-0.6.3.zip
33+
RUN cd yaml-cpp-yaml-cpp-0.6.3 && \
34+
mkdir build && cd build && \
35+
cmake .. -DYAML_BUILD_SHARED_LIBS=ON && \
36+
make -j4 && \
37+
make install
38+
39+
# Set environment variables
40+
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
41+
WORKDIR /cmake-exercise

main.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
//#include "fem/fem.hpp"
2-
//#include "flatset/flatset.hpp"
3-
//#include "filesystem/filesystem.hpp"
4-
//#include "yamlParser/yamlParser.hpp"
1+
#include "fem/fem.hpp"
2+
#include "flatset/flatset.hpp"
3+
#include "filesystem/filesystem.hpp"
4+
#include "yamlParser/yamlParser.hpp"
55
#include <iostream>
66

77
int main(int argc, char *argv[])
88
{
99
std::cout << "Let's fight with CMake, Docker, and some dependencies!" << std::endl << std::endl;
1010

11-
//std::cout << "Solve Poisson problem with FEM using deal.II" << std::endl;
12-
//Fem fem;
13-
//fem.run();
14-
//std::cout << std::endl;
11+
std::cout << "Solve Poisson problem with FEM using deal.II" << std::endl;
12+
Fem fem;
13+
fem.run();
14+
std::cout << std::endl;
1515

16-
//std::cout << "Modify a flat set using boost container" << std::endl;
17-
//modifyAndPrintSets();
18-
//std::cout << std::endl;
16+
std::cout << "Modify a flat set using boost container" << std::endl;
17+
modifyAndPrintSets();
18+
std::cout << std::endl;
1919

20-
//std::cout << "Inspect the current directory using boost filesystem" << std::endl;
21-
//inspectDirectory();
22-
//std::cout << std::endl;
20+
std::cout << "Inspect the current directory using boost filesystem" << std::endl;
21+
inspectDirectory();
22+
std::cout << std::endl;
2323

2424

25-
//if ( argc == 2 )
26-
//{
27-
// const std::string yamlFile( argv[1] );
28-
// std::cout << "Parse some yaml file with yaml-cpp" << std::endl;
29-
// std::cout << " " << yamlFile << std::endl;
30-
// parseConfig( yamlFile );
31-
//}
32-
//else
33-
//{
34-
// std::cout << "To parse a yaml file please specify file on command line" << std::endl;
35-
// std::cout << " ./main YAMLFILE" << std::endl;
36-
//}
25+
if ( argc == 2 )
26+
{
27+
const std::string yamlFile( argv[1] );
28+
std::cout << "Parse some yaml file with yaml-cpp" << std::endl;
29+
std::cout << " " << yamlFile << std::endl;
30+
parseConfig( yamlFile );
31+
}
32+
else
33+
{
34+
std::cout << "To parse a yaml file please specify file on command line" << std::endl;
35+
std::cout << " ./main YAMLFILE" << std::endl;
36+
}
3737

3838
return 0;
3939
}

0 commit comments

Comments
 (0)