opm-common
BlackOilFluidSystem.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 
10  OPM is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with OPM. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef OPM_BLACK_OIL_FLUID_SYSTEM_HPP
19 #define OPM_BLACK_OIL_FLUID_SYSTEM_HPP
20 
21 // Here we need to define certain macros before including the macrotemplate file.
22 //
23 // The idea is in essence the following:
24 // 1) In the macrotemplate file, we have method declarations of the form
25 //
26 // `STATIC_OR_DEVICE void foo();`
27 //
28 // and member variable declarations of the form
29 //
30 // `STATIC_OR_NOTHING int bar;`
31 //
32 // 2) We want to be able to compile the same code for both the dynamic (non-static) and static
33 // versions of the fluid system. The dynamic version is used when the fluid system is accessed
34 // from the GPU, while the static version is used when the fluid system is accessed from the CPU.
35 // 3) We want to be able to compile the same code for both the dynamic and static versions of the
36 // fluid system, but with different method and member variable declarations.
37 //
38 // Furthermore, we need to specify the class name of the fluid system, which is different for the
39 // nonstatic and static versions of the fluid system. We also need to specify if we are compiling
40 // the static version of the fluid system, since we will define certain constructors and singleton
41 // functions only in the static or nonstatic case.
42 
43 // Is defined for the static version of the fluid system.
44 #define COMPILING_STATIC_FLUID_SYSTEM
45 
46 // The static version does not need any gpu decorators, simply static
47 #define STATIC_OR_DEVICE static
48 
49 // Make sure member variables are declared as static
50 #define STATIC_OR_NOTHING static
51 
52 // Make sure member functions are const in non-static version of the fluid system
53 #define NOTHING_OR_CONST
54 
55 // Functions defined outside of the class need OPM_HOST_DEVICE, but never static
56 #define NOTHING_OR_DEVICE
57 
58 // Define the class names for the static and nonstatic versions of the fluid system
59 #define FLUIDSYSTEM_CLASSNAME_NONSTATIC BlackOilFluidSystemNonStatic
60 #define FLUIDSYSTEM_CLASSNAME_STATIC BlackOilFluidSystem
61 
62 // Define the class name for the fluid system
63 #define FLUIDSYSTEM_CLASSNAME BlackOilFluidSystem
64 
65 
66 // We need to forward-declare the nonstatic version of the fluid system, since we will
67 // make the nonstatic version a friend of the static version being defined here.
68 namespace Opm
69 {
70 template <class Scalar,
71  class IndexTraits,
72  template <typename> typename Storage>
74 }
75 
76 // Include the macrotemplate file
78 
79 // Undefine the macros we defined above
80 #undef NOTHING_OR_DEVICE
81 #undef STATIC_OR_DEVICE
82 #undef COMPILING_STATIC_FLUID_SYSTEM
83 #undef STATIC_OR_NOTHING
84 #undef NOTHING_OR_CONST
85 #undef FLUIDSYSTEM_CLASSNAME_STATIC
86 #undef FLUIDSYSTEM_CLASSNAME_NONSTATIC
87 #undef FLUIDSYSTEM_CLASSNAME
88 
89 #endif // OPM_BLACK_OIL_FLUID_SYSTEM_HPP
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: BlackOilFluidSystem.hpp:73