Polyfem as Libary¶
Polyfem uses modern cmake
, so it it should be enough to add this line
add_subdirectory(<path-to-polyfem> polyfem)
target_link_library(<your_target> polyfem)
SET(POLYFEM_NO_UI ON)
Interface¶
The interface of polyfem is similar as Python. You should create a polyfem::State
object and then call methods on it.
Most of the fields are public for convenience but we discourage use or access them.
This is the main interface of polyfem::State
.
Initialization¶
void init(const json &args)
void init(const std::string &json_path)
loads the settings from a json object or file
Logging¶
void set_log_level(int log_level)
std::string get_log()
Loading mesh¶
void load_mesh()
void load_mesh(const std::string &path)
void load_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
Set boundary sides sets¶
void set_boundary_side_set(const std::function<int(const polyfem::RowVectorNd&)> &boundary_marker)
void set_boundary_side_set(const std::function<int(const polyfem::RowVectorNd&, bool)> &boundary_marker)
void set_boundary_side_set(const std::function<int(const std::vector<int>&, bool)> &boundary_marker)
Solving¶
void solve();
Note the solver internally calls
void build_basis();
void assemble_stiffness_mat();
void assemble_rhs();
void solve_problem();
If you problem has a solution you can use
void compute_errors();
Getters¶
const Eigen::MatrixXd &get_solution() const
const Eigen::MatrixXd &get_pressure() const
void get_sampled_solution(Eigen::MatrixXd &points, Eigen::MatrixXi &tets, Eigen::MatrixXd &fun, bool boundary_only = false)
void get_stresses(Eigen::MatrixXd &fun, bool boundary_only = false)
void get_sampled_mises(Eigen::MatrixXd &fun, bool boundary_only = false)
void get_sampled_mises_avg(Eigen::MatrixXd &fun, Eigen::MatrixXd &tfun, bool boundary_only = false)
vismesh_rel_area
to control density
Exporting¶
Exports the solution to VTU for visualization
void get_sidesets(Eigen::MatrixXd &pts, Eigen::MatrixXi &faces, Eigen::MatrixXd &sidesets);
void export_data();
void save_vtu(const std::string &name);
void save_wire(const std::string &name, bool isolines = false);
Last update:
2023-10-03