libpgo: Library for Physically based Simulation (P), Geometric Shape Modeling (G), and Optimization (O)
The library is designed to primarily focus on physically based simulations, geometric shape modeling, and optimization. The source code extends VegaFEM and is designed for academic research purposes.
The wheel package of following platform have been provided for ease of use. They are in ./dist folder:
- Ubuntu 24.04:
ubuntu24.04/pypgo-0.0.3-cp312-cp312-linux_x86_64.whl. Note that you still need to installgmpandmpfras suggested in the prerequisites. You mayapt installthem if needed. - Ubuntu 22.04:
ubuntu22.04/pypgo-0.0.2-cp311-cp311-linux_x86_64.whl. Note that you still need to installgmpandmpfras suggested in the prerequisites. You mayapt installthem if needed. This version depends on a lower version of the libc, so it should be more compatible. - Windows:
win11/pypgo-0.0.3-cp312-cp312-win_amd64.whl. The package is built under Windows 11, Visual Studio 2022. In theory, it supports other windows platforms. - MacOS Arm:
pypgo-0.0.3-cp312-cp312-macosx_26_0_arm64.whl. The package is built under Tahoe 26.0.1 on Apple M3.
Do pip install ./dist/your-chosen.whl to install the package. Note that the packages are experimental.
-
CMake >= 3.28
We use several functionalities that are only supported by 3.28+.In most cases, both system's CMake and Conda Environment's CMake have a lower version of CMake unfortunately. In this sitation, please install a new CMake into your system. The latest CMake, either pre-built binaries or source files, can be obtained directly from the official website. Once installed, hook
cmaketo the newly installed one, either by adding theyour-new-cmake/binto the front of thePATHor by replacing the existingcmakeexecutable with the new one. -
Compilers
-
GCC 11, 12, 13 for Ubuntu
We use C++20, so only GCC 11, 12, and 13 are supported. You can get new gcc usingaptor compile a new one from its source code. -
Apple Clang (We tested on 15.0.0, Mac OS 14.5)
Earlier versions might work if it supports C++20. -
Visual Studio 2022 (We tested on 17.9.5, Windows)
Earlier Visual Studio 2022 versions might work.
-
-
GMP and MPFR for Ubuntu and Mac OS
This can be installed on Ubuntu bysudo apt install libgmp-dev libmpfr-dev
Or it can be installed on Mac OS by
brew install gmp mpfr
-
(Optional) Ninja
It can be installed bypip install ninja
for better compilation performance
-
(Optional) numpy
This is used for running tests.
Going forward, it is assumed that all specified prerequisites are installed and that a Conda environment is used for python.
Install prerequisites:
conda install tbb tbb-devel mkl mkl-devel
conda install conda-forge::imathInstall libpgo:
cd libpgo
pip install .If ninja has been installed, it will compile source files in parallel. If it is not installed,
set CMAKE_BUILD_PARALLEL_LEVEL to n, where n is the number of threads for compilation, to control the parallel compilation.
Install libpgo
cd libpgo
pip install .We provide three python scripts to test the installation.
-
pgo_test_01.py. It runs a few basic pgo APIs.cd examples python ../src/python/pypgo/pgo_test_01.pyThe expected result will look like
Opening file torus.veg. #vtx:564 #tets:1950 164,134,506,563 L Info: 10067040 (10067040,) (10067040,) 125.0 GTLTLG Info: 503400 (503400,) (503400,) 9695578.0 [[ 6.958279 0. 0. -17.495821 0. 0. 13.10052 0. 0. -2.5629783 0. 0. ] [ 0. 6.958279 0. 0. -17.495821 0. 0. 13.10052 0. 0. -2.5629783 0. ] [ 0. 0. 6.958279 0. 0. -17.495821 0. 0. 13.10052 0. 0. -2.5629783] [ -5.1109824 0. 0. 10.111505 0. 0. 8.160282 0. 0. -13.160804 0. 0. ] [ 0. -5.1109824 0. 0. 10.111505 0. 0. 8.160282 0. 0. -13.160804 0. ] [ 0. 0. -5.1109824 0. 0. 10.111505 0. 0. 8.160282 0. 0. -13.160804 ] [ 23.97409 0. 0. -6.634346 0. 0. -1.4866991 0. 0. -15.853046 0. 0. ] [ 0. 23.97409 0. 0. -6.634346 0. 0. -1.4866991 0. 0. -15.853046 0. ] [ 0. 0. 23.97409 0. 0. -6.634346 0. 0. -1.4866991 0. 0. -15.853046 ]] -
pgo_run_sim.py. It reads input config file and run simulation. You can trybox,box-with-sphere,dragon, anddragon-dynto test different simulation results. Take the box example for illustration. You can run the box example using the following commands.cd examples/box python ../../src/python/pypgo/pgo_run_sim.py box.jsonThe expected result will look like the first image. The time integrator is hard-coded as implicit backward Euler (BE). You are free to change it to implicit Newmark (NW) or TR-BDF2 integrator (not support friction).
Box (NM) Box with Sphere (NM) 

Dragon (BE) Bunny (BE) 

Rest Dragon Deformed Dragon 

-
pgo_dump_abc.py. It creates the abc file that can be used for blender/maya from config fileanim.json. Essentially, it takes the simulation output.objsequences and output a.abcfile.cd examples/box python ../../src/python/pypgo/pgo_dump_abc.py anim.json ./
If you want to use the library with your C++ code or modify the source code, you may build it without python.
To compile the lib with a basic functionality,
cd libpgo
mkdir build
cd build
cmake ..To enable all functionalities, Install MKL. Then,
cd libpgo
mkdir build
cd build
cmake .. -DPGO_USE_MKL=1 -DPGO_ENABLE_FULL=1On Windows, a few extra steps are need before running the above commands. First, the library should be configured in "x64 Native Tools Command Prompt for VS 2022". In addition, before running the commands above, run
c:\Program Files (x86)\Intel\oneAPI\setvars.batto setup the environments for MKL, wherec:\Program Files (x86)\Intel\oneAPIis the path to the oneAPI installation. Once setup, run above commands.
On Ubuntu, a similar procedure is needed. Before configuring the library, run
bash /opt/intel/oneapi/setvars.shto setup the MKL environments for the subsequent cmake configuration.
To have a basic functionality, use CMake to compile it like on Windows & Ubuntu.
To enable all functionalities,
cd libpgo
mkdir build
cd build
cmake .. -DPGO_ENABLE_FULL=1 -DDPGO_ENABLE_ALEMBIC=1 -DPGO_ENABLE_GMSH=1The last two flags work only if you have imath and gmesh libs.
This library use the following third-party libraries:
alembic, argparse, autodiff, boost, ceres, cgal, fmt, geogram, gmesh, json, knitro, libigl, mkl, pybind11, spdlog, suitesparse, tbb, tinyobj-loader
This library is developed using VegaFEM along with various third-party libraries, each governed by their respective licenses. Detailed copyright and license information is included within the majority of the source files.
In instances where specific licensing details are not provided within a source file, the copyright remains with the author. The licensing for those source files adhere to the principles of the pre-existing license framework. For instance, if a source file without licensing details incorporates components that fall under the GPL parts of CGAL, then that file will adhere to the GPL. All other source files default to the MIT License unless stated otherwise.
- Functional and compilable on three major platforms.
- Documentation
- More python interface
- Cleanup source code with non-MIT/non-FreeBSD licence.
- GUI