[Bf-blender-cvs] [675c009bdd7] rigid_deform: CholUp update

Jacques Lucke noreply at git.blender.org
Thu Jan 31 19:56:13 CET 2019


Commit: 675c009bdd7de4f4f24d09da0f6c5dc6ae305419
Author: Jacques Lucke
Date:   Thu Jan 31 19:30:45 2019 +0100
Branches: rigid_deform
https://developer.blender.org/rB675c009bdd7de4f4f24d09da0f6c5dc6ae305419

CholUp update

===================================================================

M	extern/CholUp/CMakeLists.txt
M	extern/CholUp/source/CholUp/CholUp.hpp
M	extern/CholUp/source/CholUp/SparseSupernodal.h
R099	extern/CholUp/source/CholUp/SupernodalCholesky.hpp	extern/CholUp/source/CholUp/SupernodalCholesky.h
M	extern/CholUp/source/CholUp/main.cpp
M	source/blender/modifiers/intern/MOD_rigiddeform_system.cc

===================================================================

diff --git a/extern/CholUp/CMakeLists.txt b/extern/CholUp/CMakeLists.txt
index 1fb2be7853a..53eefcaaed8 100644
--- a/extern/CholUp/CMakeLists.txt
+++ b/extern/CholUp/CMakeLists.txt
@@ -14,7 +14,7 @@ set(SRC
 	source/CholUp/SparseMatrix_impl.h
 	source/CholUp/SparseMatrix.h
 	source/CholUp/SparseSupernodal.h
-	source/CholUp/SupernodalCholesky.hpp
+	source/CholUp/SupernodalCholesky.h
 	source/CholUp/CholUp.hpp
 )
 
diff --git a/extern/CholUp/source/CholUp/CholUp.hpp b/extern/CholUp/source/CholUp/CholUp.hpp
index a5585a4e170..724aa072ced 100644
--- a/extern/CholUp/source/CholUp/CholUp.hpp
+++ b/extern/CholUp/source/CholUp/CholUp.hpp
@@ -1 +1 @@
-#include "SupernodalCholesky.hpp"
\ No newline at end of file
+#include "SupernodalCholesky.h"
\ No newline at end of file
diff --git a/extern/CholUp/source/CholUp/SparseSupernodal.h b/extern/CholUp/source/CholUp/SparseSupernodal.h
index 207eae22ed6..44de3ce09b4 100644
--- a/extern/CholUp/source/CholUp/SparseSupernodal.h
+++ b/extern/CholUp/source/CholUp/SparseSupernodal.h
@@ -130,8 +130,6 @@ SupernodalVector<T, Cols>::~SupernodalVector()
 template<class T>
 SparseSupernodalMatrix<T>::SparseSupernodalMatrix(const SparseSupernodalMatrix& A)
 {
-    std::cout << "SparseSupernodalMatrix<T>::SparseSupernodalMatrix(const SparseSupernodalMatrix& A)" << std::endl;
-
     *this = A;
 }
 
@@ -139,10 +137,6 @@ template<class T>
 SparseSupernodalMatrix<T>&
 SparseSupernodalMatrix<T>::operator=(const SparseSupernodalMatrix& A)
 {
-
-    std::cout << "SparseSupernodalMatrix<T>& SparseSupernodalMatrix<T>::operator=(const SparseSupernodalMatrix& A)" << std::endl;
-
-
     if(&A != this)
     {
         numrows = A.numrows;
@@ -178,9 +172,6 @@ SparseSupernodalMatrix<T>::operator=(const SparseSupernodalMatrix& A)
 template<class T>
 SparseSupernodalMatrix<T>::SparseSupernodalMatrix(SparseSupernodalMatrix&& A)
 {
-    std::cout << "SparseSupernodalMatrix<T>::SparseSupernodalMatrix(SparseSupernodalMatrix&& A)" << std::endl;
-
-
     *this = std::move(A);
 }
 
@@ -188,8 +179,6 @@ template<class T>
 SparseSupernodalMatrix<T>&
 SparseSupernodalMatrix<T>::operator=(SparseSupernodalMatrix&& A)
 {
-        std::cout << "SparseSupernodalMatrix<T>::operator=(SparseSupernodalMatrix&& A)" << std::endl;
-
     if(&A != this)
     {
         numrows = A.numrows;
diff --git a/extern/CholUp/source/CholUp/SupernodalCholesky.hpp b/extern/CholUp/source/CholUp/SupernodalCholesky.h
similarity index 99%
rename from extern/CholUp/source/CholUp/SupernodalCholesky.hpp
rename to extern/CholUp/source/CholUp/SupernodalCholesky.h
index ecee5324554..5271d4595d4 100644
--- a/extern/CholUp/source/CholUp/SupernodalCholesky.hpp
+++ b/extern/CholUp/source/CholUp/SupernodalCholesky.h
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "SupernodalCholesky.hpp"
+#include "SupernodalCholesky.h"
 #include "SparseMatrix.h"
 #include "Matrix.hpp"
 #include "EliminationTreeMethods.h"
@@ -108,9 +108,6 @@ public:
 };
 
 
-
-
-
 template<class MatrixType>
 std::string
 SupernodalCholesky<MatrixType>::memoryReport()
@@ -1042,6 +1039,12 @@ void SupernodalCholesky<MatrixType>::update(SparseMatrix<double>& W)
     }
 }
 
+template<class MatrixType>
+void SupernodalCholesky<MatrixType>::solve(Matrix<T>& m)
+{  
+    solveL(m);
+    solveLT(m);
+}
 
 template<class MatrixType>
 void SupernodalCholesky<MatrixType>::solveL(Matrix<T>& m)
diff --git a/extern/CholUp/source/CholUp/main.cpp b/extern/CholUp/source/CholUp/main.cpp
index 60056cf0a37..f6133b782e3 100644
--- a/extern/CholUp/source/CholUp/main.cpp
+++ b/extern/CholUp/source/CholUp/main.cpp
@@ -1,12 +1,15 @@
 #include <iostream>
 #include <fstream>
 #include <iterator>
-#include "SparseMatrix.h"
-#include "SupernodalCholesky.hpp"
+#include <vector>
+
+#include "SupernodalCholesky.h"
+
 #include <Eigen/Sparse>
 #include <unsupported/Eigen/SparseExtra>
 #include "Timer.hpp"
 
+using namespace std;
 
 // just loads a bunch of binary integers
 vector<int>
@@ -36,16 +39,21 @@ int main(int argc, const char * argv[])
     Eigen::loadMarket(eigenM, "./data/LTL.mtx");
     auto roiIds = loadIds("./data/ids");
     std::sort(roiIds.begin(), roiIds.end());
-    SparseMatrix<double> A(eigenM);
+    CholUp::SparseMatrix<double> A(eigenM);
 
     // factorize & update
-    SupernodalCholesky<SparseMatrix<double>> chol(A);
+    Timer t0("Factor");
+    CholUp::SupernodalCholesky<CholUp::SparseMatrix<double>> chol(A);
+    t0.printTime("full");
+    t0.reset();
+
     auto cholPart0 = chol.dirichletPartialFactor(A, roiIds);
+    t0.printTime("partial");
 
-    // solve linear system involving cholPart0
 
+    // solve linear system involving cholPart0
     // setup rhs
-    Matrix<double> rhs(cholPart0.L.numcols, 3);
+    CholUp::Matrix<double> rhs(cholPart0.L.numcols, 3);
     rhs.fill();
     rhs(0, 0) = rhs(0, 1) = rhs(0, 2) = 1;
     auto rhs0 = rhs;
@@ -58,5 +66,14 @@ int main(int argc, const char * argv[])
     rhs.write("./data/x");
     cholPart0.L.toSparseMatrix().writeMatrixMarket("./data/cholPart.mtx");
 
+    // refactor
+    Eigen::SparseMatrix<double> eigenM2;
+    Eigen::loadMarket(eigenM2, "./data/subLTL.mtx");
+    CholUp::SparseMatrix<double> A2(eigenM2);
+    
+    Timer t3("Full refactor");
+    CholUp::SupernodalCholesky<CholUp::SparseMatrix<double>> chol2(A2);
+    t3.printTime();
+
     return 0;
 }
diff --git a/source/blender/modifiers/intern/MOD_rigiddeform_system.cc b/source/blender/modifiers/intern/MOD_rigiddeform_system.cc
index 2925209ec35..d826da3066d 100644
--- a/source/blender/modifiers/intern/MOD_rigiddeform_system.cc
+++ b/source/blender/modifiers/intern/MOD_rigiddeform_system.cc
@@ -398,8 +398,7 @@ namespace RigidDeform {
 			CholUp::Matrix<double> rhs(m_order.inner_amount(), 1);
 			for (uint i = 0; i < m_order.inner_amount(); i++) rhs(i, 0) = b[i];
 
-			m_solver_current.solveL(rhs);
-			m_solver_current.solveLT(rhs);
+			m_solver_current.solve(rhs);
 
 			Eigen::VectorXd result(m_order.inner_amount());
 			for (uint i = 0; i < m_order.inner_amount(); i++) result[i] = rhs(i, 0);



More information about the Bf-blender-cvs mailing list