GEOS
ThermalPhaseVolumeFractionKernel.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_THERMALPHASEVOLUMEFRACTIONKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALPHASEVOLUMEFRACTIONKERNEL_HPP
22 
24 
25 namespace geos
26 {
27 
28 namespace thermalCompositionalMultiphaseBaseKernels
29 {
30 
31 /******************************** PhaseVolumeFractionKernel ********************************/
32 
39 template< integer NUM_COMP, integer NUM_PHASE >
41 {
42 public:
43 
45  using Base::m_dPhaseDens;
46  using Base::m_dPhaseFrac;
47  using Base::m_dPhaseVolFrac;
48 
55  constitutive::MultiFluidBase const & fluid )
56  : Base( subRegion, fluid )
57  {}
58 
64  real64 compute( localIndex const ei ) const
65  {
66  using Deriv = constitutive::multifluid::DerivativeOffset;
67 
68  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseDens = m_dPhaseDens[ei][0];
69  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseFrac = m_dPhaseFrac[ei][0];
70 
71  arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac = m_dPhaseVolFrac[ei];
72 
73  // Call the base compute the compute the phase volume fraction
74  return Base::compute( ei, [&] ( localIndex const ip,
75  real64 const & phaseVolFrac,
76  real64 const & phaseDensInv,
77  real64 const & totalDensity )
78  {
79  // when this lambda is called, we are in the phase loop
80  // for each phase ip, compute the derivative of phase volume fraction wrt temperature
81  dPhaseVolFrac[ip][Deriv::dT] = (dPhaseFrac[ip][Deriv::dT] - phaseVolFrac * dPhaseDens[ip][Deriv::dT]) * phaseDensInv;
82  dPhaseVolFrac[ip][Deriv::dT] *= totalDensity;
83  } );
84  }
85 
86 };
87 
92 {
93 public:
94 
103  template< typename POLICY >
104  static real64
105  createAndLaunch( integer const numComp,
106  integer const numPhase,
107  ObjectManagerBase & subRegion,
108  constitutive::MultiFluidBase const & fluid )
109  {
110  real64 maxDeltaPhaseVolFrac = 0.0;
111  if( numPhase == 2 )
112  {
113  isothermalCompositionalMultiphaseBaseKernels::
114  internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC )
115  {
116  integer constexpr NUM_COMP = NC();
117  PhaseVolumeFractionKernel< NUM_COMP, 2 > kernel( subRegion, fluid );
118  maxDeltaPhaseVolFrac = PhaseVolumeFractionKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel );
119  } );
120  }
121  else if( numPhase == 3 )
122  {
123  isothermalCompositionalMultiphaseBaseKernels::
124  internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC )
125  {
126  integer constexpr NUM_COMP = NC();
127  PhaseVolumeFractionKernel< NUM_COMP, 3 > kernel( subRegion, fluid );
128  maxDeltaPhaseVolFrac = PhaseVolumeFractionKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel );
129  } );
130  }
131  return maxDeltaPhaseVolFrac;
132  }
133 };
134 
135 } // namespace thermalCompositionalMultiphaseBaseKernels
136 
137 } // namespace geos
138 
139 
140 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALPHASEVOLUMEFRACTIONKERNEL_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 interface for the property kernel in charge of computing the phase volume fractions.
GEOS_HOST_DEVICE real64 compute(localIndex const ei, FUNC &&phaseVolFractionKernelOp=NoOpFunc{}) const
Compute the phase volume fractions in an element.
Define the base interface for the property update kernels.
static real64 createAndLaunch(integer const numComp, integer const numPhase, ObjectManagerBase &subRegion, constitutive::MultiFluidBase const &fluid)
Create a new kernel and launch.
Define the interface for the property kernel in charge of computing the phase volume fractions.
GEOS_HOST_DEVICE real64 compute(localIndex const ei) const
Compute the phase volume fractions in an element.
PhaseVolumeFractionKernel(ObjectManagerBase &subRegion, constitutive::MultiFluidBase const &fluid)
Constructor.
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
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82