PolyFEM
Loading...
Searching...
No Matches
State.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <polyfem/Common.hpp>
5
6#include <Eigen/Dense>
7
8#include <spdlog/spdlog.h>
9
10#include <functional>
11#include <limits>
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace GEO
17{
18 class Mesh;
19}
20
22{
23 class VarForm;
24}
25
26namespace polyfem
27{
29 class State
30 {
31 public:
32 State();
33 ~State() = default;
34
38 void init(const json &args, const bool strict_validation);
39
41 void set_max_threads(const int max_threads = std::numeric_limits<int>::max());
42
45
47 std::shared_ptr<varform::VarForm> variational_formulation;
48
50 std::function<void(int, int, double, double)> time_callback = nullptr;
51
52 //---------------------------------------------------
53 //-----------------logger----------------------------
54 //---------------------------------------------------
55
61 void init_logger(
62 const std::string &log_file,
63 const spdlog::level::level_enum log_level,
64 const spdlog::level::level_enum file_log_level,
65 const bool is_quiet);
66
70 void init_logger(std::ostream &os, const spdlog::level::level_enum log_level);
71
74 void set_log_level(const spdlog::level::level_enum log_level);
75
76 private:
78 void init_logger(const std::vector<spdlog::sink_ptr> &sinks, const spdlog::level::level_enum log_level);
79
81 spdlog::sink_ptr console_sink_ = nullptr;
82 spdlog::sink_ptr file_sink_ = nullptr;
83
84 public:
86 void solve(Eigen::MatrixXd &sol);
87
88 //---------------------------------------------------
89 //-----------------Geometry--------------------------
90 //---------------------------------------------------
91
97 void load_mesh(bool non_conforming = false,
98 const std::vector<std::string> &names = std::vector<std::string>(),
99 const std::vector<Eigen::MatrixXi> &cells = std::vector<Eigen::MatrixXi>(),
100 const std::vector<Eigen::MatrixXd> &vertices = std::vector<Eigen::MatrixXd>());
101
107 void load_mesh(GEO::Mesh &meshin, const std::function<int(const size_t, const std::vector<int> &, const RowVectorNd &, bool)> &boundary_marker, bool non_conforming = false, bool skip_boundary_sideset = false);
108
113 void load_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, bool non_conforming = false);
114 };
115
116} // namespace polyfem
int V
VarForm-only simulation state.
Definition State.hpp:30
void init(const json &args, const bool strict_validation)
initialize the polyfem solver with a json settings
Definition State.cpp:243
std::shared_ptr< varform::VarForm > variational_formulation
active variational formulation
Definition State.hpp:47
void load_mesh(bool non_conforming=false, const std::vector< std::string > &names=std::vector< std::string >(), const std::vector< Eigen::MatrixXi > &cells=std::vector< Eigen::MatrixXi >(), const std::vector< Eigen::MatrixXd > &vertices=std::vector< Eigen::MatrixXd >())
loads the mesh from the json arguments
Definition State.cpp:402
void solve(Eigen::MatrixXd &sol)
solves the problem, call other methods
Definition State.cpp:454
void set_max_threads(const int max_threads=std::numeric_limits< int >::max())
Definition State.cpp:365
spdlog::sink_ptr file_sink_
Definition State.hpp:82
spdlog::sink_ptr console_sink_
logger sink to stdout
Definition State.hpp:81
~State()=default
json args
main input arguments containing all defaults
Definition State.hpp:44
void set_log_level(const spdlog::level::level_enum log_level)
change log level
Definition State.cpp:229
std::function< void(int, int, double, double)> time_callback
Optional UI progress callback.
Definition State.hpp:50
void init_logger(const std::string &log_file, const spdlog::level::level_enum log_level, const spdlog::level::level_enum file_log_level, const bool is_quiet)
initializing the logger
Definition State.cpp:175
Definition State.hpp:17
nlohmann::json json
Definition Common.hpp:9
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13