Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 3.17 KB

README.md

File metadata and controls

98 lines (71 loc) · 3.17 KB

PolyFEM Python Data

This repository stores runnable Python examples for polyfem-python.

It is intended to be checked out as the examples/ submodule inside polyfem-python:

git submodule update --init --recursive examples

Layout

  • quickstart/: small examples for the public API, including a cantilever mesh.
  • classic_example/2D/: 2D generated-API examples.
  • classic_example/3D/: 3D generated-API examples.

Quick start

Install polyfempy first, then run these commands from this repository:

python quickstart/beam.py
python quickstart/static_elasticity.py
python quickstart/transient_elasticity.py

The beam example uses the small beam.obj file beside the script. It models a 1 m x 0.2 m elastic beam with a fixed left end and a downward body force. It prints a largest displacement component of about 0.003648 m. Keep beam.py and beam.obj together when copying the example elsewhere. The mesh has 297 vertices and 512 triangles on a regular rectangular grid.

The other two examples create a small square mesh. All three use Eigen::SimplicialLDLT, which does not require Pardiso, and need no polyfem-data checkout. The transient example runs five time steps and writes to results/transient_square.

Classic example dependencies

These examples import:

import polyfem
from polyfempy import solve

The 93 classic examples build configurations in Python and use assets from polyfem-data/contact. Each example names its reference JSON in SOURCE_JSON; a few schema compatibility fallbacks also read that JSON. By default, the helper scripts look for a sibling polyfem-data checkout:

  • inside polyfem-python/examples, this resolves to polyfem-python/polyfem-data;
  • in a standalone python_data checkout, this resolves to polyfem-data next to python_data.

To use a different location, set:

export POLYFEM_DATA_ROOT=/path/to/polyfem-data

On PowerShell:

$env:POLYFEM_DATA_ROOT = "C:\path\to\polyfem-data"

Run

First generate and install the parent polyfem-python package according to its BUILD.md, then use that same Python environment here. Cloning this repository does not install the compiled solver. Start with the small square self-check in the parent's INSTALL.md or the README's cantilever beam before running these larger reference models.

Most cases explicitly select Eigen::PardisoLDLT, which requires a backend build with that solver available. The parent's regression diagnostic substitutes a portable solver and follows the reference tests.time_steps; it is not identical to running a full example directly.

From this repository root:

python classic_example/2D/contact_2d_golf_ball_generated_api.py

From the parent polyfem-python repository root:

python examples/classic_example/2D/contact_2d_golf_ball_generated_api.py

Outputs follow each example's explicit output.directory, normally results/2D/... or results/3D/..., relative to the directory where you run it. Repeated runs use that same directory. The repository ignores results/ so simulation output is kept out of source control. Reference JSON inputs remain tracked in the data repository.