PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
Installation Guide

This guide explains how to set up PolyDiM and GeDiM on your local machine.

In particular, it includes instructions for:

  • C++ users
  • Python users
  • MATLAB users

‍Before performing the following steps, make sure that an SSH key is already configured on your local machine. For more information, see the documentation.

C++ PolyDiM and GeDiM

Follow the instructions below to install the C++ library on your local machine so that it can be connected by other applications.

Note: all the following actions can be found in the build_and_run_example_cpp.sh

Requirements

Installation is based on CMake. Minimum CMake 3.12 version is required.

To build the library we require C++20 standard.

We develop and test with gcc compiler. Minimum version required is gcc-10. See compiler support for more information.

Folder Setup

Clone the repository from the GitHub repository into a local directory on your computer. In the following instructions, this directory is referred to as ${BASE_FOLDER}.

git clone git@github.com:AURION-Polito/PolyDiM.git

Navigate to the cloned repository and initialize and update all Git submodules:

cd PolyDiM
git submodule init
git submodule update

External Dependencies

PolyDiM interfaces external libraries.

The installation requires the external dependencies already compiled and installed. Set the CMake variable CMAKE_PREFIX_PATH to give PolyDiM the path where the external libraries are installed.

Required Libraries

PolyDiM linear algebra operations are based on

PolyDiM geometrical operations are based on:

Optional Libraries

Moreover, PolyDiM currently interfaces and exploits the following optional libraries:

To activate/deactivate them can use the CMake variables:

Option Default
ENABLE_TRIANGLE OFF
ENABLE_TETGEN OFF
ENABLE_VORO OFF
ENABLE_SUITESPARSE OFF
ENABLE_PETSC OFF
ENABLE_METIS OFF
ENABLE_VTK OFF

Suggestion of installation of optional libraries

The directory /${BASE_FOLDER}/PolyDiM/gedim/3rd_party_libraries contains a CMake configuration that simplifies the local installation of several third-party dependencies.

The following libraries can be installed automatically:

  • Eigen
  • GoogleTest (see the Unit Test section for more information)
  • VTK
  • Triangle
  • TetGen
  • LAPACK
  • METIS
  • Voro++

You can enable or disable the installation of each dependency using the following CMake options:

Option Default
INSTALL_EIGEN3 ON
INSTALL_GOOGLETEST ON
INSTALL_TRIANGLE ON
INSTALL_TETGEN ON
INSTALL_VORO ON
INSTALL_LAPACK ON
INSTALL_METIS OFF
INSTALL_VTK OFF

Installation Optional Library Example

The following example installs the third-party dependencies into ${BASE_FOLDER}, enabling METIS while disabling TetGen:

mkdir externals
cd externals
cmake -DINSTALL_METIS=ON -DINSTALL_TETGEN=OFF /${BASE_FOLDER}/PolyDiM/gedim/3rd_party_libraries
make

If the build completes successfully, the selected third-party libraries will be installed under:

/${BASE_FOLDER}/externals/Main_Install

These installations can then be added to the CMake prefix path. For example:

cmake -DCMAKE_PREFIX_PATH="/${BASE_FOLDER}/externals/Main_Install/eigen3;/${BASE_FOLDER}/externals/Main_Install/triangle;/${BASE_FOLDER}/externals/Main_Install/googletest;/${BASE_FOLDER}/externals/Main_Install/metis;/${BASE_FOLDER}/externals/Main_Install/voro;/${BASE_FOLDER}/externals/Main_Install/lapack"

Final Library Installation

This final section provides an example of how to build and install the PolyDiM and GeDiM libraries.

The build will be performed in the directory /${BASE_FOLDER}/PolyDiM/build. Unless otherwise specified, the Release build configuration is used.

To build and install the PolyDiM and GeDiM libraries locally, run the following commands:

Note: The example below builds PolyDiM using 4 parallel jobs and enables the optional components introduced in the previous example.

mkdir /${BASE_FOLDER}/PolyDiM/build
cd /${BASE_FOLDER}/PolyDiM/build
cmake -DCMAKE_PREFIX_PATH="/${BASE_FOLDER}/externals/Main_Install/eigen3;/${BASE_FOLDER}/externals/Main_Install/triangle;/${BASE_FOLDER}/externals/Main_Install/googletest;/${BASE_FOLDER}/externals/Main_Install/metis;/${BASE_FOLDER}/externals/Main_Install/voro" \
-DENABLE_TRIANGLE=ON \
-DENABLE_VORO=ON \
-DENABLE_METIS=ON ..
make -j4 install

After the build process completes successfully, the libraries are installed in the directory specified by CMAKE_INSTALL_PREFIX.

By default, CMAKE_INSTALL_PREFIX is set to the PolyDiM subdirectory within the build directory. For the example above, the installation path is:

/${BASE_FOLDER}/PolyDiM/build/PolyDiM

To install the libraries in a custom location, set the CMAKE_INSTALL_PREFIX variable when configuring the project with CMake.

After installation, the libraries can be used from any CMake-based application by importing the GeDiM::GeDiM and PolyDiM::PolyDiM targets. For example:

find_package(GeDiM CONFIG REQUIRED)
find_package(PolyDiM CONFIG REQUIRED)
target_link_libraries(example
GeDiM::GeDiM
PolyDiM::PolyDiM
)

Unit Test

Unit tests for PolyDiM and GeDiM are available to verify that the libraries have been compiled correctly. Running the unit tests is optional and is not required to use the libraries.

The unit tests are based on the GoogleTest framework. The GTest and GMock libraries must already be installed on your system in order to build and run the tests.

To enable the unit tests, set the CMake options ENABLE_POLYDIM_UNIT_TESTS and/or ENABLE_GEDIM_UNIT_TESTS to ON. Both options are disabled (OFF) by default.

Unit Test Example

mkdir /${BASE_FOLDER}/PolyDiM/build
cd /${BASE_FOLDER}/PolyDiM/build
cmake -DCMAKE_PREFIX_PATH="/${BASE_FOLDER}/externals/Main_Install/eigen3;/${BASE_FOLDER}/externals/Main_Install/triangle;/${BASE_FOLDER}/externals/Main_Install/googletest;/${BASE_FOLDER}/externals/Main_Install/metis;/${BASE_FOLDER}/externals/Main_Install/voro" \
-DENABLE_TRIANGLE=ON \
-DENABLE_VORO=ON \
-DENABLE_METIS=ON \
-DENABLE_POLYDIM_UNIT_TESTS=ON \
-DENABLE_GEDIM_UNIT_TESTS=ON ..
make -j4 GedimUnitTest PolyDiMUnitTest
cd /${BASE_FOLDER}/PolyDiM/build/gedim/GeDiM/test/
./GedimUnitTest
cd /${BASE_FOLDER}/PolyDiM/build/PolyDiM/test/
./PolyDiMUnitTest

Tutorials

Tutorials for the use of PolyDiM are available in the folder /${BASE_FOLDER}/PolyDiM/build/PolyDiM/examples.

To enable the unit tests, set the CMake options ENABLE_POLYDIM_EXAMPLES to ON. The option is disabled (OFF) by default.

More details in the Examples page.

Tutorial Example

In the following, we build and run the 2D elliptic problem example, Elliptic_PCC_2D.

mkdir /${BASE_FOLDER}/PolyDiM/build
cd /${BASE_FOLDER}/PolyDiM/build
cmake -DCMAKE_PREFIX_PATH="/${BASE_FOLDER}/externals/Main_Install/eigen3;/${BASE_FOLDER}/externals/Main_Install/triangle;/${BASE_FOLDER}/externals/Main_Install/googletest;/${BASE_FOLDER}/externals/Main_Install/metis;/${BASE_FOLDER}/externals/Main_Install/voro" \
-DENABLE_TRIANGLE=ON \
-DENABLE_VORO=ON \
-DENABLE_METIS=ON \
-DENABLE_POLYDIM_EXAMPLES=ON ..
make -j4 Elliptic_PCC_2D
cd /${BASE_FOLDER}/PolyDiM/build/PolyDiM/examples/Elliptic_PCC_2D
./Elliptic_PCC_2D

When executed for the first time, the program generates a Parameters.ini file containing the default settings for the tutorial example.

The parameters can be modified either by editing the file or by specifying them on the command line. For example, running

./Elliptic_PCC_2D MethodOrder:uint=2

executes the same example using a finite element method of polynomial order (k = 2).

Along with examples, integration tests, such as convergence test, are available for each methods and orders that can be exploited to solve the related PDE problems. These test are provided as Python scripts.

PyPolyDiM

Starting from v2.0.0, PolyDiM is also available for Python.

Note: all the following actions can be found in the build_and_run_example_python.sh

Requirements

Installation is based on python3. Minimum python3.11 version is required.

Setup

You can install it using pip:

pip install pypolydim

Before installing the package, make sure that all required dependencies are available in your environment. PyPolyDiM relies on several standard scientific Python packages, including:

The complete list of dependencies can be found in the requirements.txt file located in the GitHub repository.

Tutorials

The GitHub repository contains examples and tutorials to help you get started with the library.

For instance, the file main_elliptic_pcc_2d.py contains the Python implementation of the C++ example presented in the previous section.

For more information and documentation, visit the project page on PyPI.

Matlab PolyDiM

Starting from v3.0.0, PolyDiM is also available for MATLAB users.

Information for setup and use can be found in MATLAB file exchange and on the official GitHub repository.

Previous Next
Home Examples