### Start Frontend Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Command to start the JupyterLab frontend after compilation. ```bash python3 warmup.py jupyter ``` -------------------------------- ### Run Warmup Script Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Commands to navigate into the cloned repository and execute the warmup script for installation. ```bash cd ppf-contact-solver python3 warmup.py ``` -------------------------------- ### Run Warmup (First Time Setup) Source: https://github.com/st-tech/ppf-contact-solver/blob/main/build-win-native/TESTING.md Run the warmup script to download and install build tools locally on the Windows instance. ```cmd cd C:\ppf-contact-solver\build-win-native warmup.bat /nopause ``` -------------------------------- ### Install Git and Python Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Commands to update package lists and install git and python3 within the container. ```bash apt update apt install -y git python3 ``` -------------------------------- ### Simulation Start and Live Preview Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/codim.ipynb This snippet shows how to start the simulation, live-preview the results, and stream simulation logs in real-time. ```python # start the simulation and live-preview the results session.start().preview(options=opts) # also show simulation logs in realtime session.stream() ``` -------------------------------- ### Compile the Project Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Commands to set up the environment and build the project in release mode. ```bash source "$HOME/.cargo/env" cargo build --release ``` -------------------------------- ### Test the Bundle on Build Instance (All Examples) Source: https://github.com/st-tech/ppf-contact-solver/blob/main/build-win-native/TESTING.md Command to run all example notebooks within the bundle. ```cmd cd C:\ppf-contact-solver\build-win-native\dist fast-check-all.bat /nopause ``` -------------------------------- ### Run All Example Tests on Clean Instance Source: https://github.com/st-tech/ppf-contact-solver/blob/main/build-win-native/TESTING.md Command to run all example notebooks on the extracted bundle on the clean instance. ```cmd cd C:\bundle fast-check-all.bat /nopause ``` -------------------------------- ### Simulation and Preview Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/fitting.ipynb This snippet shows how to start the simulation, live-preview the results, and stream simulation logs in real-time. ```python # start the simulation and live-preview the results session.start().preview() # also show simulation logs in realtime session.stream() ``` -------------------------------- ### Clone Repository Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Command to clone the PPF Contact Solver repository. ```bash git clone https://github.com/st-tech/ppf-contact-solver.git ``` -------------------------------- ### Start Simulation and Preview Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/hang.ipynb Starts the simulation session and previews the results. ```python session.start().preview() session.stream() ``` -------------------------------- ### Vast.ai CLI Setup Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/cloud.md Installs and configures the vast.ai CLI, including setting the API key and checking jq installation. ```bash # install vast-ai CLI (https://cloud.vast.ai/cli/) wget https://raw.githubusercontent.com/vast-ai/vast-python/master/vast.py -O vast chmod +x vast # api key VAST_API_KEY="get an API key at https://cloud.vast.ai/cli/" # set API key ./vast set api-key $VAST_API_KEY # jq must be installed (sudo apt install jq) jq --version ``` -------------------------------- ### Curtain Simulation Setup Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/curtain.ipynb This code sets up the simulation environment, creates curtain meshes, and adds a moving sphere to interact with them. ```python from frontend import App # create an app app = App.create("curtain") # create a square sheet mesh V, F = app.mesh.square(res=64, ex=[0, 0, 1], ey=[0, 1, 0]) app.asset.add.tri("sheet", V, F) # create a sphere mesh V, F = app.mesh.icosphere(r=0.5, subdiv_count=4) app.asset.add.tri("sphere", V, F) # create a small sphere mesh V, F = app.mesh.icosphere(r=0.25, subdiv_count=3) sphere = app.asset.add.tri("small-sphere", V, F) # create a scene scene = app.scene.create() # add multiple sheets as curtains with spacing space = 0.25 for i in range(15): obj = scene.add("sheet") obj.param.set("strain-limit", 0.05) obj.at(i * space, 0, 0) # pin top edge of each sheet obj.pin(obj.grab([0, 1, 0])) # add moving sphere that will push through the curtains sphere = scene.add("sphere") ( sphere.color(0.75, 0.75, 0.75) .at(-1, 0, 0) .jitter() .pin() .move_by([8, 0, 0], 0, 5) ) # compile the scene and report stats scene = scene.build().report() # preview the initial scene scene.preview() # create a new session with the compiled scene session = app.session.create(scene) # build this session session = session.build() ``` -------------------------------- ### RunPodctl Installation and Setup Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/cloud.md Clones and compiles the runpodctl tool for deploying instances on RunPod. Sets the PATH for the current shell. ```bash # clone runpodctl latest copy git clone https://github.com/runpod/runpodctl.git $HOME/runpodctl # compile runpodctl cd $HOME/runpodctl; make; cd - # set ephemeral path only valid in the current shell PATH=$PATH:$HOME/runpodctl/bin/ # this must return greater than 1.0.0-test ``` -------------------------------- ### SSH Port Forwarding for Headless Installation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Command to establish SSH port forwarding for accessing the solver's frontend on a headless remote machine. ```bash MY_WEB_PORT=8080 ssh -L 8080:localhost:$MY_WEB_PORT user@remote_server_address ``` -------------------------------- ### Example: Register a mesh as an asset, drop it into a scene, and run a short simulation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md A comprehensive example showing app creation, asset registration, scene setup, session configuration, and simulation execution. ```python from frontend import App app = App.create("hello") V, F = app.mesh.square(res=64, ex=[1, 0, 0], ey=[0, 0, 1]) app.asset.add.tri("sheet", V, F) scene = app.scene.create() scene.add("sheet").at(0, 0.6, 0) scene = scene.build() session = app.session.create(scene) session.param.set("frames", 60).set("dt", 0.01) session = session.build() session.start(blocking=True) session.export.animation().zip() ``` -------------------------------- ### Session Setup and Simulation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/twist.ipynb This code snippet sets up a new simulation session, configures session parameters such as time step, frames, gravity, and sparse matrix capacity, and then builds the session. ```python # create a new session with the compiled scene session = app.session.create(fixed) # set session parameters - disable gravity and increase sparse matrix capacity ( session.param.set("dt", 1 / 60) .set("frames", 430) .set("gravity", [0, 0, 0]) .set("csrmat-max-nnz", 35000000) # 5GB VRAM needed ) # build this session fixed_session = session.build() ``` -------------------------------- ### Run Simulation and Preview Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/twist.ipynb This code snippet starts the simulation, provides a live preview of the results, and streams the simulation logs in real-time. ```python # start the simulation and live-preview the results fixed_session.start().preview() # also show simulation logs in realtime fixed_session.stream() ``` -------------------------------- ### Session Creation and Parameter Setup Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/ribbon.ipynb This code snippet creates a new session from the compiled scene and sets session parameters, including the number of frames, air density, and friction mode. ```python # create a new session with the compiled scene session = app.session.create(scene) # set session parameters with air resistance session.param.set("frames", 480).set("air-density", 2e-3).set("friction-mode", "max") # build this session session = session.build() ``` -------------------------------- ### Setup and Asset Creation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/friction.ipynb This snippet initializes the PPF Contact Solver app, creates an armadillo mesh with specified parameters, and adds a rectangular slope mesh. ```python import numpy as np from frontend import App # create an app app = App.create("friction") # create an armadillo tetrahedral mesh V, F, T = app.mesh.preset("armadillo").decimate(2400).tetrahedralize().normalize() app.asset.add.tet("armadillo", V, F, T) # create a rectangular slope mesh V, F = app.mesh.rectangle(res_x=43, width=15, height=3, ex=[1, 0, 0], ey=[0, 0, 1]) app.asset.add.tri("slope", V, F) # create a scene scene = app.scene.create() # add armadillo with friction properties armadillo = scene.add("armadillo") armadillo.param.set("poiss-rat", 0.49).set("friction", 0.51).set("model", "snhk") armadillo.rotate(180, "y").rotate(-90, "x").rotate(-30, "z").at( -5.8, 3.35, -0.25 ).jitter() # add sloped surface with angle based on friction coefficient deg = 180 * np.arctan(0.5) / np.pi slope = scene.add("slope") slope.rotate(-deg, "z").pin() # compile the scene and report stats scene = scene.build().report() # preview the initial scene scene.preview() ``` -------------------------------- ### Session Setup Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/trampoline.ipynb This code sets up a new session with the compiled scene and configures session parameters like the number of frames and friction mode. ```python # create a new session with the compiled scene session = app.session.create(scene) # set session parameters if app.ci: session.param.set("frames", 60) else: session.param.set("frames", 120) session.param.set("friction-mode", "max") # build this session session = session.build() ``` -------------------------------- ### Plastic Simulation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/plastic.ipynb This code snippet demonstrates how to create a session from the compiled scene, set simulation parameters, build the session, and start the simulation with live preview and streaming logs. ```python # create a new session with the compiled scene session = app.session.create(scene) # set session parameters session.param.set("frames", 180).set("dt", 0.01) # build this session session = session.build() # start the simulation and live-preview the results session.start().preview() # also show simulation logs in realtime session.stream() ``` -------------------------------- ### Blender Add-on Manifest Example Source: https://github.com/st-tech/ppf-contact-solver/blob/main/blender_addon/LLM/blender_addon/getting_started.md This snippet shows the structure of the extension manifest file required for Blender add-ons, specifying version and ID. ```toml blender_manifest.toml schema = "1.0.0" id = "ppf_contact_solver" blender_version_min = "5.0.0" ``` -------------------------------- ### Loading and Setting Up Meshes Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/fitting.ipynb This snippet shows how to load dress and body meshes, set up paths to repository assets, and clone necessary directories from a Git repository. ```python # File: fitting.ipynb # Code: Claude Code and Codex # Review: Ryoichi Ando (ryoichi.ando@zozo.com) # License: Apache v2.0 import os import random from frontend import App, get_cache_dir # create an app app = App.create("fitting") # set up paths to Codim-IPC repository assets codim_ipc_root = os.path.join(get_cache_dir(), "Codim-IPC") checkout_list = [ "Projects/FEMShell/input/dress_knife", "Projects/FEMShell/input/Rumba_Dancing", ] # sparse clone only needed directories from the repository app.extra.sparse_clone( "https://github.com/ipc-sim/Codim-IPC", codim_ipc_root, checkout_list ) stage_path = os.path.join(codim_ipc_root, checkout_list[0], "stage.obj") body_path = os.path.join(codim_ipc_root, checkout_list[1], "shell0.obj") # load dress mesh with stitching information V, F, S = app.extra.load_CIPC_stitch_mesh(stage_path) app.asset.add.tri("dress", V, F) app.asset.add.stitch("glue", S) # load body mesh V, F = app.mesh.load_tri(body_path) app.asset.add.tri("body", V, F) # create a scene scene = app.scene.create() # add dress with stitching and rotation dress = scene.add("dress") dress.param.set("young-mod", 100).set("bend", 1.0).set("strain-limit", 0.1) dress.stitch("glue").rotate(-90, "x") # add body with animated motion from sequence of meshes jitter = 0.01 * random.random() body = scene.add("body").at(0, -0.78 + jitter, 0) pin = body.pin() # load body animation sequence from files body_dir = os.path.join(codim_ipc_root, checkout_list[1]) frame = 1 while True: path = os.path.join(body_dir, f"shell{frame}.obj") if os.path.exists(path): V, _ = app.mesh.load_tri(path) t0, t1 = 0.5 + 0.025 * (frame - 1), 0.5 + 0.025 * frame pin.move_to(V, t0, t1) frame += 1 else: break # compile the scene and report stats scene = scene.build().report() # preview the initial scene scene.preview(options={"pin": False}) ``` -------------------------------- ### Start Simulation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/large-five-twist.ipynb This code snippet starts the simulation. It is noted that this example takes a long time to run. ```python # start the simulation (this example takes a long time) session.start() ``` -------------------------------- ### Start Simulation Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/large-woven.ipynb Starts the physics simulation. Note that this example is computationally intensive and takes a long time to complete. ```python # start the simulation (this example takes a long time) session.start() ``` -------------------------------- ### Purge Docker Image Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Command to remove the specific Docker image used for installation. Use with caution. ```bash docker rmi $(docker images | grep 'nvidia/cuda' | grep '12.8.0-devel-ubuntu24.04' | awk '{print $3}') ``` -------------------------------- ### Create and Start Session Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md Example of creating a session from a built scene, configuring parameters, building, and starting it. ```default session = app.session.create(scene) session.param.set("frames", 60).set("dt", 0.01) session = session.build() session.start(blocking=True) ``` -------------------------------- ### Session Configuration Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/fitting.ipynb This snippet demonstrates how to create a new session, set physics parameters like inactive momentum mode and time step, and configure dynamic parameter transitions. ```python # create a new session with the compiled scene session = app.session.create(scene) # set session parameters with dynamic inactive momentum mode param = session.param.set("inactive-momentum").set("dt", 1e-3).set("frames", 240) # configure dynamic parameters to transition out of inactive momentum mode param.dyn("inactive-momentum").time(0.15).hold().change(False) param.dyn("dt").time(0.15).hold().change(0.01) # build this session session = session.build() ``` -------------------------------- ### Initialize App Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/walkthrough.ipynb Creates an instance of the App for the walkthrough demonstration. ```python from frontend import App # create an app for this walkthrough demonstration app = App.create("walkthrough") ``` -------------------------------- ### Configure a session and build it Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md This example shows how to create a session, configure its parameters, and then build it into a runnable fixed session. ```default session = app.session.create(scene) session.param.set("frames", 120).set("dt", 0.01) fixed_session = session.build() fixed_session.start(blocking=True) ``` -------------------------------- ### Stop and Remove Container Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Commands to stop and remove the Docker container. ```bash docker stop $MY_CONTAINER_NAME docker rm $MY_CONTAINER_NAME ``` -------------------------------- ### Example: Snapshot the current parameters before tweaking one of them Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md Shows how to copy the current parameter state to a baseline before making modifications. ```default baseline = session.param.copy() session.param.set("dt", 0.005) ``` -------------------------------- ### Example: Write the parameters alongside a session directory for inspection or external launching Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md This example shows how to export simulation parameters to a specified directory. ```default session.param.export(fixed_session.info.path) ``` -------------------------------- ### Python Scripting Example Source: https://github.com/st-tech/ppf-contact-solver/blob/main/README.md Example of driving the PPF Contact Solver pipeline from a Python script within Blender for procedural scene setup and variant generation. ```python import addon_utils import importlib import bpy # Look up the add-on module under whichever extension repository Blender # installed it into and grab the public solver API. addon = next(m for m in addon_utils.modules() if m.__name__.endswith(".ppf_contact_solver")) solver = importlib.import_module(f"{addon.__name__}.ops.api").solver # Reset any prior state. solver.clear() # Create a sphere (the static collider) at the origin. bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=4, radius=0.5, location=(0, 0, 0)) bpy.context.object.name = "Sphere" # Create a 2x2 sheet just above the sphere as a 64x64 grid. bpy.ops.mesh.primitive_grid_add(x_subdivisions=64, y_subdivisions=64, size=2, location=(0, 0, 0.6)) sheet = bpy.context.object sheet.name = "Sheet" # Pin the two corners on the -x edge via a vertex group. vg = sheet.vertex_groups.new(name="Corners") corner_indices = [ i for i, v in enumerate(sheet.data.vertices) if v.co.x < -0.99 and abs(abs(v.co.y) - 1.0) < 0.01 ] vg.add(corner_indices, 1.0, "REPLACE") # Build solver groups. cloth = solver.create_group("Cloth", type="SHELL") cloth.add("Sheet") cloth.param.enable_strain_limit = True cloth.param.strain_limit = 0.05 cloth.param.bend = 1 ball = solver.create_group("Ball", type="STATIC") ball.add("Sphere") # Pin the two sheet corners. cloth.create_pin("Sheet", "Corners") # Scene parameters. solver.param.frame_count = 100 solver.param.step_size = 0.01 ``` -------------------------------- ### Example: Guard against starting a second simulation while one is still in progress Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md Shows how to use App.busy() to prevent starting a new simulation if one is already running. ```python from frontend import App if App.busy(): print("solver is still running; skipping") else: print("ready to start a new session") ``` -------------------------------- ### Example: Inspect every parameter currently configured on the session Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md Shows how to iterate through all the parameters configured on a session and print their key-value pairs. ```default for key, value in session.param.items(): print(f"{key} = {value}") ``` -------------------------------- ### Python Scripting Example Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/blender_addon/gallery.md Example of driving the PPF Contact Solver pipeline from a Python script within Blender for procedural scene setup and batch variant generation. ```python import bpy from bl_ext.user_default.ppf_contact_solver.ops.api import solver # Reset any prior state. solver.clear() # Create a sphere (the static collider) at the origin. bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=4, radius=0.5, location=(0, 0, 0)) bpy.context.object.name = "Sphere" # Create a 2x2 sheet just above the sphere as a 64x64 grid. bpy.ops.mesh.primitive_grid_add(x_subdivisions=64, y_subdivisions=64, size=2, location=(0, 0, 0.6)) sheet = bpy.context.object sheet.name = "Sheet" # Pin the two corners on the -x edge via a vertex group. vg = sheet.vertex_groups.new(name="Corners") corner_indices = [ i for i, v in enumerate(sheet.data.vertices) if v.co.x < -0.99 and abs(abs(v.co.y) - 1.0) < 0.01 ] vg.add(corner_indices, 1.0, "REPLACE") # Build solver groups. cloth = solver.create_group("Cloth", type="SHELL") cloth.add("Sheet") cloth.param.enable_strain_limit = True cloth.param.strain_limit = 0.05 cloth.param.bend = 1 ball = solver.create_group("Ball", type="STATIC") ball.add("Sphere") # Pin the two sheet corners. cloth.create_pin("Sheet", "Corners") # Scene parameters. solver.param.frame_count = 100 solver.param.step_size = 0.01 ``` -------------------------------- ### NeoVim Installation Commands Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/develop.md One-liners to install NeoVim and other tools into the container. ```bash python3 warmup.py nvim ``` ```bash python3 warmup.py lazyvim ``` ```bash python3 warmup.py lazygit ``` ```bash python3 warmup.py fish ``` ```bash python3 warmup.py ohmyzsh ``` -------------------------------- ### Example: Build a trivial scene and run it to completion Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md Demonstrates creating an App instance, adding a mesh asset, building a scene, and running a simulation. ```python from frontend import App app = App.create("intro") V, F = app.mesh.square(res=32) app.asset.add.tri("sheet", V, F) scene = app.scene.create().add("sheet").build() session = app.session.create(scene).build() session.start(blocking=True) ``` -------------------------------- ### Setup Environment Source: https://github.com/st-tech/ppf-contact-solver/blob/main/build-win-native/README.md This batch script downloads and installs all necessary build tools locally, including 7-Zip, MinGit, CUDA Toolkit, MSVC compiler, Rust, and an embedded Python environment. It also verifies download URLs before proceeding. ```batch warmup.bat ``` -------------------------------- ### Verify NVIDIA Driver Visibility Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/install.md Command to check if the NVIDIA driver is visible from within the Docker container. ```bash nvidia-smi ``` -------------------------------- ### clangd Setup Command Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/develop.md This command generates the .clangd and .clang-format configuration files for linting and formatting. ```bash python3 warmup.py clangd ``` -------------------------------- ### Terminate Simulation Example Source: https://github.com/st-tech/ppf-contact-solver/blob/main/docs/jupyterlab_api/module_reference.md Stop a stuck solver process before starting a new run. ```default from frontend import App if App.busy(): App.terminate() ``` -------------------------------- ### Simulation Execution and Logging Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/cards.ipynb This code starts the simulation, live-previews the results, and streams the simulation logs in real-time. ```python # start the simulation and live-preview the results session.start().preview() # also show simulation logs in realtime session.stream() ``` -------------------------------- ### VSCode Setup Command Source: https://github.com/st-tech/ppf-contact-solver/blob/main/articles/develop.md This command generates the .vscode/extensions.json file for VSCode, listing recommended extensions. ```bash python3 warmup.py vscode ``` -------------------------------- ### Simulation Execution Source: https://github.com/st-tech/ppf-contact-solver/blob/main/examples/belt.ipynb This code starts the simulation and provides a live preview of the results, along with streaming simulation logs. ```python # start the simulation and live-preview the results session.start().preview(options=opts) # also show simulation logs in realtime session.stream() ```