|
14 | 14 | #include <pybind11/pybind11.h>
|
15 | 15 | #include <pybind11/eigen.h>
|
16 | 16 | #include <pybind11/functional.h>
|
| 17 | +#include <pybind11/stl.h> |
17 | 18 |
|
18 | 19 | namespace py = pybind11;
|
19 | 20 |
|
@@ -111,6 +112,11 @@ PYBIND11_MODULE(polyfempy, m) {
|
111 | 112 | else
|
112 | 113 | polyfem::to_geogram_mesh_3d(V, F, M);
|
113 | 114 | s.load_mesh(M, [](const polyfem::RowVectorNd&){ return -1; }, true);
|
| 115 | + |
| 116 | + double boundary_id_threshold = s.args["boundary_id_threshold"]; |
| 117 | + if(boundary_id_threshold <= 0) |
| 118 | + boundary_id_threshold = s.mesh->is_volume() ? 1e-2 : 1e-7; |
| 119 | + s.mesh->compute_boundary_ids(boundary_id_threshold); |
114 | 120 | },
|
115 | 121 | "Loads a mesh from vertices and connectivity",
|
116 | 122 | py::arg("vertices"), py::arg("connectivity"))
|
@@ -162,7 +168,10 @@ PYBIND11_MODULE(polyfempy, m) {
|
162 | 168 | s.assemble_rhs();
|
163 | 169 | s.assemble_stiffness_mat();
|
164 | 170 |
|
| 171 | + s.solve_export_to_file = false; |
| 172 | + s.solution_frames.clear(); |
165 | 173 | s.solve_problem();
|
| 174 | + s.solve_export_to_file = true; |
166 | 175 | },
|
167 | 176 | "solve the pde")
|
168 | 177 |
|
@@ -239,7 +248,80 @@ PYBIND11_MODULE(polyfempy, m) {
|
239 | 248 | return py::make_tuple(fun, tfun);
|
240 | 249 | },
|
241 | 250 | "returns the von mises stresses and stress tensor averaged around a vertex on a densly sampled mesh, use 'vismesh_rel_area' to control density",
|
242 |
| - py::arg("boundary_only") = bool(false)); |
| 251 | + py::arg("boundary_only") = bool(false)) |
| 252 | + |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | + //////////////////////////////////////////////////////////////////////////////////////////// |
| 257 | + .def("get_sampled_points_frames", [](polyfem::State &s) { |
| 258 | + assert(!s.solution_frames.empty()); |
| 259 | + |
| 260 | + std::vector<Eigen::MatrixXd> pts; |
| 261 | + |
| 262 | + for(const auto &sol : s.solution_frames){ |
| 263 | + pts.push_back(sol.points); |
| 264 | + } |
| 265 | + |
| 266 | + |
| 267 | + return pts; |
| 268 | + }, |
| 269 | + "returns the points frames for a time dependent problem on a densly sampled mesh, use 'vismesh_rel_area' to control density") |
| 270 | + |
| 271 | + .def("get_sampled_connectivity_frames", [](polyfem::State &s) { |
| 272 | + assert(!s.solution_frames.empty()); |
| 273 | + |
| 274 | + std::vector<Eigen::MatrixXi> tets; |
| 275 | + |
| 276 | + for(const auto &sol : s.solution_frames) |
| 277 | + tets.push_back(sol.connectivity); |
| 278 | + |
| 279 | + |
| 280 | + return tets; |
| 281 | + }, |
| 282 | + "returns the connectivity frames for a time dependent problem on a densly sampled mesh, use 'vismesh_rel_area' to control density") |
| 283 | + |
| 284 | + |
| 285 | + .def("get_sampled_solution_frames", [](polyfem::State &s) { |
| 286 | + assert(!s.solution_frames.empty()); |
| 287 | + |
| 288 | + std::vector<Eigen::MatrixXd> fun; |
| 289 | + |
| 290 | + for(const auto &sol : s.solution_frames){ |
| 291 | + fun.push_back(sol.solution); |
| 292 | + } |
| 293 | + |
| 294 | + |
| 295 | + return fun; |
| 296 | + }, |
| 297 | + "returns the solution frames for a time dependent problem on a densly sampled mesh, use 'vismesh_rel_area' to control density") |
| 298 | + |
| 299 | + .def("get_sampled_mises_frames", [](polyfem::State &s) { |
| 300 | + assert(!s.solution_frames.empty()); |
| 301 | + |
| 302 | + std::vector<Eigen::MatrixXd> mises; |
| 303 | + |
| 304 | + for(const auto &sol : s.solution_frames) |
| 305 | + mises.push_back(sol.scalar_value); |
| 306 | + |
| 307 | + return mises; |
| 308 | + }, |
| 309 | + "returns the von mises stresses frames on a densly sampled mesh, use 'vismesh_rel_area' to control density") |
| 310 | + |
| 311 | + .def("get_sampled_mises_avg_frames", [](polyfem::State &s) { |
| 312 | + assert(!s.solution_frames.empty()); |
| 313 | + |
| 314 | + std::vector<Eigen::MatrixXd> mises; |
| 315 | + |
| 316 | + for(const auto &sol : s.solution_frames) |
| 317 | + mises.push_back(sol.scalar_value_avg); |
| 318 | + |
| 319 | + return mises; |
| 320 | + }, |
| 321 | + "returns the von mises stresses per frame averaged around a vertex on a densly sampled mesh, use 'vismesh_rel_area' to control density"); |
| 322 | + |
| 323 | + |
| 324 | + |
243 | 325 |
|
244 | 326 | solver.doc() = "Polyfem solver";
|
245 | 327 |
|
|
0 commit comments