Skip to content

Commit a6da4cf

Browse files
committed
update polyfem
1 parent 5cf3dbc commit a6da4cf

5 files changed

Lines changed: 7 additions & 113 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ __pycache__
1919
temp-plot.html
2020
data*
2121
*libTracyClient.*
22+
.cache/

cmake/recipes/polyfem.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include(FetchContent)
1111
FetchContent_Declare(
1212
polyfem
1313
GIT_REPOSITORY https://github.com/polyfem/polyfem.git
14-
GIT_TAG ffb1d130e70fc913ec4546c8683d6d22bd58a700
14+
GIT_TAG ea0e5cc25f2ffba64ea47225cf106460935cda5f
1515
GIT_SHALLOW FALSE
1616
)
1717
FetchContent_MakeAvailable(polyfem)

cmake/recipes/polyfem_data.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include(FetchContent)
77
FetchContent_Declare(
88
polyfem_data
99
GIT_REPOSITORY https://github.com/polyfem/polyfem-data
10-
GIT_TAG 56e70d2d7199fe4822b259c47fada97f70e32a72
10+
GIT_TAG 29a46df1fd90c237a82c219f346a956e72bd17d3
1111
GIT_SHALLOW FALSE
1212
SOURCE_DIR ${POLYFEMPY_DATA_ROOT}/data
1313
)

polyfempy/test/test_pythonic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def sideset(p):
3838
diriclet_bc=[{"id": 4, "value": [0, 0]}],
3939
materials=[{"id": 0, "E": 2100, "nu": 0.3}],
4040
rhs=[0, 0.1],
41-
pde=pf.PDEs.LinearElasticity,
4241
discr_order=1
4342
)
4443

src/binding.cpp

Lines changed: 4 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -959,126 +959,20 @@ PYBIND11_MODULE(polyfempy, m)
959959
"runs FEBio", py::arg("febio_file"), py::arg("output_path") = std::string(""), py::arg("log_level") = 2);
960960

961961
m.def(
962-
"solve", [](const Eigen::MatrixXd &vertices, const Eigen::MatrixXi &cells, const py::object &sidesets_func, const py::list &sidesets_selection, const py::list &body_selection, const py::list &materials, const std::string &pde, const py::list &diriclet_bc, const py::list &neumann_bc, const py::list &pressure_bc, const py::object &rhs, const bool is_time_dependent, const py::dict &expo, const int log_level, const py::kwargs &kwargs) {
962+
"solve", [](const Eigen::MatrixXd &vertices, const Eigen::MatrixXi &cells, const py::object &sidesets_func, const int log_level, const py::kwargs &kwargs) {
963963
std::string log_file = "";
964-
const bool is2d = vertices.cols() == 2;
965964

966965
std::unique_ptr<polyfem::State> res = std::make_unique<polyfem::State>();
967966
polyfem::State &state = *res;
968967
state.init_logger(log_file, log_level, false);
969-
// const int kwargs_size = std::distance(kwargs.begin(), kwargs.end());
970-
json in_args = json(static_cast<py::dict>(kwargs));
971-
972-
if (!in_args.contains("normalize_mesh"))
973-
in_args["normalize_mesh"] = false;
974-
975-
const bool is_scalar = polyfem::AssemblerUtils::is_scalar(pde);
976-
in_args["scalar_formulation"] = "";
977-
in_args["tensor_formulation"] = "";
978-
979-
if (is_scalar)
980-
in_args["scalar_formulation"] = pde;
981-
else
982-
in_args["tensor_formulation"] = pde;
983-
in_args["problem"] = is_scalar ? "GenericScalar" : "GenericTensor";
984-
985-
const int sidesets_selection_size = std::distance(sidesets_selection.begin(), sidesets_selection.end());
986-
987-
if (!sidesets_func.is_none())
988-
{
989-
}
990-
else if (sidesets_selection_size > 0 && !in_args.contains("boundary_sidesets"))
991-
{
992-
json selections = json::array();
993-
994-
for (const auto &d : sidesets_selection)
995-
{
996-
selections.push_back(json(d));
997-
}
998-
999-
in_args["boundary_sidesets"] = selections;
1000-
}
1001-
1002-
const int body_selection_size = std::distance(body_selection.begin(), body_selection.end());
1003-
if (body_selection_size > 0 && !in_args.contains("body_ids"))
1004-
{
1005-
json selections = json::array();
1006-
1007-
for (const auto &d : body_selection)
1008-
{
1009-
selections.push_back(json(d));
1010-
}
1011-
1012-
in_args["body_ids"] = selections;
1013-
}
1014-
1015-
const int materials_size = std::distance(materials.begin(), materials.end());
1016-
if (materials_size > 1 && !in_args.contains("body_params"))
1017-
{
1018-
1019-
json materialss = json::array();
1020968

1021-
for (const auto &d : materials)
1022-
{
1023-
materialss.push_back(json(d));
1024-
}
1025-
1026-
in_args["body_params"] = materialss;
1027-
}
1028-
else if (materials_size == 1 && !in_args.contains("params"))
1029-
{
1030-
in_args["params"] = json(materials[0]);
1031-
}
1032-
1033-
if (!in_args.contains("problem_params"))
1034-
in_args["problem_params"] = {};
1035-
1036-
if (!in_args["problem_params"].contains("is_time_dependent"))
1037-
in_args["problem_params"]["is_time_dependent"] = is_time_dependent;
1038-
1039-
const int diriclet_bc_size = std::distance(diriclet_bc.begin(), diriclet_bc.end());
1040-
if (diriclet_bc_size > 0 && !in_args["problem_params"].contains("dirichlet_boundary"))
1041-
{
1042-
json bcs = json::array();
1043-
for (const auto &d : diriclet_bc)
1044-
{
1045-
bcs.push_back(json(d));
1046-
}
1047-
in_args["problem_params"]["dirichlet_boundary"] = bcs;
1048-
}
1049-
const int neumann_bc_size = std::distance(neumann_bc.begin(), neumann_bc.end());
1050-
if (neumann_bc_size > 0 && !in_args["problem_params"].contains("neumann_boundary"))
1051-
{
1052-
json bcs = json::array();
1053-
for (const auto &d : neumann_bc)
1054-
{
1055-
bcs.push_back(json(d));
1056-
}
1057-
in_args["problem_params"]["neumann_boundary"] = bcs;
1058-
}
1059-
const int pressure_bc_size = std::distance(pressure_bc.begin(), pressure_bc.end());
1060-
if (pressure_bc_size > 0 && !in_args["problem_params"].contains("pressure_boundary"))
1061-
{
1062-
json bcs = json::array();
1063-
for (const auto &d : pressure_bc)
1064-
{
1065-
bcs.push_back(json(d));
1066-
}
1067-
in_args["problem_params"]["pressure_boundary"] = bcs;
1068-
}
1069-
1070-
if (!rhs.is_none() && !in_args["problem_params"].contains("rhs"))
1071-
in_args["problem_params"]["rhs"] = json(rhs);
1072-
1073-
json export_json = json(expo);
1074-
1075-
if (!in_args.contains("export"))
1076-
in_args["export"] = export_json;
969+
json in_args = json(static_cast<py::dict>(kwargs));
1077970

1078971
state.init(in_args);
1079972

1080973
if (vertices.size() > 0 && cells.size() > 0)
1081974
{
975+
const bool is2d = vertices.cols() == 2;
1082976
if (is2d)
1083977
state.mesh = std::make_unique<polyfem::CMesh2D>();
1084978
else
@@ -1140,5 +1034,5 @@ PYBIND11_MODULE(polyfempy, m)
11401034

11411035
return res;
11421036
},
1143-
"single solve function", py::kw_only(), py::arg("vertices") = Eigen::MatrixXd(), py::arg("cells") = Eigen::MatrixXi(), py::arg("sidesets_func") = py::none(), py::arg("sidesets_selection") = py::list(), py::arg("body_selection") = py::list(), py::arg("materials") = py::list(), py::arg("pde") = std::string("LinearElasticity"), py::arg("diriclet_bc") = py::list(), py::arg("neumann_bc") = py::list(), py::arg("pressure_bc") = py::list(), py::arg("rhs") = py::none(), py::arg("is_time_dependent") = bool(false), py::arg("export") = py::dict(), py::arg("log_level") = 2);
1037+
"single solve function", py::kw_only(), py::arg("vertices") = Eigen::MatrixXd(), py::arg("cells") = Eigen::MatrixXi(), py::arg("sidesets_func") = py::none(), py::arg("log_level") = 2);
11441038
}

0 commit comments

Comments
 (0)