FlexibleSolver: optionally instantiate for float

PreconditionerFactory: optionally instantiate for float

these need to go in the same commit due to circular dependencies
This commit is contained in:
Arne Morten Kvarving 2024-04-13 16:01:11 +02:00
parent d244f49813
commit 1cc27754d8
14 changed files with 150 additions and 100 deletions

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
INSTANTIATE_FLEXIBLESOLVER(1);
INSTANTIATE_FLEXIBLESOLVER(double,1)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FLEXIBLESOLVER(float,1)
#endif

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
INSTANTIATE_FLEXIBLESOLVER(2);
INSTANTIATE_FLEXIBLESOLVER(double,2)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FLEXIBLESOLVER(float,2)
#endif

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
INSTANTIATE_FLEXIBLESOLVER(3);
INSTANTIATE_FLEXIBLESOLVER(double,3)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FLEXIBLESOLVER(float,3)
#endif

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
INSTANTIATE_FLEXIBLESOLVER(4);
INSTANTIATE_FLEXIBLESOLVER(double,4)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FLEXIBLESOLVER(float,4)
#endif

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
INSTANTIATE_FLEXIBLESOLVER(5);
INSTANTIATE_FLEXIBLESOLVER(double,5)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FLEXIBLESOLVER(float,5)
#endif

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp>
INSTANTIATE_FLEXIBLESOLVER(6);
INSTANTIATE_FLEXIBLESOLVER(double,6)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FLEXIBLESOLVER(float,6)
#endif

View File

@ -265,57 +265,57 @@ namespace Dune
// Macros to simplify explicit instantiation of FlexibleSolver for various block sizes.
// Vectors and matrices.
template <int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>;
template <int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>;
template<class Scalar, int N>
using BV = Dune::BlockVector<Dune::FieldVector<Scalar, N>>;
template<class Scalar, int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, N, N>>;
// Sequential operators.
template <int N>
using SeqOpM = Dune::MatrixAdapter<OBM<N>, BV<N>, BV<N>>;
template <int N>
using SeqOpW = Opm::WellModelMatrixAdapter<OBM<N>, BV<N>, BV<N>, false>;
template<class Scalar, int N>
using SeqOpM = Dune::MatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>>;
template<class Scalar, int N>
using SeqOpW = Opm::WellModelMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, false>;
#if HAVE_MPI
// Parallel communicator and operators.
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
template <int N>
using ParOpM = Opm::GhostLastMatrixAdapter<OBM<N>, BV<N>, BV<N>, Comm>;
template <int N>
using ParOpW = Opm::WellModelGhostLastMatrixAdapter<OBM<N>, BV<N>, BV<N>, true>;
template <int N>
using ParOpD = Dune::OverlappingSchwarzOperator<OBM<N>, BV<N>, BV<N>, Comm>;
template<class Scalar, int N>
using ParOpM = Opm::GhostLastMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, Comm>;
template<class Scalar, int N>
using ParOpW = Opm::WellModelGhostLastMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, true>;
template<class Scalar, int N>
using ParOpD = Dune::OverlappingSchwarzOperator<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, Comm>;
// Note: we must instantiate the constructor that is a template.
// This is only needed in the parallel case, since otherwise the Comm type is
// not a template argument but always SequentialInformation.
#define INSTANTIATE_FLEXIBLESOLVER_OP(Operator) \
template class Dune::FlexibleSolver<Operator>; \
template Dune::FlexibleSolver<Operator>::FlexibleSolver(Operator& op, \
const Comm& comm, \
const Opm::PropertyTree& prm, \
const std::function<typename Operator::domain_type()>& weightsCalculator, \
std::size_t pressureIndex);
#define INSTANTIATE_FLEXIBLESOLVER(N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpM<N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpW<N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpD<N>);
#define INSTANTIATE_FLEXIBLESOLVER_OP(...) \
template class Dune::FlexibleSolver<__VA_ARGS__>; \
template Dune::FlexibleSolver<__VA_ARGS__>:: \
FlexibleSolver(__VA_ARGS__& op, \
const Comm& comm, \
const Opm::PropertyTree& prm, \
const std::function<typename __VA_ARGS__::domain_type()>& weightsCalculator, \
std::size_t pressureIndex);
#define INSTANTIATE_FLEXIBLESOLVER(T,N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpM<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpW<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpD<T,N>);
#else // HAVE_MPI
#define INSTANTIATE_FLEXIBLESOLVER_OP(Operator) \
template class Dune::FlexibleSolver<Operator>;
#define INSTANTIATE_FLEXIBLESOLVER_OP(...) \
template class Dune::FlexibleSolver<__VA_ARGS__>;
#define INSTANTIATE_FLEXIBLESOLVER(N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<N>);
#define INSTANTIATE_FLEXIBLESOLVER(T,N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<T,N>);
#endif // HAVE_MPI
#endif // OPM_FLEXIBLE_SOLVER_IMPL_HEADER_INCLUDED

View File

@ -4,6 +4,10 @@
namespace Opm {
INSTANCE_PF(1)
INSTANTIATE_PF(double,1)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_PF(float,1)
#endif
}

View File

@ -4,6 +4,10 @@
namespace Opm {
INSTANCE_PF(2)
INSTANTIATE_PF(double,2)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_PF(float,2)
#endif
}

View File

@ -4,6 +4,10 @@
namespace Opm {
INSTANCE_PF(3)
INSTANTIATE_PF(double,3)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_PF(float,3)
#endif
}

View File

@ -4,6 +4,10 @@
namespace Opm {
INSTANCE_PF(4)
INSTANTIATE_PF(double,4)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_PF(float,4)
#endif
}

View File

@ -4,6 +4,10 @@
namespace Opm {
INSTANCE_PF(5)
INSTANTIATE_PF(double,5)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_PF(float,5)
#endif
}

View File

@ -4,6 +4,11 @@
namespace Opm {
INSTANCE_PF(6)
INSTANTIATE_PF(double,6)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_PF(float,6)
#endif
}

View File

@ -17,12 +17,14 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/TimingMacros.hpp>
#include <opm/simulators/linalg/PreconditionerFactory.hpp>
#include <opm/simulators/linalg/DILU.hpp>
#include <opm/simulators/linalg/ExtraSmoothers.hpp>
#include <opm/simulators/linalg/FlexibleSolver.hpp>
@ -44,8 +46,6 @@
#include <dune/istl/paamg/kamg.hh>
#include <dune/istl/preconditioners.hh>
#include <config.h>
// Include all cuistl/GPU preconditioners inside of this headerfile
#include <opm/simulators/linalg/PreconditionerFactoryGPUIncludeWrapper.hpp>
@ -778,76 +778,77 @@ PreconditionerFactory<Operator, Comm>::addCreator(const std::string& type, ParCr
using CommSeq = Dune::Amg::SequentialInformation;
template <int Dim>
using OpFSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>>;
template <int Dim>
using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>>;
template<class Scalar, int Dim>
using OpFSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>>;
template<class Scalar, int Dim>
using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>>;
template <int Dim, bool overlap>
using OpW = WellModelMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
template<class Scalar, int Dim, bool overlap>
using OpW = WellModelMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
overlap>;
template <int Dim, bool overlap>
using OpWG = WellModelGhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
template<class Scalar, int Dim, bool overlap>
using OpWG = WellModelGhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
overlap>;
#if HAVE_MPI
using CommPar = Dune::OwnerOverlapCopyCommunication<int, int>;
template <int Dim>
using OpFPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<Dune::FieldMatrix<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
template<class Scalar, int Dim>
using OpFPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
CommPar>;
template <int Dim>
using OpBPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
template<class Scalar, int Dim>
using OpBPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
CommPar>;
template<int Dim>
using OpGLFPar = Opm::GhostLastMatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<double,Dim,Dim>>,
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
template<class Scalar, int Dim>
using OpGLFPar = Opm::GhostLastMatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<Scalar,Dim,Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
CommPar>;
template<int Dim>
using OpGLBPar = Opm::GhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double,Dim,Dim>>,
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
template<class Scalar, int Dim>
using OpGLBPar = Opm::GhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar,Dim,Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
CommPar>;
#define INSTANCE_PF_PAR(Dim) \
template class PreconditionerFactory<OpBSeq<Dim>, CommPar>; \
template class PreconditionerFactory<OpFPar<Dim>, CommPar>; \
template class PreconditionerFactory<OpBPar<Dim>, CommPar>; \
template class PreconditionerFactory<OpGLFPar<Dim>,CommPar>; \
template class PreconditionerFactory<OpGLBPar<Dim>,CommPar>; \
template class PreconditionerFactory<OpW<Dim, false>, CommPar>; \
template class PreconditionerFactory<OpWG<Dim, true>, CommPar>; \
template class PreconditionerFactory<OpBPar<Dim>,CommSeq>; \
template class PreconditionerFactory<OpGLBPar<Dim>,CommSeq>;
#define INSTANTIATE_PF_PAR(T,Dim) \
template class PreconditionerFactory<OpBSeq<T,Dim>, CommPar>; \
template class PreconditionerFactory<OpFPar<T,Dim>, CommPar>; \
template class PreconditionerFactory<OpBPar<T,Dim>, CommPar>; \
template class PreconditionerFactory<OpGLFPar<T,Dim>, CommPar>; \
template class PreconditionerFactory<OpGLBPar<T,Dim>, CommPar>; \
template class PreconditionerFactory<OpW<T,Dim, false>, CommPar>; \
template class PreconditionerFactory<OpWG<T,Dim, true>, CommPar>; \
template class PreconditionerFactory<OpBPar<T,Dim>, CommSeq>; \
template class PreconditionerFactory<OpGLBPar<T,Dim>, CommSeq>;
#endif
#define INSTANCE_PF_SEQ(Dim) \
template class PreconditionerFactory<OpFSeq<Dim>, CommSeq>; \
template class PreconditionerFactory<OpBSeq<Dim>, CommSeq>; \
template class PreconditionerFactory<OpW<Dim, false>, CommSeq>; \
template class PreconditionerFactory<OpWG<Dim, true>, CommSeq>;
#define INSTANTIATE_PF_SEQ(T,Dim) \
template class PreconditionerFactory<OpFSeq<T,Dim>, CommSeq>; \
template class PreconditionerFactory<OpBSeq<T,Dim>, CommSeq>; \
template class PreconditionerFactory<OpW<T,Dim, false>, CommSeq>; \
template class PreconditionerFactory<OpWG<T,Dim, true>, CommSeq>;
#if HAVE_MPI
#define INSTANCE_PF(Dim) \
INSTANCE_PF_PAR(Dim) \
INSTANCE_PF_SEQ(Dim)
#define INSTANTIATE_PF(T,Dim) \
INSTANTIATE_PF_PAR(T,Dim) \
INSTANTIATE_PF_SEQ(T,Dim)
#else
#define INSTANCE_PF(Dim) INSTANCE_PF_SEQ(Dim)
#define INSTANTIATE_PF(T,Dim) INSTANTIATE_PF_SEQ(T,Dim)
#endif
} // namespace Opm