Skip to content

Feature/icp contact#22

Draft
chemiskyy wants to merge 30 commits intomasterfrom
feature/ICP_contact
Draft

Feature/icp contact#22
chemiskyy wants to merge 30 commits intomasterfrom
feature/ICP_contact

Conversation

@chemiskyy
Copy link
Member

@chemiskyy chemiskyy commented Feb 11, 2026

This pull request introduces comprehensive support for IPC (Incremental Potential Contact) methods in the documentation and examples, clarifies the distinction between penalty-based and IPC contact approaches, and adds comparison scripts for CCD vs OGC line search methods. The documentation is updated to explain the IPC method, its parameters, and includes examples for both contact and self-contact scenarios. Additionally, new example scripts are provided to benchmark and compare CCD and OGC approaches for contact and self-contact problems.

Documentation improvements and IPC support:

  • Added instructions for installing the optional ipctk dependency to enable IPC support in docs/Install.rst.
  • Expanded the docs/boundary_conditions.rst to clearly distinguish between penalty-based and IPC contact methods, including detailed descriptions, parameter explanations, and usage guidance for both approaches. [1] [2]
  • Added IPC contact and IPC self-contact examples, showing how to use these methods in practice, including code snippets and notes on output extraction.

Update error criterion.

  • The error criterion of the Newton-Raphson loop have been updated to be more robust and appropriate for contact analysis.
  • The "Displacement" error criterion is now normalized from the current displacement increment and not the total displacement.
  • The "Force" error criterion is now normalized from the current external forces.
  • A critical bug has been corrected related to the computation of external forces.
  • The default values of the error criterion have been updated.

New comparison scripts for CCD vs OGC line search:

  • Added examples/contact/comparison/ccd_vs_ogc.py, a script to benchmark and compare CCD and OGC line search methods for 2D disk indentation, including convergence metrics, force–indentation curves, and summary plots.
  • Added examples/contact/comparison/ccd_vs_ogc_selfcontact.py, a script to compare CCD and OGC for self-contact in a hole plate compression scenario, with timing, convergence, and reaction force plots.

Example improvements:

  • Scaled the penalty parameter in examples/03-advanced/tube_compression.py for more accurate weighting in contact calculations.

Introduce a new IPC-based contact module (fedoo/constraint/ipc_contact.py) providing IPCContact and IPCSelfContact assemblies that use the ipctk library for barrier/contact handling. Features include surface DOF scatter mapping, collision mesh construction, barrier stiffness auto-initialization and adaptive updates, friction support, SDI safeguards (minimum NR sub-iterations when contact state changes or gaps are small), and optional CCD line-search for collision-free step sizing. Update fedoo/problem/non_linear.py to integrate IPC CCD callbacks and SDI: add _step_size_callback and _nr_min_subiter members, invoke the step-size callback after solves (both in solve flow and NewtonRaphsonIncrement), reset _nr_min_subiter at increment start/to_start, and require subiter >= _nr_min_subiter for NR convergence. The changes enable robust, intersection-free contact handling when ipctk is available.
Install.rst: add instruction to install the optional IPC dependency (pip install fedoo[ipc]) and document ipctk usage.

boundary_conditions.rst: reorganize the Contact section to separate Penalty-based and IPC methods; expand IPC documentation describing features (2D/3D support, friction, CCD line search, automatic barrier stiffness, dhat guidance), installation, usage and examples (IPC contact and IPC self-contact), and a note about using solid assemblies for outputs. Also clarify penalty-contact scope and update the penalty example formatting and minor code cleanups.
Add a suite of contact example scripts comparing penalty, IPC, CCD and OGC approaches and multiple benchmarks (disk-rectangle, hole-plate/ring crush, gyroid self-contact, and CCD vs OGC comparisons). New files added under examples/contact/comparison and examples/contact/ipc /ogc/penalty provide instrumentation, plotting and summaries for performance and convergence comparisons; several IPC/OGC/penalty demo scripts for indentation, compression and self-contact were also added. Remove older examples/examples contact scripts (examples/contact/disk_rectangle_contact.py and examples/contact/self_contact.py) that are superseded by the new organized examples. Also adjust tube_compression.py: scale contact.eps_n by 1/(2*pi*24) with a clarifying comment to account for 2πr weighting when computing the contact penalty.
Detect axisymmetric problems (space._dimension == '2Daxi') and collect radial coordinates for slave nodes. After computing normal contact forces, apply 2πr circumferential weighting to Fcontact and eps so contact contributions are scaled correctly in axisymmetric formulations. Also include minor cleanups (removed unused commented lines and prints).
@chemiskyy chemiskyy marked this pull request as draft February 11, 2026 23:10
chemiskyy and others added 19 commits February 12, 2026 00:13
When applying a step-size scaling (alpha < 1), ensure prescribed Dirichlet DOFs are not altered. Update blends the scaled update with the stored Dirichlet boundary values (Xbc/_Xbc) so only free DOFs are scaled. Changes applied in ipc_contact.py and non_linear.py to maintain consistency of boundary conditions during step-size adjustments.
fedoo: enforce at least one Newton-Raphson sub-iteration when IPC is active (ipc_contact.py) to avoid accepting iter=0 elastic predictions that accumulate equilibrium errors and cause stress oscillations. In non_linear.py introduce a frozen per-increment t_fact (_t_fact_inc) so the adimensional time used by boundary conditions is stable for the duration of a solve_time_increment (set/cleared around the NR loop). Also change the Displacement convergence criterion to normalize by the current increment (self._dU) instead of accumulated displacement, preventing the tolerance from becoming progressively looser as loading proceeds.
Document energy-based backtracking and recommend the 'Force' NR convergence criterion for IPC problems (with example usage). Add a note about line_search_energy for robustness. Update examples: gyroid_compression now uses a local mesh path, increases compression to 50%, raises dhat to 1e-2, adjusts NR settings and output interval, and mentions an Augmented Lagrangian outer loop for high-strain robustness; self_contact.py argument formatting was cleaned up and NR tolerance tightened to 5e-3. Minor comment added in docs for extra robustness.
Introduce optional ipctk-based broad-phase for contact search when search_algorithm='ipctk'. Adds initialization (_setup_ipctk_broad_phase) to build a compact CollisionMesh (handles duplicated codimensional vertices for slave nodes shared with master elements), computes an inflation radius from element edge sizes, and prepares mappings between compact and original indices. Adds _nearest_element_ipctk to generate edge-vertex / face-vertex candidates via ipctk.HashGrid and return possible master elements per slave node. The global_search dispatcher now supports 'ipctk' and an ImportError with installation hint is raised if ipctk is missing. Also updates the search_algorithm comment to include 'ipctk'.
Change the gyroid example to use the centralized mesh path (../../../util/meshes/gyroid_per.vtk) and add a new example gyroid_compression_plastic.py. The new example demonstrates 3D gyroid compression with IPC self-contact (CCD enabled, relative dhat), uses a Simcoon constitutive law for plasticity, sets up BCs for 50% compression, and writes results to results/gyroid_ipc_plastic. Notes that ipctk is required for IPC functionality.
Add two new contact benchmark examples under examples/contact/benchmark: hertz_axisymmetric.py (axisymmetric Hertz rigid-sphere on elastic half-space, penalty contact, numerical vs analytical comparison and plots) and westergaard_sinusoidal.py (Westergaard sinusoidal periodic contact, compares IPC and penalty contact implementations, outputs, timing and per-step diagnostics and plots). These scripts provide reproducible tests and visualization for validating contact algorithms and their performance.
Most times, the external forces was wrongly computed
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