mirror of https://github.com/CGAL/cgal
Shape smoothing: some comments added to accelerate matrix construction.
Konstantinos: this is what is so slow, not the solver!
This commit is contained in:
parent
e05831c1b3
commit
079f1baf86
|
|
@ -171,7 +171,6 @@ public:
|
||||||
//void solve_system(Eigen_matrix& stiffness_matrix)
|
//void solve_system(Eigen_matrix& stiffness_matrix)
|
||||||
void solve_system(Eigen::SparseMatrix<double>& L, const double time)
|
void solve_system(Eigen::SparseMatrix<double>& L, const double time)
|
||||||
{
|
{
|
||||||
|
|
||||||
Eigen_matrix A(nb_vert_, nb_vert_);
|
Eigen_matrix A(nb_vert_, nb_vert_);
|
||||||
|
|
||||||
Eigen_vector bx(nb_vert_);
|
Eigen_vector bx(nb_vert_);
|
||||||
|
|
@ -182,33 +181,33 @@ public:
|
||||||
Eigen_vector Xy(nb_vert_);
|
Eigen_vector Xy(nb_vert_);
|
||||||
Eigen_vector Xz(nb_vert_);
|
Eigen_vector Xz(nb_vert_);
|
||||||
|
|
||||||
std::cout << "compute coefficients...";
|
std::cerr << "compute coefficients...";
|
||||||
compute_coeff_matrix(A, L, time);
|
compute_coeff_matrix(A, L, time);
|
||||||
std::cout << "done" << std::endl;
|
std::cerr << "done" << std::endl;
|
||||||
|
|
||||||
std::cout << "rhs...";
|
std::cerr << "rhs...";
|
||||||
compute_rhs(bx, by, bz);
|
compute_rhs(bx, by, bz);
|
||||||
std::cout << "done" << std::endl;
|
std::cerr << "done" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// Cholesky factorization
|
// Cholesky factorization
|
||||||
std::cout << "compute ...";
|
std::cerr << "compute ...";
|
||||||
Eigen_solver solver;
|
Eigen_solver solver;
|
||||||
solver.compute(A);
|
solver.compute(A);
|
||||||
std::cout << "done" << std::endl;
|
std::cerr << "done" << std::endl;
|
||||||
// solver.analyzePattern(A);
|
// solver.analyzePattern(A);
|
||||||
// solver.factorize(A);
|
// solver.factorize(A);
|
||||||
|
|
||||||
// back-substitution
|
// back-substitution
|
||||||
std::cout << "solve...";
|
std::cerr << "solve...";
|
||||||
Xx = solver.solve(bx);
|
Xx = solver.solve(bx);
|
||||||
Xy = solver.solve(by);
|
Xy = solver.solve(by);
|
||||||
Xz = solver.solve(bz);
|
Xz = solver.solve(bz);
|
||||||
std::cout << "done" << std::endl;
|
std::cerr << "done" << std::endl;
|
||||||
|
|
||||||
if(solver.info() != Eigen::Success)
|
if(solver.info() != Eigen::Success)
|
||||||
{
|
{
|
||||||
std::cerr<<"Not Solved!\n";
|
std::cerr << "Not Solved!" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,9 +296,13 @@ private:
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
||||||
Eigen_matrix stiff_matrix()
|
Eigen_matrix stiff_matrix() // TOFIX: pass reference to matrix
|
||||||
{
|
{
|
||||||
Eigen_matrix mat(nb_vert_, nb_vert_);
|
Eigen_matrix mat(nb_vert_, nb_vert_); // TOFIX
|
||||||
|
|
||||||
|
// TOFIX: very slow way to fill the matrx
|
||||||
|
// avoid matrix C!! and use triplets
|
||||||
|
// read http://eigen.tuxfamily.org/dox/group__TutorialSparse.html#TutorialSparseFilling
|
||||||
|
|
||||||
// cot values
|
// cot values
|
||||||
Eigen_matrix C = cot_entries();
|
Eigen_matrix C = cot_entries();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,10 @@ void smooth_shape(PolygonMesh& mesh, const double time, std::size_t nb_iter)
|
||||||
internal::Shape_smoother<PolygonMesh, VertexPointMap> smoother(mesh, vpmap);
|
internal::Shape_smoother<PolygonMesh, VertexPointMap> smoother(mesh, vpmap);
|
||||||
|
|
||||||
Eigen::SparseMatrix<double> stiffness_matrix;
|
Eigen::SparseMatrix<double> stiffness_matrix;
|
||||||
stiffness_matrix = smoother.calc_stiff_matrix();
|
|
||||||
|
std::cerr << "compute stiffness matrix...";
|
||||||
|
stiffness_matrix = smoother.calc_stiff_matrix(); // TOFIX: avoid copy
|
||||||
|
std::cerr << "done" << std::endl;
|
||||||
|
|
||||||
for(std::size_t t=0; t<nb_iter; ++t)
|
for(std::size_t t=0; t<nb_iter; ++t)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue