20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALSOLUTIONSCALINGKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALSOLUTIONSCALINGKERNEL_HPP
28 namespace thermalCompositionalMultiphaseBaseKernels
66 real64 const maxAbsolutePresChange,
67 real64 const maxRelativeTempChange,
68 real64 const maxAbsoluteTempChange,
69 real64 const maxCompFracChange,
70 real64 const maxRelativeCompDensChange,
82 integer const temperatureOffset )
83 :
Base( maxRelativePresChange,
84 maxAbsolutePresChange,
86 maxRelativeCompDensChange,
94 pressureScalingFactor,
95 compDensScalingFactor ),
97 m_maxAbsoluteTempChange( maxAbsoluteTempChange ),
124 real64 constexpr eps = isothermalCompositionalMultiphaseBaseKernels::minDensForDivision;
130 if( stack.localMaxDeltaTemp < absTempChange )
132 stack.localMaxDeltaTemp = absTempChange;
136 real64 tempScalingFactor = 1.0;
138 if( m_maxAbsoluteTempChange > 0.0 )
140 if( absTempChange > m_maxAbsoluteTempChange )
142 tempScalingFactor = m_maxAbsoluteTempChange / absTempChange;
147 real64 const relativeTempChange = absTempChange / temp;
154 if( stack.localMinVal > tempScalingFactor )
156 stack.localMinVal = tempScalingFactor;
158 if( stack.localMinTempScalingFactor > tempScalingFactor )
160 stack.localMinTempScalingFactor = tempScalingFactor;
169 real64 const m_maxAbsoluteTempChange;
203 template<
typename POLICY >
206 real64 const maxAbsolutePresChange,
207 real64 const maxRelativeTempChange,
208 real64 const maxAbsoluteTempChange,
209 real64 const maxCompFracChange,
210 real64 const maxRelativeCompDensChange,
222 integer const temperatureOffset )
224 SolutionScalingKernel kernel( maxRelativePresChange, maxAbsolutePresChange, maxRelativeTempChange, maxAbsoluteTempChange,
225 maxCompFracChange, maxRelativeCompDensChange,
226 rankOffset, numComp, dofKey, subRegion, localSolution,
227 pressure, temperature, compDens, pressureScalingFactor,
228 compDensScalingFactor, temperatureScalingFactor, temperatureOffset );
229 return thermalCompositionalMultiphaseBaseKernels::
230 SolutionScalingKernel::launch< POLICY >( subRegion.
size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
arrayView1d< real64 const > const m_localSolution
View on the local residual.
real64 const m_numComp
Number of components.
Define the kernel for scaling the Newton update.
GEOS_HOST_DEVICE void computeScalingFactor(localIndex const ei, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local value of the scaling factor.
static SolutionScalingKernel::StackVariables createAndLaunch(real64 const maxRelativePresChange, real64 const maxAbsolutePresChange, real64 const maxRelativeTempChange, real64 const maxAbsoluteTempChange, real64 const maxCompFracChange, real64 const maxRelativeCompDensChange, arrayView1d< real64 const > const pressure, arrayView1d< real64 const > const temperature, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > compDensScalingFactor, arrayView1d< real64 > temperatureScalingFactor, globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase &subRegion, arrayView1d< real64 const > const localSolution, integer const temperatureOffset)
Create a new kernel and launch.
Define the kernel for scaling the Newton update.
GEOS_HOST_DEVICE void compute(localIndex const ei, StackVariables &stack) const
Compute the local value.
arrayView1d< real64 > const m_temperatureScalingFactor
View on the scaling factor.
real64 const m_maxRelativeTempChange
Max allowed changes in primary variables.
arrayView1d< real64 const > const m_temperature
View on the primary variables.
integer const m_temperatureOffset
Temperature offset in solution array.
GEOS_HOST_DEVICE void computeScalingFactor(localIndex const ei, StackVariables &stack) const
Compute the local value of the scaling factor.
SolutionScalingKernel(real64 const maxRelativePresChange, real64 const maxAbsolutePresChange, real64 const maxRelativeTempChange, real64 const maxAbsoluteTempChange, real64 const maxCompFracChange, real64 const maxRelativeCompDensChange, globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase const &subRegion, arrayView1d< real64 const > const localSolution, arrayView1d< real64 const > const pressure, arrayView1d< real64 const > const temperature, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > compDensScalingFactor, arrayView1d< real64 > temperatureScalingFactor, integer const temperatureOffset)
Create a new kernel instance.
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).
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
int integer
Signed integer type.
Kernel variables located on the stack.