GpuFlowGasWaterEnergyContract.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 Copyright 2026 Equinor ASA
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12*/
23#ifndef OPM_GPU_FLOW_GASWATER_ENERGY_CONTRACT_HPP
24#define OPM_GPU_FLOW_GASWATER_ENERGY_CONTRACT_HPP
25
26#if HAVE_CUDA
27
28#include <opm/material/fluidmatrixinteractions/EclMaterialLawTwoPhaseTypes.hpp>
29#include <opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp>
30#include <opm/material/fluidmatrixinteractions/GpuEclMaterialLawManager.hpp>
31#include <opm/material/fluidmatrixinteractions/PiecewiseLinearTwoPhaseMaterial.hpp>
32#include <opm/material/fluidmatrixinteractions/PiecewiseLinearTwoPhaseMaterialParams.hpp>
33#include <opm/material/fluidsystems/BlackOilFluidSystemNonStatic.hpp>
34#include <opm/material/thermal/EclSpecrockLaw.hpp>
35#include <opm/material/thermal/EclSpecrockLawParams.hpp>
36#include <opm/material/thermal/EclThconrLaw.hpp>
37#include <opm/material/thermal/EclThconrLawParams.hpp>
38#include <opm/material/thermal/GpuEclThermalLawManager.hpp>
39
44
50
51#include <tuple>
52
53namespace Opm::Properties {
54
55// These Flow properties are normally declared by
56// FlowBaseProblemProperties.hpp. Forward-declaring them here avoids pulling
57// that header (and its tpfalinearizer dependency) into the contract cycle.
58template <class TypeTag, class MyTypeTag>
59struct EnableHysteresis;
60template <class TypeTag, class MyTypeTag>
61struct EnableEndpointScaling;
62
63namespace TTag {
64
65// The definitions live in FlowGasWaterEnergyTypeTag.hpp. Forward declarations
66// keep this contract usable from tpfalinearizer.hh without introducing its
67// dependency cycle through the Flow executable TypeTags.
68struct FlowProblem;
69struct FlowGasWaterEnergyProblem;
70struct FlowGasWaterEnergyProblemGPU;
71
80template <template <class> class Storage>
81struct FlowGasWaterEnergyDeviceTypeTag {
82 using InheritsFrom = std::tuple<FlowGasWaterEnergyProblem>;
83};
84
91template <class ParentTypeTag>
92struct FlowGasWaterEnergyCpuDeviceContract {
93 using InheritsFrom = std::tuple<FlowGasWaterEnergyProblem>;
94};
95
96// Compatibility names for the pre-contract GPU IQ test and external users.
97using FlowGasWaterEnergyKernelBaseGPU = FlowGasWaterEnergyDeviceTypeTag<gpuistl::GpuView>;
98using FlowGasWaterEnergyDummyProblemGPU = FlowGasWaterEnergyDeviceTypeTag<gpuistl::GpuView>;
99using FlowGasWaterEnergyCpuKernelBase = FlowGasWaterEnergyCpuDeviceContract<FlowGasWaterEnergyProblem>;
100
101template <template <class> class Storage>
102struct to_gpu_type<FlowGasWaterEnergyProblemGPU, Storage> {
103 using type = FlowGasWaterEnergyDeviceTypeTag<Storage>;
104};
105
106template <template <class> class Storage>
107struct to_gpu_type<FlowGasWaterEnergyProblem, Storage> {
108 using type = FlowGasWaterEnergyDeviceTypeTag<Storage>;
109};
110
111} // namespace TTag
112
113// Unsupported BlackOil modules must not change the device IQ layout.
114template <class TypeTag, template <class> class Storage>
115struct EnableDiffusion<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
116 static constexpr bool value = false;
117};
118
119template <class TypeTag, template <class> class Storage>
120struct EnableDispersion<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
121 static constexpr bool value = false;
122};
123
124template <class TypeTag, template <class> class Storage>
125struct EnableSolvent<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
126 static constexpr bool value = false;
127};
128
129template <class TypeTag, template <class> class Storage>
130struct EnableExtbo<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
131 static constexpr bool value = false;
132};
133
134template <class TypeTag, template <class> class Storage>
135struct EnablePolymer<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
136 static constexpr bool value = false;
137};
138
139template <class TypeTag, template <class> class Storage>
140struct EnablePolymerMW<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
141 static constexpr bool value = false;
142};
143
144template <class TypeTag, template <class> class Storage>
145struct EnableFoam<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
146 static constexpr bool value = false;
147};
148
149template <class TypeTag, template <class> class Storage>
150struct EnableBrine<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
151 static constexpr bool value = false;
152};
153
154template <class TypeTag, template <class> class Storage>
155struct EnableSaltPrecipitation<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
156 static constexpr bool value = false;
157};
158
159template <class TypeTag, template <class> class Storage>
160struct EnableBioeffects<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
161 static constexpr bool value = false;
162};
163
164template <class TypeTag, template <class> class Storage>
165struct EnableMech<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
166 static constexpr bool value = false;
167};
168
169template <class TypeTag, template <class> class Storage>
170struct EnableGeochemistry<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
171 static constexpr bool value = false;
172};
173
174template <class TypeTag, template <class> class Storage>
175struct EnableConvectiveMixing<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
176 static constexpr bool value = false;
177};
178
179template <class TypeTag, template <class> class Storage>
180struct EnableEnergy<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
181 static constexpr bool value = true;
182};
183
184// Match the device contract when making an IQ prototype on the host.
185template <class TypeTag, class ParentTypeTag>
186struct EnableDiffusion<TypeTag, TTag::FlowGasWaterEnergyCpuDeviceContract<ParentTypeTag>> {
187 static constexpr bool value = false;
188};
189
190template <class TypeTag, class ParentTypeTag>
191struct EnableDispersion<TypeTag, TTag::FlowGasWaterEnergyCpuDeviceContract<ParentTypeTag>> {
192 static constexpr bool value = false;
193};
194
195// Material law: GPU-friendly EclTwoPhaseMaterial backed by device views.
196template <class TypeTag, template <class> class Storage>
197struct MaterialLaw<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>>
198{
199private:
200 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
201 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
202 using Traits = ThreePhaseMaterialTraits<Scalar,
203 FluidSystem::waterPhaseIdx,
204 FluidSystem::oilPhaseIdx,
205 FluidSystem::gasPhaseIdx,
206 getPropValue<TypeTag, Properties::EnableHysteresis>(),
207 getPropValue<TypeTag, Properties::EnableEndpointScaling>()>;
208 using TwoPhaseTraits = TwoPhaseMaterialTraits<Scalar,
209 Traits::wettingPhaseIdx,
210 Traits::nonWettingPhaseIdx>;
211 using TwoPhaseParams =
212 ::Opm::PiecewiseLinearTwoPhaseMaterialParams<TwoPhaseTraits, ::Opm::gpuistl::GpuView<const Scalar>>;
213 using TwoPhaseLaw = ::Opm::PiecewiseLinearTwoPhaseMaterial<TwoPhaseTraits, TwoPhaseParams>;
214 using GpuMaterialLawParams =
215 ::Opm::EclTwoPhaseMaterialParams<Traits,
216 TwoPhaseParams,
217 TwoPhaseParams,
218 TwoPhaseParams,
220 using GpuMaterialLaw =
221 ::Opm::EclTwoPhaseMaterial<Traits, TwoPhaseLaw, TwoPhaseLaw, TwoPhaseLaw, GpuMaterialLawParams>;
222
223public:
224 using EclMaterialLawManager =
225 ::Opm::EclMaterialLaw::GpuManager<Traits,
226 TwoPhaseLaw,
227 TwoPhaseLaw,
228 ::Opm::VectorWithDefaultAllocator,
229 GpuMaterialLaw>;
230 using type = typename EclMaterialLawManager::MaterialLaw;
231};
232
233template <class TypeTag, template <class> class Storage>
234struct PrimaryVariables<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
236};
237
238template <class TypeTag, template <class> class Storage>
239struct FluidSystem<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
240 using type = ::Opm::BlackOilFluidSystemNonStatic<
241 GetPropType<TypeTag, Properties::Scalar>,
242 ::Opm::BlackOilDefaultFluidSystemIndices,
243 Storage>;
244};
245
246template <class TypeTag, template <class> class Storage>
247struct SolidEnergyLaw<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>>
248{
249private:
250 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
251 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
252
253public:
254 using EclThermalLawManager =
255 ::Opm::EclThermalLaw::GpuManager<Scalar, FluidSystem, ::Opm::gpuistl::GpuView, ::Opm::gpuistl::GpuView>;
256 using type = ::Opm::EclSpecrockLaw<Scalar, ::Opm::EclSpecrockLawParams<Scalar, ::Opm::gpuistl::GpuView>>;
257};
258
259template <class TypeTag, template <class> class Storage>
260struct ThermalConductionLaw<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>>
261{
262private:
263 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
264 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
265
266public:
267 using EclThermalLawManager =
268 ::Opm::EclThermalLaw::GpuManager<Scalar, FluidSystem, ::Opm::gpuistl::GpuView, ::Opm::gpuistl::GpuView>;
269 using type = ::Opm::EclThconrLaw<Scalar, FluidSystem>;
270};
271
272template <class TypeTag, template <class> class Storage>
273struct Problem<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>>
274{
275private:
276 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
277 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
278 using MaterialLawManager = typename GetProp<TypeTag, Properties::MaterialLaw>::EclMaterialLawManager;
279 using GpuViewMaterialLawManager =
280 ::Opm::EclMaterialLaw::GpuManager<typename MaterialLawManager::Traits,
281 typename MaterialLawManager::GasOilLaw,
282 typename MaterialLawManager::OilWaterLaw,
284 typename MaterialLawManager::MaterialLaw>;
285 using GpuViewThermalLawManager =
286 ::Opm::EclThermalLaw::GpuManager<Scalar, FluidSystem, ::Opm::gpuistl::GpuView, ::Opm::gpuistl::GpuView>;
287
288public:
290 Scalar, GpuViewMaterialLawManager, ::Opm::gpuistl::GpuView, GpuViewThermalLawManager>;
291};
292
293template <class TypeTag, template <class> class Storage>
294struct ElementContext<TypeTag, TTag::FlowGasWaterEnergyDeviceTypeTag<Storage>> {
295 using type = std::nullptr_t;
296};
297
298} // namespace Opm::Properties
299
300#endif // HAVE_CUDA
301
302#endif // OPM_GPU_FLOW_GASWATER_ENERGY_CONTRACT_HPP
GPU-compatible, simplified version of Opm::FlowProblem.
Declares the properties required by the black oil model.
Represents the primary variables used by the black-oil model.
Definition: blackoilprimaryvariables.hh:87
Minimal, GPU-compatible problem class.
Definition: GpuFlowProblem.hpp:137
The GpuView class is provides a view of some data allocated on the GPU Essenstially is only stores a ...
Definition: GpuView.hpp:53
A value stored with a pointer interface. Can be used to wrap objects in GPU kernels that were otherwi...
Definition: gpu_smart_pointer.hpp:420
Defines the common properties required by the porous medium multi-phase models.
Definition: blackoilmodel.hh:74
The Opm property system, traits with inheritance.
UndefinedProperty type
Definition: fvbaseproperties.hh:154
UndefinedProperty type
Definition: multiphasebaseproperties.hh:79
UndefinedProperty type
Definition: multiphasebaseproperties.hh:55
UndefinedProperty type
Definition: fvbaseproperties.hh:135
UndefinedProperty type
Definition: fvbaseproperties.hh:86
UndefinedProperty type
Definition: multiphasebaseproperties.hh:63
UndefinedProperty type
Definition: multiphasebaseproperties.hh:71