Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 450a1d5

Browse files
committed
enum class BroadPhaseMethod
1 parent 11467a0 commit 450a1d5

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

src/ipc/broad_phase/broad_phase.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@
1111

1212
namespace ipc {
1313

14+
std::shared_ptr<ipc::BroadPhase> build_broad_phase(const BroadPhaseMethod& broad_phase_method)
15+
{
16+
switch(broad_phase_method)
17+
{
18+
case BroadPhaseMethod::HASH_GRID:
19+
return std::make_shared<ipc::HashGrid>();
20+
case BroadPhaseMethod::BRUTE_FORCE:
21+
return std::make_shared<ipc::BruteForce>();
22+
case BroadPhaseMethod::SPATIAL_HASH:
23+
return std::make_shared<ipc::SpatialHash>();
24+
case BroadPhaseMethod::BVH:
25+
return std::make_shared<ipc::BVH>();
26+
#ifdef IPC_TOOLKIT_WITH_CUDA
27+
case BroadPhaseMethod::SWEEP_AND_TINIEST_QUEUE:
28+
return std::make_shared<ipc::SweepAndTiniestQueue>();
29+
#endif
30+
default:
31+
log_and_throw_error("Unknown broad phase type!");
32+
}
33+
34+
return std::make_shared<ipc::HashGrid>();
35+
}
36+
1437
void BroadPhase::build(
1538
Eigen::ConstRef<Eigen::MatrixXd> vertices,
1639
Eigen::ConstRef<Eigen::MatrixXi> edges,

src/ipc/broad_phase/broad_phase.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace ipc {
1515

1616
class Candidates; // Forward declaration
1717

18+
enum class BroadPhaseMethod { HASH_GRID, BRUTE_FORCE, SPATIAL_HASH, BVH, SWEEP_AND_TINIEST_QUEUE };
19+
1820
class BroadPhase {
1921
public:
2022
BroadPhase() { }
@@ -104,4 +106,5 @@ class BroadPhase {
104106
std::vector<AABB> face_boxes;
105107
};
106108

109+
std::shared_ptr<BroadPhase> build_broad_phase(const BroadPhaseMethod& broad_phase_method);
107110
} // namespace ipc

src/ipc/potentials/potential.tpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <tbb/combinable.h>
99
#include <tbb/enumerable_thread_specific.h>
1010
#include <ipc/utils/MaybeParallelFor.hpp>
11-
#include <igl/Timer.h>
1211

1312
namespace ipc {
1413

@@ -101,9 +100,6 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
101100
const int dim = X.cols();
102101
const int ndof = X.size();
103102

104-
igl::Timer timer;
105-
timer.start();
106-
107103
const int max_triplets_size = int(1e7);
108104
const int buffer_size = std::min(max_triplets_size, ndof);
109105
auto storage = ipc::utils::create_thread_storage(LocalThreadMatStorage(buffer_size, ndof, ndof));
@@ -127,9 +123,6 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
127123
local_hess, vids, dim, *(hess_triplets.cache));
128124
}
129125
});
130-
131-
timer.stop();
132-
logger().trace("done separate assembly {}s...", timer.getElapsedTime());
133126

134127
Eigen::SparseMatrix<double> hess(ndof, ndof);
135128

@@ -143,12 +136,9 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
143136
storages[index++] = &local_storage;
144137
}
145138

146-
timer.start();
147139
utils::maybe_parallel_for(storages.size(), [&](int i) {
148140
storages[i]->cache->prune();
149141
});
150-
timer.stop();
151-
logger().trace("done pruning triplets {}s...", timer.getElapsedTime());
152142

153143
if (storage.size() == 0)
154144
{
@@ -171,42 +161,28 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
171161
assert(storages.size() >= 1);
172162
if (storages[0]->cache->is_dense())
173163
{
174-
timer.start();
175164
// Serially merge local storages
176165
Eigen::MatrixXd tmp(hess);
177166
for (const auto &local_storage : storage)
178167
tmp += dynamic_cast<const DenseMatrixCache &>(*local_storage.cache).mat();
179168
hess = tmp.sparseView();
180169
hess.makeCompressed();
181-
timer.stop();
182-
183-
logger().trace("Serial assembly time: {}s...", timer.getElapsedTime());
184170
}
185171
else if (triplet_count >= triplets.max_size())
186172
{
187173
// Serial fallback version in case the vector of triplets cannot be allocated
188174

189175
logger().warn("Cannot allocate space for triplets, switching to serial assembly.");
190176

191-
timer.start();
192177
// Serially merge local storages
193178
for (LocalThreadMatStorage &local_storage : storage)
194179
hess += local_storage.cache->get_matrix(false); // will also prune
195180
hess.makeCompressed();
196-
timer.stop();
197-
198-
logger().trace("Serial assembly time: {}s...", timer.getElapsedTime());
199181
}
200182
else
201183
{
202-
timer.start();
203184
triplets.resize(triplet_count);
204-
timer.stop();
205185

206-
logger().trace("done allocate triplets {}s...", timer.getElapsedTime());
207-
logger().trace("Triplets Count: {}", triplet_count);
208-
209-
timer.start();
210186
// Parallel copy into triplets
211187
utils::maybe_parallel_for(storages.size(), [&](int i) {
212188
const SparseMatrixCache &cache = dynamic_cast<const SparseMatrixCache &>(*storages[i]->cache);
@@ -229,15 +205,8 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
229205
}
230206
});
231207

232-
timer.stop();
233-
logger().trace("done concatenate triplets {}s...", timer.getElapsedTime());
234-
235-
timer.start();
236208
// Sort and assemble
237209
hess.setFromTriplets(triplets.begin(), triplets.end());
238-
timer.stop();
239-
240-
logger().trace("done setFromTriplets assembly {}s...", timer.getElapsedTime());
241210
}
242211

243212
return hess;

src/ipc/utils/math.tpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace {
3636
return scalar(1.);
3737
}
3838

39-
double smooth_heaviside_standard_grad(const double& x)
39+
[[maybe_unused]] double smooth_heaviside_standard_grad(const double& x)
4040
{
4141
if (x <= -3 || x >= 0)
4242
return 0.;
@@ -48,7 +48,7 @@ namespace {
4848
return Math<double>::sqr(x) / 2.;
4949
}
5050

51-
double smooth_heaviside_standard_hess(const double& x)
51+
[[maybe_unused]] double smooth_heaviside_standard_hess(const double& x)
5252
{
5353
if (x <= -3 || x >= 0)
5454
return 0.;

0 commit comments

Comments
 (0)