Skip to content

Commit 25a8914

Browse files
authored
Python API (#96)
This revision includes the new Python API and minor updates on the C++ API.
1 parent 17bc449 commit 25a8914

File tree

271 files changed

+13786
-2063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+13786
-2063
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "external/googletest"]
22
path = external/googletest
33
url = https://github.com/google/googletest
4+
[submodule "external/pybind11"]
5+
path = external/pybind11
6+
url = https://github.com/pybind/pybind11.git

.travis.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,11 @@ language: cpp
22

33
matrix:
44
include:
5-
# Test Ubuntu 14.04 + clang
6-
- os: linux
7-
dist: trusty
8-
sudo: required
9-
compiler: clang
105
# Test Ubuntu 14.04 + gcc
116
- os: linux
127
dist: trusty
138
sudo: required
149
compiler: gcc
15-
# Test OS X 10.10 + Xcode 6.4 + clang
16-
- os: osx
17-
osx_image: xcode6.4
18-
compiler: clang
19-
# Test OS X 10.10 + Xcode 6.4 + gcc
20-
- os: osx
21-
osx_image: xcode6.4
22-
compiler: gcc
2310
# Test OS X 10.11 + Xcode 7.3 + clang
2411
- os: osx
2512
osx_image: xcode7.3
@@ -28,10 +15,20 @@ matrix:
2815
- os: osx
2916
osx_image: xcode7.3
3017
compiler: gcc
18+
# Test OS X 10.12 + Xcode 8.3 + clang
19+
- os: osx
20+
osx_image: xcode8.3
21+
compiler: clang
22+
# Test OS X 10.12 + Xcode 8.3 + gcc
23+
- os: osx
24+
osx_image: xcode8.3
25+
compiler: gcc
3126

3227
script:
3328
- mkdir build
3429
- cd build
3530
- cmake ..
3631
- make
3732
- bin/unit_tests
33+
- pip install --user ..
34+
- python ../src/tests/python_tests/main.py

3RD_PARTY.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,85 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
401401

402402
Jet uses portion of Fluid3D by Christopher Batty.
403403
Original code from: https://github.com/christopherbatty/Fluid3D
404+
405+
---
406+
407+
Jet uses pybind11 for Python binding.
408+
409+
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
410+
411+
Redistribution and use in source and binary forms, with or without
412+
modification, are permitted provided that the following conditions are met:
413+
414+
1. Redistributions of source code must retain the above copyright notice, this
415+
list of conditions and the following disclaimer.
416+
417+
2. Redistributions in binary form must reproduce the above copyright notice,
418+
this list of conditions and the following disclaimer in the documentation
419+
and/or other materials provided with the distribution.
420+
421+
3. Neither the name of the copyright holder nor the names of its contributors
422+
may be used to endorse or promote products derived from this software
423+
without specific prior written permission.
424+
425+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
426+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
427+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
428+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
429+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
430+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
431+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
432+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
433+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
434+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
435+
436+
You are under no obligation whatsoever to provide any bug fixes, patches, or
437+
upgrades to the features, functionality or performance of the source code
438+
("Enhancements") to anyone; however, if you choose to make your Enhancements
439+
available either publicly, or directly to the author of this software, without
440+
imposing a separate written license agreement for such Enhancements, then you
441+
hereby grant the following license: a non-exclusive, royalty-free perpetual
442+
license to install, use, modify, prepare derivative works, incorporate into
443+
other computer software, distribute, and sublicense such enhancements or
444+
derivative works thereof, in binary and source code form.
445+
446+
---
447+
448+
Jet uses portion of pybind/cmake_example for Python binding.
449+
450+
Copyright (c) 2016 The Pybind Development Team, All rights reserved.
451+
452+
Redistribution and use in source and binary forms, with or without
453+
modification, are permitted provided that the following conditions are met:
454+
455+
1. Redistributions of source code must retain the above copyright notice, this
456+
list of conditions and the following disclaimer.
457+
458+
2. Redistributions in binary form must reproduce the above copyright notice,
459+
this list of conditions and the following disclaimer in the documentation
460+
and/or other materials provided with the distribution.
461+
462+
3. Neither the name of the copyright holder nor the names of its contributors
463+
may be used to endorse or promote products derived from this software
464+
without specific prior written permission.
465+
466+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
467+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
468+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
469+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
470+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
471+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
472+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
473+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
474+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
475+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
476+
477+
You are under no obligation whatsoever to provide any bug fixes, patches, or
478+
upgrades to the features, functionality or performance of the source code
479+
("Enhancements") to anyone; however, if you choose to make your Enhancements
480+
available either publicly, or directly to the author of this software, without
481+
imposing a separate written license agreement for such Enhancements, then you
482+
hereby grant the following license: a non-exclusive, royalty-free perpetual
483+
license to install, use, modify, prepare derivative works, incorporate into
484+
other computer software, distribute, and sublicense such enhancements or
485+
derivative works thereof, in binary and source code form.

CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88

99
# CMake version
10-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
10+
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
1111

1212
# Include cmake modules
1313
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -16,13 +16,15 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1616
project(jet)
1717

1818
# Set output directories
19+
set(DEFAULT_CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
1920
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
2021
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
2122
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
2223

2324
# Includes
2425
include_directories(include)
2526
include_directories(external)
27+
include_directories(external/pybind11/include)
2628
include_directories(external/googletest/googletest/include)
2729
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
2830
include_directories(src/winix)
@@ -55,9 +57,14 @@ add_custom_target(unzip_py ALL
5557
DEPENDS ${RESOURCES_OBJS})
5658

5759
# Project modules
58-
add_subdirectory(external/cnpy)
5960
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
6061
add_subdirectory(external/googletest EXCLUDE_FROM_ALL)
62+
if ((CMAKE_VERSION VERSION_EQUAL 3.3) OR (CMAKE_VERSION VERSION_GREATER 3.3))
63+
cmake_policy(SET CMP0063 NEW)
64+
endif()
65+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
66+
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
67+
add_subdirectory(external/cnpy)
6168
add_subdirectory(external/pystring)
6269
add_subdirectory(src/jet)
6370
add_subdirectory(src/tests/manual_tests)
@@ -74,3 +81,9 @@ add_subdirectory(src/examples/particles2obj)
7481
add_subdirectory(src/examples/particles2xml)
7582
add_subdirectory(src/examples/smoke_sim)
7683
add_subdirectory(src/examples/sph_sim)
84+
85+
add_subdirectory(external/pybind11)
86+
if (BUILD_FROM_PIP)
87+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DEFAULT_CMAKE_LIBRARY_OUTPUT_DIRECTORY})
88+
endif()
89+
add_subdirectory(src/python)

INSTALL.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ To build the code, a compiler that supports C++11 is required. Platform-specific
1818
Jet supports OS X 10.10 Yosemite or higher. Also, Xcode 6.4 or higher and the command line tools are required for building Jet. Once ready, install [Homebrew](http://brew.sh) and run the following command line to setup [CMake](https://cmake.org/):
1919

2020
```
21-
brew install cmake
21+
brew install cmake python
2222
```
2323

24+
> Note that we want `brew` version of Python which is recommended. You can still use macOS's default Python.
25+
2426
Once CMake is installed, build the code by running
2527

2628
```
@@ -30,18 +32,22 @@ cmake ..
3032
make
3133
```
3234

35+
> Of course, use `make -j<num_threads>` flag to boost up the build performance by using multithreads.
36+
3337
This will build entire codebase. To run the unit test, execute
3438

3539
```
3640
bin/unit_tests
3741
```
3842

43+
It should show all the tests are passing.
44+
3945
### Building from Ubuntu
4046

4147
Jet supports Ubuntu 14.04 or higher. Using `apt-get`, install required tools and libraries by running,
4248

4349
```
44-
sudo apt-get install build-essential python cmake
50+
sudo apt-get install build-essential python-dev python-pip cmake
4551
```
4652

4753
This will install GNU compilers, python, and CMake. Once installed, build the code by running
@@ -53,15 +59,19 @@ cmake ..
5359
make
5460
```
5561

62+
> Again, use `make -j<num_threads>` flag to boost up the build performance by using multithreads.
63+
5664
This will build entire codebase. To run the unit test, execute
5765

5866
```
5967
bin/unit_tests
6068
```
6169

70+
It should show all the tests are passing.
71+
6272
### Building from Windows
6373

64-
To build the code on Windows, [CMake](https://cmake.org/) and Visual Studio 2015 is required. Windows' version of CMake is available from [this website](https://cmake.org/), and free version of VS 2015 also can be downloaded from [Visual Studio Community 2015](https://www.Visualstudio.com/en-us/products/Visual-studio-community-vs.aspx). In addition to Visual Studio, install [Python](https://www.python.org/) (2.7.9 or higher recommended) to run post-build events.
74+
To build the code on Windows, CMake, Python, and Visual Studio 2015 (or higher) is required. Windows' version of CMake is available from [this website](https://cmake.org/), Python installer can be downloaded from [here](https://python.org/). For Python, version 2.7.9 or later is recommended. To install Visual Studio, the community edition of the tool can be downloaded from [Visual Studio Community 2015](https://www.Visualstudio.com/en-us/products/Visual-studio-community-vs.aspx). You can also use Visual Studio 2017.
6575

6676
Once everything is installed, run the following commands:
6777

@@ -87,9 +97,9 @@ bin\Release\unit_tests.exe
8797

8898
### Running Tests
8999

90-
There are three different tests in the codebase including the unit test, manual test, and performance test. For the detailed instruction on how to run those tests, please checkout the documentation page from [the project website](http://doyubkim.github.io/fluid-engine-dev/documentation/).
100+
There are four different tests in the codebase including the unit test, manual test, performance test, and Python API test. For the detailed instruction on how to run those tests, please checkout the documentation page from [the project website](http://doyubkim.github.io/fluid-engine-dev/documentation/).
91101

92-
### Installing SDK
102+
### Installing C++ SDK
93103

94104
For macOS and Ubuntu platforms, the library can be installed by running
95105

@@ -109,6 +119,22 @@ cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=_INSTALL_PATH_
109119

110120
Then, build `INSTALL` project under `jet.sln`. This will install the header files and the static library `jet.lib` under `_INSTALL_PATH_`.
111121

122+
### Installing Python SDK
123+
124+
To install the Python SDK, `pyjet`, run the following command from the project root directory (where `setup.py` lives):
125+
126+
```
127+
pip install .
128+
```
129+
130+
Once installed, try running the unit test to see if the module is installed correctly:
131+
132+
```
133+
python src/tests/python_tests/main.py
134+
```
135+
136+
The tests should pass.
137+
112138
### Coding Style
113139

114140
Jet uses clang-format. Checkout [`.clang-format`](https://github.com/doyubkim/fluid-engine-dev/blob/master/.clang-format) file for the style guideline.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Fluid Engine Dev - Jet
22

3-
[![License](http://img.shields.io/:license-mit-blue.svg)](LICENSE.md) [![Build Status](https://travis-ci.org/doyubkim/fluid-engine-dev.svg?branch=master)](https://travis-ci.org/doyubkim/fluid-engine-dev) [![Build status](https://ci.appveyor.com/api/projects/status/kulihlhy43vbwou6/branch/master?svg=true)](https://ci.appveyor.com/project/doyubkim/fluid-engine-dev/branch/master)
3+
[![License](http://img.shields.io/:license-mit-blue.svg)](LICENSE.md) [![Build Status](https://travis-ci.org/doyubkim/fluid-engine-dev.svg?branch=python)](https://travis-ci.org/doyubkim/fluid-engine-dev) [![Build status](https://ci.appveyor.com/api/projects/status/kulihlhy43vbwou6/branch/python?svg=true)](https://ci.appveyor.com/project/doyubkim/fluid-engine-dev/branch/python)
44

5-
Jet framework is a fluid simulation engine SDK for computer graphics applications that was created by Doyub Kim as part of the book, ["Fluid Engine Development"](https://www.crcpress.com/Fluid-Engine-Development/Kim/p/book/9781498719926). The code is built on C++11 and can be compiled with most of the commonly available compilers such as g++, clang++, or Microsoft Visual Studio. Jet currently supports macOS (10.10 or later), Ubuntu (14.04 or later), and Windows (Visual Studio 2015 or later). Other untested platforms that support C++11 also should be able to build Jet.
5+
Jet framework is a fluid simulation engine SDK for computer graphics applications that was created by Doyub Kim as part of the book, ["Fluid Engine Development"](https://www.crcpress.com/Fluid-Engine-Development/Kim/p/book/9781498719926). The code is built on C++11 and can be compiled with most of the commonly available compilers such as g++, clang++, or Microsoft Visual Studio. Jet currently supports macOS (10.10 or later), Ubuntu (14.04 or later), and Windows (Visual Studio 2015 or later). Other untested platforms that support C++11 also should be able to build Jet. The framework also provides Python API for faster prototyping.
66

77
The latest code is always available from the [`master`](https://github.com/doyubkim/fluid-engine-dev/tree/master) branch. Since the code evolves over time, the latest from the master could be somewhat different from the code in the book. To find the version that is consistent with the book, check out the branch [`book-1st-edition`](https://github.com/doyubkim/fluid-engine-dev/tree/book-1st-edition).
88

@@ -15,6 +15,7 @@ The latest code is always available from the [`master`](https://github.com/doyub
1515
* PIC, FLIP, and APIC fluid simulators
1616
* Upwind, ENO, and FMM level set solvers
1717
* Converters between signed distance function and triangular mesh
18+
* C++ and Python API
1819

1920
Every simulator has both 2-D and 3-D implementations.
2021

appveyor.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
version: 1.0.6 ({build})
1+
# Adopted from https://github.com/pybind/pybind11/blob/master/.appveyor.yml
2+
3+
version: 1.1.0-rc1 ({build})
24

35
os:
6+
- Visual Studio 2017
47
- Visual Studio 2015
58

69
platform:
710
- x64
811

12+
matrix:
13+
fast_finish: true # Stop remaining jobs after a job failure
14+
915
configuration:
1016
- Release
1117

1218
clone_folder: c:\jet
1319

1420
install:
1521
- git submodule update --init
22+
- ps: |
23+
if ($env:PLATFORM -eq "x64") { $env:CMAKE_ARCH = "x64" }
24+
if ($env:APPVEYOR_JOB_NAME -like "*Visual Studio 2017*") { $env:CMAKE_GENERATOR = "Visual Studio 15 2017" }
25+
else { $env:CMAKE_GENERATOR = "Visual Studio 14 2015" }
26+
$env:PYTHON = "27"
27+
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
28+
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
1629
1730
before_build:
1831
- md c:\jet\build
1932
- cd c:\jet\build
20-
- cmake .. -G"Visual Studio 14 2015 Win64"
33+
- cmake .. -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%"
2134

2235
build:
2336
project: c:\jet\build\jet.sln
@@ -26,3 +39,5 @@ build:
2639

2740
after_build:
2841
- c:\jet\build\bin\Release\unit_tests.exe
42+
- pip install --user c:\jet
43+
- python c:\jet\src\tests\python_tests\main.py

doc/doxygen/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = Jet
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = v1.0.6
41+
PROJECT_NUMBER = v1.1.0-rc1
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

doc/doxygen/main.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Jet framework is a fluid simulation engine SDK for computer graphics applications that was created by Doyub Kim as part of the book, ["Fluid Engine Development"](https://www.crcpress.com/Fluid-Engine-Development/Kim/p/book/9781498719926). The code is built on C++11 and can be compiled with most of the commonly available compilers such as g++, clang++, or Microsoft Visual Studio. Jet currently supports macOS (10.10 or later), Ubuntu (14.04 or later), and Windows (Visual Studio 2015 or later). Other untested platforms that support C++11 also should be able to build Jet.
1+
Jet framework is a fluid simulation engine SDK for computer graphics applications that was created by Doyub Kim as part of the book, ["Fluid Engine Development"](https://www.crcpress.com/Fluid-Engine-Development/Kim/p/book/9781498719926). The code is built on C++11 and can be compiled with most of the commonly available compilers such as g++, clang++, or Microsoft Visual Studio. Jet currently supports macOS (10.10 or later), Ubuntu (14.04 or later), and Windows (Visual Studio 2015 or later). Other untested platforms that support C++11 also should be able to build Jet. The framework also provides Python API for faster prototyping.
22

33
### Key Features
44
* Basic math and geometry operations and data structures
@@ -9,5 +9,6 @@ Jet framework is a fluid simulation engine SDK for computer graphics application
99
* PIC, FLIP, and APIC fluid simulators
1010
* Upwind, ENO, and FMM level set solvers
1111
* Converters between signed distance function and triangular mesh
12+
* C++ and Python API
1213

1314
Every simulator has both 2-D and 3-D implementations.

external/pybind11

Submodule pybind11 added at 2d14c1c

0 commit comments

Comments
 (0)