GEOS
PPUPhaseFlux.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 TotalEnergies
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_PPUPHASEFLUX_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_PPUPHASEFLUX_HPP
22 
23 #include "common/DataLayouts.hpp"
24 #include "common/DataTypes.hpp"
25 #include "constitutive/fluid/multifluid/Layouts.hpp"
26 #include "constitutive/capillaryPressure/layouts.hpp"
30 
31 namespace geos
32 {
33 
34 namespace isothermalCompositionalMultiphaseFVMKernelUtilities
35 {
36 
37 template< typename VIEWTYPE >
38 using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >;
39 
40 using Deriv = constitutive::multifluid::DerivativeOffset;
41 
43 {
72  template< integer numComp, integer numFluxSupportPoints >
74  static void
75  compute( integer const numPhase,
76  integer const ip,
77  integer const hasCapPressure,
78  integer const checkPhasePresenceInGravity,
79  localIndex const ( &seri )[numFluxSupportPoints],
80  localIndex const ( &sesri )[numFluxSupportPoints],
81  localIndex const ( &sei )[numFluxSupportPoints],
82  real64 const ( &trans )[2],
83  real64 const ( &dTrans_dPres )[2],
84  ElementViewConst< arrayView1d< real64 const > > const & pres,
85  ElementViewConst< arrayView1d< real64 const > > const & gravCoef,
86  ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob,
87  ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob,
88  ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseVolFrac,
89  ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac,
90  ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const & phaseCompFrac,
91  ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac,
92  ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens,
93  ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > > const & phaseMassDens,
94  ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > > const & dPhaseMassDens,
95  ElementViewConst< arrayView3d< real64 const, constitutive::cappres::USD_CAPPRES > > const & phaseCapPressure,
96  ElementViewConst< arrayView4d< real64 const, constitutive::cappres::USD_CAPPRES_DS > > const & dPhaseCapPressure_dPhaseVolFrac,
97  localIndex & k_up,
98  real64 & potGrad,
99  real64 ( &phaseFlux ),
100  real64 ( & dPhaseFlux_dP )[numFluxSupportPoints],
101  real64 ( & dPhaseFlux_dC )[numFluxSupportPoints][numComp],
102  real64 ( & compFlux )[numComp],
103  real64 ( & dCompFlux_dP )[numFluxSupportPoints][numComp],
104  real64 ( & dCompFlux_dC )[numFluxSupportPoints][numComp][numComp] )
105  {
106  real64 dPresGrad_dP[numFluxSupportPoints]{};
107  real64 dPresGrad_dC[numFluxSupportPoints][numComp]{};
108  real64 dGravHead_dP[numFluxSupportPoints]{};
109  real64 dGravHead_dC[numFluxSupportPoints][numComp]{};
110  PotGrad::compute< numComp, numFluxSupportPoints >( numPhase, ip, hasCapPressure, checkPhasePresenceInGravity,
111  seri, sesri, sei, trans, dTrans_dPres, pres,
112  gravCoef, phaseVolFrac, dPhaseVolFrac, dCompFrac_dCompDens,
113  phaseMassDens, dPhaseMassDens,
114  phaseCapPressure, dPhaseCapPressure_dPhaseVolFrac, potGrad,
115  dPresGrad_dP, dPresGrad_dC, dGravHead_dP, dGravHead_dC );
116 
117  // *** upwinding ***
118 
119  // choose upstream cell
120  k_up = (potGrad >= 0) ? 0 : 1;
121 
122  localIndex const er_up = seri[k_up];
123  localIndex const esr_up = sesri[k_up];
124  localIndex const ei_up = sei[k_up];
125 
126  real64 const mobility = phaseMob[er_up][esr_up][ei_up][ip];
127 
128  // pressure gradient depends on all points in the stencil
129  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
130  {
131  dPhaseFlux_dP[ke] += dPresGrad_dP[ke] - dGravHead_dP[ke];
132  dPhaseFlux_dP[ke] *= mobility;
133  for( integer jc = 0; jc < numComp; ++jc )
134  {
135  dPhaseFlux_dC[ke][jc] += dPresGrad_dC[ke][jc] - dGravHead_dC[ke][jc];
136  dPhaseFlux_dC[ke][jc] *= mobility;
137  }
138  }
139  // compute phase flux using upwind mobility.
140  phaseFlux = mobility * potGrad;
141 
142  real64 const dMob_dP = dPhaseMob[er_up][esr_up][ei_up][ip][Deriv::dP];
143  arraySlice1d< real64 const, compflow::USD_PHASE_DC - 2 > dPhaseMobSub =
144  dPhaseMob[er_up][esr_up][ei_up][ip];
145 
146  // add contribution from upstream cell mobility derivatives
147  dPhaseFlux_dP[k_up] += dMob_dP * potGrad;
148  for( integer jc = 0; jc < numComp; ++jc )
149  {
150  dPhaseFlux_dC[k_up][jc] += dPhaseMobSub[Deriv::dC+jc] * potGrad;
151  }
152 
153  //distribute on phaseComponentFlux here
154  PhaseComponentFlux::compute( ip, k_up, seri, sesri, sei, phaseCompFrac, dPhaseCompFrac, dCompFrac_dCompDens, phaseFlux
155  , dPhaseFlux_dP, dPhaseFlux_dC, compFlux, dCompFlux_dP, dCompFlux_dC );
156 
157  }
158 };
159 
160 } // namespace isothermalCompositionalMultiPhaseFVMKernelUtilities
161 
162 } // namespace geos
163 
164 
165 #endif // GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_PPUPHASEFLUX_HPP
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
ArrayView< T, 5, USD > arrayView5d
Alias for 5D array view.
Definition: DataTypes.hpp:244
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
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
Definition: DataTypes.hpp:228
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:212
static GEOS_HOST_DEVICE void compute(integer const numPhase, integer const ip, integer const hasCapPressure, integer const checkPhasePresenceInGravity, localIndex const (&seri)[numFluxSupportPoints], localIndex const (&sesri)[numFluxSupportPoints], localIndex const (&sei)[numFluxSupportPoints], real64 const (&trans)[2], real64 const (&dTrans_dPres)[2], ElementViewConst< arrayView1d< real64 const > > const &pres, ElementViewConst< arrayView1d< real64 const > > const &gravCoef, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const &phaseMob, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const &dPhaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const &phaseVolFrac, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const &dPhaseVolFrac, ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const &phaseCompFrac, ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > > const &dPhaseCompFrac, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const &dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > > const &phaseMassDens, ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > > const &dPhaseMassDens, ElementViewConst< arrayView3d< real64 const, constitutive::cappres::USD_CAPPRES > > const &phaseCapPressure, ElementViewConst< arrayView4d< real64 const, constitutive::cappres::USD_CAPPRES_DS > > const &dPhaseCapPressure_dPhaseVolFrac, localIndex &k_up, real64 &potGrad, real64(&phaseFlux), real64(&dPhaseFlux_dP)[numFluxSupportPoints], real64(&dPhaseFlux_dC)[numFluxSupportPoints][numComp], real64(&compFlux)[numComp], real64(&dCompFlux_dP)[numFluxSupportPoints][numComp], real64(&dCompFlux_dC)[numFluxSupportPoints][numComp][numComp])
Form the PhasePotentialUpwind from pressure gradient and gravitational head.
static GEOS_HOST_DEVICE void compute(localIndex const ip, localIndex const k_up, localIndex const (&seri)[numFluxSupportPoints], localIndex const (&sesri)[numFluxSupportPoints], localIndex const (&sei)[numFluxSupportPoints], ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const &phaseCompFrac, ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > > const &dPhaseCompFrac, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const &dCompFrac_dCompDens, real64 const &phaseFlux, real64 const (&dPhaseFlux_dP)[numFluxSupportPoints], real64 const (&dPhaseFlux_dC)[numFluxSupportPoints][numComp], real64(&compFlux)[numComp], real64(&dCompFlux_dP)[numFluxSupportPoints][numComp], real64(&dCompFlux_dC)[numFluxSupportPoints][numComp][numComp])
Compute the component flux for a given phase.