GEOS
PhaseComponentFluxZFormulation.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_PHASECOMPONENTFLUXZFORMULATION_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_PHASECOMPONENTFLUXZFORMULATION_HPP
22 
23 #include "common/DataLayouts.hpp"
24 #include "common/DataTypes.hpp"
25 #include "constitutive/fluid/multifluid/Layouts.hpp"
27 
28 
29 namespace geos
30 {
31 
32 namespace isothermalCompositionalMultiphaseFVMKernelUtilities
33 {
34 
35 template< typename VIEWTYPE >
36 using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >;
37 
38 using Deriv = constitutive::multifluid::DerivativeOffset;
39 
41 {
60  template< localIndex numComp, localIndex numFluxSupportPoints >
62  static void
63  compute( localIndex const ip,
64  localIndex const k_up,
65  localIndex const ( &seri )[numFluxSupportPoints],
66  localIndex const ( &sesri )[numFluxSupportPoints],
67  localIndex const ( &sei )[numFluxSupportPoints],
68  ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const & phaseCompFrac,
69  ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac,
70  real64 const & phaseFlux,
71  real64 const ( &dPhaseFlux_dP )[numFluxSupportPoints],
72  real64 const ( &dPhaseFlux_dC )[numFluxSupportPoints][numComp],
73  real64 ( & compFlux )[numComp],
74  real64 ( & dCompFlux_dP )[numFluxSupportPoints][numComp],
75  real64 ( & dCompFlux_dC )[numFluxSupportPoints][numComp][numComp] )
76  {
77  localIndex const er_up = seri[k_up];
78  localIndex const esr_up = sesri[k_up];
79  localIndex const ei_up = sei[k_up];
80 
81  // slice some constitutive arrays to avoid too much indexing in component loop
82  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE_COMP-3 > phaseCompFracSub =
83  phaseCompFrac[er_up][esr_up][ei_up][0][ip];
84  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFracSub =
85  dPhaseCompFrac[er_up][esr_up][ei_up][0][ip];
86 
87  // compute component fluxes and derivatives using upstream cell composition
88  for( integer ic = 0; ic < numComp; ++ic )
89  {
90  real64 const ycp = phaseCompFracSub[ic];
91  compFlux[ic] += phaseFlux * ycp;
92 
93  // derivatives stemming from phase flux
94  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
95  {
96  dCompFlux_dP[ke][ic] += dPhaseFlux_dP[ke] * ycp;
97  for( integer jc = 0; jc < numComp; ++jc )
98  {
99  dCompFlux_dC[ke][ic][jc] += dPhaseFlux_dC[ke][jc] * ycp;
100  }
101  }
102 
103  // additional derivatives stemming from upstream cell phase composition
104  dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFracSub[ic][Deriv::dP];
105 
106  // convert derivatives of comp fraction w.r.t. comp fractions to derivatives w.r.t. comp densities
107  for( integer jc = 0; jc < numComp; ++jc )
108  {
109  dCompFlux_dC[k_up][ic][jc] += phaseFlux * dPhaseCompFracSub[ic][Deriv::dC+jc];
110  }
111  }
112  }
113 };
114 
115 } // namespace isothermalCompositionalMultiPhaseFVMKernelUtilities
116 
117 } // namespace geos
118 
119 #endif // GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_PHASECOMPONENTFLUXZFORMULATION_HPP
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:200
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
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, 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.