Skip to content

Conversation

@mehdiataei
Copy link
Contributor

@mehdiataei mehdiataei commented Mar 8, 2025

Contributing Guidelines

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • All pytest tests pass

Linting and Code Formatting

Make sure the code follows the project's linting and formatting standards. This project uses Ruff for linting.

To run Ruff, execute the following command from the root of the repository:

ruff check .
  • Ruff passes

@mehdiataei mehdiataei marked this pull request as ready for review November 12, 2025 21:53
@mehdiataei mehdiataei changed the title [WIP] Immersed Boundary Method Immersed Boundary Method Implementation with examples Nov 12, 2025
@mehdiataei mehdiataei changed the title Immersed Boundary Method Implementation with examples Immersed Boundary Method Implementation with Examples Nov 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements Immersed Boundary Method (IBM) support with post-processing capabilities and example applications. The implementation enables simulation of complex solid objects immersed in fluid domains without requiring body-conforming meshes.

Key Changes:

  • Added IBM stepper with iterative force correction scheme using Warp kernels
  • Implemented post-processing operators for vorticity and Q-criterion visualization
  • Added utility functions for USD export, mesh handling, and force calculation
  • Created example applications demonstrating IBM for various geometries (sphere, airfoil, car, wind turbine)

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
xlb/operator/stepper/ibm_stepper.py New IBM stepper with Peskin weighting and iterative force correction
xlb/operator/postprocess/vorticity.py Vorticity computation using central differences
xlb/operator/postprocess/q_criterion.py Q-criterion field calculation for vortex identification
xlb/operator/postprocess/grid_to_point.py Trilinear interpolation from grid to arbitrary points
xlb/helper/ibm_helper.py Mesh transformation, Voronoi area calculation, and IBM field setup
xlb/utils/utils.py USD export, colorization, and visualization utilities
xlb/default_config.py Added Warp max_unroll configuration
examples/ibm/*.py Four example applications with drag/lift coefficient validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

DefaultConfig.default_precision_policy = default_precision_policy

if default_backend == ComputeBackend.WARP:
import warp as wp
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wp.max_unroll = 32 setting should be documented with a comment explaining why this specific value is chosen and what impact it has on compilation/performance. This magic number lacks context for future maintainers.

Suggested change
import warp as wp
import warp as wp
# Set the maximum loop unroll factor for WARP kernels.
# The value 32 is chosen as it matches the typical warp size on NVIDIA GPUs,
# which can improve performance by aligning with hardware execution units.
# Increasing this value may lead to longer compilation times and higher code size,
# while decreasing it could reduce performance. Adjust only if you understand the tradeoffs.

Copilot uses AI. Check for mistakes.
vertex_areas_wp = wp.zeros(num_vertices, dtype=wp.float32)

# Launch the kernel
wp.launch(kernel=voronoi_area_kernel, dim=num_faces, inputs=[faces_wp, vertices_wp, face_areas_wp, vertex_areas_wp], device="cuda")
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device is hardcoded to 'cuda'. This should be configurable or use the default device to support CPU-only systems and multi-GPU setups. Consider adding a device parameter to the function.

Copilot uses AI. Check for mistakes.
Comment on lines 107 to 114
# First normalize the mesh to the desired LBM length
# max_length = mesh.extents.max()
# normalize_scale = max_lbm_length / max_length
# mesh.apply_scale(normalize_scale)

# # Apply additional transformations
# mesh = transform_mesh(mesh, translation=translation, rotation=rotation, rotation_order=rotation_order, scale=scale)

Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large blocks of commented-out code should be removed. If this normalization logic might be needed in the future, it should be documented in a comment rather than left as dead code.

Suggested change
# First normalize the mesh to the desired LBM length
# max_length = mesh.extents.max()
# normalize_scale = max_lbm_length / max_length
# mesh.apply_scale(normalize_scale)
# # Apply additional transformations
# mesh = transform_mesh(mesh, translation=translation, rotation=rotation, rotation_order=rotation_order, scale=scale)
# Mesh normalization to max_lbm_length and additional transformations were previously performed here.
# If normalization or transformation is needed in the future, consider:
# max_length = mesh.extents.max()
# normalize_scale = max_lbm_length / max_length
# mesh.apply_scale(normalize_scale)
# mesh = transform_mesh(mesh, translation=translation, rotation=rotation, rotation_order=rotation_order, scale=scale)

Copilot uses AI. Check for mistakes.
mehdiataei and others added 10 commits November 15, 2025 01:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@hsalehipour hsalehipour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I already communicated my comments and they have been applied.

@mehdiataei mehdiataei merged commit 572c983 into Autodesk:main Nov 21, 2025
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants