20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_STATISTICSKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_STATISTICSKERNEL_HPP
25 #include "common/GEOS_RAJA_Interface.hpp"
26 #include "constitutive/relativePermeability/Layouts.hpp"
32 namespace isothermalCompositionalMultiphaseBaseKernels
39 template<
typename POLICY >
48 deltaPres[ei] = pres[ei] - initPres[ei];
52 template<
typename POLICY >
57 real64 const relpermThreshold,
79 real64 & totalUncompactedPoreVol,
86 RAJA::ReduceSum< parallelDeviceReduce, localIndex > subRegionElemCount( 0 );
87 RAJA::ReduceMin< parallelDeviceReduce, real64 > subRegionMinPres( LvArray::NumericLimits< real64 >::max );
88 RAJA::ReduceSum< parallelDeviceReduce, real64 > subRegionAvgPresNumerator( 0.0 );
89 RAJA::ReduceMax< parallelDeviceReduce, real64 > subRegionMaxPres( -LvArray::NumericLimits< real64 >::max );
90 RAJA::ReduceMin< parallelDeviceReduce, real64 > subRegionMinDeltaPres( LvArray::NumericLimits< real64 >::max );
91 RAJA::ReduceMax< parallelDeviceReduce, real64 > subRegionMaxDeltaPres( -LvArray::NumericLimits< real64 >::max );
92 RAJA::ReduceMin< parallelDeviceReduce, real64 > subRegionMinTemp( LvArray::NumericLimits< real64 >::max );
93 RAJA::ReduceSum< parallelDeviceReduce, real64 > subRegionAvgTempNumerator( 0.0 );
94 RAJA::ReduceMax< parallelDeviceReduce, real64 > subRegionMaxTemp( 0.0 );
95 RAJA::ReduceSum< parallelDeviceReduce, real64 > subRegionTotalUncompactedPoreVol( 0.0 );
101 forAll< parallelDevicePolicy<> >( targetSet.size(),
120 subRegionAvgPresNumerator,
122 subRegionMinDeltaPres,
123 subRegionMaxDeltaPres,
125 subRegionAvgTempNumerator,
127 subRegionTotalUncompactedPoreVol,
136 if( elemGhostRank[ei] >= 0 )
140 real64 const uncompactedPoreVol = volume[ei] * refPorosity[ei];
141 real64 const dynamicPoreVol = volume[ei] * porosity[ei][0];
143 subRegionElemCount += 1;
145 subRegionMinPres.min( pres[ei] );
146 subRegionAvgPresNumerator += uncompactedPoreVol * pres[ei];
147 subRegionMaxPres.max( pres[ei] );
149 subRegionMaxDeltaPres.max( deltaPres[ei] );
150 subRegionMinDeltaPres.min( deltaPres[ei] );
152 subRegionMinTemp.min( temp[ei] );
153 subRegionAvgTempNumerator += uncompactedPoreVol * temp[ei];
154 subRegionMaxTemp.max( temp[ei] );
155 subRegionTotalUncompactedPoreVol += uncompactedPoreVol;
156 for(
integer ip = 0; ip < numPhases; ++ip )
158 real64 const elemPhaseVolume = dynamicPoreVol * phaseVolFrac[ei][ip];
159 real64 const elemPhaseMass = phaseDensity[ei][0][ip] * elemPhaseVolume;
160 real64 const elemTrappedPhaseMass = phaseDensity[ei][0][ip] * dynamicPoreVol * phaseTrappedVolFrac[ei][0][ip];
162 RAJA::atomicAdd( parallelDeviceAtomic{}, &phaseDynamicPoreVol[ip], elemPhaseVolume );
163 RAJA::atomicAdd( parallelDeviceAtomic{}, &phaseMass[ip], elemPhaseMass );
164 RAJA::atomicAdd( parallelDeviceAtomic{}, &trappedPhaseMass[ip], elemTrappedPhaseMass );
165 if( phaseRelperm[ei][0][ip] < relpermThreshold )
167 RAJA::atomicAdd( parallelDeviceAtomic{}, &immobilePhaseMass[ip], elemPhaseMass );
169 for(
integer ic = 0; ic < numComps; ++ic )
172 RAJA::atomicAdd( parallelDeviceAtomic{}, &dissolvedComponentMass[ip][ic], phaseCompFraction[ei][0][ip][ic] * elemPhaseMass );
178 elemCount =
globalIndex( subRegionElemCount.get() );
180 minPres = subRegionMinPres.get();
181 avgPresNumerator = subRegionAvgPresNumerator.get();
182 maxPres = subRegionMaxPres.get();
183 minDeltaPres = subRegionMinDeltaPres.get();
184 maxDeltaPres = subRegionMaxDeltaPres.get();
186 minTemp = subRegionMinTemp.get();
187 avgTempNumerator = subRegionAvgTempNumerator.get();
188 maxTemp = subRegionMaxTemp.get();
190 totalUncompactedPoreVol = subRegionTotalUncompactedPoreVol.get();
193 forAll< serialPolicy >( 1, [phaseDynamicPoreVol, phaseMass, trappedPhaseMass, immobilePhaseMass, dissolvedComponentMass] (
localIndex const )
195 GEOS_UNUSED_VAR( phaseDynamicPoreVol, phaseMass, trappedPhaseMass, immobilePhaseMass, dissolvedComponentMass );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
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.