From fc3057caedf406b9bf430167a1d7ce02f800bdc3 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Fri, 6 Apr 2018 12:04:43 -0400 Subject: [PATCH] Use child property tree --- include/mfmg/dealii_adapters.hpp | 15 ++++++++------- include/mfmg/dealii_operator.templates.hpp | 4 ++-- tests/data/hierarchy_input.info | 22 +++++++++++++++++----- tests/test_hierarchy.cc | 4 ++-- tests/test_restriction_matrix.cc | 10 +++++----- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/include/mfmg/dealii_adapters.hpp b/include/mfmg/dealii_adapters.hpp index 74e7b7b4..87638a43 100644 --- a/include/mfmg/dealii_adapters.hpp +++ b/include/mfmg/dealii_adapters.hpp @@ -166,17 +166,18 @@ class Adapter> mesh_type &mesh, std::shared_ptr params) { + auto eigensolver_params = params->get_child("eigensolver"); AMGe_host amge( - comm, mesh._dof_handler, params->get("eigensolver: type", "arpack")); + comm, mesh._dof_handler, eigensolver_params.get("type", "arpack")); std::array agglomerate_dim; - agglomerate_dim[0] = params->get("agglomeration: nx"); - agglomerate_dim[1] = params->get("agglomeration: ny"); + auto agglomerate_params = params->get_child("agglomeration"); + agglomerate_dim[0] = agglomerate_params.get("nx"); + agglomerate_dim[1] = agglomerate_params.get("ny"); if (dim == 3) - agglomerate_dim[2] = params->get("agglomeration: nz"); - int n_eigenvectors = - params->get("eigensolver: number of eigenvectors", 1); - double tolerance = params->get("eigensolver: tolerance", 1e-14); + agglomerate_dim[2] = agglomerate_params.get("nz"); + int n_eigenvectors = eigensolver_params.get("number of eigenvectors", 1); + double tolerance = eigensolver_params.get("tolerance", 1e-14); auto restrictor_matrix = std::make_shared(); diff --git a/include/mfmg/dealii_operator.templates.hpp b/include/mfmg/dealii_operator.templates.hpp index 5e585b6c..690147b4 100644 --- a/include/mfmg/dealii_operator.templates.hpp +++ b/include/mfmg/dealii_operator.templates.hpp @@ -149,8 +149,8 @@ DealIISmootherOperator::DealIISmootherOperator( std::shared_ptr params) : _matrix(matrix) { - std::string prec_type = params->get("preconditioner: type", - "Symmetric Gauss-Seidel"); + std::string prec_type = + params->get("smoother.type", "Symmetric Gauss-Seidel"); initialize(prec_type); } diff --git a/tests/data/hierarchy_input.info b/tests/data/hierarchy_input.info index a7d0eb42..7abbc4a8 100644 --- a/tests/data/hierarchy_input.info +++ b/tests/data/hierarchy_input.info @@ -1,9 +1,21 @@ -"eigensolver: number of eigenvectors" 2 -"eigensolver: tolerance" 1e-14 -"preconditioner: type" "Gauss-Seidel" +eigensolver +{ + "number of eigenvectors" 2 + tolerance 1e-14 +} + +smoother +{ + type "Gauss-Seidel" +} + "is preconditioner" false -"agglomeration: nx" 2 -"agglomeration: ny" 2 + +agglomeration +{ + nx 2 + ny 2 +} material_property { diff --git a/tests/test_hierarchy.cc b/tests/test_hierarchy.cc index 98915adf..ae645dbd 100644 --- a/tests/test_hierarchy.cc +++ b/tests/test_hierarchy.cc @@ -322,8 +322,8 @@ BOOST_DATA_TEST_CASE(hierarchy_3d, boost::property_tree::info_parser::read_info("hierarchy_input.info", *params); - params->put("eigensolver: type", "lapack"); - params->put("agglomeration: nz", 2); + params->put("eigensolver.type", "lapack"); + params->put("agglomeration.nz", 2); params->put("laplace.n_refinements", 2); params->put("laplace.mesh", mesh); params->put("laplace.distort_random", distort_random); diff --git a/tests/test_restriction_matrix.cc b/tests/test_restriction_matrix.cc index e2c761e4..3fca21b4 100644 --- a/tests/test_restriction_matrix.cc +++ b/tests/test_restriction_matrix.cc @@ -254,13 +254,13 @@ BOOST_AUTO_TEST_CASE(weight_sum, *utf::tolerance(1e-14)) auto params = std::make_shared(); boost::property_tree::info_parser::read_info("hierarchy_input.info", *params); - params->put("eigensolver: number of eigenvectors", 1); + params->put("eigensolver.number of eigenvectors", 1); std::array agglomerate_dim; - agglomerate_dim[0] = params->get("agglomeration: nx"); - agglomerate_dim[1] = params->get("agglomeration: ny"); + agglomerate_dim[0] = params->get("agglomeration.nx"); + agglomerate_dim[1] = params->get("agglomeration.ny"); int n_eigenvectors = - params->get("eigensolver: number of eigenvectors", 1); - double tolerance = params->get("eigensolver: tolerance", 1e-14); + params->get("eigensolver.number of eigenvectors", 1); + double tolerance = params->get("eigensolver.tolerance", 1e-14); params->put("laplace.n_refinements", 4); std::shared_ptr> material_property =