Skip to content

Commit acb2871

Browse files
committed
fix bug in patching for degenerate patches
1 parent 640e830 commit acb2871

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

apps/NeoHookean/neo_hookean.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void neo_hookean(RXMeshStatic& rx, T dx)
350350
}
351351
}
352352

353-
RXMESH_INFO("\n===================\n");
353+
RXMESH_INFO("===================");
354354

355355
// update velocity
356356
rx.for_each_vertex(

include/rxmesh/patcher/patcher.cu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ void Patcher::get_multi_components(
557557
current_component.reserve(
558558
static_cast<uint32_t>(static_cast<double>(m_num_faces) / 10.0));
559559

560+
current_component.push_back(f);
561+
560562
std::queue<uint32_t> face_queue;
561563
face_queue.push(f);
562564
while (!face_queue.empty()) {
@@ -1007,7 +1009,7 @@ void Patcher::run_lloyd(uint32_t* d_face_patch,
10071009
d_ff_values,
10081010
d_queue);
10091011

1010-
if (max_patch_size < m_patch_size) {
1012+
if (max_patch_size <= m_patch_size) {
10111013
shift<<<blocks_f, threads_f>>>(
10121014
m_num_faces, d_face_patch, d_patches_val);
10131015

include/rxmesh/patcher/patcher_kernel.cuh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,21 +267,32 @@ __global__ static void add_more_seeds(const uint32_t num_patches,
267267
const uint32_t p_end = d_patches_offset[patch_id];
268268
const uint32_t p_size = p_end - p_start;
269269

270-
if (p_size > threshold) {
270+
271+
if (p_size >= threshold) {
271272

272273
if (threadIdx.x == 0) {
273274
// look for a boundary face
274275
// printf("\n patch_id = %u, p_size = %u", patch_id, p_size);
275276

277+
bool added = false;
278+
276279
for (uint32_t f = p_start; f < p_end; ++f) {
277280
uint32_t face = d_patches_val[f];
278281
if (face & 1) {
282+
added = true;
279283
uint32_t new_patch_id =
280284
::atomicAdd(d_new_num_patches, 1u);
281285
d_seeds[new_patch_id] = face >> 1;
282286
break;
283287
}
284288
}
289+
290+
if (!added) {
291+
// if we can not find a boundary edge (it is a single patch
292+
// or isolated), then add the first face
293+
uint32_t new_patch_id = ::atomicAdd(d_new_num_patches, 1u);
294+
d_seeds[new_patch_id] = d_patches_val[p_start] >> 1;
295+
}
285296
}
286297
}
287298
}

0 commit comments

Comments
 (0)