Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0d8cb2c
update polyfem
Huangzizhou Jun 30, 2024
fe02e7e
fix set_log_level
Huangzizhou Jun 30, 2024
96420e6
separate classes into separate folders
Huangzizhou Jun 30, 2024
5d713ba
polyfem_command
Huangzizhou Jul 1, 2024
a5de325
command line tool
Huangzizhou Jul 1, 2024
d317a58
shape derivative python interface
Huangzizhou Jul 2, 2024
94b57c5
fix memory issue, support multiple states
Huangzizhou Jul 2, 2024
6433fec
python binding for adjoint form
Huangzizhou Jul 26, 2024
1c0de74
Update README.md
Huangzizhou Jul 26, 2024
6bb996e
Update README.md
Huangzizhou Jul 26, 2024
51f0e8d
initial condition opt
Huangzizhou Jul 27, 2024
946d4bf
Merge branch 'main' of https://github.com/Huangzizhou/polyfem-python
Huangzizhou Jul 27, 2024
84e5221
python binding material opt
Huangzizhou Jul 27, 2024
40e9b2d
python binding for friction coeff
Huangzizhou Jul 27, 2024
670378e
more util functions
Huangzizhou Jul 27, 2024
37cdee6
update polyfem
Huangzizhou Aug 22, 2024
ced1fdd
fix bug in test
Huangzizhou Aug 22, 2024
2fc4990
fix missing option
Huangzizhou Aug 22, 2024
4ec050b
fix import error
Huangzizhou Aug 22, 2024
41179a1
Update README.md
Huangzizhou Aug 22, 2024
9c90b3a
fix double free
Huangzizhou Aug 22, 2024
53e4959
Merge branch 'main' of github.com:Huangzizhou/polyfem-python
Huangzizhou Aug 22, 2024
b0b5490
Update README.md
Huangzizhou Aug 22, 2024
a40b7f3
fix test
Huangzizhou Aug 22, 2024
d205e08
update polyfem
Huangzizhou Sep 15, 2024
fc87731
Merge branch 'main' of https://github.com/Huangzizhou/polyfem-python
Huangzizhou Sep 15, 2024
323b256
fix tests
Huangzizhou Sep 25, 2024
efb6bfa
comment missing files
Huangzizhou Oct 10, 2024
68cb9a7
Update Pybind
Huangzizhou Oct 16, 2024
aa0c9df
python binding fixes
arvigj Dec 7, 2024
e63f747
Merge pull request #2 from arvigj/main
Huangzizhou Apr 1, 2025
efc994f
Update setup.py
arvigj May 10, 2025
c5c25f9
Update setup.py
arvigj May 10, 2025
566f0d2
Merge pull request #3 from arvigj/main
Huangzizhou May 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix import error
  • Loading branch information
Huangzizhou committed Aug 22, 2024
commit 4ec050ba6ada95f422bec17d18d39713d3a24557
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build-system]
requires = ["setuptools", "wheel", "pybind11", "cmake"]
build-backend = "setuptools.build_meta"

[project]
name = "polyfempy"
version = "0.8"
description="Polyfem Python Bindings"
readme = "README.md"
authors = [
{ name = "Zizhou Huang", email = "[email protected]" },
]
requires-python = ">=3.6"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License"
]
21 changes: 1 addition & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,17 @@ def run(self):
self.build_extension(ext)

def build_extension(self, ext):
use_cholmod = os.environ.get( "USE_CHOLMOD", "1" )
n_threads_str = os.environ.get( "N_THREADS", "1" )
n_threads = int(n_threads_str)

cholmod_str = "-DPOLYSOLVE_WITH_CHOLMOD=OFF" if use_cholmod == "0" else "-DPOLYSOLVE_WITH_CHOLMOD=ON"


extdir = os.path.join(os.path.abspath(os.path.dirname(
self.get_ext_fullpath(ext.name))), "polyfempy")

python_include_directory = str(get_python_inc())

cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable,
'-DPYTHON_INCLUDE_DIR=' + python_include_directory,
cholmod_str,
'-DPOLYSOLVE_WITH_AMGCL=OFF',
'-DPOLYSOLVE_WITH_MKL=OFF',
'-DPOLYSOLVE_WITH_SPECTRA=OFF']
'-DPYTHON_INCLUDE_DIR=' + python_include_directory]

cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
Expand Down Expand Up @@ -93,9 +85,6 @@ def build_extension(self, ext):

setup(
name="polyfempy",
version="0.7",
author="Teseo Schneider",
author_email="",
description="Polyfem Python Bindings",
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -108,13 +97,5 @@ def build_extension(self, ext):
"License :: OSI Approved :: MIT License"
],
python_requires='>=3.6',
install_requires=[
'numpy',
'argparse'],
entry_points={
'console_scripts': [
'polyfem = polyfempy.command:polyfem'
]
},
test_suite="test"
)
5 changes: 0 additions & 5 deletions src/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
#include <polyfem/time_integrator/ImplicitTimeIntegrator.hpp>
#include <polyfem/State.hpp>

// #include "raster.hpp"

#include <igl/boundary_facets.h>
#include <igl/remove_unreferenced.h>

#include <stdexcept>

#include <pybind11_json/pybind11_json.hpp>
Expand Down
63 changes: 63 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# %%
import polyfempy as pf
import json
import numpy as np

# %%
root = "../data/differentiable/input"
with open(root + "/initial-contact.json", "r") as f:
config = json.load(f)

config["contact"]["use_convergent_formulation"] = True
config["root_path"] = root + "/initial-contact.json"

solver = pf.Solver()
solver.set_settings(json.dumps(config), False)
solver.set_log_level(2)
solver.load_mesh_from_settings()

# %%
mesh = solver.mesh()

print(mesh.n_vertices())
print(mesh.n_elements())
print(mesh.n_cell_vertices(1))
print(mesh.element_vertex(3, 0))
print(mesh.boundary_element_vertex(3, 0))
assert(mesh.is_boundary_vertex(1))

min, max = mesh.bounding_box()

# %%
config = solver.settings()
t0 = config["time"]["t0"]
dt = config["time"]["dt"]

# inits stuff
solver.build_basis()
solver.assemble()
sol = solver.init_timestepping(t0, dt)

for i in range(1, 5):

# substepping
for t in range(1):
sol = solver.step_in_time(sol, t0, dt, t+1)

t0 += dt
solver.export_vtu("step_" + str(i) + ".vtu", sol, np.zeros((0, 0)), t0, dt)

prob = solver.nl_problem()

h = prob.hessian(sol)
reduced_sol = prob.full_to_reduced(sol)
full_sol = prob.reduced_to_full(reduced_sol)

assert(np.linalg.norm(full_sol - sol.flatten()) < 1e-12)

cache = solver.get_solution_cache()

print(cache.solution(1).shape)
print(cache.velocity(2).shape)
print(cache.acceleration(3).shape)
print(cache.hessian(4).shape)