20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_SOLUTIONCHECKKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_SOLUTIONCHECKKERNEL_HPP
28 namespace isothermalCompositionalMultiphaseBaseKernels
48 using Base::m_compDens;
63 integer const allowNegativePressure,
65 real64 const scalingFactor,
82 pressureScalingFactor,
83 compDensScalingFactor ),
103 real64 _localMinTotalDens,
106 integer _localNumNegTotalDens )
108 Base::StackVariables( _localMinVal ),
109 localMinPres( _localMinPres ),
110 localMinDens( _localMinDens ),
111 localMinTotalDens( _localMinTotalDens ),
112 localNumNegPressures( _localNumNegPressures ),
113 localNumNegDens( _localNumNegDens ),
114 localNumNegTotalDens( _localNumNegTotalDens )
134 template<
typename POLICY,
typename KERNEL_TYPE >
137 KERNEL_TYPE
const & kernelComponent )
139 RAJA::ReduceMin< ReducePolicy< POLICY >,
integer > globalMinVal( 1 );
141 RAJA::ReduceMin< ReducePolicy< POLICY >,
real64 > minPres( 0.0 );
142 RAJA::ReduceMin< ReducePolicy< POLICY >,
real64 > minDens( 0.0 );
143 RAJA::ReduceMin< ReducePolicy< POLICY >,
real64 > minTotalDens( 0.0 );
145 RAJA::ReduceSum< ReducePolicy< POLICY >,
integer > numNegPressures( 0 );
146 RAJA::ReduceSum< ReducePolicy< POLICY >,
integer > numNegDens( 0 );
147 RAJA::ReduceSum< ReducePolicy< POLICY >,
integer > numNegTotalDens( 0 );
151 if( kernelComponent.ghostRank( ei ) >= 0 )
157 kernelComponent.setup( ei, stack );
158 kernelComponent.compute( ei, stack );
160 globalMinVal.min( stack.localMinVal );
162 minPres.min( stack.localMinPres );
163 minDens.min( stack.localMinDens );
164 minTotalDens.min( stack.localMinTotalDens );
166 numNegPressures += stack.localNumNegPressures;
167 numNegDens += stack.localNumNegDens;
168 numNegTotalDens += stack.localNumNegTotalDens;
175 numNegPressures.get(),
177 numNegTotalDens.get() );
182 StackVariables & stack )
const
186 stack.localMinPres = 0.0;
187 stack.localMinDens = 0.0;
188 stack.localMinTotalDens = 0.0;
190 stack.localNumNegPressures = 0;
191 stack.localNumNegDens = 0;
192 stack.localNumNegTotalDens = 0;
214 template<
typename FUNC = NoOpFunc >
218 FUNC && kernelOp = NoOpFunc{} )
const
227 stack.localMinVal = 0;
229 stack.localNumNegPressures += 1;
230 if( newPres < stack.localMinPres )
231 stack.localMinPres = newPres;
244 stack.localMinVal = 0;
245 stack.localNumNegDens += 1;
246 if( newDens < stack.localMinDens )
247 stack.localMinDens = newDens;
257 totalDens += ( newDens > 0.0 ) ? newDens : 0.0;
261 stack.localMinVal = 0;
262 stack.localNumNegTotalDens += 1;
263 if( totalDens < stack.localMinTotalDens )
264 stack.localMinTotalDens = totalDens;
305 template<
typename POLICY >
308 integer const allowNegativePressure,
310 real64 const scalingFactor,
321 SolutionCheckKernel kernel( allowCompDensChopping, allowNegativePressure, scalingType, scalingFactor,
322 pressure, compDens, pressureScalingFactor, compDensScalingFactor, rankOffset,
323 numComp, dofKey, subRegion, localSolution );
324 return SolutionCheckKernel::launch< POLICY >( subRegion.
size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
ScalingType
Solution scaling type.
@ Local
Scale the Newton update locally (modifies the Newton direction)
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
static SolutionCheckKernel::StackVariables createAndLaunch(integer const allowCompDensChopping, integer const allowNegativePressure, CompositionalMultiphaseFVM::ScalingType const scalingType, real64 const scalingFactor, arrayView1d< real64 const > const pressure, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > compDensScalingFactor, globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase &subRegion, arrayView1d< real64 const > const localSolution)
Create a new kernel and launch.
Define the kernel for checking the updated solution.
GEOS_HOST_DEVICE void computeSolutionCheck(localIndex const ei, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local value of the check.
integer const m_allowNegativePressure
flag to allow negative pressure values
real64 const m_scalingFactor
scaling factor
SolutionCheckKernel(integer const allowCompDensChopping, integer const allowNegativePressure, CompositionalMultiphaseFVM::ScalingType const scalingType, real64 const scalingFactor, arrayView1d< real64 const > const pressure, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > compDensScalingFactor, globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase const &subRegion, arrayView1d< real64 const > const localSolution)
Create a new kernel instance.
GEOS_HOST_DEVICE void compute(localIndex const ei, StackVariables &stack) const
Compute the local value.
static StackVariables launch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
CompositionalMultiphaseFVM::ScalingType const m_scalingType
scaling type (global or local)
integer const m_allowCompDensChopping
flag to allow the component density chopping
Define the kernel for scaling the solution and check its validity.
arrayView1d< integer const > const m_ghostRank
View on the ghost ranks.
globalIndex const m_rankOffset
Offset for my MPI rank.
arrayView1d< real64 const > const m_localSolution
View on the local residual.
arrayView1d< real64 > const m_pressureScalingFactor
View on the scaling factors.
arrayView1d< globalIndex const > const m_dofNumber
View on the dof numbers.
GEOS_HOST_DEVICE void setup(localIndex const ei, StackVariables &stack) const
Performs the setup phase for the kernel.
arrayView1d< real64 const > const m_pressure
View on the primary variables.
real64 const m_numComp
Number of components.
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).
std::int32_t integer
Signed integer type.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Kernel variables located on the stack.