PolyFEM
|
main class that contains the polyfem adjoint solver and all its state More...
#include <OptState.hpp>
Public Member Functions | |
~OptState () | |
OptState () | |
Constructor. | |
void | init (const json &args, const bool strict_validation) |
initialize the polyfem solver with a json settings | |
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 | |
void | init_logger (std::ostream &os, const spdlog::level::level_enum log_level) |
initializing the logger writes to an output stream | |
void | set_log_level (const spdlog::level::level_enum log_level) |
change log level | |
void | create_states (const polyfem::solver::CacheLevel level, const int max_threads=-1) |
create the opt states | |
void | init_variables () |
init variables | |
void | create_problem () |
void | initial_guess (Eigen::VectorXd &x) |
double | eval (Eigen::VectorXd &x) const |
void | solve (Eigen::VectorXd &x) |
Public Attributes | |
json | args |
main input arguments containing all defaults | |
std::string | output_dir |
Directory for output files. | |
Private Member Functions | |
std::string | root_path () const |
void | init_logger (const std::vector< spdlog::sink_ptr > &sinks, const spdlog::level::level_enum log_level) |
initializing the logger meant for internal usage | |
Private Attributes | |
spdlog::sink_ptr | console_sink_ = nullptr |
logger sink to stdout | |
spdlog::sink_ptr | file_sink_ = nullptr |
std::vector< std::shared_ptr< State > > | states |
State used in the opt. | |
std::vector< int > | variable_sizes |
variables | |
int | ndof |
solver::VariableToSimulationGroup | variable_to_simulations |
std::unique_ptr< solver::AdjointNLProblem > | nl_problem |
main class that contains the polyfem adjoint solver and all its state
Definition at line 21 of file OptState.hpp.
polyfem::OptState::~OptState | ( | ) |
Definition at line 39 of file OptState.cpp.
polyfem::OptState::OptState | ( | ) |
Constructor.
Definition at line 44 of file OptState.cpp.
References polyfem::utils::GeogramUtils::initialize(), and polyfem::utils::GeogramUtils::instance().
void polyfem::OptState::create_problem | ( | ) |
Definition at line 156 of file OptState.cpp.
References args, polyfem::solver::AdjointOptUtils::create_form(), nl_problem, states, and variable_to_simulations.
Referenced by optimization_simulation().
void polyfem::OptState::create_states | ( | const polyfem::solver::CacheLevel | level, |
const int | max_threads = -1 |
||
) |
create the opt states
Definition at line 131 of file OptState.cpp.
References polyfem::adjoint_logger(), args, polyfem::solver::AdjointOptUtils::create_states(), polyfem::utils::GeogramUtils::instance(), polyfem::utils::GeogramUtils::set_logger(), and states.
Referenced by optimization_simulation().
double polyfem::OptState::eval | ( | Eigen::VectorXd & | x | ) | const |
Definition at line 179 of file OptState.cpp.
References nl_problem, and x.
Referenced by optimization_simulation().
void polyfem::OptState::init | ( | const json & | args, |
const bool | strict_validation | ||
) |
initialize the polyfem solver with a json settings
[in] | args | input arguments |
[in] | strict_validation | strict validation of input |
Definition at line 100 of file OptState.cpp.
References polyfem::adjoint_logger(), polyfem::solver::AdjointOptUtils::apply_opt_json_spec(), args, polyfem::utils::NThread::get(), init_logger(), output_dir, polyfem::utils::resolve_path(), root_path(), and polyfem::utils::NThread::set_num_threads().
Referenced by optimization_simulation().
void polyfem::OptState::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
[in] | log_file | is to write it to a file (use log_file="") to output to stdout |
[in] | log_level | 0 all message, 6 no message. 2 is info, 1 is debug |
[in] | file_log_level | 0 all message, 6 no message. 2 is info, 1 is debug |
[in] | is_quit | quiets the log |
Definition at line 49 of file OptState.cpp.
References console_sink_, file_sink_, and init_logger().
Referenced by init(), init_logger(), and init_logger().
|
private |
initializing the logger meant for internal usage
Definition at line 82 of file OptState.cpp.
References polyfem::adjoint_logger(), polyfem::set_adjoint_logger(), and set_log_level().
void polyfem::OptState::init_logger | ( | std::ostream & | os, |
const spdlog::level::level_enum | log_level | ||
) |
initializing the logger writes to an output stream
[in] | os | output stream |
[in] | log_level | 0 all message, 6 no message. 2 is info, 1 is debug |
Definition at line 75 of file OptState.cpp.
References init_logger().
void polyfem::OptState::init_variables | ( | ) |
init variables
Definition at line 141 of file OptState.cpp.
References args, polyfem::solver::AdjointOptUtils::compute_variable_size(), polyfem::solver::VariableToSimulationGroup::init(), ndof, states, variable_sizes, and variable_to_simulations.
Referenced by optimization_simulation().
void polyfem::OptState::initial_guess | ( | Eigen::VectorXd & | x | ) |
Definition at line 172 of file OptState.cpp.
References args, polyfem::solver::AdjointOptUtils::inverse_evaluation(), ndof, polyfem::solver::VariableToSimulationGroup::update(), variable_sizes, variable_to_simulations, and x.
Referenced by optimization_simulation().
|
inlineprivate |
Definition at line 75 of file OptState.hpp.
References args, and polyfem::utils::is_param_valid().
Referenced by init().
void polyfem::OptState::set_log_level | ( | const spdlog::level::level_enum | log_level | ) |
change log level
[in] | log_level | 0 all message, 6 no message. 2 is info, 1 is debug |
Definition at line 93 of file OptState.cpp.
References polyfem::adjoint_logger(), and console_sink_.
Referenced by init_logger().
void polyfem::OptState::solve | ( | Eigen::VectorXd & | x | ) |
Definition at line 185 of file OptState.cpp.
References args, polyfem::solver::AdjointOptUtils::make_nl_solver(), nl_problem, and x.
Referenced by optimization_simulation().
json polyfem::OptState::args |
main input arguments containing all defaults
Definition at line 38 of file OptState.hpp.
Referenced by create_problem(), create_states(), init(), init_variables(), initial_guess(), optimization_simulation(), root_path(), and solve().
|
private |
logger sink to stdout
Definition at line 86 of file OptState.hpp.
Referenced by init_logger(), and set_log_level().
|
private |
Definition at line 87 of file OptState.hpp.
Referenced by init_logger().
|
private |
Definition at line 98 of file OptState.hpp.
Referenced by init_variables(), and initial_guess().
|
private |
Definition at line 102 of file OptState.hpp.
Referenced by create_problem(), eval(), and solve().
std::string polyfem::OptState::output_dir |
|
private |
State used in the opt.
Definition at line 94 of file OptState.hpp.
Referenced by create_problem(), create_states(), and init_variables().
|
private |
variables
Definition at line 97 of file OptState.hpp.
Referenced by init_variables(), and initial_guess().
|
private |
Definition at line 100 of file OptState.hpp.
Referenced by create_problem(), init_variables(), and initial_guess().