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

main class that contains the polyfem solver and all its state More...

#include <State.hpp>

Collaboration diagram for polyfem::State:
[legend]

Public Member Functions

 ~State ()=default
 
 State ()
 Constructor.
 
void set_max_threads (const int max_threads=std::numeric_limits< int >::max())
 
void init (const json &args, const bool strict_validation)
 initialize the polyfem solver with a json settings
 
void init_time ()
 initialize time settings if args contains "time"
 
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
 
std::string get_log (const Eigen::MatrixXd &sol)
 gets the output log as json this is not what gets printed but more informative information, e.g., it contains runtimes, errors, etc.
 
std::string formulation () const
 return the formulation (checks if the problem is scalar or not and deals with multiphysics)
 
bool iso_parametric () const
 check if using iso parametric bases
 
const std::vector< basis::ElementBases > & geom_bases () const
 Get a constant reference to the geometry mapping bases.
 
void build_basis ()
 builds the bases step 2 of solve modifies bases, pressure_bases, geom_bases_, boundary_nodes, dirichlet_nodes, neumann_nodes, local_boundary, total_local_boundary local_neumann_boundary, polys, poly_edge_to_data, rhs
 
void assemble_rhs ()
 compute rhs, step 3 of solve build rhs vector based on defined basis and given rhs of the problem modifies rhs (and maybe more?)
 
void assemble_mass_mat ()
 assemble mass, step 4 of solve build mass matrix based on defined basis modifies mass (and maybe more?)
 
std::shared_ptr< assembler::RhsAssemblerbuild_rhs_assembler (const int n_bases, const std::vector< basis::ElementBases > &bases, const assembler::AssemblyValsCache &ass_vals_cache) const
 build a RhsAssembler for the problem
 
std::shared_ptr< assembler::RhsAssemblerbuild_rhs_assembler () const
 build a RhsAssembler for the problem
 
std::shared_ptr< assembler::PressureAssemblerbuild_pressure_assembler (const int n_bases_, const std::vector< basis::ElementBases > &bases_) const
 
std::shared_ptr< assembler::PressureAssemblerbuild_pressure_assembler () const
 
int n_boundary_samples () const
 quadrature used for projecting boundary conditions
 
void set_materials (std::vector< std::shared_ptr< assembler::Assembler > > &assemblers) const
 set the material and the problem dimension
 
void set_materials (assembler::Assembler &assembler) const
 utility to set the material and the problem dimension to only 1 assembler
 
void solve_problem (Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves the problems
 
void solve (Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves the problem, call other methods
 
void init_solve (Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 initialize solver
 
void solve_transient_navier_stokes_split (const int time_steps, const double dt, Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves transient navier stokes with operator splitting
 
void solve_transient_navier_stokes (const int time_steps, const double t0, const double dt, Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves transient navier stokes with FEM
 
void solve_transient_linear (const int time_steps, const double t0, const double dt, Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves transient linear problem
 
void solve_transient_tensor_nonlinear (const int time_steps, const double t0, const double dt, Eigen::MatrixXd &sol)
 solves transient tensor nonlinear problem
 
void init_nonlinear_tensor_solve (Eigen::MatrixXd &sol, const double t=1.0, const bool init_time_integrator=true)
 initialize the nonlinear solver
 
void init_linear_solve (Eigen::MatrixXd &sol, const double t=1.0)
 initialize the linear solve
 
void initial_solution (Eigen::MatrixXd &solution) const
 Load or compute the initial solution.
 
void initial_velocity (Eigen::MatrixXd &velocity) const
 Load or compute the initial velocity.
 
void initial_acceleration (Eigen::MatrixXd &acceleration) const
 Load or compute the initial acceleration.
 
void solve_linear (Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves a linear problem
 
void solve_navier_stokes (Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 solves a navier stokes
 
void solve_tensor_nonlinear (Eigen::MatrixXd &sol, const int t=0, const bool init_lagging=true)
 solves nonlinear problems
 
std::shared_ptr< polysolve::nonlinear::Solver > make_nl_solver (bool for_al) const
 factory to create the nl solver depending on input
 
bool has_periodic_bc () const
 
void solve_linear (const std::unique_ptr< polysolve::linear::Solver > &solver, StiffnessMatrix &A, Eigen::VectorXd &b, const bool compute_spectrum, Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 Solve the linear problem with the given solver and system.
 
bool is_problem_linear () const
 Returns whether the system is linear. Collisions and pressure add nonlinearity to the problem.
 
void build_stiffness_mat (StiffnessMatrix &stiffness)
 utility that builds the stiffness matrix and collects stats, used only for linear problems
 
std::unordered_map< int, std::array< bool, 3 > > boundary_conditions_ids (const std::string &bc_type) const
 Construct a vector of boundary conditions ids with their dimension flags.
 
std::vector< int > primitive_to_node () const
 
std::vector< int > node_to_primitive () const
 
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 RowVectorNd &)> &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,
 
void set_boundary_side_set (const std::function< int(const RowVectorNd &)> &boundary_marker)
 set the boundary sideset from a lambda that takes the face/edge barycenter
 
void set_boundary_side_set (const std::function< int(const RowVectorNd &, bool)> &boundary_marker)
 set the boundary sideset from a lambda that takes the face/edge barycenter and a flag if the face/edge is boundary or not (used to set internal boundaries)
 
void set_boundary_side_set (const std::function< int(const std::vector< int > &, bool)> &boundary_marker)
 set the boundary sideset from a lambda that takes the face/edge vertices and a flag if the face/edge is boundary or not (used to set internal boundaries)
 
void reset_mesh ()
 Resets the mesh.
 
void build_mesh_matrices (Eigen::MatrixXd &V, Eigen::MatrixXi &F)
 Build the mesh matrices (vertices and elements) from the mesh using the bases node ordering.
 
void build_collision_mesh ()
 extracts the boundary mesh for collision, called in build_basis
 
void build_periodic_collision_mesh ()
 
bool is_obstacle_vertex (const size_t vi) const
 checks if vertex is obstacle
 
bool is_contact_enabled () const
 does the simulation has contact
 
bool is_pressure_enabled () const
 does the simulation has pressure
 
void export_data (const Eigen::MatrixXd &sol, const Eigen::MatrixXd &pressure)
 saves all data on the disk according to the input params
 
void save_timestep (const double time, const int t, const double t0, const double dt, const Eigen::MatrixXd &sol, const Eigen::MatrixXd &pressure)
 saves a timestep
 
void save_subsolve (const int i, const int t, const Eigen::MatrixXd &sol, const Eigen::MatrixXd &pressure)
 saves a subsolve when save_solve_sequence_debug is true
 
void save_json (const Eigen::MatrixXd &sol, std::ostream &out)
 saves the output statistic to a stream
 
void save_json (const Eigen::MatrixXd &sol)
 saves the output statistic to disc according to params
 
void compute_errors (const Eigen::MatrixXd &sol)
 computes all errors
 
void save_restart_json (const double t0, const double dt, const int t) const
 Save a JSON sim file for restarting the simulation at time t.
 
std::string root_path () const
 Get the root path for the state (e.g., args["root_path"] or ".")
 
std::string resolve_input_path (const std::string &path, const bool only_if_exists=false) const
 Resolve input path relative to root_path() if the path is not absolute.
 
std::string resolve_output_path (const std::string &path) const
 Resolve output path relative to output_dir if the path is not absolute.
 
void cache_transient_adjoint_quantities (const int current_step, const Eigen::MatrixXd &sol, const Eigen::MatrixXd &disp_grad)
 
int ndof () const
 
void compute_force_jacobian (const Eigen::MatrixXd &sol, const Eigen::MatrixXd &disp_grad, StiffnessMatrix &hessian)
 
void compute_force_jacobian_prev (const int force_step, const int sol_step, StiffnessMatrix &hessian_prev) const
 
void solve_adjoint_cached (const Eigen::MatrixXd &rhs)
 
Eigen::MatrixXd solve_adjoint (const Eigen::MatrixXd &rhs) const
 
Eigen::MatrixXd get_adjoint_mat (int type) const
 
Eigen::MatrixXd solve_static_adjoint (const Eigen::MatrixXd &adjoint_rhs) const
 
Eigen::MatrixXd solve_transient_adjoint (const Eigen::MatrixXd &adjoint_rhs) const
 
void set_mesh_vertex (int v_id, const Eigen::VectorXd &vertex)
 
void get_vertices (Eigen::MatrixXd &vertices) const
 
void get_elements (Eigen::MatrixXi &elements) const
 
void compute_surface_node_ids (const int surface_selection, std::vector< int > &node_ids) const
 
void compute_total_surface_node_ids (std::vector< int > &node_ids) const
 
void compute_volume_node_ids (const int volume_selection, std::vector< int > &node_ids) const
 
void solve_homogenization_step (Eigen::MatrixXd &sol, const int t=0, bool adaptive_initial_weight=false)
 In Elasticity PDE, solve for "min W(disp_grad + \grad u)" instead of "min W(\grad u)".
 
void init_homogenization_solve (const double t)
 
void solve_homogenization (const int time_steps, const double t0, const double dt, Eigen::MatrixXd &sol)
 
bool is_homogenization () const
 

Static Public Member Functions

static void build_collision_mesh (const mesh::Mesh &mesh, const int n_bases, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const std::vector< mesh::LocalBoundary > &total_local_boundary, const mesh::Obstacle &obstacle, const json &args, const std::function< std::string(const std::string &)> &resolve_input_path, const Eigen::VectorXi &in_node_to_node, ipc::CollisionMesh &collision_mesh)
 extracts the boundary mesh for collision, called in build_basis
 

Public Attributes

json args
 main input arguments containing all defaults
 
Units units
 
std::shared_ptr< assembler::Assemblerassembler = nullptr
 assemblers
 
std::shared_ptr< assembler::Massmass_matrix_assembler = nullptr
 
std::shared_ptr< assembler::MixedAssemblermixed_assembler = nullptr
 
std::shared_ptr< assembler::Assemblerpressure_assembler = nullptr
 
std::shared_ptr< assembler::PressureAssemblerelasticity_pressure_assembler = nullptr
 
std::shared_ptr< assembler::ViscousDampingdamping_assembler = nullptr
 
std::shared_ptr< assembler::ViscousDampingPrevdamping_prev_assembler = nullptr
 
std::shared_ptr< assembler::Problemproblem
 current problem, it contains rhs and bc
 
std::vector< basis::ElementBasesbases
 FE bases, the size is #elements.
 
std::vector< basis::ElementBasespressure_bases
 FE pressure bases for mixed elements, the size is #elements.
 
std::vector< basis::ElementBasesgeom_bases_
 Geometric mapping bases, if the elements are isoparametric, this list is empty.
 
int n_bases
 number of bases
 
int n_pressure_bases
 number of pressure bases
 
int n_geom_bases
 number of geometric bases
 
std::map< int, Eigen::MatrixXd > polys
 polygons, used since poly have no geom mapping
 
std::map< int, std::pair< Eigen::MatrixXd, Eigen::MatrixXi > > polys_3d
 polyhedra, used since poly have no geom mapping
 
Eigen::VectorXi disc_orders
 vector of discretization orders, used when not all elements have the same degree, one per element
 
std::shared_ptr< polyfem::mesh::MeshNodesmesh_nodes
 Mapping from input nodes to FE nodes.
 
std::shared_ptr< polyfem::mesh::MeshNodesgeom_mesh_nodes
 
std::shared_ptr< polyfem::mesh::MeshNodespressure_mesh_nodes
 
assembler::AssemblyValsCache ass_vals_cache
 used to store assembly values for small problems
 
assembler::AssemblyValsCache mass_ass_vals_cache
 
assembler::AssemblyValsCache pressure_ass_vals_cache
 used to store assembly values for pressure for small problems
 
StiffnessMatrix mass
 Mass matrix, it is computed only for time dependent problems.
 
double avg_mass
 average system mass, used for contact with IPC
 
Eigen::MatrixXd rhs
 System right-hand side.
 
bool use_avg_pressure
 use average pressure for stokes problem to fix the additional dofs, true by default if false, it will fix one pressure node to zero
 
solver::SolveData solve_data
 timedependent stuff cached
 
std::shared_ptr< utils::PeriodicBoundaryperiodic_bc
 periodic BC and periodic mesh utils
 
std::vector< int > boundary_nodes
 list of boundary nodes
 
std::vector< int > pressure_boundary_nodes
 list of neumann boundary nodes
 
std::vector< mesh::LocalBoundarytotal_local_boundary
 mapping from elements to nodes for all mesh
 
std::vector< mesh::LocalBoundarylocal_boundary
 mapping from elements to nodes for dirichlet boundary conditions
 
std::vector< mesh::LocalBoundarylocal_neumann_boundary
 mapping from elements to nodes for neumann boundary conditions
 
std::vector< mesh::LocalBoundarylocal_pressure_boundary
 mapping from elements to nodes for pressure boundary conditions
 
std::unordered_map< int, std::vector< mesh::LocalBoundary > > local_pressure_cavity
 mapping from elements to nodes for pressure boundary conditions
 
std::map< int, basis::InterfaceDatapoly_edge_to_data
 nodes on the boundary of polygonal elements, used for harmonic bases
 
std::vector< int > dirichlet_nodes
 per node dirichlet
 
std::vector< RowVectorNddirichlet_nodes_position
 
std::vector< int > neumann_nodes
 per node neumann
 
std::vector< RowVectorNdneumann_nodes_position
 
Eigen::VectorXi in_node_to_node
 Inpute nodes (including high-order) to polyfem nodes, only for isoparametric.
 
Eigen::VectorXi in_primitive_to_primitive
 maps in vertices/edges/faces/cells to polyfem vertices/edges/faces/cells
 
std::unique_ptr< mesh::Meshmesh
 current mesh, it can be a Mesh2D or Mesh3D
 
mesh::Obstacle obstacle
 Obstacles used in collisions.
 
ipc::CollisionMesh collision_mesh
 IPC collision mesh.
 
ipc::CollisionMesh periodic_collision_mesh
 IPC collision mesh under periodic BC.
 
Eigen::VectorXi periodic_collision_mesh_to_basis
 index mapping from periodic 2x2 collision mesh to FE periodic mesh
 
bool has_dhat = false
 stores if input json contains dhat
 
std::string output_dir
 Directory for output files.
 
bool solve_export_to_file = true
 flag to decide if exporting the time dependent solution to files or save it in the solution_frames array
 
std::vector< io::SolutionFramesolution_frames
 saves the frames in a vector instead of VTU
 
io::OutGeometryData out_geom
 visualization stuff
 
io::OutRuntimeData timings
 runtime statistics
 
io::OutStatsData stats
 Other statistics.
 
double starting_min_edge_length = -1
 
double starting_max_edge_length = -1
 
double min_boundary_edge_length = -1
 
solver::CacheLevel optimization_enabled = solver::CacheLevel::None
 
solver::DiffCache diff_cached
 
std::unique_ptr< polysolve::linear::Solver > lin_solver_cached
 
Eigen::MatrixXd initial_sol_update
 
Eigen::MatrixXd initial_vel_update
 
StiffnessMatrix gbasis_nodes_to_basis_nodes
 
assembler::MacroStrainValue macro_strain_constraint
 

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
 
void sol_to_pressure (Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
 splits the solution in solution and pressure for mixed problems
 
void build_polygonal_basis ()
 builds bases for polygons, called inside build_basis
 
void build_node_mapping ()
 build the mapping from input nodes to polyfem nodes
 

Private Attributes

spdlog::sink_ptr console_sink_ = nullptr
 logger sink to stdout
 
spdlog::sink_ptr file_sink_ = nullptr
 

Detailed Description

main class that contains the polyfem solver and all its state

Definition at line 78 of file State.hpp.

Constructor & Destructor Documentation

◆ ~State()

polyfem::State::~State ( )
default

◆ State()

polyfem::State::State ( )

Constructor.

Definition at line 58 of file StateInit.cpp.

References polyfem::problem::ProblemFactory::factory(), polyfem::problem::ProblemFactory::get_problem(), polyfem::utils::GeogramUtils::initialize(), polyfem::utils::GeogramUtils::instance(), and problem.

Here is the call graph for this function:

Member Function Documentation

◆ assemble_mass_mat()

void polyfem::State::assemble_mass_mat ( )

assemble mass, step 4 of solve build mass matrix based on defined basis modifies mass (and maybe more?)

Definition at line 1530 of file State.cpp.

References args, assembler, polyfem::io::OutRuntimeData::assembling_mass_mat_time, polyfem::io::OutRuntimeData::assembling_stiffness_mat_time, avg_mass, bases, geom_bases(), polyfem::logger(), polyfem::utils::lump_matrix(), mass, mass_ass_vals_cache, mass_matrix_assembler, polyfem::io::OutStatsData::mat_size, mesh, mixed_assembler, n_bases, polyfem::io::OutStatsData::nn_zero, polyfem::io::OutStatsData::num_dofs, problem, stats, and timings.

Referenced by forward_simulation(), solve(), and polyfem::solver::AdjointOptUtils::solve_pde().

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

◆ assemble_rhs()

void polyfem::State::assemble_rhs ( )

compute rhs, step 3 of solve build rhs vector based on defined basis and given rhs of the problem modifies rhs (and maybe more?)

Definition at line 1654 of file State.cpp.

References assembler, polyfem::io::OutRuntimeData::assigning_rhs_time, build_rhs_assembler(), local_neumann_boundary, polyfem::logger(), mass_matrix_assembler, mesh, mixed_assembler, n_bases, n_boundary_samples(), n_pressure_bases, pressure_ass_vals_cache, pressure_bases, problem, rhs, polyfem::solver::SolveData::rhs_assembler, root_path(), solve_data, timings, and use_avg_pressure.

Referenced by forward_simulation(), solve(), and polyfem::solver::AdjointOptUtils::solve_pde().

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

◆ boundary_conditions_ids()

std::unordered_map< int, std::array< bool, 3 > > polyfem::State::boundary_conditions_ids ( const std::string &  bc_type) const

Construct a vector of boundary conditions ids with their dimension flags.

Definition at line 182 of file StateLoad.cpp.

References args, polyfem::utils::json_as_array(), and mesh.

Here is the call graph for this function:

◆ build_basis()

void polyfem::State::build_basis ( )

builds the bases step 2 of solve modifies bases, pressure_bases, geom_bases_, boundary_nodes, dirichlet_nodes, neumann_nodes, local_boundary, total_local_boundary local_neumann_boundary, polys, poly_edge_to_data, rhs

Definition at line 577 of file State.cpp.

References args, ass_vals_cache, assembler, bases, boundary_nodes, polyfem::basis::LagrangeBasis2d::build_bases(), polyfem::basis::SplineBasis2d::build_bases(), polyfem::basis::LagrangeBasis3d::build_bases(), polyfem::basis::SplineBasis3d::build_bases(), build_collision_mesh(), polyfem::io::OutGeometryData::build_grid(), build_node_mapping(), build_periodic_collision_mesh(), build_polygonal_basis(), polyfem::io::OutRuntimeData::building_basis_time, polyfem::assembler::AssemblyValsCache::clear(), collision_mesh, polyfem::assembler::ElementAssemblyValues::compute(), polyfem::io::OutStatsData::compute_mesh_size(), polyfem::Units::convert(), polyfem::io::OutStatsData::count_flipped_elements(), polyfem::solver::Derivatives, dirichlet_nodes, dirichlet_nodes_position, disc_orders, gbasis_nodes_to_basis_nodes, geom_bases(), geom_bases_, geom_mesh_nodes, has_dhat, has_periodic_bc(), in_node_to_node, polyfem::assembler::AssemblyValsCache::init(), polyfem::assembler::MacroStrainValue::init(), is_contact_enabled(), iso_parametric(), polyfem::Units::length(), local_boundary, local_neumann_boundary, local_pressure_boundary, local_pressure_cavity, polyfem::log_and_throw_error(), polyfem::logger(), macro_strain_constraint, mass_ass_vals_cache, mesh, mesh_nodes, polyfem::io::OutStatsData::mesh_size, min_boundary_edge_length, polyfem::io::OutStatsData::min_edge_length, mixed_assembler, n_bases, polyfem::io::OutStatsData::n_flipped, n_geom_bases, n_pressure_bases, polyfem::mesh::Obstacle::n_vertices(), neumann_nodes, neumann_nodes_position, obstacle, optimization_enabled, out_geom, polyfem::autogen::p_nodes_2d(), polyfem::autogen::p_nodes_3d(), polyfem::refinement::APriori::p_refine(), periodic_bc, poly_edge_to_data, polys, pressure_ass_vals_cache, pressure_bases, pressure_boundary_nodes, pressure_mesh_nodes, problem, polyfem::autogen::q_nodes_2d(), polyfem::autogen::q_nodes_3d(), polyfem::io::read_matrix(), polyfem::io::OutStatsData::reset(), rhs, starting_max_edge_length, starting_min_edge_length, stats, timings, total_local_boundary, units, use_avg_pressure, vals, and polyfem::Units::velocity().

Referenced by forward_simulation(), and solve().

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

◆ build_collision_mesh() [1/2]

void polyfem::State::build_collision_mesh ( )

extracts the boundary mesh for collision, called in build_basis

Definition at line 1407 of file State.cpp.

References args, bases, build_collision_mesh(), collision_mesh, geom_bases(), in_node_to_node, mesh, n_bases, obstacle, resolve_input_path(), and total_local_boundary.

Referenced by build_basis(), build_collision_mesh(), polyfem::solver::CollisionBarrierForm::CollisionBarrierForm(), and polyfem::solver::DeformedCollisionBarrierForm::DeformedCollisionBarrierForm().

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

◆ build_collision_mesh() [2/2]

void polyfem::State::build_collision_mesh ( const mesh::Mesh mesh,
const int  n_bases,
const std::vector< basis::ElementBases > &  bases,
const std::vector< basis::ElementBases > &  geom_bases,
const std::vector< mesh::LocalBoundary > &  total_local_boundary,
const mesh::Obstacle obstacle,
const json args,
const std::function< std::string(const std::string &)> &  resolve_input_path,
const Eigen::VectorXi &  in_node_to_node,
ipc::CollisionMesh &  collision_mesh 
)
static

◆ build_mesh_matrices()

void polyfem::State::build_mesh_matrices ( Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F 
)

Build the mesh matrices (vertices and elements) from the mesh using the bases node ordering.

Definition at line 158 of file StateLoad.cpp.

References polyfem::basis::ElementBases::bases, bases, polyfem::F, polyfem::basis::Basis::global(), mesh, n_bases, polyfem::mesh::Obstacle::n_vertices(), obstacle, and V.

Referenced by solve_transient_tensor_nonlinear().

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

◆ build_node_mapping()

void polyfem::State::build_node_mapping ( )
private

build the mapping from input nodes to polyfem nodes

Definition at line 244 of file State.cpp.

References args, disc_orders, in_node_to_node, in_primitive_to_primitive, polyfem::logger(), mesh, and mesh_nodes.

Referenced by build_basis().

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

◆ build_periodic_collision_mesh()

void polyfem::State::build_periodic_collision_mesh ( )

Definition at line 1277 of file State.cpp.

References args, bases, collision_mesh, polyfem::log_and_throw_error(), mesh, n_bases, periodic_bc, periodic_collision_mesh, periodic_collision_mesh_to_basis, and V.

Referenced by build_basis().

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

◆ build_polygonal_basis()

void polyfem::State::build_polygonal_basis ( )
private

builds bases for polygons, called inside build_basis

Definition at line 1114 of file State.cpp.

References args, assembler, bases, polyfem::basis::PolygonalBasis2d::build_bases(), polyfem::basis::PolygonalBasis3d::build_bases(), polyfem::basis::MVPolygonalBasis2d::build_bases(), polyfem::basis::WSPolygonalBasis2d::build_bases(), polyfem::io::OutRuntimeData::computing_poly_basis_time, geom_bases_, iso_parametric(), local_boundary, polyfem::logger(), mesh, n_bases, n_pressure_bases, poly_edge_to_data, polys, polys_3d, rhs, and timings.

Referenced by build_basis().

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

◆ build_pressure_assembler() [1/2]

std::shared_ptr< assembler::PressureAssembler > polyfem::State::build_pressure_assembler ( ) const
inline

Definition at line 256 of file State.hpp.

References bases, build_pressure_assembler(), and n_bases.

Referenced by build_pressure_assembler(), and init_nonlinear_tensor_solve().

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

◆ build_pressure_assembler() [2/2]

std::shared_ptr< PressureAssembler > polyfem::State::build_pressure_assembler ( const int  n_bases_,
const std::vector< basis::ElementBases > &  bases_ 
) const

Definition at line 1639 of file State.cpp.

References assembler, boundary_nodes, geom_bases(), local_pressure_boundary, local_pressure_cavity, mesh, node_to_primitive(), obstacle, primitive_to_node(), and problem.

Here is the call graph for this function:

◆ build_rhs_assembler() [1/2]

std::shared_ptr< assembler::RhsAssembler > polyfem::State::build_rhs_assembler ( ) const
inline

build a RhsAssembler for the problem

Definition at line 248 of file State.hpp.

References bases, build_rhs_assembler(), mass_ass_vals_cache, and n_bases.

Referenced by assemble_rhs(), build_rhs_assembler(), and init_solve().

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

◆ build_rhs_assembler() [2/2]

std::shared_ptr< RhsAssembler > polyfem::State::build_rhs_assembler ( const int  n_bases,
const std::vector< basis::ElementBases > &  bases,
const assembler::AssemblyValsCache ass_vals_cache 
) const

build a RhsAssembler for the problem

Definition at line 1618 of file State.cpp.

References args, assembler, dirichlet_nodes, dirichlet_nodes_position, geom_bases(), mesh, neumann_nodes, neumann_nodes_position, obstacle, and problem.

Here is the call graph for this function:

◆ build_stiffness_mat()

void polyfem::State::build_stiffness_mat ( StiffnessMatrix stiffness)

utility that builds the stiffness matrix and collects stats, used only for linear problems

Parameters
[out]stiffnessmatrix

Definition at line 27 of file StateSolveLinear.cpp.

References args, ass_vals_cache, assembler, polyfem::io::OutRuntimeData::assembling_stiffness_mat_time, bases, geom_bases(), polyfem::logger(), polyfem::io::OutStatsData::mat_size, polyfem::assembler::AssemblerUtils::merge_mixed_matrices(), mesh, mixed_assembler, n_bases, n_pressure_bases, polyfem::io::OutStatsData::nn_zero, polyfem::io::OutStatsData::num_dofs, pressure_ass_vals_cache, pressure_assembler, pressure_bases, problem, stats, timings, and use_avg_pressure.

Referenced by compute_force_jacobian(), solve_linear(), solve_transient_linear(), and solve_transient_navier_stokes_split().

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

◆ cache_transient_adjoint_quantities()

void polyfem::State::cache_transient_adjoint_quantities ( const int  current_step,
const Eigen::MatrixXd &  sol,
const Eigen::MatrixXd &  disp_grad 
)

◆ compute_errors()

void polyfem::State::compute_errors ( const Eigen::MatrixXd &  sol)

computes all errors

Definition at line 10 of file StateOutput.cpp.

References args, bases, polyfem::io::OutStatsData::compute_errors(), geom_bases(), mesh, n_bases, problem, and stats.

Referenced by forward_simulation().

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

◆ compute_force_jacobian()

void polyfem::State::compute_force_jacobian ( const Eigen::MatrixXd &  sol,
const Eigen::MatrixXd &  disp_grad,
StiffnessMatrix hessian 
)

Definition at line 164 of file StateDiff.cpp.

References assembler, boundary_nodes, build_stiffness_mat(), is_contact_enabled(), is_homogenization(), polyfem::log_and_throw_adjoint_error(), polyfem::solver::SolveData::nl_problem, problem, and solve_data.

Referenced by cache_transient_adjoint_quantities().

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

◆ compute_force_jacobian_prev()

void polyfem::State::compute_force_jacobian_prev ( const int  force_step,
const int  sol_step,
StiffnessMatrix hessian_prev 
) const

Definition at line 205 of file StateDiff.cpp.

References args, ass_vals_cache, assembler, bases, polyfem::solver::DiffCache::bdf_order(), polyfem::time_integrator::BDF::betas(), polyfem::solver::SolveData::body_form, collision_mesh, polyfem::solver::SolveData::contact_form, damping_assembler, damping_prev_assembler, diff_cached, polyfem::solver::DiffCache::friction_collision_set(), polyfem::solver::SolveData::friction_form, geom_bases(), is_contact_enabled(), mesh, n_bases, ndof(), problem, solve_data, polyfem::solver::SolveData::time_integrator, polyfem::solver::DiffCache::u(), and polyfem::utils::unflatten().

Referenced by solve_transient_adjoint().

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

◆ compute_surface_node_ids()

void polyfem::State::compute_surface_node_ids ( const int  surface_selection,
std::vector< int > &  node_ids 
) const

Definition at line 496 of file StateDiff.cpp.

References geom_bases(), mesh, and total_local_boundary.

Here is the call graph for this function:

◆ compute_total_surface_node_ids()

void polyfem::State::compute_total_surface_node_ids ( std::vector< int > &  node_ids) const

Definition at line 524 of file StateDiff.cpp.

References geom_bases(), mesh, and total_local_boundary.

Here is the call graph for this function:

◆ compute_volume_node_ids()

void polyfem::State::compute_volume_node_ids ( const int  volume_selection,
std::vector< int > &  node_ids 
) const

Definition at line 548 of file StateDiff.cpp.

References geom_bases(), and mesh.

Here is the call graph for this function:

◆ export_data()

void polyfem::State::export_data ( const Eigen::MatrixXd &  sol,
const Eigen::MatrixXd &  pressure 
)

saves all data on the disk according to the input params

Parameters
[in]solsolution
[in]pressurepressure

Definition at line 129 of file StateOutput.cpp.

References args, polyfem::io::OutGeometryData::export_data(), is_contact_enabled(), polyfem::logger(), mesh, n_bases, out_geom, problem, resolve_output_path(), solution_frames, and solve_export_to_file.

Referenced by forward_simulation(), and solve_homogenization_step().

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

◆ formulation()

std::string polyfem::State::formulation ( ) const

return the formulation (checks if the problem is scalar or not and deals with multiphysics)

Returns
formulation

Definition at line 387 of file State.cpp.

References args, and polyfem::logger().

Referenced by polyfem::solver::ElasticEnergyForm::get_integral_functional(), polyfem::solver::StressNormForm::get_integral_functional(), polyfem::solver::ComplianceForm::get_integral_functional(), polyfem::solver::StressForm::get_integral_functional(), init(), polyfem::mesh::LocalRelaxationData< M >::init_assembler(), polyfem::mesh::LocalRelaxationData< M >::init_bases(), and polyfem::mesh::Remesher::project_quantities().

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

◆ geom_bases()

const std::vector< basis::ElementBases > & polyfem::State::geom_bases ( ) const
inline

Get a constant reference to the geometry mapping bases.

Returns
A constant reference to the geometry mapping bases.

Definition at line 223 of file State.hpp.

References bases, geom_bases_, and iso_parametric().

Referenced by polyfem::solver::AMIPSForm::AMIPSForm(), assemble_mass_mat(), build_basis(), build_collision_mesh(), build_collision_mesh(), build_pressure_assembler(), build_rhs_assembler(), build_stiffness_mat(), polyfem::solver::CollisionBarrierForm::CollisionBarrierForm(), compute_errors(), compute_force_jacobian_prev(), polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::WeightedVolumeForm::compute_partial_gradient_with_param(), polyfem::solver::AdjointTools::compute_shape_derivative_functional_term(), compute_surface_node_ids(), compute_total_surface_node_ids(), compute_volume_node_ids(), polyfem::solver::DeformedCollisionBarrierForm::DeformedCollisionBarrierForm(), polyfem::solver::AdjointTools::dJ_du_step(), polyfem::solver::AdjointTools::dJ_shape_transient_adjoint_term(), polyfem::io::OutGeometryData::export_data(), get_elements(), polyfem::solver::KineticForm::get_integral_functional(), init_homogenization_solve(), init_linear_solve(), init_nonlinear_tensor_solve(), polyfem::solver::AdjointTools::integrate_objective(), polyfem::io::OutGeometryData::save_surface(), polyfem::io::OutGeometryData::save_volume(), polyfem::io::OutGeometryData::save_wire(), solve_homogenization_step(), solve_linear(), solve_navier_stokes(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), polyfem::solver::WeightedVolumeForm::value_unweighted_with_param(), polyfem::solver::VariableToBoundaryNodes::VariableToBoundaryNodes(), polyfem::solver::VariableToBoundaryNodesExclusive::VariableToBoundaryNodesExclusive(), and polyfem::solver::VariableToInteriorNodes::VariableToInteriorNodes().

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

◆ get_adjoint_mat()

Eigen::MatrixXd polyfem::State::get_adjoint_mat ( int  type) const
inline

Definition at line 689 of file State.hpp.

References polyfem::solver::DiffCache::adjoint_mat(), diff_cached, polyfem::log_and_throw_adjoint_error(), and problem.

Here is the call graph for this function:

◆ get_elements()

void polyfem::State::get_elements ( Eigen::MatrixXi &  elements) const

Definition at line 77 of file StateDiff.cpp.

References geom_bases(), mesh, and node_to_primitive().

Referenced by polyfem::solver::AMIPSForm::AMIPSForm().

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

◆ get_log()

std::string polyfem::State::get_log ( const Eigen::MatrixXd &  sol)
inline

gets the output log as json this is not what gets printed but more informative information, e.g., it contains runtimes, errors, etc.

Definition at line 130 of file State.hpp.

References save_json().

Here is the call graph for this function:

◆ get_vertices()

void polyfem::State::get_vertices ( Eigen::MatrixXd &  vertices) const

Definition at line 69 of file StateDiff.cpp.

References mesh.

Referenced by polyfem::solver::AMIPSForm::AMIPSForm(), polyfem::solver::CollisionBarrierForm::CollisionBarrierForm(), polyfem::solver::BoundarySmoothingForm::compute_partial_gradient(), polyfem::solver::DeformedCollisionBarrierForm::DeformedCollisionBarrierForm(), and polyfem::solver::BoundarySmoothingForm::value_unweighted().

Here is the caller graph for this function:

◆ has_periodic_bc()

bool polyfem::State::has_periodic_bc ( ) const
inline

Definition at line 390 of file State.hpp.

References args.

Referenced by build_basis(), iso_parametric(), solve_linear(), and solve_static_adjoint().

Here is the caller graph for this function:

◆ 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 139 of file StateInit.cpp.

References polyfem::utils::apply_common_params(), args, assembler, polyfem::solver::Derivatives, polyfem::problem::ProblemFactory::factory(), formulation(), polyfem::problem::ProblemFactory::get_problem(), has_dhat, polyfem::Units::init(), init_logger(), init_time(), is_contact_enabled(), polyfem::logger(), polyfem::assembler::AssemblerUtils::make_assembler(), polyfem::assembler::AssemblerUtils::make_mixed_assembler(), mass_matrix_assembler, mixed_assembler, optimization_enabled, polyfem::assembler::AssemblerUtils::other_assembler_name(), output_dir, pressure_assembler, problem, resolve_input_path(), resolve_output_path(), rhs, root_path(), set_max_threads(), and units.

Referenced by forward_simulation().

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

◆ init_homogenization_solve()

◆ init_linear_solve()

void polyfem::State::init_linear_solve ( Eigen::MatrixXd &  sol,
const double  t = 1.0 
)

◆ 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 67 of file StateInit.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 100 of file StateInit.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 93 of file StateInit.cpp.

References init_logger().

Here is the call graph for this function:

◆ init_nonlinear_tensor_solve()

void polyfem::State::init_nonlinear_tensor_solve ( Eigen::MatrixXd &  sol,
const double  t = 1.0,
const bool  init_time_integrator = true 
)

initialize the nonlinear solver

Parameters
[out]solsolution
[in]t(optional) initial time

Definition at line 142 of file StateSolveNonlinear.cpp.

References args, ass_vals_cache, assembler, avg_mass, bases, boundary_nodes, build_pressure_assembler(), collision_mesh, polyfem::time_integrator::ImplicitTimeIntegrator::construct_time_integrator(), polyfem::solver::SolveData::contact_form, damping_assembler, damping_prev_assembler, polyfem::solver::Derivatives, elasticity_pressure_assembler, geom_bases(), polyfem::solver::SolveData::init_forms(), initial_acceleration(), initial_sol_update, initial_solution(), initial_vel_update, initial_velocity(), is_contact_enabled(), local_boundary, local_neumann_boundary, local_pressure_boundary, local_pressure_cavity, polyfem::log_and_throw_error(), macro_strain_constraint, mass, mass_ass_vals_cache, mass_matrix_assembler, mesh, mixed_assembler, n_bases, n_boundary_samples(), n_pressure_bases, polyfem::mesh::Obstacle::ndof(), ndof(), polyfem::solver::SolveData::nl_problem, polyfem::solver::None, obstacle, optimization_enabled, output_dir, periodic_bc, periodic_collision_mesh, periodic_collision_mesh_to_basis, POLYFEM_SCOPED_TIMER, problem, resolve_output_path(), rhs, polyfem::solver::SolveData::rhs_assembler, set_materials(), solve_data, polyfem::io::OutStatsData::solver_info, stats, polyfem::solver::SolveData::time_integrator, polyfem::utils::unflatten(), units, and polyfem::io::OBJWriter::write().

Referenced by solve_problem(), and solve_transient_tensor_nonlinear().

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

◆ init_solve()

void polyfem::State::init_solve ( Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

initialize solver

Parameters
[out]solsolution
[out]pressurepressure

Definition at line 12 of file StateSolve.cpp.

References build_rhs_assembler(), initial_solution(), mesh, mixed_assembler, n_bases, n_pressure_bases, POLYFEM_SCOPED_TIMER, problem, rhs, polyfem::solver::SolveData::rhs_assembler, save_timestep(), sol_to_pressure(), and solve_data.

Referenced by solve_problem().

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

◆ init_time()

void polyfem::State::init_time ( )

initialize time settings if args contains "time"

Definition at line 340 of file StateInit.cpp.

References args, polyfem::Units::characteristic_length(), polyfem::Units::convert(), polyfem::utils::is_param_valid(), polyfem::log_and_throw_error(), polyfem::logger(), polyfem::Units::time(), and units.

Referenced by init().

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

◆ initial_acceleration()

void polyfem::State::initial_acceleration ( Eigen::MatrixXd &  acceleration) const

Load or compute the initial acceleration.

Parameters
[out]solutionOutput acceleration variable.

Definition at line 103 of file StateSolve.cpp.

References args, in_node_to_node, mesh, resolve_input_path(), polyfem::solver::SolveData::rhs_assembler, and solve_data.

Referenced by init_linear_solve(), init_nonlinear_tensor_solve(), and solve_transient_linear().

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

◆ initial_solution()

void polyfem::State::initial_solution ( Eigen::MatrixXd &  solution) const

Load or compute the initial solution.

Parameters
[out]solutionOutput solution variable.

Definition at line 69 of file StateSolve.cpp.

References args, in_node_to_node, mesh, problem, resolve_input_path(), rhs, polyfem::solver::SolveData::rhs_assembler, and solve_data.

Referenced by init_linear_solve(), init_nonlinear_tensor_solve(), init_solve(), and solve_transient_linear().

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

◆ initial_velocity()

void polyfem::State::initial_velocity ( Eigen::MatrixXd &  velocity) const

Load or compute the initial velocity.

Parameters
[out]solutionOutput velocity variable.

Definition at line 90 of file StateSolve.cpp.

References args, in_node_to_node, mesh, resolve_input_path(), polyfem::solver::SolveData::rhs_assembler, and solve_data.

Referenced by init_linear_solve(), init_nonlinear_tensor_solve(), and solve_transient_linear().

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

◆ is_contact_enabled()

bool polyfem::State::is_contact_enabled ( ) const
inline

does the simulation has contact

Returns
true/false

Definition at line 574 of file State.hpp.

References args.

Referenced by build_basis(), compute_force_jacobian(), compute_force_jacobian_prev(), polyfem::solver::AdjointTools::dJ_shape_static_adjoint_term(), polyfem::solver::AdjointTools::dJ_shape_transient_adjoint_term(), export_data(), init(), init_linear_solve(), init_nonlinear_tensor_solve(), is_problem_linear(), save_subsolve(), save_timestep(), solve_linear(), solve_linear(), and solve_transient_linear().

Here is the caller graph for this function:

◆ is_homogenization()

bool polyfem::State::is_homogenization ( ) const
inline

Definition at line 731 of file State.hpp.

References args.

Referenced by compute_force_jacobian(), solve_problem(), and solve_static_adjoint().

Here is the caller graph for this function:

◆ is_obstacle_vertex()

bool polyfem::State::is_obstacle_vertex ( const size_t  vi) const
inline

checks if vertex is obstacle

Parameters
[in]vivertex index
Returns
if vertex is obstalce

Definition at line 565 of file State.hpp.

References collision_mesh, polyfem::mesh::Obstacle::n_vertices(), and obstacle.

Here is the call graph for this function:

◆ is_pressure_enabled()

bool polyfem::State::is_pressure_enabled ( ) const
inline

does the simulation has pressure

Returns
true/false

Definition at line 579 of file State.hpp.

References args.

Referenced by is_problem_linear().

Here is the caller graph for this function:

◆ is_problem_linear()

bool polyfem::State::is_problem_linear ( ) const
inline

Returns whether the system is linear. Collisions and pressure add nonlinearity to the problem.

Definition at line 410 of file State.hpp.

References assembler, is_contact_enabled(), and is_pressure_enabled().

Referenced by solve_problem().

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

◆ iso_parametric()

bool polyfem::State::iso_parametric ( ) const

check if using iso parametric bases

Returns
if basis are isoparametric

Definition at line 536 of file State.cpp.

References args, polyfem::solver::Derivatives, has_periodic_bc(), mesh, and optimization_enabled.

Referenced by build_basis(), build_polygonal_basis(), geom_bases(), primitive_to_node(), and save_json().

Here is the call graph for this function:
Here is the caller 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 91 of file StateLoad.cpp.

References args, assembler, polyfem::io::OutGeometryData::init_sampler(), polyfem::utils::is_param_valid(), polyfem::utils::json_as_array(), polyfem::log_and_throw_error(), polyfem::logger(), mass_matrix_assembler, mesh, mixed_assembler, obstacle, out_geom, pressure_assembler, polyfem::mesh::read_fem_geometry(), polyfem::mesh::read_obstacle_geometry(), reset_mesh(), set_materials(), and units.

Referenced by forward_simulation(), and load_mesh().

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 
)
inline

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

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

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 RowVectorNd &)> &  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 41 of file StateLoad.cpp.

References args, assembler, polyfem::mesh::Mesh::create(), polyfem::io::OutGeometryData::init_sampler(), polyfem::utils::json_as_array(), polyfem::logger(), mass_matrix_assembler, mesh, mixed_assembler, obstacle, out_geom, pressure_assembler, polyfem::mesh::read_obstacle_geometry(), reset_mesh(), set_materials(), and units.

Here is the call graph for this function:

◆ make_nl_solver()

std::shared_ptr< polysolve::nonlinear::Solver > polyfem::State::make_nl_solver ( bool  for_al) const

factory to create the nl solver depending on input

Returns
nonlinear solver (eg newton or LBFGS)

Definition at line 35 of file StateSolveNonlinear.cpp.

References args, polyfem::Units::characteristic_length(), polyfem::logger(), and units.

Referenced by polyfem::mesh::Remesher::project_quantities(), solve_homogenization_step(), and solve_tensor_nonlinear().

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

◆ n_boundary_samples()

int polyfem::State::n_boundary_samples ( ) const
inline

quadrature used for projecting boundary conditions

Returns
the quadrature used for projecting boundary conditions

Definition at line 263 of file State.hpp.

References args, disc_orders, mesh, and polyfem::assembler::AssemblerUtils::quadrature_order().

Referenced by assemble_rhs(), init_homogenization_solve(), init_linear_solve(), init_nonlinear_tensor_solve(), polyfem::mesh::LocalRelaxationData< M >::init_solve_data(), solve_linear(), solve_navier_stokes(), solve_transient_linear(), solve_transient_navier_stokes(), and solve_transient_navier_stokes_split().

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

◆ ndof()

◆ node_to_primitive()

std::vector< int > polyfem::State::node_to_primitive ( ) const

Definition at line 234 of file State.cpp.

References n_geom_bases, and primitive_to_node().

Referenced by build_pressure_assembler(), get_elements(), and polyfem::solver::AdjointTools::map_node_to_primitive_order().

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

◆ primitive_to_node()

std::vector< int > polyfem::State::primitive_to_node ( ) const

Definition at line 227 of file State.cpp.

References geom_mesh_nodes, iso_parametric(), mesh, and mesh_nodes.

Referenced by build_pressure_assembler(), polyfem::solver::AdjointTools::dJ_shape_static_adjoint_term(), polyfem::solver::AdjointTools::dJ_shape_transient_adjoint_term(), polyfem::solver::AdjointTools::map_primitive_to_node_order(), and node_to_primitive().

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

◆ reset_mesh()

void polyfem::State::reset_mesh ( )

Resets the mesh.

Definition at line 22 of file StateLoad.cpp.

References bases, boundary_nodes, polyfem::mesh::Obstacle::clear(), geom_bases_, local_boundary, local_neumann_boundary, mass, n_bases, n_pressure_bases, obstacle, poly_edge_to_data, polys, pressure_bases, and rhs.

Referenced by load_mesh(), and load_mesh().

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

◆ resolve_input_path()

std::string polyfem::State::resolve_input_path ( const std::string &  path,
const bool  only_if_exists = false 
) const

Resolve input path relative to root_path() if the path is not absolute.

Parameters
[in]pathpath to resolve
[in]only_if_existsresolve only if relative path exists
Returns
path

Definition at line 32 of file StateOutput.cpp.

References polyfem::utils::resolve_path(), and root_path().

Referenced by build_collision_mesh(), init(), initial_acceleration(), initial_solution(), and initial_velocity().

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

◆ resolve_output_path()

std::string polyfem::State::resolve_output_path ( const std::string &  path) const

Resolve output path relative to output_dir if the path is not absolute.

Parameters
[in]pathpath to resolve
Returns
resolvedpath

Definition at line 37 of file StateOutput.cpp.

References output_dir.

Referenced by export_data(), init(), init_nonlinear_tensor_solve(), save_json(), save_restart_json(), save_subsolve(), save_timestep(), solve_problem(), solve_transient_linear(), and solve_transient_tensor_nonlinear().

Here is the caller graph for this function:

◆ root_path()

std::string polyfem::State::root_path ( ) const

Get the root path for the state (e.g., args["root_path"] or ".")

Returns
root path

Definition at line 25 of file StateOutput.cpp.

References args, and polyfem::utils::is_param_valid().

Referenced by assemble_rhs(), build_collision_mesh(), init(), resolve_input_path(), and save_restart_json().

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

◆ save_json() [1/2]

void polyfem::State::save_json ( const Eigen::MatrixXd &  sol)

saves the output statistic to disc according to params

Parameters
[in]solsolution

Definition at line 70 of file StateOutput.cpp.

References args, polyfem::logger(), resolve_output_path(), and save_json().

Here is the call graph for this function:

◆ save_json() [2/2]

void polyfem::State::save_json ( const Eigen::MatrixXd &  sol,
std::ostream &  out 
)

saves the output statistic to a stream

Parameters
[in]solsolution
[out]outstream to write output

Definition at line 86 of file StateOutput.cpp.

References args, assembler, disc_orders, iso_parametric(), polyfem::logger(), mesh, n_bases, n_pressure_bases, problem, polyfem::io::OutStatsData::save_json(), stats, and timings.

Referenced by forward_simulation(), get_log(), and save_json().

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

◆ save_restart_json()

void polyfem::State::save_restart_json ( const double  t0,
const double  dt,
const int  t 
) const

Save a JSON sim file for restarting the simulation at time t.

Parameters
tcurrent time to restart at

Definition at line 178 of file StateOutput.cpp.

References args, resolve_output_path(), root_path(), and starting_min_edge_length.

Referenced by solve_homogenization(), and solve_transient_tensor_nonlinear().

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

◆ save_subsolve()

void polyfem::State::save_subsolve ( const int  i,
const int  t,
const Eigen::MatrixXd &  sol,
const Eigen::MatrixXd &  pressure 
)

saves a subsolve when save_solve_sequence_debug is true

Parameters
[in]isub solve index
[in]ttime index
[in]solsolution
[in]pressurepressure

Definition at line 110 of file StateOutput.cpp.

References args, is_contact_enabled(), mesh, out_geom, problem, resolve_output_path(), polyfem::io::OutGeometryData::save_vtu(), solution_frames, and solve_export_to_file.

Referenced by solve_tensor_nonlinear().

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

◆ save_timestep()

void polyfem::State::save_timestep ( const double  time,
const int  t,
const double  t0,
const double  dt,
const Eigen::MatrixXd &  sol,
const Eigen::MatrixXd &  pressure 
)

saves a timestep

Parameters
[in]timetime in secs
[in]ttime index
[in]t0initial time
[in]dtdelta t
[in]solsolution
[in]pressurepressure

Definition at line 46 of file StateOutput.cpp.

References args, is_contact_enabled(), polyfem::logger(), mesh, out_geom, POLYFEM_SCOPED_TIMER, problem, resolve_output_path(), polyfem::io::OutGeometryData::save_pvd(), polyfem::io::OutGeometryData::save_vtu(), solution_frames, and solve_export_to_file.

Referenced by init_solve(), solve_homogenization(), solve_transient_linear(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), and solve_transient_tensor_nonlinear().

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

◆ set_boundary_side_set() [1/3]

void polyfem::State::set_boundary_side_set ( const std::function< int(const RowVectorNd &)> &  boundary_marker)
inline

set the boundary sideset from a lambda that takes the face/edge barycenter

Parameters
[in]boundary_markerfunction from face/edge barycenter that returns the sideset id

Definition at line 499 of file State.hpp.

References mesh.

◆ set_boundary_side_set() [2/3]

void polyfem::State::set_boundary_side_set ( const std::function< int(const RowVectorNd &, bool)> &  boundary_marker)
inline

set the boundary sideset from a lambda that takes the face/edge barycenter and a flag if the face/edge is boundary or not (used to set internal boundaries)

Parameters
[in]boundary_markerfunction from face/edge barycenter and a flag if the face/edge is boundary that returns the sideset id

Definition at line 506 of file State.hpp.

References mesh.

◆ set_boundary_side_set() [3/3]

void polyfem::State::set_boundary_side_set ( const std::function< int(const std::vector< int > &, bool)> &  boundary_marker)
inline

set the boundary sideset from a lambda that takes the face/edge vertices and a flag if the face/edge is boundary or not (used to set internal boundaries)

Parameters
[in]boundary_markerfunction from face/edge vertices and a flag if the face/edge is boundary that returns the sideset id

Definition at line 513 of file State.hpp.

References mesh.

◆ 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 123 of file StateInit.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_materials() [1/2]

void polyfem::State::set_materials ( assembler::Assembler assembler) const

utility to set the material and the problem dimension to only 1 assembler

Parameters
[in/out]assembler to set

Definition at line 511 of file StateInit.cpp.

References args, assembler, polyfem::assembler::Assembler::is_fluid(), polyfem::utils::is_param_valid(), polyfem::assembler::Assembler::is_tensor(), mesh, polyfem::assembler::Assembler::set_size(), and units.

Here is the call graph for this function:

◆ set_materials() [2/2]

void polyfem::State::set_materials ( std::vector< std::shared_ptr< assembler::Assembler > > &  assemblers) const

set the material and the problem dimension

Parameters
[in/out]list of assembler to set

Definition at line 424 of file StateInit.cpp.

References args, assembler, polyfem::mesh::Mesh3D::compute_cell_jacobian(), polyfem::mesh::Mesh2D::compute_face_jacobian(), polyfem::utils::is_param_valid(), mesh, and units.

Referenced by init_nonlinear_tensor_solve(), load_mesh(), load_mesh(), solve_navier_stokes(), and solve_transient_navier_stokes().

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 335 of file StateInit.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_vertex()

void polyfem::State::set_mesh_vertex ( int  v_id,
const Eigen::VectorXd &  vertex 
)

Definition at line 94 of file StateDiff.cpp.

References mesh.

◆ sol_to_pressure()

void polyfem::State::sol_to_pressure ( Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)
private

splits the solution in solution and pressure for mixed problems

Parameters
[in/out]sol solution
[out]pressurepressure

Definition at line 445 of file State.cpp.

References assembler, polyfem::logger(), mesh, mixed_assembler, n_bases, n_pressure_bases, problem, and use_avg_pressure.

Referenced by init_solve(), solve_linear(), solve_navier_stokes(), and solve_transient_navier_stokes().

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

◆ solve()

void polyfem::State::solve ( Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)
inline

solves the problem, call other methods

Parameters
[out]solsolution
[out]pressurepressure

Definition at line 303 of file State.hpp.

References assemble_mass_mat(), assemble_rhs(), build_basis(), polyfem::io::OutStatsData::compute_mesh_stats(), polyfem::logger(), mesh, solution_frames, solve_export_to_file, solve_problem(), and stats.

Here is the call graph for this function:

◆ solve_adjoint()

Eigen::MatrixXd polyfem::State::solve_adjoint ( const Eigen::MatrixXd &  rhs) const

Definition at line 325 of file StateDiff.cpp.

References problem, rhs, solve_static_adjoint(), and solve_transient_adjoint().

Referenced by solve_adjoint_cached().

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

◆ solve_adjoint_cached()

void polyfem::State::solve_adjoint_cached ( const Eigen::MatrixXd &  rhs)

Definition at line 320 of file StateDiff.cpp.

References polyfem::solver::DiffCache::cache_adjoints(), diff_cached, rhs, and solve_adjoint().

Here is the call graph for this function:

◆ solve_homogenization()

void polyfem::State::solve_homogenization ( const int  time_steps,
const double  t0,
const double  dt,
Eigen::MatrixXd &  sol 
)

Definition at line 273 of file StateHomogenization.cpp.

References args, polyfem::io::Evaluator::generate_linear_field(), init_homogenization_solve(), polyfem::utils::is_param_valid(), polyfem::log_and_throw_error(), polyfem::logger(), mesh, mesh_nodes, n_bases, polyfem::solver::SolveData::nl_problem, POLYFEM_SCOPED_TIMER, save_restart_json(), save_timestep(), solve_data, solve_homogenization_step(), polyfem::utils::unflatten(), polyfem::solver::SolveData::update_barrier_stiffness(), and polyfem::solver::SolveData::update_dt().

Referenced by solve_problem().

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

◆ solve_homogenization_step()

void polyfem::State::solve_homogenization_step ( Eigen::MatrixXd &  sol,
const int  t = 0,
bool  adaptive_initial_weight = false 
)

In Elasticity PDE, solve for "min W(disp_grad + \grad u)" instead of "min W(\grad u)".

Definition at line 121 of file StateHomogenization.cpp.

References args, bases, cache_transient_adjoint_quantities(), polyfem::assembler::MacroStrainValue::eval(), export_data(), polyfem::utils::flatten(), geom_bases(), polyfem::assembler::MacroStrainValue::get_fixed_entry(), polyfem::io::Evaluator::integrate_function(), polyfem::logger(), macro_strain_constraint, make_nl_solver(), mesh, n_bases, ndof(), polyfem::solver::SolveData::nl_problem, polyfem::solver::None, optimization_enabled, solve_data, polyfem::solver::SolveData::strain_al_lagr_form, polyfem::solver::SolveData::strain_al_pen_form, polyfem::utils::unflatten(), and x.

Referenced by solve_homogenization().

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

◆ solve_linear() [1/2]

void polyfem::State::solve_linear ( const std::unique_ptr< polysolve::linear::Solver > &  solver,
StiffnessMatrix A,
Eigen::VectorXd &  b,
const bool  compute_spectrum,
Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

Solve the linear problem with the given solver and system.

Parameters
solverLinear solver.
ALinear system matrix.
bRight-hand side.
compute_spectrumIf true, compute the spectrum.
[out]solsolution
[out]pressurepressure

Definition at line 69 of file StateSolveLinear.cpp.

References args, assembler, bases, boundary_nodes, polyfem::solver::Derivatives, geom_bases(), has_periodic_bc(), polyfem::io::Evaluator::integrate_function(), is_contact_enabled(), polyfem::logger(), mesh, mixed_assembler, n_bases, optimization_enabled, periodic_bc, problem, polyfem::solver::SolveData::rhs_assembler, sol_to_pressure(), solve_data, polyfem::io::OutStatsData::solver_info, polyfem::io::OutStatsData::spectrum, stats, use_avg_pressure, and x.

Here is the call graph for this function:

◆ solve_linear() [2/2]

void polyfem::State::solve_linear ( Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

solves a linear problem

Parameters
[out]solsolution
[out]pressurepressure

Definition at line 134 of file StateSolveLinear.cpp.

References args, assembler, boundary_nodes, build_stiffness_mat(), is_contact_enabled(), lin_solver_cached, local_boundary, local_neumann_boundary, polyfem::logger(), n_boundary_samples(), problem, rhs, polyfem::solver::SolveData::rhs_assembler, solve_data, and solve_linear().

Referenced by solve_linear(), solve_problem(), and solve_transient_linear().

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

◆ solve_navier_stokes()

void polyfem::State::solve_navier_stokes ( Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

solves a navier stokes

Parameters
[out]solsolution
[out]pressurepressure

Definition at line 20 of file StateSolveNavierStokes.cpp.

References args, ass_vals_cache, assembler, bases, boundary_nodes, geom_bases(), local_boundary, local_neumann_boundary, mesh, polyfem::solver::NavierStokesSolver::minimize(), mixed_assembler, n_bases, n_boundary_samples(), n_pressure_bases, pressure_ass_vals_cache, pressure_assembler, pressure_bases, problem, rhs, polyfem::solver::SolveData::rhs_assembler, set_materials(), sol_to_pressure(), solve_data, use_avg_pressure, and x.

Referenced by solve_problem().

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

◆ solve_problem()

void polyfem::State::solve_problem ( Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

solves the problems

Parameters
[out]solsolution
[out]pressurepressure

Definition at line 1726 of file State.cpp.

References args, assembler, cache_transient_adjoint_quantities(), init_linear_solve(), init_nonlinear_tensor_solve(), init_solve(), is_homogenization(), is_problem_linear(), polyfem::logger(), mesh, n_bases, polyfem::solver::None, optimization_enabled, problem, resolve_output_path(), solve_homogenization(), solve_linear(), solve_navier_stokes(), solve_tensor_nonlinear(), solve_transient_linear(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), solve_transient_tensor_nonlinear(), polyfem::io::OutRuntimeData::solving_time, polyfem::io::OutStatsData::spectrum, stats, timings, and polyfem::io::write_matrix().

Referenced by forward_simulation(), solve(), and polyfem::solver::AdjointOptUtils::solve_pde().

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

◆ solve_static_adjoint()

Eigen::MatrixXd polyfem::State::solve_static_adjoint ( const Eigen::MatrixXd &  adjoint_rhs) const

Definition at line 333 of file StateDiff.cpp.

References polyfem::adjoint_logger(), args, boundary_nodes, diff_cached, polyfem::solver::DiffCache::gradu_h(), has_periodic_bc(), is_homogenization(), lin_solver_cached, mesh, n_bases, ndof(), polyfem::solver::SolveData::nl_problem, periodic_bc, problem, solve_data, and x.

Referenced by solve_adjoint().

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

◆ solve_tensor_nonlinear()

void polyfem::State::solve_tensor_nonlinear ( Eigen::MatrixXd &  sol,
const int  t = 0,
const bool  init_lagging = true 
)

◆ solve_transient_adjoint()

Eigen::MatrixXd polyfem::State::solve_transient_adjoint ( const Eigen::MatrixXd &  adjoint_rhs) const

Definition at line 403 of file StateDiff.cpp.

References polyfem::adjoint_logger(), polyfem::time_integrator::BDF::alphas(), args, polyfem::solver::DiffCache::bdf_order(), polyfem::time_integrator::BDF::betas(), boundary_nodes, compute_force_jacobian_prev(), diff_cached, polyfem::solver::DiffCache::gradu_h(), polyfem::log_and_throw_adjoint_error(), mass, ndof(), and x.

Referenced by solve_adjoint().

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

◆ solve_transient_linear()

void polyfem::State::solve_transient_linear ( const int  time_steps,
const double  t0,
const double  dt,
Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

solves transient linear problem

Parameters
[in]time_stepsnumber of time steps
[in]t0initial times
[in]dttimestep size
[out]solsolution
[out]pressurepressure

Definition at line 219 of file StateSolveLinear.cpp.

References args, assembler, boundary_nodes, build_stiffness_mat(), cache_transient_adjoint_quantities(), polyfem::time_integrator::ImplicitTimeIntegrator::construct_time_integrator(), initial_acceleration(), initial_solution(), initial_velocity(), is_contact_enabled(), local_boundary, local_neumann_boundary, polyfem::log_and_throw_adjoint_error(), polyfem::logger(), mass, mass_matrix_assembler, mesh, mixed_assembler, n_boundary_samples(), n_pressure_bases, polyfem::solver::None, optimization_enabled, problem, resolve_output_path(), rhs, polyfem::solver::SolveData::rhs_assembler, save_timestep(), solve_data, solve_linear(), and use_avg_pressure.

Referenced by solve_problem().

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

◆ solve_transient_navier_stokes()

void polyfem::State::solve_transient_navier_stokes ( const int  time_steps,
const double  t0,
const double  dt,
Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

solves transient navier stokes with FEM

Parameters
[in]time_stepsnumber of time steps
[in]t0initial times
[in]dttimestep size
[out]solsolution
[out]pressurepressure

Definition at line 169 of file StateSolveNavierStokes.cpp.

References polyfem::time_integrator::BDF::acceleration_scaling(), args, ass_vals_cache, assembler, bases, boundary_nodes, geom_bases(), polyfem::time_integrator::ImplicitTimeIntegrator::init(), local_boundary, local_neumann_boundary, polyfem::logger(), mass_ass_vals_cache, mass_matrix_assembler, mesh, polyfem::solver::TransientNavierStokesSolver::minimize(), mixed_assembler, n_bases, n_boundary_samples(), n_pressure_bases, pressure_ass_vals_cache, pressure_assembler, pressure_bases, problem, rhs, polyfem::solver::SolveData::rhs_assembler, save_timestep(), set_materials(), polyfem::time_integrator::BDF::set_parameters(), sol_to_pressure(), solve_data, polyfem::time_integrator::BDF::update_quantities(), use_avg_pressure, and polyfem::time_integrator::BDF::weighted_sum_x_prevs().

Referenced by solve_problem().

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

◆ solve_transient_navier_stokes_split()

void polyfem::State::solve_transient_navier_stokes_split ( const int  time_steps,
const double  dt,
Eigen::MatrixXd &  sol,
Eigen::MatrixXd &  pressure 
)

solves transient navier stokes with operator splitting

Parameters
[in]time_stepsnumber of time steps
[in]dttimestep size
[out]solsolution
[out]pressurepressure

Definition at line 53 of file StateSolveNavierStokes.cpp.

References polyfem::solver::OperatorSplittingSolver::advection(), polyfem::solver::OperatorSplittingSolver::advection_FLIP(), args, ass_vals_cache, polyfem::assembler::Laplacian::assemble(), assembler, bases, boundary_nodes, build_stiffness_mat(), polyfem::solver::OperatorSplittingSolver::external_force(), geom_bases(), local_boundary, local_neumann_boundary, polyfem::log_and_throw_error(), polyfem::logger(), mass, mass_ass_vals_cache, mass_matrix_assembler, mesh, mixed_assembler, n_bases, n_boundary_samples(), n_pressure_bases, polyfem::autogen::p_nodes_2d(), polyfem::autogen::p_nodes_3d(), pressure_ass_vals_cache, pressure_bases, pressure_boundary_nodes, problem, polyfem::solver::OperatorSplittingSolver::projection(), polyfem::autogen::q_nodes_2d(), polyfem::autogen::q_nodes_3d(), polyfem::solver::SolveData::rhs_assembler, save_timestep(), polyfem::assembler::Assembler::set_size(), solve_data, polyfem::solver::OperatorSplittingSolver::solve_diffusion_1st(), and polyfem::solver::OperatorSplittingSolver::solve_pressure().

Referenced by solve_problem().

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

◆ solve_transient_tensor_nonlinear()

void polyfem::State::solve_transient_tensor_nonlinear ( const int  time_steps,
const double  t0,
const double  dt,
Eigen::MatrixXd &  sol 
)

solves transient tensor nonlinear problem

Parameters
[in]time_stepsnumber of time steps
[in]t0initial times
[in]dttimestep size
[out]solsolution

Definition at line 40 of file StateSolveNonlinear.cpp.

References args, build_mesh_matrices(), cache_transient_adjoint_quantities(), polyfem::F, init_nonlinear_tensor_solve(), polyfem::log_and_throw_error(), polyfem::logger(), mesh, polyfem::solver::SolveData::nl_problem, polyfem::solver::None, optimization_enabled, POLYFEM_SCOPED_TIMER, resolve_output_path(), save_restart_json(), save_timestep(), solve_data, solve_tensor_nonlinear(), polyfem::solver::SolveData::time_integrator, polyfem::solver::SolveData::update_barrier_stiffness(), polyfem::solver::SolveData::update_dt(), V, polyfem::io::EnergyCSVWriter::write(), polyfem::io::RuntimeStatsCSVWriter::write(), and polyfem::io::MshWriter::write().

Referenced by solve_problem().

Here is the call graph for this function:
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 101 of file State.hpp.

Referenced by assemble_mass_mat(), boundary_conditions_ids(), build_basis(), build_collision_mesh(), build_collision_mesh(), build_node_mapping(), build_periodic_collision_mesh(), build_polygonal_basis(), build_rhs_assembler(), build_stiffness_mat(), cache_transient_adjoint_quantities(), polyfem::solver::CollisionBarrierForm::CollisionBarrierForm(), compute_errors(), compute_force_jacobian_prev(), polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::AdjointTools::compute_shape_derivative_functional_term(), polyfem::solver::DeformedCollisionBarrierForm::DeformedCollisionBarrierForm(), polyfem::solver::AdjointTools::dJ_damping_transient_adjoint_term(), polyfem::solver::AdjointTools::dJ_dirichlet_transient_adjoint_term(), polyfem::solver::AdjointTools::dJ_du_step(), polyfem::solver::AdjointTools::dJ_friction_transient_adjoint_term(), polyfem::solver::AdjointTools::dJ_material_transient_adjoint_term(), polyfem::solver::AdjointTools::dJ_shape_transient_adjoint_term(), export_data(), formulation(), has_periodic_bc(), init(), polyfem::mesh::LocalRelaxationData< M >::init_assembler(), init_homogenization_solve(), init_linear_solve(), init_nonlinear_tensor_solve(), polyfem::mesh::LocalRelaxationData< M >::init_solve_data(), init_time(), initial_acceleration(), initial_solution(), initial_velocity(), polyfem::solver::AdjointTools::integrate_objective(), is_contact_enabled(), is_homogenization(), is_pressure_enabled(), iso_parametric(), load_mesh(), load_mesh(), make_nl_solver(), n_boundary_samples(), polyfem::mesh::Remesher::project_quantities(), root_path(), polyfem::io::OutGeometryData::save_contact_surface(), save_json(), save_json(), save_restart_json(), save_subsolve(), save_timestep(), set_materials(), set_materials(), solve_homogenization(), solve_homogenization_step(), solve_linear(), solve_linear(), solve_navier_stokes(), solve_problem(), solve_static_adjoint(), solve_tensor_nonlinear(), solve_transient_adjoint(), solve_transient_linear(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), solve_transient_tensor_nonlinear(), and polyfem::solver::MaxStressForm::value_unweighted_step().

◆ ass_vals_cache

◆ assembler

◆ avg_mass

double polyfem::State::avg_mass

◆ bases

std::vector<basis::ElementBases> polyfem::State::bases

FE bases, the size is #elements.

Definition at line 171 of file State.hpp.

Referenced by assemble_mass_mat(), build_basis(), build_collision_mesh(), build_collision_mesh(), build_mesh_matrices(), build_periodic_collision_mesh(), build_polygonal_basis(), build_pressure_assembler(), build_rhs_assembler(), build_stiffness_mat(), compute_errors(), compute_force_jacobian_prev(), polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::WeightedVolumeForm::compute_partial_gradient_with_param(), polyfem::solver::AdjointTools::compute_shape_derivative_functional_term(), polyfem::solver::AdjointTools::dJ_du_step(), polyfem::solver::AdjointTools::dJ_material_transient_adjoint_term(), polyfem::solver::AdjointTools::dJ_shape_transient_adjoint_term(), polyfem::io::OutGeometryData::export_data(), geom_bases(), polyfem::solver::KineticForm::get_integral_functional(), init_homogenization_solve(), init_linear_solve(), init_nonlinear_tensor_solve(), polyfem::solver::AdjointTools::integrate_objective(), reset_mesh(), polyfem::io::OutGeometryData::save_surface(), polyfem::io::OutGeometryData::save_volume(), polyfem::io::OutGeometryData::save_volume_vector_field(), polyfem::io::OutGeometryData::save_wire(), polyfem::solver::TargetForm::set_reference(), solve_homogenization_step(), solve_linear(), solve_navier_stokes(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), polyfem::solver::MaxStressForm::value_unweighted_step(), polyfem::solver::WeightedVolumeForm::value_unweighted_with_param(), polyfem::solver::VariableToBoundaryNodes::VariableToBoundaryNodes(), polyfem::solver::VariableToBoundaryNodesExclusive::VariableToBoundaryNodesExclusive(), and polyfem::solver::VariableToInteriorNodes::VariableToInteriorNodes().

◆ boundary_nodes

◆ collision_mesh

◆ console_sink_

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

logger sink to stdout

Definition at line 142 of file State.hpp.

Referenced by init_logger(), and set_log_level().

◆ damping_assembler

std::shared_ptr<assembler::ViscousDamping> polyfem::State::damping_assembler = nullptr

Definition at line 164 of file State.hpp.

Referenced by compute_force_jacobian_prev(), and init_nonlinear_tensor_solve().

◆ damping_prev_assembler

std::shared_ptr<assembler::ViscousDampingPrev> polyfem::State::damping_prev_assembler = nullptr

Definition at line 165 of file State.hpp.

Referenced by compute_force_jacobian_prev(), and init_nonlinear_tensor_solve().

◆ diff_cached

◆ dirichlet_nodes

std::vector<int> polyfem::State::dirichlet_nodes

per node dirichlet

Definition at line 443 of file State.hpp.

Referenced by build_basis(), build_rhs_assembler(), and polyfem::io::OutGeometryData::save_points().

◆ dirichlet_nodes_position

std::vector<RowVectorNd> polyfem::State::dirichlet_nodes_position

◆ disc_orders

Eigen::VectorXi polyfem::State::disc_orders

◆ elasticity_pressure_assembler

std::shared_ptr<assembler::PressureAssembler> polyfem::State::elasticity_pressure_assembler = nullptr

Definition at line 162 of file State.hpp.

Referenced by init_homogenization_solve(), and init_nonlinear_tensor_solve().

◆ file_sink_

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

Definition at line 143 of file State.hpp.

Referenced by init_logger().

◆ gbasis_nodes_to_basis_nodes

◆ geom_bases_

std::vector<basis::ElementBases> polyfem::State::geom_bases_

Geometric mapping bases, if the elements are isoparametric, this list is empty.

Definition at line 175 of file State.hpp.

Referenced by build_basis(), build_polygonal_basis(), geom_bases(), and reset_mesh().

◆ geom_mesh_nodes

std::shared_ptr<polyfem::mesh::MeshNodes> polyfem::State::geom_mesh_nodes

Definition at line 193 of file State.hpp.

Referenced by build_basis(), and primitive_to_node().

◆ has_dhat

bool polyfem::State::has_dhat = false

stores if input json contains dhat

Definition at line 586 of file State.hpp.

Referenced by build_basis(), and init().

◆ in_node_to_node

◆ in_primitive_to_primitive

Eigen::VectorXi polyfem::State::in_primitive_to_primitive

maps in vertices/edges/faces/cells to polyfem vertices/edges/faces/cells

Definition at line 452 of file State.hpp.

Referenced by build_node_mapping().

◆ initial_sol_update

Eigen::MatrixXd polyfem::State::initial_sol_update

Definition at line 717 of file State.hpp.

Referenced by init_nonlinear_tensor_solve().

◆ initial_vel_update

Eigen::MatrixXd polyfem::State::initial_vel_update

Definition at line 717 of file State.hpp.

Referenced by init_nonlinear_tensor_solve().

◆ lin_solver_cached

std::unique_ptr<polysolve::linear::Solver> polyfem::State::lin_solver_cached

◆ local_boundary

◆ local_neumann_boundary

std::vector<mesh::LocalBoundary> polyfem::State::local_neumann_boundary

◆ local_pressure_boundary

std::vector<mesh::LocalBoundary> polyfem::State::local_pressure_boundary

mapping from elements to nodes for pressure boundary conditions

Definition at line 437 of file State.hpp.

Referenced by build_basis(), build_pressure_assembler(), init_homogenization_solve(), and init_nonlinear_tensor_solve().

◆ local_pressure_cavity

std::unordered_map<int, std::vector<mesh::LocalBoundary> > polyfem::State::local_pressure_cavity

mapping from elements to nodes for pressure boundary conditions

Definition at line 439 of file State.hpp.

Referenced by build_basis(), build_pressure_assembler(), init_homogenization_solve(), and init_nonlinear_tensor_solve().

◆ macro_strain_constraint

assembler::MacroStrainValue polyfem::State::macro_strain_constraint

◆ mass

StiffnessMatrix polyfem::State::mass

◆ mass_ass_vals_cache

◆ mass_matrix_assembler

◆ mesh

std::unique_ptr<mesh::Mesh> polyfem::State::mesh

current mesh, it can be a Mesh2D or Mesh3D

Definition at line 466 of file State.hpp.

Referenced by polyfem::solver::AMIPSForm::AMIPSForm(), assemble_mass_mat(), assemble_rhs(), boundary_conditions_ids(), build_basis(), build_collision_mesh(), build_collision_mesh(), build_mesh_matrices(), build_node_mapping(), build_periodic_collision_mesh(), build_polygonal_basis(), build_pressure_assembler(), build_rhs_assembler(), build_stiffness_mat(), cache_transient_adjoint_quantities(), polyfem::solver::CollisionBarrierForm::CollisionBarrierForm(), polyfem::solver::NodeTargetForm::compute_adjoint_rhs_step(), compute_errors(), compute_force_jacobian_prev(), polyfem::solver::AMIPSForm::compute_partial_gradient(), polyfem::solver::CollisionBarrierForm::compute_partial_gradient(), polyfem::solver::DeformedCollisionBarrierForm::compute_partial_gradient(), polyfem::solver::BoundarySmoothingForm::compute_partial_gradient(), polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::WeightedVolumeForm::compute_partial_gradient_with_param(), polyfem::solver::AdjointTools::compute_shape_derivative_functional_term(), compute_surface_node_ids(), compute_total_surface_node_ids(), compute_volume_node_ids(), polyfem::solver::NLHomoProblem::constraint_grad(), polyfem::solver::DeformedCollisionBarrierForm::DeformedCollisionBarrierForm(), polyfem::solver::AdjointTools::dJ_du_step(), polyfem::solver::AdjointTools::dJ_friction_transient_adjoint_term(), polyfem::solver::AdjointTools::dJ_shape_static_adjoint_term(), polyfem::solver::AdjointTools::dJ_shape_transient_adjoint_term(), export_data(), polyfem::io::OutGeometryData::export_data(), polyfem::solver::NLHomoProblem::extended_hessian_to_reduced_hessian(), polyfem::solver::NLHomoProblem::extended_to_reduced(), polyfem::solver::NLHomoProblem::extended_to_reduced_grad(), forward_simulation(), polyfem::solver::NLHomoProblem::full_hessian_to_reduced_hessian(), polyfem::solver::NLHomoProblem::full_to_reduced(), polyfem::solver::NLHomoProblem::full_to_reduced_grad(), get_elements(), polyfem::solver::KineticForm::get_integral_functional(), polyfem::solver::StressForm::get_integral_functional(), polyfem::solver::TargetForm::get_integral_functional(), get_vertices(), polyfem::solver::BoundarySmoothingForm::init_form(), init_homogenization_solve(), init_linear_solve(), init_nonlinear_tensor_solve(), polyfem::solver::NLHomoProblem::init_projection(), init_solve(), initial_acceleration(), initial_solution(), initial_velocity(), polyfem::solver::AdjointTools::integrate_objective(), polyfem::solver::CollisionBarrierForm::is_step_collision_free(), polyfem::solver::AMIPSForm::is_step_valid(), iso_parametric(), load_mesh(), load_mesh(), load_mesh(), polyfem::solver::AdjointTools::map_node_to_primitive_order(), polyfem::solver::AdjointTools::map_primitive_to_node_order(), polyfem::solver::CollisionBarrierForm::max_step_size(), n_boundary_samples(), ndof(), polyfem::solver::NodeTargetForm::NodeTargetForm(), primitive_to_node(), polyfem::solver::NLHomoProblem::reduced_to_extended(), polyfem::solver::NLHomoProblem::reduced_to_full(), polyfem::io::OutGeometryData::save_contact_surface(), save_json(), polyfem::io::OutGeometryData::save_points(), save_subsolve(), polyfem::io::OutGeometryData::save_surface(), save_timestep(), polyfem::io::OutGeometryData::save_volume(), polyfem::io::OutGeometryData::save_volume_vector_field(), polyfem::io::OutGeometryData::save_vtu(), polyfem::io::OutGeometryData::save_wire(), set_boundary_side_set(), set_boundary_side_set(), set_boundary_side_set(), polyfem::solver::NLHomoProblem::set_fixed_entry(), set_materials(), set_materials(), set_mesh_vertex(), polyfem::solver::TargetForm::set_reference(), sol_to_pressure(), polyfem::solver::CollisionBarrierForm::solution_changed(), polyfem::solver::DeformedCollisionBarrierForm::solution_changed(), solve(), solve_homogenization(), solve_homogenization_step(), solve_linear(), solve_navier_stokes(), solve_problem(), solve_static_adjoint(), solve_transient_linear(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), solve_transient_tensor_nonlinear(), polyfem::solver::AMIPSForm::value_unweighted(), polyfem::solver::CollisionBarrierForm::value_unweighted(), polyfem::solver::DeformedCollisionBarrierForm::value_unweighted(), polyfem::solver::BoundarySmoothingForm::value_unweighted(), polyfem::solver::NodeTargetForm::value_unweighted_step(), polyfem::solver::WeightedVolumeForm::value_unweighted_with_param(), polyfem::solver::VariableToBoundaryNodes::VariableToBoundaryNodes(), polyfem::solver::VariableToBoundaryNodesExclusive::VariableToBoundaryNodesExclusive(), polyfem::solver::VariableToInteriorNodes::VariableToInteriorNodes(), polyfem::solver::VariableToNodes::VariableToNodes(), and polyfem::io::RuntimeStatsCSVWriter::write().

◆ mesh_nodes

◆ min_boundary_edge_length

double polyfem::State::min_boundary_edge_length = -1

Definition at line 608 of file State.hpp.

Referenced by build_basis().

◆ mixed_assembler

◆ n_bases

◆ n_geom_bases

◆ n_pressure_bases

◆ neumann_nodes

std::vector<int> polyfem::State::neumann_nodes

per node neumann

Definition at line 446 of file State.hpp.

Referenced by build_basis(), and build_rhs_assembler().

◆ neumann_nodes_position

std::vector<RowVectorNd> polyfem::State::neumann_nodes_position

Definition at line 447 of file State.hpp.

Referenced by build_basis(), and build_rhs_assembler().

◆ obstacle

◆ optimization_enabled

◆ out_geom

io::OutGeometryData polyfem::State::out_geom

visualization stuff

Definition at line 601 of file State.hpp.

Referenced by build_basis(), export_data(), load_mesh(), load_mesh(), save_subsolve(), and save_timestep().

◆ output_dir

std::string polyfem::State::output_dir

Directory for output files.

Definition at line 593 of file State.hpp.

Referenced by init(), init_nonlinear_tensor_solve(), and resolve_output_path().

◆ periodic_bc

std::shared_ptr<utils::PeriodicBoundary> polyfem::State::periodic_bc

periodic BC and periodic mesh utils

Definition at line 389 of file State.hpp.

Referenced by build_basis(), build_periodic_collision_mesh(), init_nonlinear_tensor_solve(), solve_linear(), and solve_static_adjoint().

◆ periodic_collision_mesh

ipc::CollisionMesh polyfem::State::periodic_collision_mesh

IPC collision mesh under periodic BC.

Definition at line 541 of file State.hpp.

Referenced by build_periodic_collision_mesh(), init_homogenization_solve(), and init_nonlinear_tensor_solve().

◆ periodic_collision_mesh_to_basis

Eigen::VectorXi polyfem::State::periodic_collision_mesh_to_basis

index mapping from periodic 2x2 collision mesh to FE periodic mesh

Definition at line 543 of file State.hpp.

Referenced by build_periodic_collision_mesh(), init_homogenization_solve(), and init_nonlinear_tensor_solve().

◆ poly_edge_to_data

std::map<int, basis::InterfaceData> polyfem::State::poly_edge_to_data

nodes on the boundary of polygonal elements, used for harmonic bases

Definition at line 441 of file State.hpp.

Referenced by build_basis(), build_polygonal_basis(), and reset_mesh().

◆ polys

std::map<int, Eigen::MatrixXd> polyfem::State::polys

◆ polys_3d

std::map<int, std::pair<Eigen::MatrixXd, Eigen::MatrixXi> > polyfem::State::polys_3d

◆ pressure_ass_vals_cache

assembler::AssemblyValsCache polyfem::State::pressure_ass_vals_cache

used to store assembly values for pressure for small problems

Definition at line 199 of file State.hpp.

Referenced by assemble_rhs(), build_basis(), build_stiffness_mat(), solve_navier_stokes(), solve_transient_navier_stokes(), and solve_transient_navier_stokes_split().

◆ pressure_assembler

std::shared_ptr<assembler::Assembler> polyfem::State::pressure_assembler = nullptr

◆ pressure_bases

◆ pressure_boundary_nodes

std::vector<int> polyfem::State::pressure_boundary_nodes

list of neumann boundary nodes

Definition at line 429 of file State.hpp.

Referenced by build_basis(), and solve_transient_navier_stokes_split().

◆ pressure_mesh_nodes

std::shared_ptr<polyfem::mesh::MeshNodes> polyfem::State::pressure_mesh_nodes

Definition at line 193 of file State.hpp.

Referenced by build_basis().

◆ problem

std::shared_ptr<assembler::Problem> polyfem::State::problem

current problem, it contains rhs and bc

Definition at line 168 of file State.hpp.

Referenced by assemble_mass_mat(), assemble_rhs(), build_basis(), build_pressure_assembler(), build_rhs_assembler(), build_stiffness_mat(), cache_transient_adjoint_quantities(), compute_errors(), compute_force_jacobian(), compute_force_jacobian_prev(), polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::AdjointForm::compute_reduced_adjoint_rhs(), polyfem::solver::AdjointTools::compute_shape_derivative_functional_term(), polyfem::solver::AdjointTools::dJ_du_step(), export_data(), polyfem::io::OutGeometryData::export_data(), get_adjoint_mat(), polyfem::solver::KineticForm::get_integral_functional(), init(), polyfem::mesh::LocalRelaxationData< M >::init_boundary_conditions(), init_linear_solve(), init_nonlinear_tensor_solve(), init_solve(), polyfem::mesh::LocalRelaxationData< M >::init_solve_data(), initial_solution(), polyfem::solver::AdjointTools::integrate_objective(), ndof(), save_json(), polyfem::io::OutGeometryData::save_points(), save_subsolve(), polyfem::io::OutGeometryData::save_surface(), save_timestep(), polyfem::io::OutGeometryData::save_volume(), polyfem::io::OutGeometryData::save_volume_vector_field(), polyfem::io::OutGeometryData::save_wire(), sol_to_pressure(), solve_adjoint(), solve_linear(), solve_linear(), solve_navier_stokes(), solve_problem(), solve_static_adjoint(), solve_transient_linear(), solve_transient_navier_stokes(), solve_transient_navier_stokes_split(), State(), and polyfem::solver::MaxStressForm::value_unweighted_step().

◆ rhs

◆ solution_frames

std::vector<io::SolutionFrame> polyfem::State::solution_frames

saves the frames in a vector instead of VTU

Definition at line 599 of file State.hpp.

Referenced by export_data(), save_subsolve(), save_timestep(), and solve().

◆ solve_data

◆ solve_export_to_file

bool polyfem::State::solve_export_to_file = true

flag to decide if exporting the time dependent solution to files or save it in the solution_frames array

Definition at line 597 of file State.hpp.

Referenced by export_data(), save_subsolve(), save_timestep(), and solve().

◆ starting_max_edge_length

double polyfem::State::starting_max_edge_length = -1

Definition at line 607 of file State.hpp.

Referenced by build_basis().

◆ starting_min_edge_length

double polyfem::State::starting_min_edge_length = -1

Definition at line 606 of file State.hpp.

Referenced by build_basis(), and save_restart_json().

◆ stats

◆ timings

◆ total_local_boundary

◆ units

◆ use_avg_pressure

bool polyfem::State::use_avg_pressure

use average pressure for stokes problem to fix the additional dofs, true by default if false, it will fix one pressure node to zero

Definition at line 211 of file State.hpp.

Referenced by assemble_rhs(), build_basis(), build_stiffness_mat(), sol_to_pressure(), solve_linear(), solve_navier_stokes(), solve_transient_linear(), and solve_transient_navier_stokes().


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