GEOS
ThermalPhaseMobilityKernel.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALPHASEMOBILITYKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALPHASEMOBILITYKERNEL_HPP
22 
24 
25 namespace geos
26 {
27 
28 namespace thermalCompositionalMultiphaseFVMKernels
29 {
30 
31 /******************************** PhaseMobilityKernel ********************************/
32 
39 template< integer NUM_COMP, integer NUM_PHASE >
41 {
42 public:
43 
45  using Base::numPhase;
46  using Base::m_dPhaseVolFrac;
47  using Base::m_dPhaseMob;
48  using Base::m_phaseDens;
49  using Base::m_dPhaseDens;
50  using Base::m_phaseVisc;
51  using Base::m_dPhaseVisc;
52  using Base::m_dPhaseRelPerm_dPhaseVolFrac;
53 
61  constitutive::MultiFluidBase const & fluid,
62  constitutive::RelativePermeabilityBase const & relperm )
63  : Base( subRegion, fluid, relperm )
64  {}
65 
71  inline
72  void compute( localIndex const ei ) const
73  {
74  using Deriv = constitutive::multifluid::DerivativeOffset;
75 
76  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseDens = m_phaseDens[ei][0];
77  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseDens = m_dPhaseDens[ei][0];
78  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseVisc = m_phaseVisc[ei][0];
79  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseVisc = m_dPhaseVisc[ei][0];
80  arraySlice2d< real64 const, constitutive::relperm::USD_RELPERM_DS - 2 > const dPhaseRelPerm_dPhaseVolFrac = m_dPhaseRelPerm_dPhaseVolFrac[ei][0];
81  arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac = m_dPhaseVolFrac[ei];
82 
83  Base::compute( ei, [&] ( localIndex const ip,
84  real64 const & phaseMob,
86  {
87  // Step 1: compute the derivative of relPerm[ip] wrt temperature
88  real64 dRelPerm_dT = 0.0;
89  for( integer jp = 0; jp < numPhase; ++jp )
90  {
91  dRelPerm_dT += dPhaseRelPerm_dPhaseVolFrac[ip][jp] * dPhaseVolFrac[jp][Deriv::dT];
92  }
93 
94  // Step 2: compute the derivative of phaseMob[ip] wrt temperature
95  dPhaseMob[Deriv::dT] = dRelPerm_dT * phaseDens[ip] / phaseVisc[ip]
96  + phaseMob * (dPhaseDens[ip][Deriv::dT] / phaseDens[ip] - dPhaseVisc[ip][Deriv::dT] / phaseVisc[ip] );
97  } );
98  }
99 
100 };
101 
106 {
107 public:
108 
118  template< typename POLICY >
119  static void
120  createAndLaunch( integer const numComp,
121  integer const numPhase,
122  ObjectManagerBase & subRegion,
123  constitutive::MultiFluidBase const & fluid,
124  constitutive::RelativePermeabilityBase const & relperm )
125  {
126  if( numPhase == 2 )
127  {
128  isothermalCompositionalMultiphaseBaseKernels::
129  internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC )
130  {
131  integer constexpr NUM_COMP = NC();
132  PhaseMobilityKernel< NUM_COMP, 2 > kernel( subRegion, fluid, relperm );
133  PhaseMobilityKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel );
134  } );
135  }
136  else if( numPhase == 3 )
137  {
138  isothermalCompositionalMultiphaseBaseKernels::
139  internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC )
140  {
141  integer constexpr NUM_COMP = NC();
142  PhaseMobilityKernel< NUM_COMP, 3 > kernel( subRegion, fluid, relperm );
143  PhaseMobilityKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel );
144  } );
145  }
146  }
147 };
148 
149 } // namespace thermalCompositionalMultiphaseFVMKernels
150 
151 } // namespace geos
152 
153 
154 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALPHASEMOBILITYKERNEL_HPP
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
Define the base interface for the property update kernels.
Defines the interface for the property kernel in charge of computing the phase mobilities.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_phaseDens
Views on the phase densities.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_phaseVisc
Views on the phase viscosities.
static constexpr integer numPhase
Compile time value for the number of phases.
GEOS_HOST_DEVICE void compute(localIndex const ei, FUNC &&phaseMobilityKernelOp=NoOpFunc{}) const
Compute the phase mobilities in an element.
static void createAndLaunch(integer const numComp, integer const numPhase, ObjectManagerBase &subRegion, constitutive::MultiFluidBase const &fluid, constitutive::RelativePermeabilityBase const &relperm)
Create a new kernel and launch.
Define the interface for the property kernel in charge of computing the phase mobilities.
PhaseMobilityKernel(ObjectManagerBase &subRegion, constitutive::MultiFluidBase const &fluid, constitutive::RelativePermeabilityBase const &relperm)
Constructor.
GEOS_HOST_DEVICE void compute(localIndex const ei) const
Compute the phase mobilities in an element.
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:200
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:184
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82