Skip to content

Commit efaa917

Browse files
committed
Populate high-level documentation quick and dirty
1 parent 0f4b635 commit efaa917

File tree

11 files changed

+252
-16
lines changed

11 files changed

+252
-16
lines changed

doc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ if (DOXYGEN_FOUND)
8383
"install.md"
8484
"profiling.md"
8585
"userguide.md"
86+
"gallery.md"
8687
ALL
8788
COMMENT "Generating docs"
8889
)

doc/build.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
\page build Build
22

3+
\note We recommend exploring the official [CMake documentation](https://cmake.org/cmake/help/latest/) to beginner CMake users, if they wish to build this project from source.
34

5+
Consider locally building and installing `pbatoolkit` against your native GPU for the following reasons.
6+
- Achieve optimal GPU performance for your platform.
7+
- Support older/newer GPUs and CUDA Toolkit versions.
8+
9+
Next steps:
410
- \subpage dependencies
511
- \subpage configuration
612
- \subpage install
713

814
<div class="section_buttons">
915

10-
| Previous | Next |
11-
|:----------------|------------------:|
12-
| \ref quickstart | \ref dependencies |
16+
| Previous | Next |
17+
|:-------------|------------------:|
18+
| \ref gallery | \ref dependencies |
1319

1420
</div>

doc/configuration.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
\page configuration Configuration
22

3+
| Option | Values | Default | Description |
4+
| ---------------------------- | -------- | ------- | ----------- |
5+
| `PBAT_BUILD_PYTHON_BINDINGS` | `ON,OFF` | `OFF` | Enable `PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit` Python bindings. Generates the CMake target `PhysicsBasedAnimationToolkit_Python`, an extension module for Python, built by this project. |
6+
| `PBAT_BUILD_TESTS` | `ON,OFF` | `OFF` | Enable `PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit` unit tests. Generates the CMake target executable `PhysicsBasedAnimationToolkit_Tests`, built by this project. |
7+
| `PBAT_ENABLE_PROFILER` | `ON,OFF` | `OFF` | Enable [`Tracy`](https://github.com/wolfpld/tracy) instrumentation profiling in built `PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit`. |
8+
| `PBAT_PROFILE_ON_DEMAND` | `ON,OFF` | `OFF` | Activate Tracy's on-demand profiling when `PBAT_ENABLE_PROFILER` is `ON`. |
9+
| `PBAT_USE_INTEL_MKL` | `ON,OFF` | `OFF` | Link to user-provided [Intel MKL](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html) installation via CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html). |
10+
| `PBAT_USE_SUITESPARSE` | `ON,OFF` | `OFF` | Link to user-provided [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse) installation via CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html). |
11+
| `PBAT_BUILD_SHARED_LIBS` | `ON,OFF` | `OFF` | Build project's library targets as shared/dynamic. |
12+
13+
Either run CMake's configure step manually
14+
```bash
15+
cmake -S <path/to/PhysicsBasedAnimationToolkit> -B <path/to/build> -D<option>=<value> ...
16+
```
17+
or, alternatively (and preferably)
18+
```bash
19+
cmake --preset=<my-favorite-user-preset>
20+
```
21+
22+
Our project provides [configuration presets](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/blob/master/CMakePresets.json) that capture typical use configurations. For the best experience, install [`vcpkg`](https://github.com/microsoft/vcpkg) and set `VCPKG_ROOT=path/to/vcpkg` as an environment variable. Then, you can select one of our available presets, for example `cmake --preset=default`. Refer to the [CMake presets documentation](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) for more information.
23+
324
<div class="section_buttons">
425

526
| Previous | Next |

doc/dependencies.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
\page dependencies Dependencies
22

3+
See [`vcpkg.json`](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/blob/master/vcpkg.json) for a versioned list of our external dependencies, available via [vcpkg](https://github.com/microsoft/vcpkg).
4+
5+
\note Use of [vcpkg](https://github.com/microsoft/vcpkg) is not mandatory, as long as external dependencies have compatible versions and are discoverable by CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) mechanism.
6+
7+
### CUDA
8+
9+
#### PyPI
10+
11+
[`pbatoolkit-gpu`](https://pypi.org/project/pbatoolkit-gpu/) (downloaded from PyPI) requires dynamically linking to an instance of the
12+
- [CUDA 12 Runtime library](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cuda-runtime), and your
13+
- [CUDA Driver](https://docs.nvidia.com/cuda/cuda-c-programming-guide/#driver-api).
14+
15+
\note Recall that the CUDA Runtime is [ABI compatible](https://docs.nvidia.com/cuda/archive/12.5.1/cuda-driver-api/version-mixing-rules.html) up to major version.
16+
17+
On 64-bit Windows, these are `cudart64_12.dll` and `nvcuda.dll`. Ensure that they are discoverable via Windows' [DLL search order](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order). We recommend adding `<drive>:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.<minor>\bin` (i.e. the binary folder of your CUDA Toolkit installation) to the `PATH` environment variable. The driver should already be on the search path by default after installation.
18+
19+
On Linux, they are `libcudart.so.12` and `libcuda.so.1`. Ensure that they are discoverable via Linux's [dynamic linker/loader](https://man7.org/linux/man-pages/man8/ld.so.8.html). If they are not already in a default search path, we recommend simply updating the library search path, i.e. `export LD_LIBRARY_PATH="path/to/driver/folder;path/to/runtime/folder;$LD_LIBRARY_PATH"`.
20+
21+
\note MacOS does not support CUDA GPUs.
22+
23+
Our [`pbatoolkit-gpu`](https://pypi.org/project/pbatoolkit/) prebuilt binaries include [PTX](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#virtual-architectures), such that program load times will be delayed by [JIT](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#just-in-time-compilation) compilation on first use. [Verify](https://developer.nvidia.com/cuda-gpus) that your NVIDIA GPU supports [compute capability](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#compute-capabilities) at least 7.0. For example, only RTX 2060 up to 4090 chips are supported in the GeForce series. Runtime GPU performance may be constrained by the targeted compute capability.
24+
325
<div class="section_buttons">
426

527
| Previous | Next |

doc/features.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
\page features Features
22

3+
- [Finite Element Method](https://hplgit.github.io/fem-book/doc/pub/book/pdf/fem-book-4print-2up.pdf#page=47.07) (FEM) meshes and operators
4+
- Dimensions `1,2,3`
5+
- [Lagrange shape functions](https://doc.comsol.com/5.3/doc/com.comsol.help.comsol/comsol_api_xmesh.40.4.html) of order `1,2,3`
6+
- Line, triangle, quadrilateral, tetrahedron and hexahedron elements
7+
- [Hyperelastic material models](https://en.wikipedia.org/wiki/Hyperelastic_material)
8+
- Saint-Venant Kirchhoff
9+
- [Stable Neo-Hookean](https://graphics.pixar.com/library/StableElasticity/paper.pdf)
10+
- Polynomial [quadrature rules](https://en.wikipedia.org/wiki/Numerical_integration)
11+
- [Simplices in dimensions `1,2,3`](https://lsec.cc.ac.cn/~tcui/myinfo/paper/quad.pdf)
12+
- [Gauss-Legendre quadrature](https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_quadrature)
13+
- Spatial query acceleration data structures
14+
- [Bounding volume hierarchy](https://en.wikipedia.org/wiki/Bounding_volume_hierarchy) for triangles (2D+3D) and tetrahedra (3D)
15+
- Nearest neighbours
16+
- Overlapping primitive pairs
17+
- Point containment
18+
- GPU algorithms
19+
- [Vertex Block Descent](https://graphics.cs.utah.edu/research/projects/vbd/vbd-siggraph2024.pdf) (VBD)
20+
- [eXtended Position Based Dynamics](https://mmacklin.com/xpbd.pdf) (XPBD)
21+
- Broad phase collision detection
22+
- [Sweep and Prune](https://en.wikipedia.org/wiki/Sweep_and_prune)
23+
- [Linear Bounding Volume Hierarchy](https://research.nvidia.com/sites/default/files/pubs/2012-06_Maximizing-Parallelism-in/karras2012hpg_paper.pdf)
24+
- Fixed-size linear algebra library for kernel programming
25+
- Seamless profiling integration via [Tracy](https://github.com/wolfpld/tracy)
26+
327
<div class="section_buttons">
428

529
| Previous | Next |

doc/gallery.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
\page gallery Gallery
2+
3+
Below, we show a few examples of what can be done in just a few lines of code using [`pbatoolkit`](https://pypi.org/project/pbatoolkit/) and Python. Code can be found [here](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/tree/master/python/examples).
4+
5+
## Real-time hyper elasticity dynamics
6+
7+
Our GPU implementation of the eXtended Position Based Dynamics (XPBD) algorithm simulates a ~324k element FEM elastic mesh interactively with contact.
8+
9+
<p float="left">
10+
<img src="gpu.xpbd.bvh.gif" width="250" alt="A 162k element armadillo mesh is dropped on top of another duplicate, but fixed, armadillo mesh on the bottom." />
11+
</p>
12+
13+
## Inter-penetration free elastodynamic contact
14+
15+
Combining [`pbatoolkit`](https://pypi.org/project/pbatoolkit/)'s FEM+elasticity features and the [`IPC Toolkit`](https://ipctk.xyz/) results in guaranteed inter-penetration free contact dynamics between deformable bodies.
16+
17+
<p float="left">
18+
<img src="ipc.bar.stacks.gif" width="250" alt="A stack of bending beams fall on top of each other, simulated via Incremental Potential Contact (IPC)." />
19+
</p>
20+
21+
## Modal analysis
22+
23+
The hyper elastic beam's representative deformation modes, i.e. its low frequency eigen vectors,
24+
are animated as time continuous signals.
25+
26+
<p float="left">
27+
<img src="beam.modes.gif" width="250" alt="Unconstrained hyper elastic beam's eigen frequencies" />
28+
</p>
29+
30+
## GPU broad phase collision detection
31+
32+
Real-time collision detection between 2 large scale meshes (~324k tetrahedra) is accelerated by highly parallel implementations of the [sweep and prune](https://en.wikipedia.org/wiki/Sweep_and_prune) algorithm, or [linear bounding volume hierarchies](https://research.nvidia.com/sites/default/files/pubs/2012-06_Maximizing-Parallelism-in/karras2012hpg_paper.pdf).
33+
34+
<p float="left">
35+
<img src="gpu.broadphase.gif" width="250" alt="Broad phase collision detection on the GPU between 2 moving tetrahedral meshes" />
36+
</p>
37+
38+
## Harmonic interpolation
39+
40+
A smooth (harmonic) function is constructed on [Entei](<https://bulbapedia.bulbagarden.net/wiki/Entei_(Pok%C3%A9mon)>), required to evaluate to `1` on its paws, and `0` at the top of its tail, using piece-wise linear (left) and quadratic (right) shape functions. Its isolines are displayed as black curves.
41+
42+
<p float="left">
43+
<img src="entei.harmonic.interpolation.order.1.png" width="250" alt="Harmonic interpolation on Entei model using linear shape functions" />
44+
<img src="entei.harmonic.interpolation.order.2.png" width="250" alt="Harmonic interpolation on Entei model using quadratic shape functions" />
45+
</p>
46+
47+
## Heat method for geodesic distance computation
48+
49+
Approximate geodesic distances are computed from the top center vertex of [Metagross](<https://bulbapedia.bulbagarden.net/wiki/Metagross_(Pok%C3%A9mon)>) by diffusing heat from it (left), and recovering a function whose gradient matches the normalized heat's negative gradient. Its isolines are displayed as black curves.
50+
51+
<p float="left">
52+
<img src="metagross.heat.source.png" width="250" alt="Heat source on top center of metagross model" />
53+
<img src="metagross.heat.geodesics.png" width="250" alt="Reconstructed single source geodesic distance" />
54+
</p>
55+
56+
## Mesh smoothing via diffusion
57+
58+
Fine details of Godzilla's skin are smoothed out by diffusing `x,y,z` coordinates in time.
59+
60+
<p float="left">
61+
<img src="godzilla.diffusion.smoothing.gif" width="250" alt="Godzilla model with fine details being smoothed out via diffusion" />
62+
</p>
63+
64+
<div class="section_buttons">
65+
66+
| Previous | Next |
67+
|:----------------|-----------:|
68+
| \ref quickstart | \ref build |
69+
70+
</div>

doc/install.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
\page install Install
22

3+
<div class="tabbed">
4+
- <b class="tab-title">C++</b>
5+
Build and install transparently across platforms using the [cmake build CLI](https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project) and [cmake install CLI](https://cmake.org/cmake/help/latest/guide/tutorial/Installing%20and%20Testing.html), respectively.
6+
7+
Our CMake project exposes the following build targets
8+
| Target | Description |
9+
|---|---|
10+
| `PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit` | The PBA Toolkit library. |
11+
| `PhysicsBasedAnimationToolkit_Tests` | The test executable, using [doctest](https://github.com/doctest/doctest). |
12+
| `PhysicsBasedAnimationToolkit_Python` | PBAT's Python extension module, using [pybind11](https://github.com/pybind/pybind11). |
13+
14+
For example, to build tests, run
15+
```bash
16+
cmake --build <path/to/build/folder> --target PhysicsBasedAnimationToolkit_Tests --config Release
17+
```
18+
19+
To install *PhysicsBasedAnimationToolkit* locally, run
20+
```bash
21+
cd path/to/PhysicsBasedAnimationToolkit
22+
cmake -S . -B build -D<option>=<value> ...
23+
cmake --install build --config Release
24+
```
25+
- <b class="tab-title">Python</b>
26+
27+
For a local installation, which builds from source, our Python bindings build relies on [Scikit-build-core](https://scikit-build-core.readthedocs.io/en/latest/index.html), which relies on CMake's [`install`](https://cmake.org/cmake/help/latest/command/install.html) mechanism. As such, you can configure the installation as you typically would when using the CMake CLI directly, by now passing the corresponding CMake arguments in `pip`'s `config-settings` parameter (refer to the [Scikit-build-core](https://scikit-build-core.readthedocs.io/en/latest/index.html) documentation for the relevant parameters). See our [pyinstall workflow](.github/workflows/pyinstall.yml) for working examples of building from source on Linux, MacOS and Windows. Then, assuming that external dependencies are found via CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html), you can build and install our Python package [`pbatoolkit`](https://pypi.org/project/pbatoolkit/) locally and get the most up to date features.
28+
29+
\note Consider using a [Python virtual environment](https://docs.python.org/3/library/venv.html) for this step.
30+
31+
As an example, assuming use of [`vcpkg`](https://github.com/microsoft/vcpkg) for external dependency management with `VCPKG_ROOT=path/to/vcpkg` set as an environment variable, run
32+
33+
```bash
34+
pip install . --config-settings=cmake.args="--preset=pip-cuda" -v
35+
```
36+
37+
on the command line to build [`pbatoolkit`](https://pypi.org/project/pbatoolkit/) from source with GPU algorithms included. Additional environment variables (i.e. [`CUDA_PATH`](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html)) and/or CMake variables (i.e. [`CMAKE_CUDA_COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html#variable:CMAKE_%3CLANG%3E_COMPILER)) may be required to be set in order for CMake to correctly discover and compile against your targeted local CUDA installation. Refer to [the CMake documentation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html) for more details.
38+
339
<div class="section_buttons">
440

541
| Previous | Next |

doc/main.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@
88

99
![](img/entei.icon.png)
1010

11-
<div class="tabbed">
12-
- <b class="tab-title">C++</b>
13-
```cpp
14-
#include <pbat/Pbat.h>
15-
```
16-
- <b class="tab-title">Python</b>
17-
```python
18-
import pbatoolkit as pbat
19-
```
20-
</div>
11+
The Physics Based Animation Toolkit (PBAT) is a cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation in dimensions `1,2,3`. For most use cases, we recommend using our library via its Python interface, enabling seamless integration into Python's ecosystem of powerful scientific computing packages.
12+
13+
\note Currently, the `master` branch may contain breaking changes at any point in time. We recommend users to use specific git tags, i.e. via `git checkout v<major>.<minor>.<patch>`, where the version `<major>.<minor>.<patch>` matches the installed `pbatoolkit`'s version downloaded from PyPI (i.e. from `pip install pbatoolkit`).
2114

2215
- \subpage features
2316
- \subpage quickstart
17+
- \subpage gallery
2418

2519
<div class="section_buttons">
2620

doc/profiling.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
\page profiling Profiling
22

3+
\note We recommend downloading the [Tracy](https://github.com/wolfpld/tracy) profiler server to analyze execution of PBAT algorithms, available as [precompiled executable](https://github.com/wolfpld/tracy/releases). PBAT currently supports [Tracy 0.10](https://github.com/wolfpld/tracy/releases/tag/v0.10).
4+
5+
##### Profiling statistics
6+
7+
Computation details are gathered when using [`pbatoolkit`](https://pypi.org/project/pbatoolkit/) and consulted in the [Tracy](https://github.com/wolfpld/tracy) profiling server GUI.
8+
9+
<p float="left">
10+
<img src="profiling.statistics.png" alt="Profiling statistics widget in Tracy server" />
11+
</p>
12+
313
<div class="section_buttons">
414

515
| Previous |

doc/quickstart.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,55 @@
11
\page quickstart Quick start
22

3+
<div class="tabbed">
4+
- <b class="tab-title">C++</b>
5+
Take a look at the unit tests, found in the library's source (`.cpp` or `.cu`) files.
6+
```cpp
7+
#include <pbat/Pbat.h>
8+
```
9+
- <b class="tab-title">Python</b>
10+
To download and install from PyPI, run in command line
11+
```bash
12+
pip install pbatoolkit
13+
```
14+
or, alternatively
15+
```bash
16+
pip install pbatoolkit-gpu
17+
```
18+
if your environment is properly setup to use our GPU algorithms.
19+
20+
Verify [`pbatoolkit`](https://pypi.org/project/pbatoolkit/)'s contents in a Python shell
21+
```python
22+
import pbatoolkit as pbat
23+
help(pbat.fem)
24+
help(pbat.geometry)
25+
help(pbat.profiling)
26+
help(pbat.math)
27+
help(pbat.gpu)
28+
```
29+
30+
A bunch of Python scripts demonstrating usage of [`pbatoolkit`](https://pypi.org/project/pbatoolkit/) can be found in the [examples folder](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/tree/master/python/examples), along with their associated [`requirements.txt`](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/tree/master/python/examples/requirements.txt) for easily downloading necessary dependencies via `pip install -r path/to/requirements.txt`.
31+
32+
Their command line interface follows the pattern
33+
```bash
34+
python[.exe] path/to/examples/[example].py -i path/to/input/mesh
35+
```
36+
37+
The full interface is always revealed by `-h` or `--help`, i.e.
38+
```bash
39+
python[.exe] path/to/examples/[example].py -h
40+
```
41+
42+
\note The examples assume the user provides the meshes to [`pbatoolkit`](https://pypi.org/project/pbatoolkit/). Triangle (surface) meshes can easily be obtained via [Thingi10K](https://ten-thousand-models.appspot.com/), [TurboSquid](https://www.turbosquid.com/Search/3D-Models/free) or authored yourself in [Blender](https://www.blender.org/). Tools like [TetWild](https://github.com/Yixin-Hu/TetWild), [fTetWild](https://github.com/wildmeshing/fTetWild) and [TetGen](https://wias-berlin.de/software/index.jsp?id=TetGen&lang=1) can then convert them into tetrahedral (volume) meshes. We provide [helper scripts](python/tools/mesh/) to facilitate mesh processing and their associated [`requirements.txt`](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/blob/master/python/tools/mesh/requirements.txt).
43+
44+
</div>
45+
46+
47+
Example results are showcased in our [Gallery](https://github.com/Q-Minh/PhysicsBasedAnimationToolkit/tree/master?tab=readme-ov-file#gallery).
48+
349
<div class="section_buttons">
450

5-
| Previous | Next |
6-
|:--------------|-----------:|
7-
| \ref features | \ref build |
51+
| Previous | Next |
52+
|:--------------|-------------:|
53+
| \ref features | \ref gallery |
854

955
</div>

0 commit comments

Comments
 (0)