mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added: PropertyTree class
this is a thin wrapper around boost::property_tree with this we avoid parsing property tree headers in all simulator objects
This commit is contained in:
@@ -296,8 +296,9 @@ void runBlackoilAmgLaplace()
|
||||
Dune::OverlappingSchwarzScalarProduct<Vector,Communication> sp(comm);
|
||||
Dune::InverseOperatorResult r;
|
||||
|
||||
boost::property_tree::ptree prm;
|
||||
prm.put("type", "amg");
|
||||
using namespace std::string_literals;
|
||||
Opm::PropertyTree prm;
|
||||
prm.put("type", "amg"s);
|
||||
std::function<Vector()> weights = [&mat]() {
|
||||
return Opm::Amg::getQuasiImpesWeights<BCRSMat, Vector>(mat, 0, false);
|
||||
};
|
||||
|
@@ -30,20 +30,19 @@
|
||||
|
||||
#include <opm/simulators/linalg/FlexibleSolver.hpp>
|
||||
#include <opm/simulators/linalg/getQuasiImpesWeights.hpp>
|
||||
#include <opm/simulators/linalg/PropertyTree.hpp>
|
||||
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <dune/istl/bcrsmatrix.hh>
|
||||
#include <dune/istl/matrixmarket.hh>
|
||||
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
template <int bz>
|
||||
Dune::BlockVector<Dune::FieldVector<double, bz>>
|
||||
testSolver(const boost::property_tree::ptree& prm, const std::string& matrix_filename, const std::string& rhs_filename)
|
||||
testSolver(const Opm::PropertyTree& prm, const std::string& matrix_filename, const std::string& rhs_filename)
|
||||
{
|
||||
using Matrix = Dune::BCRSMatrix<Dune::FieldMatrix<double, bz, bz>>;
|
||||
using Vector = Dune::BlockVector<Dune::FieldVector<double, bz>>;
|
||||
@@ -86,15 +85,8 @@ testSolver(const boost::property_tree::ptree& prm, const std::string& matrix_fil
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestFlexibleSolver)
|
||||
{
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree prm;
|
||||
|
||||
// Read parameters.
|
||||
{
|
||||
std::ifstream file("options_flexiblesolver.json");
|
||||
pt::read_json(file, prm);
|
||||
// pt::write_json(std::cout, prm);
|
||||
}
|
||||
Opm::PropertyTree prm("options_flexiblesolver.json");
|
||||
|
||||
// Test with 1x1 block solvers.
|
||||
{
|
||||
|
@@ -29,6 +29,7 @@
|
||||
BOOST_VERSION / 100 % 1000 > 48
|
||||
|
||||
#include <opm/simulators/linalg/PreconditionerFactory.hpp>
|
||||
#include <opm/simulators/linalg/PropertyTree.hpp>
|
||||
#include <opm/simulators/linalg/FlexibleSolver.hpp>
|
||||
|
||||
#include <dune/common/fvector.hh>
|
||||
@@ -37,9 +38,6 @@
|
||||
#include <dune/istl/matrixmarket.hh>
|
||||
#include <dune/istl/solvers.hh>
|
||||
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
@@ -70,7 +68,7 @@ public:
|
||||
|
||||
template <int bz>
|
||||
Dune::BlockVector<Dune::FieldVector<double, bz>>
|
||||
testPrec(const boost::property_tree::ptree& prm, const std::string& matrix_filename, const std::string& rhs_filename)
|
||||
testPrec(const Opm::PropertyTree& prm, const std::string& matrix_filename, const std::string& rhs_filename)
|
||||
{
|
||||
using Matrix = Dune::BCRSMatrix<Dune::FieldMatrix<double, bz, bz>>;
|
||||
using Vector = Dune::BlockVector<Dune::FieldVector<double, bz>>;
|
||||
@@ -113,9 +111,7 @@ testPrec(const boost::property_tree::ptree& prm, const std::string& matrix_filen
|
||||
return x;
|
||||
}
|
||||
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
void test1(const pt::ptree& prm)
|
||||
void test1(const Opm::PropertyTree& prm)
|
||||
{
|
||||
const int bz = 1;
|
||||
auto sol = testPrec<bz>(prm, "matr33.txt", "rhs3.txt");
|
||||
@@ -136,7 +132,7 @@ void test1(const pt::ptree& prm)
|
||||
}
|
||||
}
|
||||
|
||||
void test3(const pt::ptree& prm)
|
||||
void test3(const Opm::PropertyTree& prm)
|
||||
{
|
||||
const int bz = 3;
|
||||
auto sol = testPrec<bz>(prm, "matr33.txt", "rhs3.txt");
|
||||
@@ -155,13 +151,8 @@ void test3(const pt::ptree& prm)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestDefaultPreconditionerFactory)
|
||||
{
|
||||
pt::ptree prm;
|
||||
|
||||
// Read parameters.
|
||||
{
|
||||
std::ifstream file("options_flexiblesolver.json");
|
||||
pt::read_json(file, prm);
|
||||
}
|
||||
Opm::PropertyTree prm("options_flexiblesolver.json");
|
||||
|
||||
// Test with 1x1 block solvers.
|
||||
test1(prm);
|
||||
@@ -183,14 +174,8 @@ using PF = Opm::PreconditionerFactory<O<bz>>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestAddingPreconditioner)
|
||||
{
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree prm;
|
||||
|
||||
// Read parameters.
|
||||
{
|
||||
std::ifstream file("options_flexiblesolver_simple.json"); // Requests "nothing" for preconditioner type.
|
||||
pt::read_json(file, prm);
|
||||
}
|
||||
Opm::PropertyTree prm("options_flexiblesolver_simple.json");
|
||||
|
||||
// Test with 1x1 block solvers.
|
||||
{
|
||||
@@ -206,7 +191,7 @@ BOOST_AUTO_TEST_CASE(TestAddingPreconditioner)
|
||||
|
||||
|
||||
// Add preconditioner to factory for block size 1.
|
||||
PF<1>::addCreator("nothing", [](const O<1>&, const pt::ptree&, const std::function<V<1>()>&) {
|
||||
PF<1>::addCreator("nothing", [](const O<1>&, const Opm::PropertyTree&, const std::function<V<1>()>&) {
|
||||
return Dune::wrapPreconditioner<NothingPreconditioner<V<1>>>();
|
||||
});
|
||||
|
||||
@@ -221,7 +206,7 @@ BOOST_AUTO_TEST_CASE(TestAddingPreconditioner)
|
||||
}
|
||||
|
||||
// Add preconditioner to factory for block size 3.
|
||||
PF<3>::addCreator("nothing", [](const O<3>&, const pt::ptree&, const std::function<V<3>()>&) {
|
||||
PF<3>::addCreator("nothing", [](const O<3>&, const Opm::PropertyTree&, const std::function<V<3>()>&) {
|
||||
return Dune::wrapPreconditioner<NothingPreconditioner<V<3>>>();
|
||||
});
|
||||
|
||||
@@ -288,7 +273,7 @@ protected:
|
||||
|
||||
template <int bz>
|
||||
Dune::BlockVector<Dune::FieldVector<double, bz>>
|
||||
testPrecRepeating(const boost::property_tree::ptree& prm, const std::string& matrix_filename, const std::string& rhs_filename)
|
||||
testPrecRepeating(const Opm::PropertyTree& prm, const std::string& matrix_filename, const std::string& rhs_filename)
|
||||
{
|
||||
using Matrix = Dune::BCRSMatrix<Dune::FieldMatrix<double, bz, bz>>;
|
||||
using Vector = Dune::BlockVector<Dune::FieldVector<double, bz>>;
|
||||
@@ -313,7 +298,7 @@ testPrecRepeating(const boost::property_tree::ptree& prm, const std::string& mat
|
||||
using PrecFactory = Opm::PreconditionerFactory<Operator>;
|
||||
|
||||
// Add no-oppreconditioner to factory for block size 1.
|
||||
PrecFactory::addCreator("nothing", [](const Operator&, const pt::ptree&, const std::function<Vector()>&) {
|
||||
PrecFactory::addCreator("nothing", [](const Operator&, const Opm::PropertyTree&, const std::function<Vector()>&) {
|
||||
return Dune::wrapPreconditioner<NothingPreconditioner<Vector>>();
|
||||
});
|
||||
|
||||
@@ -325,7 +310,7 @@ testPrecRepeating(const boost::property_tree::ptree& prm, const std::string& mat
|
||||
return x;
|
||||
}
|
||||
|
||||
void test1rep(const pt::ptree& prm)
|
||||
void test1rep(const Opm::PropertyTree& prm)
|
||||
{
|
||||
const int bz = 1;
|
||||
auto sol = testPrecRepeating<bz>(prm, "matr33rep.txt", "rhs3rep.txt");
|
||||
@@ -346,7 +331,7 @@ void test1rep(const pt::ptree& prm)
|
||||
}
|
||||
}
|
||||
|
||||
void test3rep(const pt::ptree& prm)
|
||||
void test3rep(const Opm::PropertyTree& prm)
|
||||
{
|
||||
const int bz = 3;
|
||||
auto sol = testPrecRepeating<bz>(prm, "matr33rep.txt", "rhs3rep.txt");
|
||||
@@ -366,13 +351,8 @@ void test3rep(const pt::ptree& prm)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestWithRepeatingOperator)
|
||||
{
|
||||
pt::ptree prm;
|
||||
|
||||
// Read parameters.
|
||||
{
|
||||
std::ifstream file("options_flexiblesolver_simple.json");
|
||||
pt::read_json(file, prm);
|
||||
}
|
||||
Opm::PropertyTree prm("options_flexiblesolver_simple.json");
|
||||
|
||||
// Test with 1x1 block solvers.
|
||||
test1rep(prm);
|
||||
|
Reference in New Issue
Block a user