20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_THERMALSOLUTIONSCALINGKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_THERMALSOLUTIONSCALINGKERNEL_HPP
24 #include "common/GEOS_RAJA_Interface.hpp"
30 namespace thermalSinglePhaseBaseKernels
37 template<
typename POLICY >
41 integer const temperatureOffset,
44 real64 const maxAbsolutePresChange,
45 real64 const maxAbsoluteTempChange,
49 RAJA::ReduceMin< ReducePolicy< POLICY >,
real64 > scalingFactor( 1.0 );
50 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > maxDeltaPres( 0.0 );
51 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > maxDeltaTemp( 0.0 );
53 RAJA::ReduceMin< ReducePolicy< POLICY >,
real64 > localMinPresScalingFactor( 1.0 );
54 RAJA::ReduceMin< ReducePolicy< POLICY >,
real64 > localMinTempScalingFactor( 1.0 );
58 if( ghostRank[ei] < 0 && dofNumber[ei] >= 0 )
60 pressureScalingFactor[ei] = 1.0;
61 temperatureScalingFactor[ei] = 1.0;
63 localIndex const lid = dofNumber[ei] - rankOffset;
66 real64 const absPresChange = LvArray::math::abs( localSolution[lid] );
67 maxDeltaPres.max( absPresChange );
70 real64 const absTempChange = LvArray::math::abs( localSolution[lid + temperatureOffset] );
71 maxDeltaTemp.max( absTempChange );
74 if( maxAbsolutePresChange > 0.0 && absPresChange > maxAbsolutePresChange )
76 real64 const presScalingFactor = maxAbsolutePresChange / absPresChange;
77 pressureScalingFactor[ei] = presScalingFactor;
78 scalingFactor.min( presScalingFactor );
80 localMinPresScalingFactor.min( presScalingFactor );
84 if( maxAbsoluteTempChange > 0.0 && absTempChange > maxAbsoluteTempChange )
86 real64 const tempScalingFactor = maxAbsoluteTempChange / absTempChange;
87 temperatureScalingFactor[ei] = tempScalingFactor;
88 scalingFactor.min( tempScalingFactor );
90 localMinTempScalingFactor.min( tempScalingFactor );
98 scalingData.maxDeltaPres = maxDeltaPres.get();
99 scalingData.maxDeltaTemp = maxDeltaTemp.get();
100 scalingData.minPresScalingFactor = localMinPresScalingFactor.get();
101 scalingData.minTempScalingFactor = localMinTempScalingFactor.get();
#define GEOS_HOST_DEVICE
Marks a host-device function.
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).
int integer
Signed integer type.
Rank-local reductions from the single-phase solution scaling kernels.
real64 scalingFactor
the Newton update scaling factor