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
21namespace polyfem::varform
22{
23 class VarForm;
24}
25
26namespace polyfem
27{
29 class State
30 {
31 public:
32 State();
33 ~State() = default;
34
38 void init(
39 const json &args,
40 bool strict_validation,
41 bool is_adjoint_optimization = false);
42
44 void set_max_threads(const int max_threads = std::numeric_limits<int>::max());
45
48
50 std::shared_ptr<varform::VarForm> variational_formulation;
51
53 std::function<void(int, int, double, double)> time_callback = nullptr;
54
55 //---------------------------------------------------
56 //-----------------logger----------------------------
57 //---------------------------------------------------
58
64 void init_logger(
65 const std::string &log_file,
66 const spdlog::level::level_enum log_level,
67 const spdlog::level::level_enum file_log_level,
68 const bool is_quiet);
69
73 void init_logger(std::ostream &os, const spdlog::level::level_enum log_level);
74
77 void set_log_level(const spdlog::level::level_enum log_level);
78
79 private:
81 void init_logger(const std::vector<spdlog::sink_ptr> &sinks, const spdlog::level::level_enum log_level);
82
84 spdlog::sink_ptr console_sink_ = nullptr;
85 spdlog::sink_ptr file_sink_ = nullptr;
86
87 public:
89 void solve(Eigen::MatrixXd &sol);
90
91 //---------------------------------------------------
92 //-----------------Geometry--------------------------
93 //---------------------------------------------------
94
100 void load_mesh(bool non_conforming = false,
101 const std::vector<std::string> &names = std::vector<std::string>(),
102 const std::vector<Eigen::MatrixXi> &cells = std::vector<Eigen::MatrixXi>(),
103 const std::vector<Eigen::MatrixXd> &vertices = std::vector<Eigen::MatrixXd>());
104
110 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);
111
116 void load_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, bool non_conforming = false);
117 };
118
119} // namespace polyfem
int V
VarForm-only simulation state.
Definition State.hpp:30
std::shared_ptr< varform::VarForm > variational_formulation
active variational formulation
Definition State.hpp:50
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:409
void init(const json &args, bool strict_validation, bool is_adjoint_optimization=false)
initialize the polyfem solver with a json settings
Definition State.cpp:244
void solve(Eigen::MatrixXd &sol)
solves the problem, call other methods
Definition State.cpp:461
void set_max_threads(const int max_threads=std::numeric_limits< int >::max())
Definition State.cpp:372
spdlog::sink_ptr file_sink_
Definition State.hpp:85
spdlog::sink_ptr console_sink_
logger sink to stdout
Definition State.hpp:84
~State()=default
json args
main input arguments containing all defaults
Definition State.hpp:47
void set_log_level(const spdlog::level::level_enum log_level)
change log level
Definition State.cpp:230
std::function< void(int, int, double, double)> time_callback
Optional UI progress callback.
Definition State.hpp:53
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:176
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