Use macro for instantiations, and clean up includes.

This commit is contained in:
Atgeirr Flø Rasmussen 2020-06-19 16:37:43 +02:00
parent 171656144f
commit 427eac5132
7 changed files with 43 additions and 137 deletions

View File

@ -24,11 +24,7 @@
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/solvers.hh>
#include <dune/istl/umfpack.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/solver.hh>
#include <dune/istl/paamg/pinfo.hh>
#include <boost/property_tree/ptree.hpp>

View File

@ -20,37 +20,5 @@
#include "config.h"
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
#include <opm/simulators/linalg/matrixblock.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/solvers.hh>
#include <dune/istl/umfpack.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/paamg/pinfo.hh>
// Explicit instantiations of FlexibleSolver
template <int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>;
template <int N>
using BM = Dune::BCRSMatrix<Dune::FieldMatrix<double, N, N>>;
template <int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>;
// Variants using Dune::FieldMatrix blocks.
template class Dune::FlexibleSolver<BM<1>, BV<1>>;
// Variants using Opm::MatrixBlock blocks.
template class Dune::FlexibleSolver<OBM<1>, BV<1>>;
#if HAVE_MPI
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
template Dune::FlexibleSolver<OBM<1>, BV<1>>::FlexibleSolver(const MatrixType& matrix,
const Comm& comm,
const boost::property_tree::ptree& prm,
const std::function<BV<1>()>& weightsCalculator);
#endif // HAVE_MPI
INSTANTIATE_FLEXIBLESOLVER(1);

View File

@ -20,37 +20,5 @@
#include "config.h"
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
#include <opm/simulators/linalg/matrixblock.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/solvers.hh>
#include <dune/istl/umfpack.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/paamg/pinfo.hh>
// Explicit instantiations of FlexibleSolver
template <int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>;
template <int N>
using BM = Dune::BCRSMatrix<Dune::FieldMatrix<double, N, N>>;
template <int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>;
// Variants using Dune::FieldMatrix blocks.
template class Dune::FlexibleSolver<BM<2>, BV<2>>;
// Variants using Opm::MatrixBlock blocks.
template class Dune::FlexibleSolver<OBM<2>, BV<2>>;
#if HAVE_MPI
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
template Dune::FlexibleSolver<OBM<2>, BV<2>>::FlexibleSolver(const MatrixType& matrix,
const Comm& comm,
const boost::property_tree::ptree& prm,
const std::function<BV<2>()>& weightsCalculator);
#endif // HAVE_MPI
INSTANTIATE_FLEXIBLESOLVER(2);

View File

@ -20,37 +20,5 @@
#include "config.h"
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
#include <opm/simulators/linalg/matrixblock.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/solvers.hh>
#include <dune/istl/umfpack.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/paamg/pinfo.hh>
// Explicit instantiations of FlexibleSolver
template <int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>;
template <int N>
using BM = Dune::BCRSMatrix<Dune::FieldMatrix<double, N, N>>;
template <int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>;
// Variants using Dune::FieldMatrix blocks.
template class Dune::FlexibleSolver<BM<3>, BV<3>>;
// Variants using Opm::MatrixBlock blocks.
template class Dune::FlexibleSolver<OBM<3>, BV<3>>;
#if HAVE_MPI
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
template Dune::FlexibleSolver<OBM<3>, BV<3>>::FlexibleSolver(const MatrixType& matrix,
const Comm& comm,
const boost::property_tree::ptree& prm,
const std::function<BV<3>()>& weightsCalculator);
#endif // HAVE_MPI
INSTANTIATE_FLEXIBLESOLVER(3);

View File

@ -20,37 +20,5 @@
#include "config.h"
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
#include <opm/simulators/linalg/matrixblock.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/solvers.hh>
#include <dune/istl/umfpack.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/paamg/pinfo.hh>
// Explicit instantiations of FlexibleSolver
template <int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>;
template <int N>
using BM = Dune::BCRSMatrix<Dune::FieldMatrix<double, N, N>>;
template <int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>;
// Variants using Dune::FieldMatrix blocks.
template class Dune::FlexibleSolver<BM<4>, BV<4>>;
// Variants using Opm::MatrixBlock blocks.
template class Dune::FlexibleSolver<OBM<4>, BV<4>>;
#if HAVE_MPI
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
template Dune::FlexibleSolver<OBM<4>, BV<4>>::FlexibleSolver(const MatrixType& matrix,
const Comm& comm,
const boost::property_tree::ptree& prm,
const std::function<BV<4>()>& weightsCalculator);
#endif // HAVE_MPI
INSTANTIATE_FLEXIBLESOLVER(4);

View File

@ -188,4 +188,38 @@ namespace Dune
} // namespace Dune
// Macros to simplify explicit instantiation of FlexibleSolver for various block sizes.
template <int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>;
template <int N>
using BM = Dune::BCRSMatrix<Dune::FieldMatrix<double, N, N>>;
template <int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>;
// INSTANTIATE_CONSTRUCTOR instantiates the constructor that is a template,
// this is only needed in the MPI case, since otherwise the Comm type is
// not a template argument but always SequentialInformation.
#if HAVE_MPI
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
#define INSTANTIATE_FLEXIBLESOLVER_CONSTRUCTOR(n) \
template Dune::FlexibleSolver<OBM<n>, BV<n>>::FlexibleSolver(const MatrixType& matrix, \
const Comm& comm, \
const boost::property_tree::ptree& prm, \
const std::function<BV<n>()>& weightsCalculator);
#else
#define INSTANTIATE_FLEXIBLESOLVER_CONSTRUCTOR(n)
#endif
// INSTANTIATE instantiates the class including any templated constructors if necessary.
#define INSTANTIATE_FLEXIBLESOLVER(n) \
/* Variants using Dune::FieldMatrix blocks. */ \
template class Dune::FlexibleSolver<BM<n>, BV<n>>; \
/* Variants using Opm::MatrixBlock blocks. */ \
template class Dune::FlexibleSolver<OBM<n>, BV<n>>; \
INSTANTIATE_FLEXIBLESOLVER_CONSTRUCTOR(n)
#endif // OPM_FLEXIBLE_SOLVER_IMPL_HEADER_INCLUDED

View File

@ -31,6 +31,10 @@
#include <opm/simulators/linalg/FlexibleSolver.hpp>
#include <opm/simulators/linalg/getQuasiImpesWeights.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>