PolyFEM
Loading...
Searching...
No Matches
polyfem::State Class Reference

VarForm-only simulation state. More...

#include <State.hpp>

Public Member Functions

 State ()
 
 ~State ()=default
 
void init (const json &args, const bool strict_validation)
 initialize the polyfem solver with a json settings
 
void set_max_threads (const int max_threads=std::numeric_limits< int >::max())
 
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 solve (Eigen::MatrixXd &sol)
 solves the problem, call other methods
 
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
 
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)
 loads the mesh from a geogram mesh
 
void load_mesh (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, bool non_conforming=false)
 loads the mesh from V and F,
 

Public Attributes

json args
 main input arguments containing all defaults
 
std::shared_ptr< varform::VarFormvariational_formulation
 active variational formulation
 
std::function< void(int, int, double, double)> time_callback = nullptr
 Optional UI progress callback.
 

Private Member Functions

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
 

Detailed Description

VarForm-only simulation state.

Definition at line 29 of file State.hpp.

Constructor & Destructor Documentation

◆ State()

polyfem::State::State ( )

Definition at line 170 of file State.cpp.

References polyfem::utils::GeogramUtils::initialize(), and polyfem::utils::GeogramUtils::instance().

Here is the call graph for this function:

◆ ~State()

polyfem::State::~State ( )
default

Member Function Documentation

◆ init()

void polyfem::State::init ( const json args,
const bool  strict_validation 
)

initialize the polyfem solver with a json settings

Parameters
[in]argsinput arguments
[in]strict_validationstrict validation of input

Definition at line 243 of file State.cpp.

References polyfem::utils::apply_common_params(), args, polyfem::varform::VarFormFactory::create(), polyfem::varform::formulation_from_args(), polyfem::Units::init(), init_logger(), polyfem::logger(), set_max_threads(), and variational_formulation.

Referenced by forward_simulation_with_varform_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_logger() [1/3]

void polyfem::State::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

Parameters
[in]log_fileis to write it to a file (use log_file="") to output to stdout
[in]log_level0 all message, 6 no message. 2 is info, 1 is debug
[in]file_log_level0 all message, 6 no message. 2 is info, 1 is debug
[in]is_quitquiets the log

Definition at line 175 of file State.cpp.

References console_sink_, file_sink_, and init_logger().

Referenced by init(), init_logger(), and init_logger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_logger() [2/3]

void polyfem::State::init_logger ( const std::vector< spdlog::sink_ptr > &  sinks,
const spdlog::level::level_enum  log_level 
)
private

initializing the logger meant for internal usage

Definition at line 207 of file State.cpp.

References polyfem::utils::GeogramUtils::instance(), polyfem::logger(), set_log_level(), polyfem::utils::GeogramUtils::set_logger(), and polyfem::set_logger().

Here is the call graph for this function:

◆ init_logger() [3/3]

void polyfem::State::init_logger ( std::ostream &  os,
const spdlog::level::level_enum  log_level 
)

initializing the logger writes to an output stream

Parameters
[in]osoutput stream
[in]log_level0 all message, 6 no message. 2 is info, 1 is debug

Definition at line 200 of file State.cpp.

References init_logger().

Here is the call graph for this function:

◆ load_mesh() [1/3]

void polyfem::State::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

Parameters
[in]non_conformingcreates a conforming/non conforming mesh
[in]nameskeys in the hdf5
[in]cellslist of cells from hdf5
[in]verticeslist of vertices from hdf5

Definition at line 402 of file State.cpp.

References args, polyfem::Units::init(), polyfem::utils::is_param_valid(), polyfem::log_and_throw_error(), polyfem::logger(), polyfem::mesh::read_fem_geometry(), and variational_formulation.

Referenced by forward_simulation_with_varform_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_mesh() [2/3]

void polyfem::State::load_mesh ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
bool  non_conforming = false 
)

loads the mesh from V and F,

Parameters
[in]Vis #vertices x dim
[in]Fis #elements x size (size = 3 for triangle mesh, size=4 for a quad mesh if dim is 2)
[in]non_conformingcreates a conforming/non conforming mesh

Definition at line 462 of file State.cpp.

References polyfem::mesh::Mesh::create(), polyfem::F, V, and variational_formulation.

Here is the call graph for this function:

◆ load_mesh() [3/3]

void polyfem::State::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 
)

loads the mesh from a geogram mesh

Parameters
[in]meshingeo mesh
[in]boundary_markerthe input of the lambda is the face barycenter, the output is the sideset id
[in]non_conformingcreates a conforming/non conforming mesh
[in]skip_boundary_sidesetskip_boundary_sideset = false it uses the lambda boundary_marker to assign the sideset

Definition at line 370 of file State.cpp.

References polyfem::mesh::Mesh::create(), polyfem::logger(), and variational_formulation.

Here is the call graph for this function:

◆ set_log_level()

void polyfem::State::set_log_level ( const spdlog::level::level_enum  log_level)

change log level

Parameters
[in]log_level0 all message, 6 no message. 2 is info, 1 is debug

Definition at line 229 of file State.cpp.

References console_sink_, and polyfem::logger().

Referenced by init_logger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_max_threads()

void polyfem::State::set_max_threads ( const int  max_threads = std::numeric_limits<int>::max())
Parameters
[in]max_threadsmax number of threads

Definition at line 365 of file State.cpp.

References polyfem::utils::NThread::get(), and polyfem::utils::NThread::set_num_threads().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve()

void polyfem::State::solve ( Eigen::MatrixXd &  sol)

solves the problem, call other methods

Definition at line 454 of file State.cpp.

References time_callback, and variational_formulation.

Referenced by forward_simulation_with_varform_state().

Here is the caller graph for this function:

Member Data Documentation

◆ args

json polyfem::State::args

main input arguments containing all defaults

Definition at line 44 of file State.hpp.

Referenced by init(), and load_mesh().

◆ console_sink_

spdlog::sink_ptr polyfem::State::console_sink_ = nullptr
private

logger sink to stdout

Definition at line 81 of file State.hpp.

Referenced by init_logger(), and set_log_level().

◆ file_sink_

spdlog::sink_ptr polyfem::State::file_sink_ = nullptr
private

Definition at line 82 of file State.hpp.

Referenced by init_logger().

◆ time_callback

std::function<void(int, int, double, double)> polyfem::State::time_callback = nullptr

Optional UI progress callback.

Definition at line 50 of file State.hpp.

Referenced by solve().

◆ variational_formulation

std::shared_ptr<varform::VarForm> polyfem::State::variational_formulation

active variational formulation

Definition at line 47 of file State.hpp.

Referenced by forward_simulation_with_varform_state(), init(), load_mesh(), load_mesh(), load_mesh(), and solve().


The documentation for this class was generated from the following files: