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, bool strict_validation, bool is_adjoint_optimization=false)
 initialize the polyfem solver with a json settings
 
void init (const io::CheckpointReader &checkpoint, bool strict_validation)
 
void init (const json &args, const io::CheckpointReader &checkpoint, bool strict_validation)
 
void init (const json &args, const io::ResourceIO &resources, bool strict_validation, bool is_adjoint_optimization=false)
 
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)
 loads the mesh from the json arguments
 
void set_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 set_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::VarForm > variational_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
 
std::unique_ptr< const io::ResourceIO > resources_
 
std::optional< std::reference_wrapper< const io::CheckpointReader > > checkpoint_
 

Detailed Description

VarForm-only simulation state.

Definition at line 36 of file State.hpp.

Constructor & Destructor Documentation

◆ State()

polyfem::State::State ( )

Definition at line 166 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() [1/4]

void polyfem::State::init ( const io::CheckpointReader &  checkpoint,
bool  strict_validation 
)

Definition at line 385 of file State.cpp.

References polyfem::io::CheckpointReader::config(), and init().

Here is the call graph for this function:

◆ init() [2/4]

void polyfem::State::init ( const json &  args,
bool  strict_validation,
bool  is_adjoint_optimization = false 
)

initialize the polyfem solver with a json settings

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

Definition at line 239 of file State.cpp.

References init().

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

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

◆ init() [3/4]

void polyfem::State::init ( const json &  args,
const io::CheckpointReader &  checkpoint,
bool  strict_validation 
)

Definition at line 390 of file State.cpp.

References args, checkpoint_, init(), polyfem::log_and_throw_error(), polyfem::io::CheckpointReader::resources(), and variational_formulation.

Here is the call graph for this function:

◆ init() [4/4]

void polyfem::State::init ( const json &  args,
const io::ResourceIO &  resources,
bool  strict_validation,
bool  is_adjoint_optimization = false 
)

◆ 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 171 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 203 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 196 of file State.cpp.

References init_logger().

Here is the call graph for this function:

◆ load_mesh()

void polyfem::State::load_mesh ( bool  non_conforming = false)

loads the mesh from the json arguments

Parameters
[in]non_conformingcreates a conforming/non conforming mesh

Definition at line 446 of file State.cpp.

References args, checkpoint_, polyfem::mesh::LoadedGeometry::fem, polyfem::Units::init(), polyfem::utils::is_param_valid(), polyfem::utils::json_as_array(), polyfem::mesh::GeometryLoader::load(), polyfem::mesh::GeometryLoader::load_obstacles(), polyfem::log_and_throw_error(), polyfem::logger(), polyfem::mesh::LoadedGeometry::obstacle, resources_, and variational_formulation.

Referenced by run_forward_simulation().

Here is the call graph for this function:
Here is the caller 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 225 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 408 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:

◆ set_mesh() [1/2]

void polyfem::State::set_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 509 of file State.cpp.

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

Here is the call graph for this function:

◆ set_mesh() [2/2]

void polyfem::State::set_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 413 of file State.cpp.

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

Here is the call graph for this function:

◆ solve()

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

solves the problem, call other methods

Definition at line 502 of file State.cpp.

References time_callback, and variational_formulation.

Referenced by run_forward_simulation().

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 68 of file State.hpp.

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

◆ checkpoint_

std::optional<std::reference_wrapper<const io::CheckpointReader> > polyfem::State::checkpoint_
private

Definition at line 135 of file State.hpp.

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

◆ console_sink_

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

logger sink to stdout

Definition at line 105 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 106 of file State.hpp.

Referenced by init_logger().

◆ resources_

std::unique_ptr<const io::ResourceIO> polyfem::State::resources_
private

Definition at line 134 of file State.hpp.

Referenced by init(), and load_mesh().

◆ time_callback

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

Optional UI progress callback.

Definition at line 74 of file State.hpp.

Referenced by solve().

◆ variational_formulation

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

active variational formulation

Definition at line 71 of file State.hpp.

Referenced by init(), init(), load_mesh(), run_forward_simulation(), set_mesh(), set_mesh(), and solve().


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