Skip to content

Commit 6c205bb

Browse files
committed
Expose CPU VBD integrator to Python
1 parent e423376 commit 6c205bb

33 files changed

+786
-69
lines changed

bindings/pypbat/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_subdirectory(geometry)
88
add_subdirectory(gpu)
99
add_subdirectory(math)
1010
add_subdirectory(profiling)
11+
add_subdirectory(sim)
1112

1213
target_link_libraries(PhysicsBasedAnimationToolkit_Python
1314
PRIVATE

bindings/pypbat/PythonBindings.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "gpu/Gpu.h"
44
#include "math/Math.h"
55
#include "profiling/Profiling.h"
6+
#include "sim/Sim.h"
67

78
#include <pybind11/pybind11.h>
89

@@ -16,8 +17,11 @@ PYBIND11_MODULE(_pbat, m)
1617
pbat::py::fem::Bind(mfem);
1718
auto mgeometry = m.def_submodule("geometry");
1819
pbat::py::geometry::Bind(mgeometry);
19-
auto mgpu = m.def_submodule("gpu");
20-
pbat::py::gpu::Bind(mgpu);
2120
auto mmath = m.def_submodule("math");
2221
pbat::py::math::Bind(mmath);
22+
auto msim = m.def_submodule("sim");
23+
pbat::py::sim::Bind(msim);
24+
// Bind GPU module at the end, since it is layered on top of non-GPU modules
25+
auto mgpu = m.def_submodule("gpu");
26+
pbat::py::gpu::Bind(mgpu);
2327
}

bindings/pypbat/gpu/geometry/Geometry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PYPBAT_GPU_GEOMETRY_H
2-
#define PYPBAT_GPU_GEOMETRY_H
1+
#ifndef PYPBAT_GPU_GEOMETRY_GEOMETRY_H
2+
#define PYPBAT_GPU_GEOMETRY_GEOMETRY_H
33

44
#include <pybind11/pybind11.h>
55

@@ -15,4 +15,4 @@ void Bind(pybind11::module& m);
1515
} // namespace py
1616
} // namespace pbat
1717

18-
#endif // PYPBAT_GPU_GEOMETRY_H
18+
#endif // PYPBAT_GPU_GEOMETRY_GEOMETRY_H

bindings/pypbat/gpu/vbd/Vbd.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ void Bind([[maybe_unused]] pybind11::module& m)
2222
using pbat::sim::vbd::EInitializationStrategy;
2323
using pbat::gpu::vbd::Vbd;
2424

25-
pyb::enum_<EInitializationStrategy>(m, "InitializationStrategy")
26-
.value("Position", EInitializationStrategy::Position)
27-
.value("Inertia", EInitializationStrategy::Inertia)
28-
.value("KineticEnergyMinimum", EInitializationStrategy::KineticEnergyMinimum)
29-
.value("AdaptiveVbd", EInitializationStrategy::AdaptiveVbd)
30-
.value("AdaptivePbat", EInitializationStrategy::AdaptivePbat)
31-
.export_values();
32-
3325
pyb::class_<Vbd>(m, "Vbd")
3426
.def(
3527
pyb::init([](Eigen::Ref<GpuMatrixX const> const& X,

bindings/pypbat/gpu/vbd/Vbd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PYPBAT_GPU_VBD_H
2-
#define PYPBAT_GPU_VBD_H
1+
#ifndef PYPBAT_GPU_VBD_VBD_H
2+
#define PYPBAT_GPU_VBD_VBD_H
33

44
#include <pybind11/pybind11.h>
55

@@ -15,4 +15,4 @@ void Bind(pybind11::module& m);
1515
} // namespace py
1616
} // namespace pbat
1717

18-
#endif // PYPBAT_GPU_VBD_H
18+
#endif // PYPBAT_GPU_VBD_VBD_H

bindings/pypbat/gpu/xpbd/Xpbd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PYPBAT_GPU_XPBD_H
2-
#define PYPBAT_GPU_XPBD_H
1+
#ifndef PYPBAT_GPU_XPBD_XPBD_H
2+
#define PYPBAT_GPU_XPBD_XPBD_H
33

44
#include <pybind11/pybind11.h>
55

@@ -15,4 +15,4 @@ void Bind(pybind11::module& m);
1515
} // namespace py
1616
} // namespace pbat
1717

18-
#endif // PYPBAT_GPU_XPBD_H
18+
#endif // PYPBAT_GPU_XPBD_XPBD_H

bindings/pypbat/sim/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
target_sources(PhysicsBasedAnimationToolkit_Python
2+
PUBLIC
3+
FILE_SET api
4+
FILES
5+
"Sim.h"
6+
)
7+
target_sources(PhysicsBasedAnimationToolkit_Python
8+
PRIVATE
9+
"Sim.cpp"
10+
)
11+
add_subdirectory(vbd)
12+
add_subdirectory(xpbd)

bindings/pypbat/sim/Sim.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Sim.h"
2+
3+
#include "vbd/Vbd.h"
4+
#include "xpbd/Xpbd.h"
5+
6+
namespace pbat {
7+
namespace py {
8+
namespace sim {
9+
10+
void Bind(pybind11::module& m)
11+
{
12+
namespace pyb = pybind11;
13+
14+
auto mxpbd = m.def_submodule("xpbd");
15+
xpbd::Bind(mxpbd);
16+
auto mvbd = m.def_submodule("vbd");
17+
vbd::Bind(mvbd);
18+
}
19+
20+
} // namespace sim
21+
} // namespace py
22+
} // namespace pbat

bindings/pypbat/sim/Sim.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef PYPBAT_SIM_SIM_H
2+
#define PYPBAT_SIM_SIM_H
3+
4+
#include <pybind11/pybind11.h>
5+
6+
namespace pbat {
7+
namespace py {
8+
namespace sim {
9+
10+
void Bind(pybind11::module& m);
11+
12+
} // namespace sim
13+
} // namespace py
14+
} // namespace pbat
15+
16+
#endif // PYPBAT_SIM_SIM_H
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
target_sources(PhysicsBasedAnimationToolkit_Python
2+
PUBLIC
3+
FILE_SET api
4+
FILES
5+
"Data.h"
6+
"Integrator.h"
7+
"Vbd.h"
8+
)
9+
10+
target_sources(PhysicsBasedAnimationToolkit_Python
11+
PRIVATE
12+
"Data.cpp"
13+
"Integrator.cpp"
14+
"Vbd.cpp"
15+
)

0 commit comments

Comments
 (0)