Skip to content

Commit

Permalink
Merge pull request #48 from Rombur/ptree
Browse files Browse the repository at this point in the history
Use child property tree
  • Loading branch information
aprokop authored Apr 6, 2018
2 parents 862d7df + fc3057c commit ab74042
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
15 changes: 8 additions & 7 deletions include/mfmg/dealii_adapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,18 @@ class Adapter<DealIIMeshEvaluator<dim, VectorType>>
mesh_type &mesh,
std::shared_ptr<boost::property_tree::ptree> params)
{
auto eigensolver_params = params->get_child("eigensolver");
AMGe_host<mesh_type::dimension(), mesh_evaluator_type, vector_type> amge(
comm, mesh._dof_handler, params->get("eigensolver: type", "arpack"));
comm, mesh._dof_handler, eigensolver_params.get("type", "arpack"));

std::array<unsigned int, dim> agglomerate_dim;
agglomerate_dim[0] = params->get<unsigned int>("agglomeration: nx");
agglomerate_dim[1] = params->get<unsigned int>("agglomeration: ny");
auto agglomerate_params = params->get_child("agglomeration");
agglomerate_dim[0] = agglomerate_params.get<unsigned int>("nx");
agglomerate_dim[1] = agglomerate_params.get<unsigned int>("ny");
if (dim == 3)
agglomerate_dim[2] = params->get<unsigned int>("agglomeration: nz");
int n_eigenvectors =
params->get<int>("eigensolver: number of eigenvectors", 1);
double tolerance = params->get<double>("eigensolver: tolerance", 1e-14);
agglomerate_dim[2] = agglomerate_params.get<unsigned int>("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<typename global_operator_type::matrix_type>();
Expand Down
4 changes: 2 additions & 2 deletions include/mfmg/dealii_operator.templates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ DealIISmootherOperator<VectorType>::DealIISmootherOperator(
std::shared_ptr<boost::property_tree::ptree> params)
: _matrix(matrix)
{
std::string prec_type = params->get<std::string>("preconditioner: type",
"Symmetric Gauss-Seidel");
std::string prec_type =
params->get("smoother.type", "Symmetric Gauss-Seidel");
initialize(prec_type);
}

Expand Down
22 changes: 17 additions & 5 deletions tests/data/hierarchy_input.info
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions tests/test_hierarchy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tests/test_restriction_matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ BOOST_AUTO_TEST_CASE(weight_sum, *utf::tolerance(1e-14))

auto params = std::make_shared<boost::property_tree::ptree>();
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<unsigned int, dim> agglomerate_dim;
agglomerate_dim[0] = params->get<unsigned int>("agglomeration: nx");
agglomerate_dim[1] = params->get<unsigned int>("agglomeration: ny");
agglomerate_dim[0] = params->get<unsigned int>("agglomeration.nx");
agglomerate_dim[1] = params->get<unsigned int>("agglomeration.ny");
int n_eigenvectors =
params->get<int>("eigensolver: number of eigenvectors", 1);
double tolerance = params->get<double>("eigensolver: tolerance", 1e-14);
params->get<int>("eigensolver.number of eigenvectors", 1);
double tolerance = params->get<double>("eigensolver.tolerance", 1e-14);

params->put("laplace.n_refinements", 4);
std::shared_ptr<dealii::Function<dim>> material_property =
Expand Down

0 comments on commit ab74042

Please sign in to comment.