mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5285 from akva2/precond_enum_class
changed: make PreconditionerType an enum class
This commit is contained in:
commit
63cbd2adce
@ -44,7 +44,7 @@ using Opm::OpmLog;
|
|||||||
using Dune::Timer;
|
using Dune::Timer;
|
||||||
|
|
||||||
template <unsigned int block_size>
|
template <unsigned int block_size>
|
||||||
CPR<block_size>::CPR(int verbosity_, bool opencl_ilu_parallel_) :
|
CPR<block_size>::CPR(bool opencl_ilu_parallel_, int verbosity_) :
|
||||||
Preconditioner<block_size>(verbosity_), opencl_ilu_parallel(opencl_ilu_parallel_)
|
Preconditioner<block_size>(verbosity_), opencl_ilu_parallel(opencl_ilu_parallel_)
|
||||||
{
|
{
|
||||||
bilu0 = std::make_unique<BILU0<block_size> >(opencl_ilu_parallel, verbosity_);
|
bilu0 = std::make_unique<BILU0<block_size> >(opencl_ilu_parallel, verbosity_);
|
||||||
|
@ -115,8 +115,7 @@ private:
|
|||||||
void create_preconditioner_amg(BlockedMatrix *mat);
|
void create_preconditioner_amg(BlockedMatrix *mat);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
CPR(bool opencl_ilu_parallel, int verbosity);
|
||||||
CPR(int verbosity, bool opencl_ilu_parallel);
|
|
||||||
|
|
||||||
bool analyze_matrix(BlockedMatrix *mat) override;
|
bool analyze_matrix(BlockedMatrix *mat) override;
|
||||||
bool analyze_matrix(BlockedMatrix *mat, BlockedMatrix *jacMat) override;
|
bool analyze_matrix(BlockedMatrix *mat, BlockedMatrix *jacMat) override;
|
||||||
|
@ -18,14 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <memory>
|
#include <opm/simulators/linalg/bda/opencl/Preconditioner.hpp>
|
||||||
|
|
||||||
#include <opm/common/TimingMacros.hpp>
|
#include <opm/common/TimingMacros.hpp>
|
||||||
#include <opm/common/ErrorMacros.hpp>
|
#include <opm/common/ErrorMacros.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/linalg/bda/opencl/BILU0.hpp>
|
#include <opm/simulators/linalg/bda/opencl/BILU0.hpp>
|
||||||
#include <opm/simulators/linalg/bda/opencl/BISAI.hpp>
|
#include <opm/simulators/linalg/bda/opencl/BISAI.hpp>
|
||||||
#include <opm/simulators/linalg/bda/opencl/CPR.hpp>
|
#include <opm/simulators/linalg/bda/opencl/CPR.hpp>
|
||||||
#include <opm/simulators/linalg/bda/opencl/Preconditioner.hpp>
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@ -40,16 +43,20 @@ void Preconditioner<block_size>::setOpencl(std::shared_ptr<cl::Context>& context
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int block_size>
|
template <unsigned int block_size>
|
||||||
std::unique_ptr<Preconditioner<block_size> > Preconditioner<block_size>::create(PreconditionerType type, int verbosity, bool opencl_ilu_parallel) {
|
std::unique_ptr<Preconditioner<block_size>>
|
||||||
if (type == PreconditionerType::BILU0) {
|
Preconditioner<block_size>::create(Type type, bool opencl_ilu_parallel, int verbosity)
|
||||||
return std::make_unique<Opm::Accelerator::BILU0<block_size> >(opencl_ilu_parallel, verbosity);
|
{
|
||||||
} else if (type == PreconditionerType::CPR) {
|
switch (type ) {
|
||||||
return std::make_unique<Opm::Accelerator::CPR<block_size> >(verbosity, opencl_ilu_parallel);
|
case Type::BILU0:
|
||||||
} else if (type == PreconditionerType::BISAI) {
|
return std::make_unique<BILU0<block_size> >(opencl_ilu_parallel, verbosity);
|
||||||
return std::make_unique<Opm::Accelerator::BISAI<block_size> >(opencl_ilu_parallel, verbosity);
|
case Type::CPR:
|
||||||
} else {
|
return std::make_unique<CPR<block_size> >(opencl_ilu_parallel, verbosity);
|
||||||
OPM_THROW(std::logic_error, "Invalid PreconditionerType");
|
case Type::BISAI:
|
||||||
|
return std::make_unique<BISAI<block_size> >(opencl_ilu_parallel, verbosity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPM_THROW(std::logic_error,
|
||||||
|
"Invalid preconditioner type " + std::to_string(static_cast<int>(type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int block_size>
|
template <unsigned int block_size>
|
||||||
@ -63,7 +70,7 @@ bool Preconditioner<block_size>::create_preconditioner(BlockedMatrix *mat, [[may
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define INSTANTIATE_BDA_FUNCTIONS(n) \
|
#define INSTANTIATE_BDA_FUNCTIONS(n) \
|
||||||
template std::unique_ptr<Preconditioner<n> > Preconditioner<n>::create(PreconditionerType, int, bool); \
|
template std::unique_ptr<Preconditioner<n> > Preconditioner<n>::create(Type, bool, int); \
|
||||||
template void Preconditioner<n>::setOpencl(std::shared_ptr<cl::Context>&, std::shared_ptr<cl::CommandQueue>&); \
|
template void Preconditioner<n>::setOpencl(std::shared_ptr<cl::Context>&, std::shared_ptr<cl::CommandQueue>&); \
|
||||||
template bool Preconditioner<n>::analyze_matrix(BlockedMatrix *, BlockedMatrix *); \
|
template bool Preconditioner<n>::analyze_matrix(BlockedMatrix *, BlockedMatrix *); \
|
||||||
template bool Preconditioner<n>::create_preconditioner(BlockedMatrix *, BlockedMatrix *);
|
template bool Preconditioner<n>::create_preconditioner(BlockedMatrix *, BlockedMatrix *);
|
||||||
|
@ -22,12 +22,13 @@
|
|||||||
|
|
||||||
#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
|
#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
namespace Accelerator
|
namespace Accelerator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class BlockedMatrix;
|
class BlockedMatrix;
|
||||||
|
|
||||||
template <unsigned int block_size>
|
template <unsigned int block_size>
|
||||||
@ -51,13 +52,15 @@ protected:
|
|||||||
{};
|
{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum PreconditionerType {
|
enum class Type {
|
||||||
BILU0,
|
BILU0,
|
||||||
CPR,
|
CPR,
|
||||||
BISAI
|
BISAI
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<Preconditioner> create(PreconditionerType type, int verbosity, bool opencl_ilu_parallel);
|
static std::unique_ptr<Preconditioner> create(Type type,
|
||||||
|
bool opencl_ilu_parallel,
|
||||||
|
int verbosity);
|
||||||
|
|
||||||
virtual ~Preconditioner() = default;
|
virtual ~Preconditioner() = default;
|
||||||
|
|
||||||
|
@ -65,13 +65,13 @@ openclSolverBackend<block_size>::openclSolverBackend(int verbosity_, int maxit_,
|
|||||||
OPM_THROW(std::logic_error, "Error unknown value for argument --linear-solver, " + linsolver);
|
OPM_THROW(std::logic_error, "Error unknown value for argument --linear-solver, " + linsolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
using PreconditionerType = typename Preconditioner<block_size>::PreconditionerType;
|
using PreconditionerType = typename Preconditioner<block_size>::Type;
|
||||||
if (use_cpr) {
|
if (use_cpr) {
|
||||||
prec = Preconditioner<block_size>::create(PreconditionerType::CPR, verbosity, opencl_ilu_parallel);
|
prec = Preconditioner<block_size>::create(PreconditionerType::CPR, opencl_ilu_parallel, verbosity);
|
||||||
} else if (use_isai) {
|
} else if (use_isai) {
|
||||||
prec = Preconditioner<block_size>::create(PreconditionerType::BISAI, verbosity, opencl_ilu_parallel);
|
prec = Preconditioner<block_size>::create(PreconditionerType::BISAI, opencl_ilu_parallel, verbosity);
|
||||||
} else {
|
} else {
|
||||||
prec = Preconditioner<block_size>::create(PreconditionerType::BILU0, verbosity, opencl_ilu_parallel);
|
prec = Preconditioner<block_size>::create(PreconditionerType::BILU0, opencl_ilu_parallel, verbosity);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
Loading…
Reference in New Issue
Block a user