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

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 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
7637706
fix ci
Huangzizhou Oct 11, 2024
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
more util functions
  • Loading branch information
Huangzizhou committed Jul 27, 2024
commit 670378e3cfc0eb7fa8aea1cecdaa9a386c88c3f9
23 changes: 19 additions & 4 deletions src/mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ void define_mesh(py::module_ &m)
{
py::class_<Mesh>(m, "Mesh", "Mesh")

.def("dimension", &Mesh::dimension, "Dimension of the mesh (2 or 3)")

.def("n_elements", &Mesh::n_elements, "Number of elements")

.def("n_boundary_elements", &Mesh::n_boundary_elements,
Expand Down Expand Up @@ -92,6 +94,18 @@ void define_mesh(py::module_ &m)
},
"Get all vertex positions")

.def(
"set_vertices",
[](Mesh &mesh, const Eigen::VectorXi &ids,
const Eigen::MatrixXd &points) {
for (int i = 0; i < ids.size(); i++)
{
assert(ids(i) < mesh.n_vertices());
mesh.set_point(ids(i), points.row(i));
}
},
"Set a subset of vertex positions given a list of vertex indices")

.def(
"set_vertices",
[](Mesh &mesh, const Eigen::MatrixXd &points) {
Expand All @@ -103,12 +117,13 @@ void define_mesh(py::module_ &m)
.def(
"elements",
[](const Mesh &mesh) {
Eigen::MatrixXi elements(mesh.n_elements(), mesh.n_cell_vertices(0));
Eigen::MatrixXi elements(mesh.n_elements(),
mesh.n_cell_vertices(0));
for (int e = 0; e < mesh.n_elements(); e++)
{
assert(mesh.n_cell_vertices(e) == elements.cols());
for (int i = 0; i < elements.cols(); i++)
elements(e, i) = mesh.element_vertex(e, i);
assert(mesh.n_cell_vertices(e) == elements.cols());
for (int i = 0; i < elements.cols(); i++)
elements(e, i) = mesh.element_vertex(e, i);
}
return elements;
},
Expand Down
25 changes: 25 additions & 0 deletions src/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ void define_solver(py::module_ &m)
"load PDE and problem parameters from the settings", py::arg("json"),
py::arg("strict_validation") = false)

.def("set_max_threads", &State::set_max_threads,
"set maximum number of threads", py::arg("nthreads"))

.def("ndof", &State::ndof, "Dimension of the solution")

.def("n_bases", [](const State &s) { return s.n_bases; }, "Number of basis")
Expand Down Expand Up @@ -398,6 +401,28 @@ void define_solver(py::module_ &m)
"set_cache_level",
[](State &s, solver::CacheLevel level) {
s.optimization_enabled = level;
if (level == solver::CacheLevel::Derivatives)
{
if (s.is_contact_enabled())
{
if (!s.args["contact"]["use_convergent_formulation"])
{
s.args["contact"]["use_convergent_formulation"] = true;
logger().info("Use convergent formulation for differentiable contact...");
}
if (s.args["/solver/contact/barrier_stiffness"_json_pointer].is_string())
{
logger().error("Only constant barrier stiffness is supported in differentiable contact!");
}
}

if (s.args.contains("boundary_conditions") && s.args["boundary_conditions"].contains("rhs"))
{
json rhs = s.args["boundary_conditions"]["rhs"];
if ((rhs.is_array() && rhs.size() > 0 && rhs[0].is_string()) || rhs.is_string())
logger().error("Only constant rhs over space is supported in differentiable code!");
}
}
},
"Set solution caching level", py::arg("cache_level"))

Expand Down