opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
LinearSolverAcceleratorType.hpp
1
/*
2
Copyright 2025 Equinor ASA
3
4
This file is part of the Open Porous Media project (OPM).
5
OPM is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
OPM is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with OPM. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
17
#include <algorithm>
18
#include <stdexcept>
19
#include <string>
20
21
#include <opm/common/ErrorMacros.hpp>
22
#include <
opm/simulators/linalg/linalgparameters.hh
>
23
#include <
opm/simulators/linalg/linalgproperties.hh
>
24
25
26
namespace
Opm::Parameters
27
{
28
32
struct
LinearSolverAccelerator
{
static
constexpr
auto
value =
"cpu"
; };
33
37
enum class
LinearSolverAcceleratorType { GPU = 0, CPU = 1 };
38
45
inline
std::string
46
toString(LinearSolverAcceleratorType type)
47
{
48
switch
(type) {
49
case
LinearSolverAcceleratorType::GPU:
50
return
"gpu"
;
51
case
LinearSolverAcceleratorType::CPU:
52
return
"cpu"
;
53
default
:
54
OPM_THROW(std::runtime_error,
"Unknown LinearSolverAcceleratorType"
);
55
}
56
}
57
65
inline
LinearSolverAcceleratorType
66
linearSolverAcceleratorTypeFromString(
const
std::string& str)
67
{
68
std::string lowerStr = str;
69
std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), [](
unsigned
char
c) { return std::tolower(c); });
70
if
(lowerStr ==
"gpu"
) {
71
return
LinearSolverAcceleratorType::GPU;
72
}
else
if
(lowerStr ==
"cpu"
) {
73
return
LinearSolverAcceleratorType::CPU;
74
}
else
{
75
OPM_THROW(std::runtime_error,
"Unknown LinearSolverAcceleratorType: "
+ str);
76
}
77
}
78
82
inline
LinearSolverAcceleratorType
83
linearSolverAcceleratorTypeFromCLI()
84
{
85
return
linearSolverAcceleratorTypeFromString(Parameters::Get<LinearSolverAccelerator>());
86
}
87
88
}
// namespace Opm::Parameters
linalgparameters.hh
Declares the parameters for the black oil model.
linalgproperties.hh
Declares the properties required by the black oil model.
Opm::Parameters::LinearSolverAccelerator
For the CLI options.
Definition
LinearSolverAcceleratorType.hpp:32
opm
simulators
linalg
LinearSolverAcceleratorType.hpp
Generated by
1.17.0