opm-common
BlackOilFluidSystemNonStatic.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_NONSTATIC_HPP
19 #define OPM_BLACK_OIL_FLUID_SYSTEM_NONSTATIC_HPP
20 
21 #include <opm/common/utility/gpuDecorators.hpp>
22 
23 
24 // Here we need to define certain macros before including the macrotemplate file.
25 //
26 // The idea is in essence the following:
27 // 1) In the macrotemplate file, we have method declarations of the form
28 //
29 // `STATIC_OR_DEVICE void foo();`
30 //
31 // and member variable declarations of the form
32 //
33 // `STATIC_OR_NOTHING int bar;`
34 //
35 // 2) We want to be able to compile the same code for both the dynamic (non-static) and static
36 // versions of the fluid system. The dynamic version is used when the fluid system is accessed
37 // from the GPU, while the static version is used when the fluid system is accessed from the CPU.
38 // 3) We want to be able to compile the same code for both the dynamic and static versions of the
39 // fluid system, but with different method and member variable declarations.
40 //
41 // Furthermore, we need to specify the class name of the fluid system, which is different for the
42 // nonstatic and static versions of the fluid system. We also need to specify if we are compiling
43 // the static version of the fluid system, since we will define certain constructors and singleton
44 // functions only in the static or nonstatic case.
45 
46 // Nonstatic class name
47 #define FLUIDSYSTEM_CLASSNAME_NONSTATIC BlackOilFluidSystemNonStatic
48 
49 // Static class name
50 #define FLUIDSYSTEM_CLASSNAME_STATIC BlackOilFluidSystem
51 
52 // Fluid system class name for the fluid system we are defining now, ie the nonstatic version
53 #define FLUIDSYSTEM_CLASSNAME BlackOilFluidSystemNonStatic
54 
55 // We need to decorate the nonstatic member functions with the gpu decorators
56 #define STATIC_OR_DEVICE OPM_HOST_DEVICE
57 
58 // Member variables need no decorators for the nonstatic version
59 #define STATIC_OR_NOTHING
60 
61 // Make sure member functions are const in non-static version of the fluid system
62 #define NOTHING_OR_CONST const
63 
64 // Functions defined outside of the class need OPM_HOST_DEVICE, but never static
65 #define NOTHING_OR_DEVICE OPM_HOST_DEVICE
66 
67 
68 // We need to forward-declare the static version of the fluid system, since we will
69 // add it as a friend to the nonstatic version.
70 namespace Opm
71 {
72 template <class Scalar,
73  class IndexTraits,
74  template <typename> typename Storage>
76 }
77 
78 // Include the macrotemplate file
80 
81 // Undefine the macros we defined above
82 #undef NOTHING_OR_DEVICE
83 #undef STATIC_OR_DEVICE
84 #undef STATIC_OR_NOTHING
85 #undef NOTHING_OR_CONST
86 #undef FLUIDSYSTEM_CLASSNAME_NONSTATIC
87 #undef FLUIDSYSTEM_CLASSNAME_STATIC
88 #undef FLUIDSYSTEM_CLASSNAME
89 #endif
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: BlackOilFluidSystemNonStatic.hpp:75