CGAL getters don't start with get_

This commit is contained in:
Andreas Fabri 2018-06-11 16:36:26 +01:00
parent d224154e52
commit 375d45f40d
2 changed files with 29 additions and 29 deletions

View File

@ -124,14 +124,14 @@ namespace Heat_method_3 {
* add `vd` to the source set, returning `false` if `vd` is already in the set. * add `vd` to the source set, returning `false` if `vd` is already in the set.
*/ */
const Matrix& get_mass_matrix() const Matrix& mass_matrix()
{ {
return mass_matrix; return m_mass_matrix;
} }
const Matrix& get_cotan_matrix() const Matrix& cotan_matrix()
{ {
return cotan_matrix; return m_cotan_matrix;
} }
bool add_source(vertex_descriptor vd) bool add_source(vertex_descriptor vd)
@ -197,9 +197,9 @@ namespace Heat_method_3 {
return edge_sum; return edge_sum;
} }
double get_time_step() double time_step()
{ {
return time_step; return m_time_step;
} }
Matrix kronecker_delta(const std::set<vertex_descriptor>& sources) Matrix kronecker_delta(const std::set<vertex_descriptor>& sources)
@ -221,15 +221,15 @@ namespace Heat_method_3 {
} }
const Matrix& get_kronecker_delta() const Matrix& kronecker_delta()
{ {
return kronecker; return kronecker;
} }
Eigen::VectorXd solve_cotan_laplace(Matrix M, Matrix c, Matrix x, double time_step, int dimension) Eigen::VectorXd solve_cotan_laplace(Matrix M, Matrix c, Matrix x, double a_time_step, int dimension)
{ {
Eigen::VectorXd u; Eigen::VectorXd u;
Matrix A = (M+ time_step*c); Matrix A = (M+ a_time_step*c);
Eigen::SimplicialLLT<Matrix> solver; Eigen::SimplicialLLT<Matrix> solver;
solver.compute(A); solver.compute(A);
if(solver.info()!=Eigen::Success) { if(solver.info()!=Eigen::Success) {
@ -364,7 +364,7 @@ namespace Heat_method_3 {
//currently, this function will return a (number of vertices)x1 vector where //currently, this function will return a (number of vertices)x1 vector where
//the ith index has the distance from the first vertex to the ith vertex //the ith index has the distance from the first vertex to the ith vertex
const Eigen::VectorXd& get_distances() const Eigen::VectorXd& distances()
{ {
return solved_phi; return solved_phi;
} }
@ -449,29 +449,29 @@ namespace Heat_method_3 {
A_matrix_entries.push_back(triplet(j,j, (1./6.)*norm_cross)); A_matrix_entries.push_back(triplet(j,j, (1./6.)*norm_cross));
A_matrix_entries.push_back(triplet(k,k, (1./6.)*norm_cross)); A_matrix_entries.push_back(triplet(k,k, (1./6.)*norm_cross));
} }
mass_matrix.resize(m,m); m_mass_matrix.resize(m,m);
mass_matrix.setFromTriplets(A_matrix_entries.begin(), A_matrix_entries.end()); m_mass_matrix.setFromTriplets(A_matrix_entries.begin(), A_matrix_entries.end());
cotan_matrix.resize(m,m); m_cotan_matrix.resize(m,m);
cotan_matrix.setFromTriplets(c_matrix_entries.begin(), c_matrix_entries.end()); m_cotan_matrix.setFromTriplets(c_matrix_entries.begin(), c_matrix_entries.end());
time_step = 1./(num_edges(tm)); m_time_step = 1./(num_edges(tm));
time_step = time_step*summation_of_edges(); m_time_step = m_time_step*summation_of_edges();
sources = get_sources(); sources = get_sources();
kronecker = kronecker_delta(sources); kronecker = kronecker_delta(sources);
solved_u = solve_cotan_laplace(mass_matrix, cotan_matrix, kronecker, time_step, m); solved_u = solve_cotan_laplace(m_mass_matrix, m_cotan_matrix, kronecker, m_time_step, m);
X = compute_unit_gradient(solved_u); X = compute_unit_gradient(solved_u);
index_divergence = compute_divergence(X, m); index_divergence = compute_divergence(X, m);
solved_phi = solve_phi(cotan_matrix, index_divergence, m); solved_phi = solve_phi(m_cotan_matrix, index_divergence, m);
} }
const TriangleMesh& tm; const TriangleMesh& tm;
VertexDistanceMap vdm; VertexDistanceMap vdm;
VertexPointMap vpm; VertexPointMap vpm;
FaceIndexMap fpm; FaceIndexMap fpm;
std::set<vertex_descriptor> sources; std::set<vertex_descriptor> sources;
double time_step; double m_time_step;
Matrix kronecker; Matrix kronecker;
Matrix mass_matrix, cotan_matrix; Matrix m_mass_matrix, m_cotan_matrix;
Eigen::VectorXd solved_u; Eigen::VectorXd solved_u;
Eigen::MatrixXd X; Eigen::MatrixXd X;
Matrix index_divergence; Matrix index_divergence;

View File

@ -104,20 +104,20 @@ int main()
Heat_method hm(sm, vertex_distance_map); Heat_method hm(sm, vertex_distance_map);
source_set_tests(hm,sm); source_set_tests(hm,sm);
//cotan matrix tests //cotan matrix tests
const SparseMatrix& M = hm.get_mass_matrix(); const SparseMatrix& M = hm.mass_matrix();
const SparseMatrix& c = hm.get_cotan_matrix(); const SparseMatrix& c = hm.cotan_matrix();
cotan_matrix_test(c); cotan_matrix_test(c);
mass_matrix_test(M); mass_matrix_test(M);
double time_step = hm.get_time_step(); double time_step = hm.time_step();
double length_sum = hm.summation_of_edges(); double length_sum = hm.summation_of_edges();
//there are 6 edges in pyramid //there are 6 edges in pyramid
double time_step_computed = (1./6)*length_sum; double time_step_computed = (1./6)*length_sum;
assert(time_step_computed ==time_step); assert(time_step_computed ==time_step);
const SparseMatrix& K = hm.get_kronecker_delta(); const SparseMatrix& K = hm.kronecker_delta();
// AF: I commented the assert as I commented in build() // AF: I commented the assert as I commented in build()
assert(K.nonZeros()==1); assert(K.nonZeros()==1);
Eigen::VectorXd solved_u = hm.solve_cotan_laplace(M,c,K,time_step,4); Eigen::VectorXd solved_u = hm.solve_cotan_laplace(M,c,K,time_step,4);
@ -144,15 +144,15 @@ int main()
return 1; return 1;
} }
Heat_method hm2(sm2, vertex_distance_map2); Heat_method hm2(sm2, vertex_distance_map2);
//Eigen::VectorXd solved_dist_sphere = hm2.get_distances(); //Eigen::VectorXd solved_dist_sphere = hm2.distances();
const SparseMatrix& M2 = hm2.get_mass_matrix(); const SparseMatrix& M2 = hm2.mass_matrix();
const SparseMatrix& c2 = hm2.get_cotan_matrix(); const SparseMatrix& c2 = hm2.cotan_matrix();
cotan_matrix_test(c2); cotan_matrix_test(c2);
//mass_matrix_test(M2); //mass_matrix_test(M2);
const SparseMatrix& K2 = hm2.get_kronecker_delta(); const SparseMatrix& K2 = hm2.kronecker_delta();
// AF: I commented the assert as I commented in build() // AF: I commented the assert as I commented in build()
assert(K2.nonZeros()==1); assert(K2.nonZeros()==1);
double time_step_2 = hm2.get_time_step(); double time_step_2 = hm2.time_step();
Eigen::VectorXd solved_u2 = hm2.solve_cotan_laplace(M2,c2,K2,time_step_2,43562); Eigen::VectorXd solved_u2 = hm2.solve_cotan_laplace(M2,c2,K2,time_step_2,43562);
Eigen::VectorXd check_u2 = ((M2+time_step_2*c2)*solved_u2)-K2; Eigen::VectorXd check_u2 = ((M2+time_step_2*c2)*solved_u2)-K2;