8 using namespace assembler;
10 using namespace utils;
20 sol.conservativeResize(Eigen::NoChange, 1);
24 const int actual_dim =
problem->is_scalar() ? 1 :
mesh->dimension();
26 pressure.resize(0, 0);
27 sol.conservativeResize(
rhs.size(), sol.cols());
30 sol(sol.size() - 1) = 0;
35 if (
problem->is_time_dependent())
41 bool read_initial_x_from_file(
42 const std::string &state_path,
43 const std::string &x_name,
45 const Eigen::VectorXi &in_node_to_node,
49 if (state_path.empty())
54 logger().debug(
"Unable to read initial {} from file ({})", x_name, state_path);
60 const int ndof = in_node_to_node.size() * dim;
73 const bool was_solution_loaded = read_initial_x_from_file(
76 mesh->dimension(), solution);
78 if (!was_solution_loaded)
80 if (
problem->is_time_dependent())
84 solution.resize(
rhs.size(), 1);
94 const bool was_velocity_loaded = read_initial_x_from_file(
97 mesh->dimension(), velocity);
99 if (!was_velocity_loaded)
107 const bool was_acceleration_loaded = read_initial_x_from_file(
110 mesh->dimension(), acceleration);
112 if (!was_acceleration_loaded)
#define POLYFEM_SCOPED_TIMER(...)
int n_bases
number of bases
int n_pressure_bases
number of pressure bases
void sol_to_pressure(Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
splits the solution in solution and pressure for mixed problems
Eigen::VectorXi in_node_to_node
Inpute nodes (including high-order) to polyfem nodes, only for isoparametric.
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 initial_solution(Eigen::MatrixXd &solution) const
Load or compute the initial solution.
std::unique_ptr< mesh::Mesh > mesh
current mesh, it can be a Mesh2D or Mesh3D
std::shared_ptr< assembler::Problem > problem
current problem, it contains rhs and bc
json args
main input arguments containing all defaults
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.
std::shared_ptr< assembler::RhsAssembler > build_rhs_assembler() const
build a RhsAssembler for the problem
void init_solve(Eigen::MatrixXd &sol, Eigen::MatrixXd &pressure)
initialize solver
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.
solver::SolveData solve_data
timedependent stuff cached
std::shared_ptr< assembler::MixedAssembler > mixed_assembler
Eigen::MatrixXd rhs
System right-hand side.
std::shared_ptr< assembler::RhsAssembler > rhs_assembler
bool read_matrix(const std::string &path, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat)
Reads a matrix from a file. Determines the file format based on the path's extension.
Eigen::MatrixXd reorder_matrix(const Eigen::MatrixXd &in, const Eigen::VectorXi &in_to_out, int out_blocks=-1, const int block_size=1)
Reorder row blocks in a matrix.
spdlog::logger & logger()
Retrieves the current logger.