Merge pull request #5550 from akva2/float_support3

Float support in simulators: Batch 3
This commit is contained in:
Bård Skaflestad 2024-08-23 10:29:14 +02:00 committed by GitHub
commit 3dbeed2199
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 627 additions and 403 deletions

View File

@ -35,6 +35,12 @@ foreach(CL ${CL_LIST})
file(READ "${CL}" CL_CONTENT) file(READ "${CL}" CL_CONTENT)
file(APPEND ${CL_SRC_FILE} "${CL_CONTENT}") file(APPEND ${CL_SRC_FILE} "${CL_CONTENT}")
file(APPEND ${CL_SRC_FILE} "\)\"; \n\n") file(APPEND ${CL_SRC_FILE} "\)\"; \n\n")
if(BUILD_FLOW_FLOAT_VARIANTS)
string(REPLACE double float CL_CONTENT "${CL_CONTENT}")
file(APPEND ${CL_SRC_FILE} "template<> const std::string OpenclKernels<float>::${FNAME}_str = R\"\( \n")
file(APPEND ${CL_SRC_FILE} "${CL_CONTENT}")
file(APPEND ${CL_SRC_FILE} "\)\"; \n\n")
endif()
if(DEBUG_OPENCL_KERNELS_INTEL) if(DEBUG_OPENCL_KERNELS_INTEL)
execute_process( execute_process(

View File

@ -224,4 +224,8 @@ void BlackoilModelParameters<Scalar>::registerParameters()
template struct BlackoilModelParameters<double>; template struct BlackoilModelParameters<double>;
#if FLOW_INSTANTIATE_FLOAT
template struct BlackoilModelParameters<float>;
#endif
} // namespace Opm } // namespace Opm

View File

@ -37,42 +37,85 @@
namespace Opm { namespace Opm {
template class GenericTracerModel<Dune::CpGrid, #define INSTANTIATE_TYPE(T) \
Dune::GridView<Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>, template class GenericTracerModel<Dune::CpGrid, \
Dune::MultipleCodimMultipleGeomTypeMapper<Dune::GridView<Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>>, Dune::GridView< \
Opm::EcfvStencil<double,Dune::GridView<Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>,false,false>, Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>, \
BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>, Dune::MultipleCodimMultipleGeomTypeMapper< \
double>; Dune::GridView< \
Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>>, \
EcfvStencil<T,Dune::GridView< \
Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>, \
false,false>, \
BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>, \
T>;
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
#if HAVE_DUNE_FEM #if HAVE_DUNE_FEM
#if DUNE_VERSION_GTE(DUNE_FEM, 2, 9) #if DUNE_VERSION_GTE(DUNE_FEM, 2, 9)
using GV = Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, using GV = Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid,
(Dune::PartitionIteratorType)4, (Dune::PartitionIteratorType)4,
false>; false>;
template class GenericTracerModel<Dune::CpGrid, #define INSTANTIATE_FEM_TYPE(T) \
GV, template class GenericTracerModel<Dune::CpGrid, \
Dune::MultipleCodimMultipleGeomTypeMapper<GV>, GV, \
EcfvStencil<double, GV, false, false>, Dune::MultipleCodimMultipleGeomTypeMapper<GV>, \
BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>, EcfvStencil<T, GV, false, false>, \
double>; BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>, \
T>;
#else #else
template class GenericTracerModel<Dune::CpGrid, #define INSTANTIATE_FEM_TYPE(T) \
Dune::GridView<Dune::Fem::GridPart2GridViewTraits<Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, Dune::PartitionIteratorType(4), false>>>, template class GenericTracerModel<Dune::CpGrid, \
Dune::MultipleCodimMultipleGeomTypeMapper<Dune::GridView<Dune::Fem::GridPart2GridViewTraits<Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, Dune::PartitionIteratorType(4), false>>>>, Dune::GridView< \
EcfvStencil<double,Dune::GridView<Dune::Fem::GridPart2GridViewTraits<Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, Dune::PartitionIteratorType(4), false>>>,false,false>, Dune::Fem::GridPart2GridViewTraits< \
BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>, Dune::Fem::AdaptiveLeafGridPart< \
double>; Dune::CpGrid, \
template class GenericTracerModel<Dune::CpGrid, Dune::PartitionIteratorType(4), false>>>, \
Dune::Fem::GridPart2GridViewImpl<Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, (Dune::PartitionIteratorType)4, false> >, Dune::MultipleCodimMultipleGeomTypeMapper< \
Dune::MultipleCodimMultipleGeomTypeMapper< Dune::GridView< \
Dune::Fem::GridPart2GridViewImpl< Dune::Fem::GridPart2GridViewTraits< \
Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, Dune::PartitionIteratorType(4), false> > >, Dune::Fem::AdaptiveLeafGridPart< \
EcfvStencil<double, Dune::Fem::GridPart2GridViewImpl< Dune::CpGrid, \
Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, Dune::PartitionIteratorType(4), false> >, Dune::PartitionIteratorType(4), false>>>>, \
false, false>, EcfvStencil<T,Dune::GridView< \
BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>, Dune::Fem::GridPart2GridViewTraits< \
double>; Dune::Fem::AdaptiveLeafGridPart< \
Dune::CpGrid, \
Dune::PartitionIteratorType(4), \
false>>>, \
false,false>, \
BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>, \
T>; \
template class GenericTracerModel<Dune::CpGrid, \
Dune::Fem::GridPart2GridViewImpl< \
Dune::Fem::AdaptiveLeafGridPart< \
Dune::CpGrid, \
(Dune::PartitionIteratorType)4, false> >, \
Dune::MultipleCodimMultipleGeomTypeMapper< \
Dune::Fem::GridPart2GridViewImpl< \
Dune::Fem::AdaptiveLeafGridPart< \
Dune::CpGrid, \
Dune::PartitionIteratorType(4), false> > >, \
EcfvStencil<T, Dune::Fem::GridPart2GridViewImpl< \
Dune::Fem::AdaptiveLeafGridPart< \
Dune::CpGrid, \
Dune::PartitionIteratorType(4), false>>,\
false, false>, \
BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>, \
T>;
#endif #endif
INSTANTIATE_FEM_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_FEM_TYPE(float)
#endif
#endif // HAVE_DUNE_FEM #endif // HAVE_DUNE_FEM
} // namespace Opm } // namespace Opm

View File

@ -55,5 +55,9 @@ template<class Scalar> using FS = BlackOilFluidSystem<Scalar>;
INSTANTIATE_TYPE(double) INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} // namespace Equil } // namespace Equil
} // namespace Opm } // namespace Opm

View File

@ -53,7 +53,7 @@ namespace DeckDependent {
Dune::CpGrid, \ Dune::CpGrid, \
GridView, \ GridView, \
Mapper, \ Mapper, \
Dune::CartesianIndexMapper<Dune::CpGrid>>::\ Dune::CartesianIndexMapper<Dune::CpGrid>>:: \
InitialStateComputer(MatLaw<T>&, \ InitialStateComputer(MatLaw<T>&, \
const EclipseState&, \ const EclipseState&, \
const Dune::CpGrid&, \ const Dune::CpGrid&, \
@ -65,7 +65,11 @@ namespace DeckDependent {
using GridView = Dune::GridView<Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>; using GridView = Dune::GridView<Dune::DefaultLeafGridViewTraits<Dune::CpGrid>>;
using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>; using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
INSTANTIATE_COMP(double, GridView, Mapper) INSTANTIATE_COMP(double, GridView, Mapper)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_COMP(float, GridView, Mapper)
#endif
#if HAVE_DUNE_FEM #if HAVE_DUNE_FEM
#if DUNE_VERSION_GTE(DUNE_FEM, 2, 9) #if DUNE_VERSION_GTE(DUNE_FEM, 2, 9)
@ -83,6 +87,10 @@ using MapperFem = Dune::MultipleCodimMultipleGeomTypeMapper<GridViewFem>;
INSTANTIATE_COMP(double, GridViewFem, MapperFem) INSTANTIATE_COMP(double, GridViewFem, MapperFem)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_COMP(float, GridViewFem, MapperFem)
#endif
#endif // HAVE_DUNE_FEM #endif // HAVE_DUNE_FEM
} // namespace DeckDependent } // namespace DeckDependent
@ -100,6 +108,9 @@ namespace Details {
INSTANTIATE_TYPE(double) INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} }
} // namespace EQUIL } // namespace EQUIL

View File

@ -21,4 +21,8 @@
#include <opm/simulators/linalg/FlexibleSolver_impl.hpp> #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> #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> #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> #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> #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> #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

@ -195,9 +195,13 @@ namespace Dune
verbosity); verbosity);
#if HAVE_SUITESPARSE_UMFPACK #if HAVE_SUITESPARSE_UMFPACK
} else if (solver_type == "umfpack") { } else if (solver_type == "umfpack") {
if constexpr (std::is_same_v<typename VectorType::field_type,float>) {
OPM_THROW(std::invalid_argument, "UMFPack cannot be used with floats");
} else {
using MatrixType = std::remove_const_t<std::remove_reference_t<decltype(linearoperator_for_solver_->getmat())>>; using MatrixType = std::remove_const_t<std::remove_reference_t<decltype(linearoperator_for_solver_->getmat())>>;
linsolver_ = std::make_shared<Dune::UMFPack<MatrixType>>(linearoperator_for_solver_->getmat(), verbosity, false); linsolver_ = std::make_shared<Dune::UMFPack<MatrixType>>(linearoperator_for_solver_->getmat(), verbosity, false);
direct_solver_ = true; direct_solver_ = true;
}
#endif #endif
#if HAVE_CUDA #if HAVE_CUDA
} else if (solver_type == "cubicgstab") { } else if (solver_type == "cubicgstab") {
@ -227,8 +231,12 @@ namespace Dune
recreateDirectSolver() recreateDirectSolver()
{ {
#if HAVE_SUITESPARSE_UMFPACK #if HAVE_SUITESPARSE_UMFPACK
if constexpr (std::is_same_v<typename VectorType::field_type, float>) {
OPM_THROW(std::invalid_argument, "UMFPack cannot be used with floats");
} else {
using MatrixType = std::remove_const_t<std::remove_reference_t<decltype(linearoperator_for_solver_->getmat())>>; using MatrixType = std::remove_const_t<std::remove_reference_t<decltype(linearoperator_for_solver_->getmat())>>;
linsolver_ = std::make_shared<Dune::UMFPack<MatrixType>>(linearoperator_for_solver_->getmat(), 0, false); linsolver_ = std::make_shared<Dune::UMFPack<MatrixType>>(linearoperator_for_solver_->getmat(), 0, false);
}
#else #else
OPM_THROW(std::logic_error, "Direct solver specified, but the FlexibleSolver class was not compiled with SuiteSparse support."); OPM_THROW(std::logic_error, "Direct solver specified, but the FlexibleSolver class was not compiled with SuiteSparse support.");
#endif #endif
@ -257,57 +265,57 @@ namespace Dune
// Macros to simplify explicit instantiation of FlexibleSolver for various block sizes. // Macros to simplify explicit instantiation of FlexibleSolver for various block sizes.
// Vectors and matrices. // Vectors and matrices.
template <int N> template<class Scalar, int N>
using BV = Dune::BlockVector<Dune::FieldVector<double, N>>; using BV = Dune::BlockVector<Dune::FieldVector<Scalar, N>>;
template <int N> template<class Scalar, int N>
using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<double, N, N>>; using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, N, N>>;
// Sequential operators. // Sequential operators.
template <int N> template<class Scalar, int N>
using SeqOpM = Dune::MatrixAdapter<OBM<N>, BV<N>, BV<N>>; using SeqOpM = Dune::MatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>>;
template <int N> template<class Scalar, int N>
using SeqOpW = Opm::WellModelMatrixAdapter<OBM<N>, BV<N>, BV<N>, false>; using SeqOpW = Opm::WellModelMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, false>;
#if HAVE_MPI #if HAVE_MPI
// Parallel communicator and operators. // Parallel communicator and operators.
using Comm = Dune::OwnerOverlapCopyCommunication<int, int>; using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
template <int N> template<class Scalar, int N>
using ParOpM = Opm::GhostLastMatrixAdapter<OBM<N>, BV<N>, BV<N>, Comm>; using ParOpM = Opm::GhostLastMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, Comm>;
template <int N> template<class Scalar, int N>
using ParOpW = Opm::WellModelGhostLastMatrixAdapter<OBM<N>, BV<N>, BV<N>, true>; using ParOpW = Opm::WellModelGhostLastMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, true>;
template <int N> template<class Scalar, int N>
using ParOpD = Dune::OverlappingSchwarzOperator<OBM<N>, BV<N>, BV<N>, Comm>; using ParOpD = Dune::OverlappingSchwarzOperator<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, Comm>;
// Note: we must instantiate the constructor that is a template. // Note: we must instantiate the constructor that is a template.
// This is only needed in the parallel case, since otherwise the Comm type is // This is only needed in the parallel case, since otherwise the Comm type is
// not a template argument but always SequentialInformation. // not a template argument but always SequentialInformation.
#define INSTANTIATE_FLEXIBLESOLVER_OP(Operator) \ #define INSTANTIATE_FLEXIBLESOLVER_OP(...) \
template class Dune::FlexibleSolver<Operator>; \ template class Dune::FlexibleSolver<__VA_ARGS__>; \
template Dune::FlexibleSolver<Operator>::FlexibleSolver(Operator& op, \ template Dune::FlexibleSolver<__VA_ARGS__>:: \
FlexibleSolver(__VA_ARGS__& op, \
const Comm& comm, \ const Comm& comm, \
const Opm::PropertyTree& prm, \ const Opm::PropertyTree& prm, \
const std::function<typename Operator::domain_type()>& weightsCalculator, \ const std::function<typename __VA_ARGS__::domain_type()>& weightsCalculator, \
std::size_t pressureIndex); std::size_t pressureIndex);
#define INSTANTIATE_FLEXIBLESOLVER(N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<N>); \ #define INSTANTIATE_FLEXIBLESOLVER(T,N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<N>); \ INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpM<N>); \ INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpW<N>); \ INSTANTIATE_FLEXIBLESOLVER_OP(ParOpM<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpD<N>); INSTANTIATE_FLEXIBLESOLVER_OP(ParOpW<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(ParOpD<T,N>);
#else // HAVE_MPI #else // HAVE_MPI
#define INSTANTIATE_FLEXIBLESOLVER_OP(Operator) \ #define INSTANTIATE_FLEXIBLESOLVER_OP(...) \
template class Dune::FlexibleSolver<Operator>; template class Dune::FlexibleSolver<__VA_ARGS__>;
#define INSTANTIATE_FLEXIBLESOLVER(N) \ #define INSTANTIATE_FLEXIBLESOLVER(T,N) \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<N>); \ INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpM<T,N>); \
INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<N>); INSTANTIATE_FLEXIBLESOLVER_OP(SeqOpW<T,N>);
#endif // HAVE_MPI #endif // HAVE_MPI
#endif // OPM_FLEXIBLE_SOLVER_IMPL_HEADER_INCLUDED #endif // OPM_FLEXIBLE_SOLVER_IMPL_HEADER_INCLUDED

View File

@ -158,10 +158,10 @@ void FlexibleSolverInfo<Matrix,Vector,Comm>::create(const Matrix& matrix,
} }
} }
template<int Dim> template<class Scalar, int Dim>
using BM = Dune::BCRSMatrix<MatrixBlock<double,Dim,Dim>>; using BM = Dune::BCRSMatrix<MatrixBlock<Scalar,Dim,Dim>>;
template<int Dim> template<class Scalar, int Dim>
using BV = Dune::BlockVector<Dune::FieldVector<double,Dim>>; using BV = Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>;
#if HAVE_MPI #if HAVE_MPI
using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>; using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>;
@ -169,16 +169,23 @@ using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>;
using CommunicationType = Dune::Communication<int>; using CommunicationType = Dune::Communication<int>;
#endif #endif
#define INSTANCE_FLEX(Dim) \ #define INSTANTIATE_FLEX(T,Dim) \
template void makeOverlapRowsInvalid<BM<Dim>>(BM<Dim>&, const std::vector<int>&); \ template void makeOverlapRowsInvalid<BM<T,Dim>>(BM<T,Dim>&, const std::vector<int>&); \
template struct FlexibleSolverInfo<BM<Dim>,BV<Dim>,CommunicationType>; template struct FlexibleSolverInfo<BM<T,Dim>,BV<T,Dim>,CommunicationType>;
INSTANCE_FLEX(1) #define INSTANTIATE_TYPE(T) \
INSTANCE_FLEX(2) INSTANTIATE_FLEX(T,1) \
INSTANCE_FLEX(3) INSTANTIATE_FLEX(T,2) \
INSTANCE_FLEX(4) INSTANTIATE_FLEX(T,3) \
INSTANCE_FLEX(5) INSTANTIATE_FLEX(T,4) \
INSTANCE_FLEX(6) INSTANTIATE_FLEX(T,5) \
INSTANTIATE_FLEX(T,6)
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} }
} }

View File

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

View File

@ -17,17 +17,17 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>. along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <config.h> // CMake #include <config.h> // CMake
#include <opm/simulators/linalg/bda/MultisegmentWellContribution.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/TimingMacros.hpp> #include <opm/common/TimingMacros.hpp>
#if HAVE_UMFPACK #if HAVE_UMFPACK
#include <dune/istl/umfpack.hh> #include <dune/istl/umfpack.hh>
#endif // HAVE_UMFPACK #endif // HAVE_UMFPACK
#include <opm/simulators/linalg/bda/MultisegmentWellContribution.hpp> namespace Opm {
namespace Opm
{
template<class Scalar> template<class Scalar>
MultisegmentWellContribution<Scalar>:: MultisegmentWellContribution<Scalar>::
@ -59,15 +59,21 @@ MultisegmentWellContribution(unsigned int dim_, unsigned int dim_wells_,
z1.resize(Mb * dim_wells); z1.resize(Mb * dim_wells);
z2.resize(Mb * dim_wells); z2.resize(Mb * dim_wells);
if constexpr (std::is_same_v<Scalar,float>) {
OPM_THROW(std::runtime_error, "Cannot use multisegment wells with float");
} else {
umfpack_di_symbolic(M, M, Dcols.data(), Drows.data(), Dvals.data(), &UMFPACK_Symbolic, nullptr, nullptr); umfpack_di_symbolic(M, M, Dcols.data(), Drows.data(), Dvals.data(), &UMFPACK_Symbolic, nullptr, nullptr);
umfpack_di_numeric(Dcols.data(), Drows.data(), Dvals.data(), UMFPACK_Symbolic, &UMFPACK_Numeric, nullptr, nullptr); umfpack_di_numeric(Dcols.data(), Drows.data(), Dvals.data(), UMFPACK_Symbolic, &UMFPACK_Numeric, nullptr, nullptr);
}
} }
template<class Scalar> template<class Scalar>
MultisegmentWellContribution<Scalar>::~MultisegmentWellContribution() MultisegmentWellContribution<Scalar>::~MultisegmentWellContribution()
{ {
if constexpr (std::is_same_v<Scalar,double>) {
umfpack_di_free_symbolic(&UMFPACK_Symbolic); umfpack_di_free_symbolic(&UMFPACK_Symbolic);
umfpack_di_free_numeric(&UMFPACK_Numeric); umfpack_di_free_numeric(&UMFPACK_Numeric);
}
} }
// Apply the MultisegmentWellContribution, similar to MultisegmentWell::apply() // Apply the MultisegmentWellContribution, similar to MultisegmentWell::apply()
@ -98,7 +104,11 @@ void MultisegmentWellContribution<Scalar>::apply(Scalar* h_x, Scalar* h_y)
// z2 = D^-1 * (B * x) // z2 = D^-1 * (B * x)
// umfpack // umfpack
if constexpr (std::is_same_v<Scalar,float>) {
OPM_THROW(std::runtime_error, "Cannot use multisegment wells with float");
} else {
umfpack_di_solve(UMFPACK_A, Dcols.data(), Drows.data(), Dvals.data(), z2.data(), z1.data(), UMFPACK_Numeric, nullptr, nullptr); umfpack_di_solve(UMFPACK_A, Dcols.data(), Drows.data(), Dvals.data(), z2.data(), z1.data(), UMFPACK_Numeric, nullptr, nullptr);
}
// y -= (C^T * z2) // y -= (C^T * z2)
// y -= (C^T * (D^-1 * (B * x))) // y -= (C^T * (D^-1 * (B * x)))
@ -127,5 +137,9 @@ void MultisegmentWellContribution<Scalar>::setCudaStream(cudaStream_t stream_)
template class MultisegmentWellContribution<double>; template class MultisegmentWellContribution<double>;
#if FLOW_INSTANTIATE_FLOAT
template class MultisegmentWellContribution<float>;
#endif
} //namespace Opm } //namespace Opm

View File

@ -184,4 +184,8 @@ addMultisegmentWellContribution(unsigned int dim_,
template class WellContributions<double>; template class WellContributions<double>;
#if FLOW_INSTANTIATE_FLOAT
template class WellContributions<float>;
#endif
} //namespace Opm } //namespace Opm

View File

@ -262,5 +262,9 @@ void WellContributionsCuda<Scalar>::setCudaStream(cudaStream_t stream_)
template class WellContributionsCuda<double>; template class WellContributionsCuda<double>;
#if FLOW_INSTANTIATE_FLOAT
template class WellContributionsCuda<float>;
#endif
} //namespace Opm } //namespace Opm

View File

@ -561,4 +561,8 @@ void OpenclKernels<Scalar>::isaiU(cl::Buffer& diagIndex, cl::Buffer& colPointers
template class OpenclKernels<double>; template class OpenclKernels<double>;
#if FLOW_INSTANTIATE_FLOAT
template class OpenclKernels<float>;
#endif
} // namespace Opm::Accelerator } // namespace Opm::Accelerator

View File

@ -182,6 +182,10 @@ public:
DECLARE_INSTANCE(double) DECLARE_INSTANCE(double)
#if FLOW_INSTANTIATE_FLOAT
DECLARE_INSTANCE(float)
#endif
} // namespace Opm::Accelerator } // namespace Opm::Accelerator
#endif #endif

View File

@ -168,4 +168,8 @@ void WellContributionsOCL<Scalar>::APIalloc()
template class WellContributionsOCL<double>; template class WellContributionsOCL<double>;
#if FLOW_INSTANTIATE_FLOAT
template class WellContributionsOCL<float>;
#endif
} // namespace Opm } // namespace Opm

View File

@ -266,4 +266,8 @@ void WellContributionsRocsparse<Scalar>::APIalloc()
template class WellContributionsRocsparse<double>; template class WellContributionsRocsparse<double>;
#if FLOW_INSTANTIATE_FLOAT
template class WellContributionsRocsparse<float>;
#endif
} // namespace Opm } // namespace Opm

View File

@ -110,7 +110,9 @@ applyUMFPack(Dune::UMFPack<MatrixType>& linsolver,
// Object storing some statistics about the solving process // Object storing some statistics about the solving process
Dune::InverseOperatorResult res; Dune::InverseOperatorResult res;
if constexpr (std::is_same_v<typename VectorType::field_type,float>) {
OPM_THROW(std::runtime_error, "Cannot use applyUMFPack() with floats.");
} else {
// Solve // Solve
linsolver.apply(y, x, res); linsolver.apply(y, x, res);
@ -125,6 +127,7 @@ applyUMFPack(Dune::UMFPack<MatrixType>& linsolver,
} }
} }
} }
}
return y; return y;
#else #else
// this is not thread safe // this is not thread safe
@ -146,6 +149,9 @@ invertWithUMFPack(const int size,
// Make a full block matrix. // Make a full block matrix.
Dune::Matrix<typename MatrixType::block_type> inv(size, size); Dune::Matrix<typename MatrixType::block_type> inv(size, size);
if constexpr (std::is_same_v<typename VectorType::field_type,float>) {
OPM_THROW(std::runtime_error, "Cannot use invertWithUMFPack() with floats.");
} else {
// Create inverse by passing basis vectors to the solver. // Create inverse by passing basis vectors to the solver.
for (int ii = 0; ii < size; ++ii) { for (int ii = 0; ii < size; ++ii) {
for (int jj = 0; jj < bsize; ++jj) { for (int jj = 0; jj < bsize; ++jj) {
@ -159,6 +165,7 @@ invertWithUMFPack(const int size,
e[ii][jj] = 0.0; e[ii][jj] = 0.0;
} }
} }
}
return inv; return inv;
#else #else
@ -299,22 +306,19 @@ ValueType emulsionViscosity(const ValueType& water_fraction,
} }
} }
template<int Dim> template<class Scalar, int Dim>
using Vec = Dune::BlockVector<Dune::FieldVector<double,Dim>>; using Vec = Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>;
template<int Dim> template<class Scalar, int Dim>
using Mat = Dune::BCRSMatrix<Dune::FieldMatrix<double,Dim,Dim>>; using Mat = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar,Dim,Dim>>;
#define INSTANCE_UMF(Dim) \ #define INSTANTIATE_UMF(T,Dim) \
template Vec<Dim> applyUMFPack<Mat<Dim>,Vec<Dim>>(Dune::UMFPack<Mat<Dim>>&, \ template Vec<T,Dim> applyUMFPack(Dune::UMFPack<Mat<T,Dim>>&, \
Vec<Dim>); \ Vec<T,Dim>); \
template Dune::Matrix<typename Mat<Dim>::block_type> \ template Dune::Matrix<typename Mat<T,Dim>::block_type> \
invertWithUMFPack<Vec<Dim>,Mat<Dim>>(const int, const int, Dune::UMFPack<Mat<Dim>>&); invertWithUMFPack<Vec<T,Dim>,Mat<T,Dim>>(const int, const int, \
Dune::UMFPack<Mat<T,Dim>>&);
INSTANCE_UMF(2) #define INSTANTIATE_IMPL(T,...) \
INSTANCE_UMF(3)
INSTANCE_UMF(4)
#define INSTANCE_IMPL(T,...) \
template __VA_ARGS__ \ template __VA_ARGS__ \
frictionPressureLoss(const T, \ frictionPressureLoss(const T, \
const T, \ const T, \
@ -336,15 +340,25 @@ INSTANCE_UMF(4)
const __VA_ARGS__&, \ const __VA_ARGS__&, \
const SICD&); const SICD&);
#define INSTANCE_EVAL(Dim) \ #define INSTANTIATE_EVAL(T,Dim) \
INSTANCE_IMPL(double, DenseAd::Evaluation<double,Dim>) INSTANTIATE_IMPL(T, DenseAd::Evaluation<T,Dim>)
INSTANCE_EVAL(3) #define INSTANTIATE_TYPE(T) \
INSTANCE_EVAL(4) INSTANTIATE_UMF(T,2) \
INSTANCE_EVAL(5) INSTANTIATE_UMF(T,3) \
INSTANCE_EVAL(6) INSTANTIATE_UMF(T,4) \
INSTANCE_EVAL(7) INSTANTIATE_EVAL(T,3) \
INSTANCE_EVAL(8) INSTANTIATE_EVAL(T,4) \
INSTANCE_EVAL(9) INSTANTIATE_EVAL(T,5) \
INSTANTIATE_EVAL(T,6) \
INSTANTIATE_EVAL(T,7) \
INSTANTIATE_EVAL(T,8) \
INSTANTIATE_EVAL(T,9)
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} // namespace Opm::mswellhelpers } // namespace Opm::mswellhelpers

View File

@ -20,11 +20,13 @@
*/ */
#include <config.h> #include <config.h>
#include <opm/common/TimingMacros.hpp>
#include <opm/simulators/wells/MultisegmentWellEquations.hpp> #include <opm/simulators/wells/MultisegmentWellEquations.hpp>
#include <dune/istl/umfpack.hh> #include <dune/istl/umfpack.hh>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/TimingMacros.hpp>
#include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp> #include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp>
#if COMPILE_BDA_BRIDGE #if COMPILE_BDA_BRIDGE
@ -167,7 +169,12 @@ void MultisegmentWellEquations<Scalar,numWellEq,numEq>::createSolver()
return; return;
} }
if constexpr (std::is_same_v<Scalar,float>) {
OPM_THROW(std::runtime_error, "MultisegmentWell support requires UMFPACK, "
"and UMFPACK does not support float");
} else {
duneDSolver_ = std::make_shared<Dune::UMFPack<DiagMatWell>>(duneD_, 0); duneDSolver_ = std::make_shared<Dune::UMFPack<DiagMatWell>>(duneD_, 0);
}
#else #else
OPM_THROW(std::runtime_error, "MultisegmentWell support requires UMFPACK. " OPM_THROW(std::runtime_error, "MultisegmentWell support requires UMFPACK. "
"Reconfigure opm-simulators with SuiteSparse/UMFPACK support and recompile."); "Reconfigure opm-simulators with SuiteSparse/UMFPACK support and recompile.");
@ -225,6 +232,9 @@ extract(WellContributions<Scalar>& wellContribs) const
} }
// duneD // duneD
if constexpr (std::is_same_v<Scalar,float>) {
OPM_THROW(std::runtime_error, "Cannot use UMFPack with floats");
} else {
Dune::UMFPack<DiagMatWell> umfpackMatrix(duneD_, 0); Dune::UMFPack<DiagMatWell> umfpackMatrix(duneD_, 0);
double* Dvals = umfpackMatrix.getInternalMatrix().getValues(); double* Dvals = umfpackMatrix.getInternalMatrix().getValues();
auto* Dcols = umfpackMatrix.getInternalMatrix().getColStart(); auto* Dcols = umfpackMatrix.getInternalMatrix().getColStart();
@ -265,6 +275,7 @@ extract(WellContributions<Scalar>& wellContribs) const
Dcols, Dcols,
Drows, Drows,
Cvals); Cvals);
}
} }
#endif #endif
@ -386,27 +397,34 @@ extractCPRPressureMatrix(PressureMatrix& jacobian,
} }
} }
#define INSTANCE(numWellEq, numEq) \ #define INSTANTIATE(T, numWellEq, numEq) \
template class MultisegmentWellEquations<double,numWellEq,numEq>; \ template class MultisegmentWellEquations<T,numWellEq,numEq>; \
template void MultisegmentWellEquations<double,numWellEq,numEq>:: \ template void MultisegmentWellEquations<T,numWellEq,numEq>:: \
extract(Linear::IstlSparseMatrixAdapter<MatrixBlock<double,numEq,numEq>>&) const; \ extract(Linear::IstlSparseMatrixAdapter<MatrixBlock<T,numEq,numEq>>&) const; \
template void MultisegmentWellEquations<double,numWellEq,numEq>:: \ template void MultisegmentWellEquations<T,numWellEq,numEq>:: \
extractCPRPressureMatrix(Dune::BCRSMatrix<MatrixBlock<double,1,1>>&, \ extractCPRPressureMatrix(Dune::BCRSMatrix<MatrixBlock<T,1,1>>&, \
const MultisegmentWellEquations<double,numWellEq,numEq>::BVector&, \ const MultisegmentWellEquations<T,numWellEq,numEq>::BVector&, \
const int, \ const int, \
const bool, \ const bool, \
const WellInterfaceGeneric<double>&, \ const WellInterfaceGeneric<T>&, \
const int, \ const int, \
const WellState<double>&) const; const WellState<T>&) const;
INSTANCE(2,1) #define INSTANTIATE_TYPE(T) \
INSTANCE(2,2) INSTANTIATE(T,2,1) \
INSTANCE(2,6) INSTANTIATE(T,2,2) \
INSTANCE(3,2) INSTANTIATE(T,2,6) \
INSTANCE(3,3) INSTANTIATE(T,3,2) \
INSTANCE(3,4) INSTANTIATE(T,3,3) \
INSTANCE(4,3) INSTANTIATE(T,3,4) \
INSTANCE(4,4) INSTANTIATE(T,4,3) \
INSTANCE(4,5) INSTANTIATE(T,4,4) \
INSTANTIATE(T,4,5)
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} }

View File

@ -577,38 +577,43 @@ getResidualMeasureValue(const WellState<Scalar>& well_state,
return sum; return sum;
} }
#define INSTANCE(...) \ template<class Scalar>
template class MultisegmentWellEval<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__>; using FS = BlackOilFluidSystem<Scalar,BlackOilDefaultIndexTraits>;
// One phase #define INSTANTIATE(T,...) \
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) template class MultisegmentWellEval<FS<T>,__VA_ARGS__>;
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>)
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>)
// Two phase #define INSTANTIATE_TYPE(T) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>) \
INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) \
INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) \
INSTANTIATE(T,BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,true,2u,0u>) \
INSTANTIATE(T,BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,false,1u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>)
// Blackoil INSTANTIATE_TYPE(double)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>) #if FLOW_INSTANTIATE_FLOAT
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>) INSTANTIATE_TYPE(float)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,2u,0u>) #endif
INSTANCE(BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,1u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>)
INSTANCE(BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>)
} // namespace Opm } // namespace Opm

View File

@ -987,39 +987,43 @@ mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const
return mixDens; return mixDens;
} }
#define INSTANCE(...) \ template<class Scalar>
template class MultisegmentWellSegments<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__>; using FS = BlackOilFluidSystem<Scalar,BlackOilDefaultIndexTraits>;
// One phase #define INSTANTIATE(T,...) \
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) template class MultisegmentWellSegments<FS<T>,__VA_ARGS__>;
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>)
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>)
// Two phase #define INSTANTIATE_TYPE(T) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>) \
INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) \
INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) \
INSTANTIATE(T,BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,true,2u,0u>) \
INSTANTIATE(T,BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,false,1u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>)
// Blackoil INSTANTIATE_TYPE(double)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,2u,0u>)
INSTANCE(BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,1u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>)
INSTANCE(BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>) #if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} // namespace Opm } // namespace Opm

View File

@ -404,24 +404,31 @@ sumDistributed(Parallel::Communication comm)
wellhelpers::sumDistributedWellEntries(duneD_[0][0], resWell_[0], comm); wellhelpers::sumDistributedWellEntries(duneD_[0][0], resWell_[0], comm);
} }
#define INSTANCE(N) \ #define INSTANTIATE(T,N) \
template class StandardWellEquations<double,N>; \ template class StandardWellEquations<T,N>; \
template void StandardWellEquations<double,N>:: \ template void StandardWellEquations<T,N>:: \
extract(Linear::IstlSparseMatrixAdapter<MatrixBlock<double,N,N>>&) const; \ extract(Linear::IstlSparseMatrixAdapter<MatrixBlock<T,N,N>>&) const; \
template void StandardWellEquations<double,N>:: \ template void StandardWellEquations<T,N>:: \
extractCPRPressureMatrix(Dune::BCRSMatrix<MatrixBlock<double,1,1>>&, \ extractCPRPressureMatrix(Dune::BCRSMatrix<MatrixBlock<T,1,1>>&, \
const typename StandardWellEquations<double,N>::BVector&, \ const typename StandardWellEquations<T,N>::BVector&, \
const int, \ const int, \
const bool, \ const bool, \
const WellInterfaceGeneric<double>&, \ const WellInterfaceGeneric<T>&, \
const int, \ const int, \
const WellState<double>&) const; const WellState<T>&) const;
INSTANCE(1) #define INSTANTIATE_TYPE(T) \
INSTANCE(2) INSTANTIATE(T,1) \
INSTANCE(3) INSTANTIATE(T,2) \
INSTANCE(4) INSTANTIATE(T,3) \
INSTANCE(5) INSTANTIATE(T,4) \
INSTANCE(6) INSTANTIATE(T,5) \
INSTANTIATE(T,6)
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} }

View File

@ -201,38 +201,43 @@ init(std::vector<Scalar>& perf_depth,
this->linSys_.init(num_cells, numWellEq, baseif_.numPerfs(), baseif_.cells()); this->linSys_.init(num_cells, numWellEq, baseif_.numPerfs(), baseif_.cells());
} }
#define INSTANCE(...) \ template<class Scalar>
template class StandardWellEval<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__>; using FS = BlackOilFluidSystem<Scalar,BlackOilDefaultIndexTraits>;
// One phase #define INSTANTIATE(T,...) \
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) template class StandardWellEval<FS<T>,__VA_ARGS__>;
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>)
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>)
// Two phase #define INSTANTIATE_TYPE(T) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,true,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,true,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>) \
INSTANCE(BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>) \
// Blackoil INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>) INSTANTIATE(T,BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>) INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>) \
INSTANCE(BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>) INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>) \
INSTANCE(BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>) INSTANTIATE(T,BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>) INSTANTIATE(T,BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>) INSTANTIATE(T,BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,false,1u,0u>) INSTANTIATE(T,BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>) \
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>) INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,false,1u,0u>) \
INSTANTIATE(T,BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>) \
INSTANTIATE(T,BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>)
INSTANCE(BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>) INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} }