20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_PHASEVOLUMEFRACTIONKERNEL_HPP 
   21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_PHASEVOLUMEFRACTIONKERNEL_HPP 
   28 namespace isothermalCompositionalMultiphaseBaseKernels
 
   39 template< 
integer NUM_COMP, 
integer NUM_PHASE >
 
   56                              constitutive::MultiFluidBase 
const & fluid )
 
   58     m_phaseVolFrac( subRegion.getField< fields::flow::phaseVolumeFraction >() ),
 
   59     m_dPhaseVolFrac( subRegion.getField< fields::flow::dPhaseVolumeFraction >() ),
 
   60     m_compDens( subRegion.getField< fields::flow::globalCompDensity >() ),
 
   61     m_dCompFrac_dCompDens( subRegion.getField< fields::flow::dGlobalCompFraction_dGlobalCompDensity >() ),
 
   63     m_dPhaseFrac( fluid.dPhaseFraction() ),
 
   65     m_dPhaseDens( fluid.dPhaseDensity() )
 
   74   template< 
typename FUNC = NoOpFunc >
 
   77                   FUNC && phaseVolFractionKernelOp = NoOpFunc{} ) 
const 
   79     using Deriv = constitutive::multifluid::DerivativeOffset;
 
   82     arraySlice2d< 
real64 const, compflow::USD_COMP_DC - 1 > 
const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei];
 
   84     arraySlice2d< 
real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > 
const dPhaseDens = m_dPhaseDens[ei][0];
 
   86     arraySlice2d< 
real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > 
const dPhaseFrac = m_dPhaseFrac[ei][0];
 
   88     arraySlice2d< 
real64, compflow::USD_PHASE_DC - 1 > 
const dPhaseVolFrac = m_dPhaseVolFrac[ei];
 
   94     real64 const dTotalDens_dCompDens = 1.0;
 
   97       totalDensity += compDens[ic];
 
  100     real64 maxDeltaPhaseVolFrac = 0.0;
 
  106       bool const phaseExists = (phaseFrac[ip] > 0);
 
  109         phaseVolFrac[ip] = 0.;
 
  112           dPhaseVolFrac[ip][jc] = 0.;
 
  118       real64 const phaseDensInv = 1.0 / phaseDens[ip];
 
  121       real64 const satOld = phaseVolFrac[ip];
 
  124       phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv;
 
  126       dPhaseVolFrac[ip][Deriv::dP] =
 
  127         (dPhaseFrac[ip][Deriv::dP] - phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dP]) * phaseDensInv;
 
  131         dPhaseVolFrac[ip][Deriv::dC+jc] =
 
  132           (dPhaseFrac[ip][Deriv::dC+jc] - phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dC+jc]) * phaseDensInv;
 
  136       applyChainRuleInPlace( 
numComp, dCompFrac_dCompDens, dPhaseVolFrac[ip], work, Deriv::dC );
 
  140       phaseVolFractionKernelOp( ip, phaseVolFrac[ip], phaseDensInv, totalDensity );
 
  145         dPhaseVolFrac[ip][Deriv::dC+jc] *= totalDensity;
 
  146         dPhaseVolFrac[ip][Deriv::dC+jc] += phaseVolFrac[ip] * dTotalDens_dCompDens;
 
  149       phaseVolFrac[ip] *= totalDensity;
 
  150       dPhaseVolFrac[ip][Deriv::dP] *= totalDensity;
 
  152       real64 const deltaPhaseVolFrac = LvArray::math::abs( phaseVolFrac[ip] - satOld );
 
  153       if( maxDeltaPhaseVolFrac < deltaPhaseVolFrac )
 
  155         maxDeltaPhaseVolFrac = deltaPhaseVolFrac;
 
  158     return maxDeltaPhaseVolFrac;
 
  168   template< 
typename POLICY, 
typename KERNEL_TYPE >
 
  171           KERNEL_TYPE 
const & kernelComponent )
 
  173     RAJA::ReduceMax< ReducePolicy< POLICY >, 
real64 > maxDeltaPhaseVolFrac( 0.0 );
 
  176       real64 const deltaPhaseVolFrac = kernelComponent.compute( ei );
 
  177       maxDeltaPhaseVolFrac.max( deltaPhaseVolFrac );
 
  179     return maxDeltaPhaseVolFrac.get();
 
  221   template< 
typename POLICY >
 
  226                    constitutive::MultiFluidBase 
const & fluid )
 
  228     real64 maxDeltaPhaseVolFrac = 0.0;
 
  231       internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( 
auto NC )
 
  233         integer constexpr NUM_COMP = NC();
 
  238     else if( numPhase == 3 )
 
  240       internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( 
auto NC )
 
  242         integer constexpr NUM_COMP = NC();
 
  247     return maxDeltaPhaseVolFrac;
 
#define GEOS_HOST_DEVICE
Marks a host-device function.
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.
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.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_phaseDens
Views on phase densities.
static real64 launch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
static constexpr integer numPhase
Compile time value for the number of phases.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_phaseFrac
Views on phase fractions.
PhaseVolumeFractionKernel(ObjectManagerBase &subRegion, constitutive::MultiFluidBase const &fluid)
Constructor.
GEOS_HOST_DEVICE real64 compute(localIndex const ei, FUNC &&phaseVolFractionKernelOp=NoOpFunc{}) const
Compute the phase volume fractions in an element.
arrayView2d< real64, compflow::USD_PHASE > m_phaseVolFrac
Views on phase volume fractions.
static constexpr integer numComp
Compile time value for the number of components.
arrayView2d< real64 const, compflow::USD_COMP > m_compDens
Views on component densities.
Define the base interface for the property update kernels.
static constexpr integer numComp
Compile time value for the number of components.
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
int integer
Signed integer type.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.