changed: replace boost::any with std::any

This commit is contained in:
Arne Morten Kvarving 2020-02-19 10:14:49 +01:00
parent 39f5e49289
commit 4ba7d3a7bc
8 changed files with 23 additions and 21 deletions

View File

@ -537,7 +537,7 @@ namespace Opm
std::unique_ptr<EbosSimulator> ebosSimulator_; std::unique_ptr<EbosSimulator> ebosSimulator_;
int mpi_rank_ = 0; int mpi_rank_ = 0;
int mpi_size_ = 1; int mpi_size_ = 1;
boost::any parallel_information_; std::any parallel_information_;
std::unique_ptr<Simulator> simulator_; std::unique_ptr<Simulator> simulator_;
}; };
} // namespace Opm } // namespace Opm

View File

@ -27,6 +27,8 @@
#include <opm/simulators/linalg/ParallelIstlInformation.hpp> #include <opm/simulators/linalg/ParallelIstlInformation.hpp>
#include <opm/core/props/BlackoilPhases.hpp> #include <opm/core/props/BlackoilPhases.hpp>
#include <any>
namespace Opm { namespace Opm {
namespace detail { namespace detail {
@ -103,7 +105,7 @@ namespace detail {
/// \param pinfo In a parallel this holds the information about the data distribution. /// \param pinfo In a parallel this holds the information about the data distribution.
template <class Iterator> template <class Iterator>
inline inline
double euclidianNormSquared( Iterator it, const Iterator end, int num_components, const boost::any& pinfo = boost::any() ) double euclidianNormSquared( Iterator it, const Iterator end, int num_components, const std::any& pinfo = std::any() )
{ {
static_cast<void>(num_components); // Suppress warning in the serial case. static_cast<void>(num_components); // Suppress warning in the serial case.
static_cast<void>(pinfo); // Suppress warning in non-MPI case. static_cast<void>(pinfo); // Suppress warning in non-MPI case.
@ -111,7 +113,7 @@ namespace detail {
if ( pinfo.type() == typeid(ParallelISTLInformation) ) if ( pinfo.type() == typeid(ParallelISTLInformation) )
{ {
const ParallelISTLInformation& info = const ParallelISTLInformation& info =
boost::any_cast<const ParallelISTLInformation&>(pinfo); std::any_cast<const ParallelISTLInformation&>(pinfo);
typedef typename Iterator::value_type Scalar; typedef typename Iterator::value_type Scalar;
Scalar product = 0.0; Scalar product = 0.0;
int size_per_component = (end - it); int size_per_component = (end - it);

View File

@ -27,7 +27,7 @@
#if defined(HAVE_OPM_GRID) #if defined(HAVE_OPM_GRID)
#if defined(HAVE_MPI) && defined(HAVE_DUNE_ISTL) #if defined(HAVE_MPI) && defined(HAVE_DUNE_ISTL)
// Extracts the information about the data decomposition from the grid for dune-istl // Extracts the information about the data decomposition from the grid for dune-istl
void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, boost::any& anyComm) void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, std::any& anyComm)
{ {
if(grid.comm().size()>1) if(grid.comm().size()>1)
{ {
@ -35,14 +35,14 @@ void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, boost::any&
Dune::CpGrid& mgrid=const_cast<Dune::CpGrid&>(grid); Dune::CpGrid& mgrid=const_cast<Dune::CpGrid&>(grid);
Dune::CpGrid::ParallelIndexSet& idx=mgrid.getCellIndexSet(); Dune::CpGrid::ParallelIndexSet& idx=mgrid.getCellIndexSet();
Dune::CpGrid::RemoteIndices& ridx=mgrid.getCellRemoteIndices(); Dune::CpGrid::RemoteIndices& ridx=mgrid.getCellRemoteIndices();
anyComm=boost::any(Opm::ParallelISTLInformation(Dune::stackobject_to_shared_ptr(idx), anyComm=std::any(Opm::ParallelISTLInformation(Dune::stackobject_to_shared_ptr(idx),
Dune::stackobject_to_shared_ptr(ridx), Dune::stackobject_to_shared_ptr(ridx),
grid.comm())); grid.comm()));
} }
} }
#else #else
// Missing support for MPI or dune-istl -> do nothing. // Missing support for MPI or dune-istl -> do nothing.
void extractParallelGridInformationToISTL(const Dune::CpGrid&, boost::any&) void extractParallelGridInformationToISTL(const Dune::CpGrid&, std::any&)
{} {}
#endif //defined(HAVE_MPI) && defined(HAVE_DUNE_ISTL) #endif //defined(HAVE_MPI) && defined(HAVE_DUNE_ISTL)
#endif //defined(HAVE_OPM_GRID) #endif //defined(HAVE_OPM_GRID)

View File

@ -22,7 +22,7 @@
#ifdef HAVE_OPM_GRID #ifdef HAVE_OPM_GRID
#include<opm/grid/CpGrid.hpp> #include<opm/grid/CpGrid.hpp>
#include<boost/any.hpp> #include <any>
namespace Opm namespace Opm
{ {
@ -37,11 +37,11 @@ namespace Opm
/// \param[out] anyComm The handle to to store the information in. If grid is a parallel grid /// \param[out] anyComm The handle to to store the information in. If grid is a parallel grid
/// then this will ecapsulate an instance of ParallelISTLInformation. /// then this will ecapsulate an instance of ParallelISTLInformation.
void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, boost::any& anyComm); void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, std::any& anyComm);
// Grid is not CpGrid --> do nothing. // Grid is not CpGrid --> do nothing.
template <class Grid> template <class Grid>
void extractParallelGridInformationToISTL(const Grid&, boost::any&) void extractParallelGridInformationToISTL(const Grid&, std::any&)
{} {}
} // end namespace Opm } // end namespace Opm

View File

@ -123,14 +123,14 @@ public:
WellModelMatrixAdapter (const M& A, WellModelMatrixAdapter (const M& A,
const M& A_for_precond, const M& A_for_precond,
const WellModel& wellMod, const WellModel& wellMod,
const boost::any& parallelInformation OPM_UNUSED_NOMPI = boost::any() ) const std::any& parallelInformation OPM_UNUSED_NOMPI = std::any() )
: A_( A ), A_for_precond_(A_for_precond), wellMod_( wellMod ), comm_() : A_( A ), A_for_precond_(A_for_precond), wellMod_( wellMod ), comm_()
{ {
#if HAVE_MPI #if HAVE_MPI
if( parallelInformation.type() == typeid(ParallelISTLInformation) ) if( parallelInformation.type() == typeid(ParallelISTLInformation) )
{ {
const ParallelISTLInformation& info = const ParallelISTLInformation& info =
boost::any_cast<const ParallelISTLInformation&>( parallelInformation); std::any_cast<const ParallelISTLInformation&>( parallelInformation);
comm_.reset( new communication_type( info.communicator() ) ); comm_.reset( new communication_type( info.communicator() ) );
} }
#endif #endif
@ -375,7 +375,7 @@ protected:
int iterations () const { return iterations_; } int iterations () const { return iterations_; }
/// \copydoc NewtonIterationBlackoilInterface::parallelInformation /// \copydoc NewtonIterationBlackoilInterface::parallelInformation
const boost::any& parallelInformation() const { return parallelInformation_; } const std::any& parallelInformation() const { return parallelInformation_; }
protected: protected:
/// \brief construct the CPR preconditioner and the solver. /// \brief construct the CPR preconditioner and the solver.
@ -568,7 +568,7 @@ protected:
if (parallelInformation_.type() == typeid(ParallelISTLInformation)) if (parallelInformation_.type() == typeid(ParallelISTLInformation))
{ {
const ParallelISTLInformation& info = const ParallelISTLInformation& info =
boost::any_cast<const ParallelISTLInformation&>( parallelInformation_); std::any_cast<const ParallelISTLInformation&>( parallelInformation_);
Comm istlComm(info.communicator()); Comm istlComm(info.communicator());
// Construct operator, scalar product and vectors needed. // Construct operator, scalar product and vectors needed.
@ -604,7 +604,7 @@ protected:
{ {
const size_t size = opA.getmat().N(); const size_t size = opA.getmat().N();
const ParallelISTLInformation& info = const ParallelISTLInformation& info =
boost::any_cast<const ParallelISTLInformation&>( parallelInformation_); std::any_cast<const ParallelISTLInformation&>( parallelInformation_);
// As we use a dune-istl with block size np the number of components // As we use a dune-istl with block size np the number of components
// per parallel is only one. // per parallel is only one.
@ -939,7 +939,7 @@ protected:
const Simulator& simulator_; const Simulator& simulator_;
mutable int iterations_; mutable int iterations_;
mutable bool converged_; mutable bool converged_;
boost::any parallelInformation_; std::any parallelInformation_;
std::unique_ptr<Matrix> matrix_; std::unique_ptr<Matrix> matrix_;
std::unique_ptr<Matrix> noGhostMat_; std::unique_ptr<Matrix> noGhostMat_;

View File

@ -135,7 +135,7 @@ namespace Opm
const size_t size = opAParallel_->getmat().N(); const size_t size = opAParallel_->getmat().N();
const ParallelISTLInformation& info = const ParallelISTLInformation& info =
boost::any_cast<const ParallelISTLInformation&>( this->parallelInformation_); std::any_cast<const ParallelISTLInformation&>( this->parallelInformation_);
// As we use a dune-istl with block size np the number of components // As we use a dune-istl with block size np the number of components
// per parallel is only one. // per parallel is only one.

View File

@ -81,7 +81,7 @@ public:
#if HAVE_MPI #if HAVE_MPI
if (parallelInformation_.type() == typeid(ParallelISTLInformation)) { if (parallelInformation_.type() == typeid(ParallelISTLInformation)) {
// Parallel case. // Parallel case.
const ParallelISTLInformation* parinfo = boost::any_cast<ParallelISTLInformation>(&parallelInformation_); const ParallelISTLInformation* parinfo = std::any_cast<ParallelISTLInformation>(&parallelInformation_);
assert(parinfo); assert(parinfo);
comm_.reset(new Communication(parinfo->communicator())); comm_.reset(new Communication(parinfo->communicator()));
} }
@ -98,7 +98,7 @@ public:
static bool firstcall = true; static bool firstcall = true;
if (firstcall && parallelInformation_.type() == typeid(ParallelISTLInformation)) { if (firstcall && parallelInformation_.type() == typeid(ParallelISTLInformation)) {
// Parallel case. // Parallel case.
const ParallelISTLInformation* parinfo = boost::any_cast<ParallelISTLInformation>(&parallelInformation_); const ParallelISTLInformation* parinfo = std::any_cast<ParallelISTLInformation>(&parallelInformation_);
assert(parinfo); assert(parinfo);
const size_t size = mat.istlMatrix().N(); const size_t size = mat.istlMatrix().N();
parinfo->copyValuesTo(comm_->indexSet(), comm_->remoteIndices(), size, 1); parinfo->copyValuesTo(comm_->indexSet(), comm_->remoteIndices(), size, 1);
@ -205,7 +205,7 @@ protected:
boost::property_tree::ptree prm_; boost::property_tree::ptree prm_;
VectorType rhs_; VectorType rhs_;
Dune::InverseOperatorResult res_; Dune::InverseOperatorResult res_;
boost::any parallelInformation_; std::any parallelInformation_;
#if HAVE_MPI #if HAVE_MPI
std::unique_ptr<Communication> comm_; std::unique_ptr<Communication> comm_;
#endif #endif

View File

@ -24,7 +24,7 @@
#include <opm/grid/UnstructuredGrid.h> #include <opm/grid/UnstructuredGrid.h>
#include <opm/common/ErrorMacros.hpp> #include <opm/common/ErrorMacros.hpp>
#include <boost/any.hpp> #include <any>
#include <exception> #include <exception>
#include <algorithm> #include <algorithm>
@ -671,7 +671,7 @@ namespace Opm
/// then this will ecapsulate an instance of ParallelISTLInformation. /// then this will ecapsulate an instance of ParallelISTLInformation.
/// \param grid The grid to inspect. /// \param grid The grid to inspect.
inline void extractParallelGridInformationToISTL(boost::any& anyComm, const UnstructuredGrid& grid) inline void extractParallelGridInformationToISTL(std::any& anyComm, const UnstructuredGrid& grid)
{ {
(void)anyComm; (void)grid; (void)anyComm; (void)grid;
} }