11#include <unsupported/Eigen/SparseExtra>
13#include <polysolve/linear/FEMSolver.hpp>
21 const std::string full_mat_path =
args[
"output"][
"data"][
"full_mat"];
22 if (full_mat_path.empty())
25 Eigen::saveMarket(stiffness, full_mat_path);
41 const Eigen::MatrixXd &solution,
44 const std::vector<std::pair<std::string, std::shared_ptr<solver::Form>>> named_forms{
56 logger().info(
"Assembling stiffness mat...");
67 stats.
mat_size = (
long long)stiffness.rows() * (
long long)stiffness.cols();
74 const std::unique_ptr<polysolve::linear::Solver> &solver,
77 const bool compute_spectrum,
83 const int problem_dim =
problem->is_scalar() ? 1 :
mesh_->dimension();
94 args[
"output"][
"data"][
"stiffness_mat"],
102 const auto error = (A *
x - b).norm();
104 logger().error(
"Solver error: {}", error);
106 logger().debug(
"Solver error: {}", error);
111 assert(sol.cols() == 1);
119 t,
problem->is_time_dependent() ?
args[
"time"][
"dt"].get<
double>() : 0.0,
122 body_form = std::make_shared<solver::BodyForm>(
127 false,
problem->is_time_dependent());
130 if (
problem->is_time_dependent())
137 Eigen::MatrixXd solution, velocity, acceleration;
139 solution.col(0) = sol;
140 assert(solution.rows() == sol.size());
142 assert(velocity.rows() == sol.size());
144 assert(acceleration.rows() == sol.size());
159 auto solver = polysolve::linear::Solver::create(
args[
"solver"][
"linear"],
logger());
160 logger().info(
"{}...", solver->name());
169 Eigen::VectorXd b =
rhs_;
175 assert(
problem->is_time_dependent());
179 auto solver = polysolve::linear::Solver::create(
args[
"solver"][
"linear"],
logger());
180 logger().info(
"{}...", solver->name());
184 Eigen::MatrixXd current_rhs =
rhs_;
191 const double time =
t0 + t *
dt;
205 std::vector<mesh::LocalBoundary>(), current_rhs, sol, time);
208 Eigen::VectorXd b = current_rhs;
236 sol.conservativeResize(Eigen::NoChange, 1);
241 if (
problem->is_time_dependent())
#define POLYFEM_SCOPED_TIMER(...)
double assembling_stiffness_mat_time
time to assembly
double solving_time
time to solve
json solver_info
information of the solver, eg num iteration, time, errors, etc the informations varies depending on t...
Eigen::Vector4d spectrum
spectrum of the stiffness matrix, enable only if POLYSOLVE_WITH_SPECTRA is ON (off by default)
long long nn_zero
non zeros and sytem matrix size num dof is the total dof in the system
static std::shared_ptr< ImplicitTimeIntegrator > construct_time_integrator(const json ¶ms)
Factory method for constructing implicit time integrators from the name of the integrator.
spdlog::logger & logger()
Retrieves the current logger.
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix