Skip to content

Commit d205e08

Browse files
committed
update polyfem
1 parent 2fc4990 commit d205e08

File tree

4 files changed

+27
-130
lines changed

4 files changed

+27
-130
lines changed

cmake/recipes/polyfem.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ message(STATUS "Third-party: creating target 'polyfem::polyfem'")
1717
# FetchContent_MakeAvailable(polyfem)
1818

1919
include(CPM)
20-
CPMAddPackage("gh:polyfem/polyfem#81a01a71c1c1a4605812e49da4dad9f0a9404828")
20+
CPMAddPackage("gh:polyfem/polyfem#e8bd3d3")

src/mesh/mesh.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,31 @@ void define_mesh(py::module_ &m)
5050
.def("get_boundary_id", &Mesh::get_boundary_id,
5151
"Get boundary ID of one boundary primitive", py::arg("primitive"))
5252

53-
.def(
54-
"set_boundary_side_set_from_bary",
55-
[](Mesh &mesh,
56-
const std::function<int(const RowVectorNd &)> &boundary_marker) {
57-
mesh.compute_boundary_ids(boundary_marker);
58-
},
59-
"Sets the side set for the boundary conditions, the functions takes the barycenter of the boundary (edge or face)",
60-
py::arg("boundary_marker"))
61-
.def(
62-
"set_boundary_side_set_from_bary_and_boundary",
63-
[](Mesh &mesh, const std::function<int(const RowVectorNd &, bool)>
64-
&boundary_marker) {
65-
mesh.compute_boundary_ids(boundary_marker);
66-
},
67-
"Sets the side set for the boundary conditions, the functions takes the barycenter of the boundary (edge or face) and a flag that says if the element is boundary",
68-
py::arg("boundary_marker"))
69-
.def(
70-
"set_boundary_side_set_from_v_ids",
71-
[](Mesh &mesh,
72-
const std::function<int(const std::vector<int> &, bool)>
73-
&boundary_marker) {
74-
mesh.compute_boundary_ids(boundary_marker);
75-
},
76-
"Sets the side set for the boundary conditions, the functions takes the sorted list of vertex id and a flag that says if the element is boundary",
77-
py::arg("boundary_marker"))
53+
// .def(
54+
// "set_boundary_side_set_from_bary",
55+
// [](Mesh &mesh,
56+
// const std::function<int(const RowVectorNd &)> &boundary_marker) {
57+
// mesh.compute_boundary_ids(boundary_marker);
58+
// },
59+
// "Sets the side set for the boundary conditions, the functions takes the barycenter of the boundary (edge or face)",
60+
// py::arg("boundary_marker"))
61+
// .def(
62+
// "set_boundary_side_set_from_bary_and_boundary",
63+
// [](Mesh &mesh, const std::function<int(const RowVectorNd &, bool)>
64+
// &boundary_marker) {
65+
// mesh.compute_boundary_ids(boundary_marker);
66+
// },
67+
// "Sets the side set for the boundary conditions, the functions takes the barycenter of the boundary (edge or face) and a flag that says if the element is boundary",
68+
// py::arg("boundary_marker"))
69+
// .def(
70+
// "set_boundary_side_set_from_v_ids",
71+
// [](Mesh &mesh,
72+
// const std::function<int(const std::vector<int> &, bool)>
73+
// &boundary_marker) {
74+
// mesh.compute_boundary_ids(boundary_marker);
75+
// },
76+
// "Sets the side set for the boundary conditions, the functions takes the sorted list of vertex id and a flag that says if the element is boundary",
77+
// py::arg("boundary_marker"))
7878

7979
.def("set_body_ids", &Mesh::set_body_ids, "Set body IDs with an array",
8080
py::arg("ids"))

src/state/state.cpp

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -464,106 +464,6 @@ void define_solver(py::module_ &m)
464464
"exports the solution as vtu", py::arg("path"), py::arg("solution"),
465465
py::arg("pressure") = Eigen::MatrixXd(), py::arg("time") = double(0.),
466466
py::arg("dt") = double(0.))
467-
468-
.def(
469-
"get_boundary_sidesets",
470-
[](State &s) {
471-
// py::scoped_ostream_redirect output;
472-
Eigen::MatrixXd points;
473-
Eigen::MatrixXi faces;
474-
Eigen::MatrixXd sidesets;
475-
476-
io::Evaluator::get_sidesets(*s.mesh, points, faces, sidesets);
477-
478-
return py::make_tuple(points, faces, sidesets);
479-
},
480-
"exports get the boundary sideset, edges in 2d or trangles in 3d")
481-
482-
.def(
483-
"update_dirichlet_boundary",
484-
[](State &self, const int id, const py::object &val, const bool isx,
485-
const bool isy, const bool isz, const std::string &interp) {
486-
using namespace polyfem;
487-
// py::scoped_ostream_redirect output;
488-
const json json_val = val;
489-
if (assembler::GenericTensorProblem *prob0 =
490-
dynamic_cast<assembler::GenericTensorProblem *>(
491-
self.problem.get()))
492-
{
493-
prob0->update_dirichlet_boundary(id, json_val, isx, isy, isz,
494-
interp);
495-
}
496-
else if (assembler::GenericScalarProblem *prob1 =
497-
dynamic_cast<assembler::GenericScalarProblem *>(
498-
self.problem.get()))
499-
{
500-
prob1->update_dirichlet_boundary(id, json_val, interp);
501-
}
502-
else
503-
{
504-
throw "Updating BC works only for GenericProblems";
505-
}
506-
},
507-
"updates dirichlet boundary", py::arg("id"), py::arg("val"),
508-
py::arg("isx") = bool(true), py::arg("isy") = bool(true),
509-
py::arg("isz") = bool(true), py::arg("interp") = std::string(""))
510-
.def(
511-
"update_neumann_boundary",
512-
[](State &self, const int id, const py::object &val,
513-
const std::string &interp) {
514-
using namespace polyfem;
515-
// py::scoped_ostream_redirect output;
516-
const json json_val = val;
517-
518-
if (auto prob0 = dynamic_cast<assembler::GenericTensorProblem *>(
519-
self.problem.get()))
520-
{
521-
prob0->update_neumann_boundary(id, json_val, interp);
522-
}
523-
else if (auto prob1 =
524-
dynamic_cast<assembler::GenericScalarProblem *>(
525-
self.problem.get()))
526-
{
527-
prob1->update_neumann_boundary(id, json_val, interp);
528-
}
529-
else
530-
{
531-
throw "Updating BC works only for GenericProblems";
532-
}
533-
},
534-
"updates neumann boundary", py::arg("id"), py::arg("val"),
535-
py::arg("interp") = std::string(""))
536-
.def(
537-
"update_pressure_boundary",
538-
[](State &self, const int id, const py::object &val,
539-
const std::string &interp) {
540-
using namespace polyfem;
541-
// py::scoped_ostream_redirect output;
542-
const json json_val = val;
543-
544-
if (auto prob = dynamic_cast<assembler::GenericTensorProblem *>(
545-
self.problem.get()))
546-
{
547-
prob->update_pressure_boundary(id, json_val, interp);
548-
}
549-
else
550-
{
551-
throw "Updating BC works only for Tensor GenericProblems";
552-
}
553-
},
554-
"updates pressure boundary", py::arg("id"), py::arg("val"),
555-
py::arg("interp") = std::string(""))
556-
.def(
557-
"update_obstacle_displacement",
558-
[](State &self, const int oid, const py::object &val,
559-
const std::string &interp) {
560-
using namespace polyfem;
561-
// py::scoped_ostream_redirect output;
562-
const json json_val = val;
563-
self.obstacle.change_displacement(oid, json_val, interp);
564-
},
565-
"updates obstacle displacement", py::arg("oid"), py::arg("val"),
566-
py::arg("interp") = std::string(""))
567467
.def(
568468
"set_friction_coefficient", [](State &self, const double mu) {
569469
self.args["contact"]["friction_coefficient"] = mu;

test/test_diff.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ def forward(ctx, solvers, vertices):
1515
solver.mesh().set_vertices(vertices)
1616
solver.set_cache_level(pf.CacheLevel.Derivatives) # enable backward derivatives
1717
solver.solve()
18-
cache = solver.get_solution_cache()
19-
sol = torch.zeros((solver.ndof(), cache.size()))
20-
for t in range(cache.size()):
21-
sol[:, t] = torch.tensor(cache.solution(t))
18+
sol = torch.tensor(solver.get_solutions())
2219
solutions.append(sol)
2320

2421
ctx.save_for_backward(vertices)

0 commit comments

Comments
 (0)