Merge pull request #1185 from blattms/allow_amg_with_flow_ebos_umfpack

Allow usage of AMG if flow_ebos is used and UMFPack is available.
This commit is contained in:
dr-robertk
2017-05-22 13:27:17 +02:00
committed by GitHub
5 changed files with 18 additions and 7 deletions

View File

@@ -124,7 +124,7 @@ namespace Opm {
typedef Dune::BCRSMatrix <MatrixBlockType> Mat;
typedef Dune::BlockVector<VectorBlockType> BVector;
typedef ISTLSolver< MatrixBlockType, VectorBlockType > ISTLSolverType;
typedef ISTLSolver< MatrixBlockType, VectorBlockType, BlackoilIndices::pressureSwitchIdx > ISTLSolverType;
//typedef typename SolutionVector :: value_type PrimaryVariables ;
// For the conversion between the surface volume rate and resrevoir voidage rate

View File

@@ -276,7 +276,7 @@ createEllipticPreconditionerPointer(const M& Ae, double relax,
/// \param relax The relaxation parameter for ILU0.
/// \param comm The object describing the parallelization information and communication.
// \param amgPtr The unique_ptr to be filled (return)
template <class Op, class P, class AMG >
template <class Op, class P, class AMG, int pressureIndex=0 >
inline void
createAMGPreconditionerPointer( Op& opA, const double relax, const P& comm, std::unique_ptr< AMG >& amgPtr )
{
@@ -284,7 +284,7 @@ createAMGPreconditionerPointer( Op& opA, const double relax, const P& comm, std:
typedef typename Op::matrix_type M;
// The coupling metric used in the AMG
typedef Dune::Amg::FirstDiagonal CouplingMetric;
typedef Dune::Amg::Diagonal<pressureIndex> CouplingMetric;
// The coupling criterion used in the AMG
typedef Dune::Amg::SymmetricCriterion<M, CouplingMetric> CritBase;

View File

@@ -23,6 +23,8 @@
#ifndef OPM_FLOWMAIN_HEADER_INCLUDED
#define OPM_FLOWMAIN_HEADER_INCLUDED
// Define making clear that the simulator supports AMG
#define FLOW_SUPPORT_AMG !defined(HAVE_UMFPACK)
#include <opm/common/utility/platform_dependent/disable_warnings.h>

View File

@@ -23,8 +23,12 @@
#ifndef OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
#define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
// Define making clear that the simulator supports AMG
#define FLOW_SUPPORT_AMG
#include <sys/utsname.h>
#include <opm/simulators/ParallelFileMerger.hpp>
#include <opm/simulators/ensureDirectoryExists.hpp>

View File

@@ -174,7 +174,12 @@ namespace Opm
/// solving the reduced system (after eliminating well variables)
/// as a block-structured matrix (one block for all cell variables) for a fixed
/// number of cell variables np .
template < class MatrixBlockType, class VectorBlockType >
/// \tparam MatrixBlockType The type of the matrix block used.
/// \tparam VectorBlockType The type of the vector block used.
/// \tparam pressureIndex The index of the pressure component in the vector
/// vector block. It is used to guide the AMG coarsening.
/// Default is zero.
template < class MatrixBlockType, class VectorBlockType, int pressureIndex=0 >
class ISTLSolver : public NewtonIterationBlackoilInterface
{
typedef typename MatrixBlockType :: field_type Scalar;
@@ -249,7 +254,7 @@ namespace Opm
// Communicate if parallel.
parallelInformation_arg.copyOwnerToAll(istlb, istlb);
#if ! HAVE_UMFPACK
#if FLOW_SUPPORT_AMG // activate AMG if either flow_ebos is used or UMFPack is not available
if( parameters_.linear_solver_use_amg_ )
{
typedef ISTLUtility::CPRSelector< Matrix, Vector, Vector, POrComm> CPRSelectorType;
@@ -311,7 +316,7 @@ namespace Opm
void
constructAMGPrecond(LinearOperator& /* linearOperator */, const POrComm& comm, std::unique_ptr< AMG >& amg, std::unique_ptr< MatrixOperator >& opA, const double relax ) const
{
ISTLUtility::createAMGPreconditionerPointer( *opA, relax, comm, amg );
ISTLUtility::createAMGPreconditionerPointer<pressureIndex>( *opA, relax, comm, amg );
}
@@ -319,7 +324,7 @@ namespace Opm
void
constructAMGPrecond(MatrixOperator& opA, const POrComm& comm, std::unique_ptr< AMG >& amg, std::unique_ptr< MatrixOperator >&, const double relax ) const
{
ISTLUtility::createAMGPreconditionerPointer( opA, relax, comm, amg );
ISTLUtility::createAMGPreconditionerPointer<pressureIndex>( opA, relax, comm, amg );
}
/// \brief Solve the system using the given preconditioner and scalar product.