-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lanczos tests #132
Lanczos tests #132
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,9 @@ void matrix_market_output_file( | |
const std::string &filename, | ||
const dealii::TrilinosWrappers::SparseMatrix &matrix); | ||
|
||
void matrix_market_output_file(const std::string &filename, | ||
const dealii::SparseMatrix<double> &matrix); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please comment on how this gets called with the changes you propose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not, should have been a separate PR for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove from that PR. |
||
|
||
void matrix_market_output_file( | ||
const std::string &filename, | ||
const dealii::TrilinosWrappers::MPI::Vector &vector); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,9 +73,10 @@ double test(std::shared_ptr<boost::property_tree::ptree> params) | |
laplace._dof_handler, laplace._constraints, a, material_property); | ||
mfmg::Hierarchy<DVector> hierarchy(comm, evaluator, params); | ||
|
||
pcout << "Grid complexity : " << hierarchy.grid_complexity() << std::endl; | ||
pcout << "Operator complexity: " << hierarchy.operator_complexity() | ||
<< std::endl; | ||
// pcout << "Grid complexity : " << hierarchy.grid_complexity() << | ||
// std::endl; pcout << "Operator complexity: " << | ||
// hierarchy.operator_complexity() | ||
// << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove do not comment it out. What is the rational for having/not having these print to the standard output? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll remove them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check with @Rombur. I don't have an opinion on this and I am not sure why it was here in the 1st place. |
||
|
||
// We want to do 20 V-cycle iterations. The rhs of is zero. | ||
// Use D(istributed)Vector because deal has its own Vector class | ||
|
@@ -161,8 +162,9 @@ BOOST_DATA_TEST_CASE( | |
bdata::make({"hyper_cube", "hyper_ball"}) * bdata::make({false, true}) * | ||
bdata::make({"None", "Reverse Cuthill_McKee"}) * | ||
bdata::make<std::string>({"DealIIMeshEvaluator", | ||
"DealIIMatrixFreeMeshEvaluator"}), | ||
mesh, distort_random, reordering, mesh_evaluator_type) | ||
"DealIIMatrixFreeMeshEvaluator"}) * | ||
bdata::make<std::string>({"lapack", "lanczos"}), | ||
mesh, distort_random, reordering, mesh_evaluator_type, eigensolver) | ||
{ | ||
// TODO investigate why there is large difference in convergence rate when | ||
// running in parallel. | ||
|
@@ -180,7 +182,7 @@ BOOST_DATA_TEST_CASE( | |
params->put("smoother.type", "Chebyshev"); | ||
} | ||
|
||
params->put("eigensolver.type", "lapack"); | ||
params->put("eigensolver.type", eigensolver); | ||
params->put("agglomeration.nz", 2); | ||
params->put("laplace.n_refinements", 2); | ||
params->put("laplace.mesh", mesh); | ||
|
@@ -193,35 +195,51 @@ BOOST_DATA_TEST_CASE( | |
|
||
// This is a gold standard test. Not the greatest but it makes sure we don't | ||
// break the code | ||
std::map<std::tuple<std::string, bool, std::string>, double> ref_solution; | ||
ref_solution[std::make_tuple("hyper_cube", false, "None")] = | ||
is_matrix_free ? 0.1482630509 : 0.0491724046; | ||
ref_solution[std::make_tuple("hyper_cube", false, | ||
"Reverse Cuthill_McKee")] = | ||
is_matrix_free ? 0.1482630509 : 0.0491724046; | ||
ref_solution[std::make_tuple("hyper_cube", true, "None")] = | ||
is_matrix_free ? 0.1575262224 : 0.0488984875; | ||
ref_solution[std::make_tuple("hyper_cube", true, "Reverse Cuthill_McKee")] = | ||
is_matrix_free ? 0.1575262224 : 0.0488984875; | ||
ref_solution[std::make_tuple("hyper_ball", false, "None")] = | ||
ref_solution[std::make_tuple("hyper_ball", false, | ||
"Reverse Cuthill_McKee")] = | ||
is_matrix_free ? 0.3022004744 : 0.1146629782; | ||
ref_solution[std::make_tuple("hyper_ball", true, "None")] = | ||
is_matrix_free ? 0.2977841482 : 0.1024334788; | ||
ref_solution[std::make_tuple("hyper_ball", true, "Reverse Cuthill_McKee")] = | ||
is_matrix_free ? 0.2977841482 : 0.1024334788; | ||
|
||
if (mesh == std::string("hyper_cube")) | ||
BOOST_TEST( | ||
conv_rate == | ||
ref_solution[std::make_tuple(mesh, distort_random, reordering)], | ||
tt::tolerance(1e-6)); | ||
else | ||
BOOST_TEST( | ||
conv_rate == | ||
ref_solution[std::make_tuple(mesh, distort_random, reordering)], | ||
tt::tolerance(1e-6)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you comment here? Did we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
// (geometry, distortion, reordering, eigensolver, matrix-free) | ||
std::map<std::tuple<std::string, bool, std::string, std::string, bool>, | ||
double> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability: I would prefer a string or a scoped enumeration to denote matrix-free mode. |
||
ref_solution; | ||
// clang-format off | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability: Good call ! |
||
ref_solution[std::make_tuple("hyper_cube" , false , "None" , "lapack" , false)] = 0.0491724046; | ||
ref_solution[std::make_tuple("hyper_cube" , false , "None" , "lapack" , true)] = 0.1482630509; | ||
ref_solution[std::make_tuple("hyper_cube" , false , "Reverse Cuthill_McKee" , "lapack" , false)] = 0.0491724046; | ||
ref_solution[std::make_tuple("hyper_cube" , false , "Reverse Cuthill_McKee" , "lapack" , true)] = 0.1482630509; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "None" , "lapack" , false)] = 0.0488984875; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "None" , "lapack" , true)] = 0.1575262224; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "Reverse Cuthill_McKee" , "lapack" , false)] = 0.0488984875; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "Reverse Cuthill_McKee" , "lapack" , true)] = 0.1575262224; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "None" , "lapack" , false)] = 0.1146629782; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "None" , "lapack" , true)] = 0.3022004744; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "Reverse Cuthill_McKee" , "lapack" , false)] = 0.1146629782; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "Reverse Cuthill_McKee" , "lapack" , true)] = 0.3022004744; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "None" , "lapack" , false)] = 0.1024334788; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "None" , "lapack" , true)] = 0.2977841482; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "Reverse Cuthill_McKee" , "lapack" , false)] = 0.1024334788; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "Reverse Cuthill_McKee" , "lapack" , true)] = 0.2977841482; | ||
|
||
ref_solution[std::make_tuple("hyper_cube" , false , "None" , "lanczos" , false)] = 0.0491724046; | ||
ref_solution[std::make_tuple("hyper_cube" , false , "None" , "lanczos" , true)] = 0.1482630509; | ||
ref_solution[std::make_tuple("hyper_cube" , false , "Reverse Cuthill_McKee" , "lanczos" , false)] = 0.0491724046; | ||
ref_solution[std::make_tuple("hyper_cube" , false , "Reverse Cuthill_McKee" , "lanczos" , true)] = 0.1482630509; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "None" , "lanczos" , false)] = 0.0488968016; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "None" , "lanczos" , true)] = 0.1575200977; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "Reverse Cuthill_McKee" , "lanczos" , false)] = 0.0488968016; | ||
ref_solution[std::make_tuple("hyper_cube" , true , "Reverse Cuthill_McKee" , "lanczos" , true)] = 0.1575200977; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "None" , "lanczos" , false)] = 0.0953745739; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "None" , "lanczos" , true)] = 0.3017812295; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "Reverse Cuthill_McKee" , "lanczos" , false)] = 0.0953745739; | ||
ref_solution[std::make_tuple("hyper_ball" , false , "Reverse Cuthill_McKee" , "lanczos" , true)] = 0.3017812295; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "None" , "lanczos" , false)] = 0.0966058675; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "None" , "lanczos" , true)] = 0.2982453175; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "Reverse Cuthill_McKee" , "lanczos" , false)] = 0.0966058675; | ||
ref_solution[std::make_tuple("hyper_ball" , true , "Reverse Cuthill_McKee" , "lanczos" , true)] = 0.2982453175; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TL;DR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The values are really close but not sure how robust the thing is. Lanczos test now fails, so I may need to play around with things. The whole thing is annoying, but proper fix is unclear. |
||
// clang-format on | ||
|
||
BOOST_TEST( | ||
conv_rate == | ||
ref_solution[std::make_tuple(mesh, distort_random, reordering, | ||
eigensolver, is_matrix_free)], | ||
tt::tolerance(1e-6)); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,16 @@ | |
#include <deal.II/lac/la_parallel_vector.h> | ||
|
||
#include <boost/property_tree/info_parser.hpp> | ||
#include <boost/test/data/test_case.hpp> | ||
|
||
#include <random> | ||
|
||
#include "laplace.hpp" | ||
#include "main.cc" | ||
|
||
namespace utf = boost::unit_test; | ||
namespace bdata = boost::unit_test::data; | ||
namespace tt = boost::test_tools; | ||
|
||
template <int dim> | ||
class DummyMeshEvaluator : public mfmg::DealIIMeshEvaluator<dim> | ||
|
@@ -279,7 +282,8 @@ class TestMeshEvaluator : public mfmg::DealIIMeshEvaluator<dim> | |
|
||
// FIXME relaxed tolerance from 1e-14 to 1e-4 for this test to pass while using | ||
// ARPACK's regular mode instead of shift-and-invert | ||
BOOST_AUTO_TEST_CASE(weight_sum, *utf::tolerance(1e-4)) | ||
BOOST_DATA_TEST_CASE(weight_sum, bdata::make({"lapack", "lanczos"}), | ||
eigensolver) | ||
{ | ||
// Check that the weight sum is equal to one | ||
unsigned int constexpr dim = 2; | ||
|
@@ -295,6 +299,7 @@ BOOST_AUTO_TEST_CASE(weight_sum, *utf::tolerance(1e-4)) | |
|
||
auto params = std::make_shared<boost::property_tree::ptree>(); | ||
boost::property_tree::info_parser::read_info("hierarchy_input.info", *params); | ||
params->put("eigensolver.type", eigensolver); | ||
params->put("eigensolver.number of eigenvectors", 1); | ||
auto agglomerate_ptree = params->get_child("agglomeration"); | ||
int n_eigenvectors = | ||
|
@@ -311,7 +316,8 @@ BOOST_AUTO_TEST_CASE(weight_sum, *utf::tolerance(1e-4)) | |
|
||
TestMeshEvaluator<dim> evaluator(laplace._dof_handler, laplace._constraints, | ||
laplace._system_matrix); | ||
mfmg::AMGe_host<dim, MeshEvaluator, DVector> amge(comm, laplace._dof_handler); | ||
mfmg::AMGe_host<dim, MeshEvaluator, DVector> amge( | ||
comm, laplace._dof_handler, params->get_child("eigensolver")); | ||
|
||
auto locally_relevant_global_diag = evaluator.get_diagonal(); | ||
|
||
|
@@ -334,6 +340,6 @@ BOOST_AUTO_TEST_CASE(weight_sum, *utf::tolerance(1e-4)) | |
e[i] = 1.; | ||
e.compress(::dealii::VectorOperation::insert); | ||
restrictor_matrix.vmult(ee, e); | ||
BOOST_TEST(ee.l1_norm() == 1.); | ||
BOOST_TEST(ee.l1_norm() == 1., tt::tolerance(1e-4)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the rational for having the floating point comparison manipulation in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was not sure that |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to commit that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this is all in progress. I need to put a lot more comments about why I'm doing things this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do so.