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,
78 real64 & totalUncompactedPoreVol,
85 RAJA::ReduceMin< parallelDeviceReduce, real64 > subRegionMinPres( LvArray::NumericLimits< real64 >::max );
86 RAJA::ReduceSum< parallelDeviceReduce, real64 > subRegionAvgPresNumerator( 0.0 );
87 RAJA::ReduceMax< parallelDeviceReduce, real64 > subRegionMaxPres( -LvArray::NumericLimits< real64 >::max );
88 RAJA::ReduceMin< parallelDeviceReduce, real64 > subRegionMinDeltaPres( LvArray::NumericLimits< real64 >::max );
89 RAJA::ReduceMax< parallelDeviceReduce, real64 > subRegionMaxDeltaPres( -LvArray::NumericLimits< real64 >::max );
90 RAJA::ReduceMin< parallelDeviceReduce, real64 > subRegionMinTemp( LvArray::NumericLimits< real64 >::max );
91 RAJA::ReduceSum< parallelDeviceReduce, real64 > subRegionAvgTempNumerator( 0.0 );
92 RAJA::ReduceMax< parallelDeviceReduce, real64 > subRegionMaxTemp( 0.0 );
93 RAJA::ReduceSum< parallelDeviceReduce, real64 > subRegionTotalUncompactedPoreVol( 0.0 );
99 forAll< parallelDevicePolicy<> >( size, [numComps,
115 subRegionAvgPresNumerator,
117 subRegionMinDeltaPres,
118 subRegionMaxDeltaPres,
120 subRegionAvgTempNumerator,
122 subRegionTotalUncompactedPoreVol,
129 if( elemGhostRank[ei] >= 0 )
135 real64 const uncompactedPoreVol = volume[ei] * refPorosity[ei];
136 real64 const dynamicPoreVol = volume[ei] * porosity[ei][0];
138 subRegionMinPres.min( pres[ei] );
139 subRegionAvgPresNumerator += uncompactedPoreVol * pres[ei];
140 subRegionMaxPres.max( pres[ei] );
142 subRegionMaxDeltaPres.max( deltaPres[ei] );
143 subRegionMinDeltaPres.min( deltaPres[ei] );
145 subRegionMinTemp.min( temp[ei] );
146 subRegionAvgTempNumerator += uncompactedPoreVol * temp[ei];
147 subRegionMaxTemp.max( temp[ei] );
148 subRegionTotalUncompactedPoreVol += uncompactedPoreVol;
149 for(
integer ip = 0; ip < numPhases; ++ip )
151 real64 const elemPhaseVolume = dynamicPoreVol * phaseVolFrac[ei][ip];
152 real64 const elemPhaseMass = phaseDensity[ei][0][ip] * elemPhaseVolume;
153 real64 const elemTrappedPhaseMass = phaseDensity[ei][0][ip] * dynamicPoreVol * phaseTrappedVolFrac[ei][0][ip];
155 RAJA::atomicAdd( parallelDeviceAtomic{}, &phaseDynamicPoreVol[ip], elemPhaseVolume );
156 RAJA::atomicAdd( parallelDeviceAtomic{}, &phaseMass[ip], elemPhaseMass );
157 RAJA::atomicAdd( parallelDeviceAtomic{}, &trappedPhaseMass[ip], elemTrappedPhaseMass );
158 if( phaseRelperm[ei][0][ip] < relpermThreshold )
160 RAJA::atomicAdd( parallelDeviceAtomic{}, &immobilePhaseMass[ip], elemPhaseMass );
162 for(
integer ic = 0; ic < numComps; ++ic )
165 RAJA::atomicAdd( parallelDeviceAtomic{}, &dissolvedComponentMass[ip][ic], phaseCompFraction[ei][0][ip][ic] * elemPhaseMass );
171 minPres = subRegionMinPres.get();
172 avgPresNumerator = subRegionAvgPresNumerator.get();
173 maxPres = subRegionMaxPres.get();
174 minDeltaPres = subRegionMinDeltaPres.get();
175 maxDeltaPres = subRegionMaxDeltaPres.get();
176 minTemp = subRegionMinTemp.get();
177 avgTempNumerator = subRegionAvgTempNumerator.get();
178 maxTemp = subRegionMaxTemp.get();
179 totalUncompactedPoreVol = subRegionTotalUncompactedPoreVol.get();
182 forAll< serialPolicy >( 1, [phaseDynamicPoreVol, phaseMass, trappedPhaseMass, immobilePhaseMass, dissolvedComponentMass] (
localIndex const )
184 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.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::int32_t integer
Signed integer type.
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.