Skip to content

Configurable derivative layout#217

Merged
zfergus merged 17 commits intomainfrom
configurable-derivative-layout
Mar 1, 2026
Merged

Configurable derivative layout#217
zfergus merged 17 commits intomainfrom
configurable-derivative-layout

Conversation

@zfergus
Copy link
Member

@zfergus zfergus commented Feb 28, 2026

Description

  • Add a VERTEX_DERIVATIVE_LAYOUT constant to ipc/config.hpp and include Eigen.
  • Update local_to_global.hpp to parameterize all assembly helpers (gradient, sparse gradient, Hessian triplets, Jacobian triplets, MatrixCache Hessian) with an optional GlobalOrder template (defaulting to VERTEX_DERIVATIVE_LAYOUT).
  • Implement both RowMajor and ColMajor indexing code paths and add static_asserts and detailed doc comments.
  • Also include ipc/config.hpp, convert LocalThreadMatStorage to a struct with docs, and adjust MatrixCache-based hessian assembly to respect the chosen global ordering.

Type of change

  • Enhancement (non-breaking change which improves existing functionality)

zfergus and others added 10 commits February 9, 2026 00:51
Add a VERTEX_DERIVATIVE_LAYOUT constant to ipc::config and include Eigen. Update local_to_global.hpp to parameterize all assembly helpers (gradient, sparse gradient, Hessian triplets, Jacobian triplets, MatrixCache Hessian) with an optional GlobalOrder template (defaulting to VERTEX_DERIVATIVE_LAYOUT). Implement both RowMajor and ColMajor indexing code paths and add static_asserts and detailed doc comments. Also include ipc/config.hpp, convert LocalThreadMatStorage to a struct with docs, and adjust MatrixCache-based hessian assembly to respect the chosen global ordering.
* Add barrier stiffness and simplify tangential API

Introduce a barrier stiffness (kappa) to BarrierPotential: new constructors, member, getters/setters, and scale operator/gradient/hessian by stiffness. Remove the redundant normal_stiffness parameter from tangential collision constructors and tangential potential interfaces, updating all call sites, headers, and implementations accordingly. Update Python bindings, tutorials, examples (ogc, solver), and tests (test_ipc) to match the new API and default stiffness usage; also move a notebook to python/examples. Miscellaneous formatting/import cleanups and adjustments to pybind argument lists to reflect the simplified tangential API.
Disable Eigen vectorization to avoid alignment issues.
Place EIGEN_DONT_VECTORIZE on the ipc_toolkit target as PUBLIC
because setting it on the Eigen target or making it PRIVATE caused
crashes.
Detect lbvh.size() == 1 and treat the root as a leaf in both
single and batched query traversals, performing intersection tests
and adding candidate collisions as appropriate
* Integrate analytic plane-vertex primitives into the collision pipeline. 
* Add PlaneVertexCandidate, normal and tangential plane-vertex collisions, and pv handling in builders. 
* Add CollisionMesh::planes and Python bindings (Hyperplane, PlaneVertex*).
* Remove old implicits module and update CMake, tests, and small API/format fixes.
* Refactor conservative rescaling initialization in CCD classes and update documentation
Copilot AI review requested due to automatic review settings February 28, 2026 19:40
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 adds a configurable degree-of-freedom (DOF) ordering to the gradient, Hessian, and Jacobian assembly utilities in local_to_global.hpp. It introduces a VERTEX_DERIVATIVE_LAYOUT constant (defaulting to Eigen::RowMajor) in ipc/config.hpp.in and parametrizes all five local-to-global assembly helpers with a GlobalOrder template non-type parameter so callers can opt into either interleaved (RowMajor: [x0,y0,z0, x1,y1,z1,…]) or blocked (ColMajor: [x0,x1,…, y0,y1,…]) global DOF ordering. Because VERTEX_DERIVATIVE_LAYOUT defaults to Eigen::RowMajor, no existing callers are affected when using the default.

Changes:

  • Adds VERTEX_DERIVATIVE_LAYOUT = Eigen::RowMajor to config.hpp.in (with an <Eigen/Core> include).
  • Parametrizes all five local-to-global assembly helpers with an int GlobalOrder template parameter and implements both RowMajor and ColMajor index mapping code paths via if constexpr.
  • Converts LocalThreadMatStorage from class to struct and adds doxygen comments to all functions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
src/ipc/config.hpp.in Adds <Eigen/Core> include and VERTEX_DERIVATIVE_LAYOUT constant
src/ipc/utils/local_to_global.hpp Adds GlobalOrder template parameter to all assembly helpers, implements ColMajor index paths, converts LocalThreadMatStorage to struct, adds doxygen docs

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

@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (8016f25) to head (744f8f4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
- Coverage   97.18%   97.18%   -0.01%     
==========================================
  Files         160      160              
  Lines       24721    24734      +13     
  Branches      890      890              
==========================================
+ Hits        24025    24037      +12     
- Misses        696      697       +1     
Flag Coverage Δ
unittests 97.18% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

zfergus and others added 7 commits February 28, 2026 15:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Use total global vertex/row/col counts when computing column-major
indices and validate buffer sizes. Add optional n_total_verts,
n_total_rows and n_total_cols parameters (default -1) that are required
for ColMajor storage and throw an error if omitted. Include logger
header, assert grad size divisibility, and update MatrixCache/triplet
indexing accordingly. Add test_local_to_global.cpp to tests CMakeLists.
Add tests/dof_layout.hpp with helpers to flatten, unflatten, and reorder
gradients/hessians so finite-difference tests work for both
VERTEX_DERIVATIVE_LAYOUT settings. Pass mesh.num_vertices()
(n_total_verts) into shape_derivative and local_*_to_global_triplets so
global DOF indices are computed correctly for column-major layouts.
Use VERTEX_DERIVATIVE_LAYOUT to map vertex-level sparse matrices into
per-dof sparse matrices, computing triplets with n_rows/n_cols and
constructing M_dof with the correct dimensions. Move the function
declaration in the header and add unit tests (including Catch2
generators and config include) that verify sparsity pattern and the
M_dof * x == flatten(M_V * V) semantics.
Introduce IPC_TOOLKIT_VERTEX_DERIVATIVE_LAYOUT CMake cache option
(default RowMajor) with allowed values ColMajor and RowMajor, and mark
it advanced. Export the value into src/ipc/config.hpp.in so
VERTEX_DERIVATIVE_LAYOUT is set to the chosen Eigen layout at configure
time.
Describe row-major default and new CMake cache option
IPC_TOOLKIT_VERTEX_DERIVATIVE_LAYOUT (RowMajor or ColMajor), with build
examples, affected APIs, and an experimental feature warning.
@zfergus zfergus merged commit 5c5494c into main Mar 1, 2026
18 checks passed
@zfergus zfergus deleted the configurable-derivative-layout branch March 1, 2026 00:37
@zfergus zfergus added this to the v1.6.0 milestone Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants