20 #ifndef GEOS_PHYSICSSOLVERS_SOLVERBASEKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_SOLVERBASEKERNELS_HPP
30 namespace physicsSolverBaseKernels
40 template<
integer NUM_NORM >
53 real64 const minNormalizer ):
145 template<
typename POLICY,
typename KERNEL_TYPE >
148 KERNEL_TYPE
const & kernelComponent,
151 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > localResidualNorm[
numNorm]{};
155 if( kernelComponent.ghostRank( i ) >= 0 )
160 typename KERNEL_TYPE::LinfStackVariables stack;
161 kernelComponent.setupLinf( i, stack );
162 kernelComponent.computeLinf( i, stack );
166 localResidualNorm[j].max( LvArray::math::abs( stack.localValue[j] ) );
172 residualNorm[j] = localResidualNorm[j].get();
185 template<
typename POLICY,
typename KERNEL_TYPE >
188 KERNEL_TYPE
const & kernelComponent,
192 RAJA::ReduceSum< ReducePolicy< POLICY >,
real64 > localResidualNorm[
numNorm]{};
193 RAJA::ReduceSum< ReducePolicy< POLICY >,
real64 > localResidualNormalizer[
numNorm]{};
197 if( kernelComponent.ghostRank( i ) >= 0 )
202 typename KERNEL_TYPE::L2StackVariables stack;
203 kernelComponent.setupL2( i, stack );
204 kernelComponent.computeL2( i, stack );
208 localResidualNorm[j] += stack.localValue[j];
209 localResidualNormalizer[j] += stack.localNormalizer[j];
215 residualNorm[j] = localResidualNorm[j].get();
216 residualNormalizer[j] = localResidualNormalizer[j].get();
248 template<
integer NUM_NORM >
249 static void updateLocalNorm(
real64 const (&subRegionResidualNorm)[NUM_NORM],
252 for(
integer i = 0; i < NUM_NORM; ++i )
254 if( subRegionResidualNorm[i] > localResidualNorm[i] )
256 localResidualNorm[i] = subRegionResidualNorm[i];
261 static void computeGlobalNorm(
real64 const & localResidualNorm,
262 real64 & globalResidualNorm )
271 globalResidualNorm.data(),
272 localResidualNorm.size(),
286 template<
integer NUM_NORM >
287 static void updateLocalNorm(
real64 const (&subRegionResidualNorm)[NUM_NORM],
288 real64 const (&subRegionResidualNormalizer)[NUM_NORM],
292 for(
integer i = 0; i < NUM_NORM; ++i )
294 localResidualNorm[i] += subRegionResidualNorm[i];
295 localResidualNormalizer[i] += subRegionResidualNormalizer[i];
299 static void computeGlobalNorm(
real64 const & localResidualNorm,
300 real64 const & localResidualNormalizer,
301 real64 & globalResidualNorm )
313 sumLocalResidualNorm.data(),
314 localResidualNorm.size(),
318 sumLocalResidualNormalizer.data(),
319 localResidualNormalizer.size(),
322 for(
integer i = 0; i < localResidualNorm.size(); ++i )
324 globalResidualNorm[i] = sqrt( sumLocalResidualNorm[i] ) / sqrt( sumLocalResidualNormalizer[i] );
#define GEOS_HOST_DEVICE
Marks a host-device function.
NormType
Type of norm used to check convergence TODO: find a way to put this inside the class.
Utility class to compute the global L2 residual norm.
Utility class to compute the global Linf residual norm.
Define the base interface for the residual calculations.
arrayView1d< integer const > const m_ghostRank
View on the ghost ranks.
virtual GEOS_HOST_DEVICE void computeL2(localIndex const i, L2StackVariables &stack) const =0
Compute the local values and normalizer for the L2 norm.
real64 const m_minNormalizer
Value used to make sure that normalizers are never zero.
virtual GEOS_HOST_DEVICE void setupLinf(localIndex const i, LinfStackVariables &stack) const
Setup the residual Linf normal calculations.
arrayView1d< globalIndex const > const m_dofNumber
View on the dof numbers.
GEOS_HOST_DEVICE integer ghostRank(localIndex const i) const
Getter for the ghost rank.
static void launchLinf(localIndex const size, KERNEL_TYPE const &kernelComponent, real64(&residualNorm)[numNorm])
Performs the kernel launch for the L-\infty norm.
static void launchL2(localIndex const size, KERNEL_TYPE const &kernelComponent, real64(&residualNorm)[numNorm], real64(&residualNormalizer)[numNorm])
Performs the kernel launch for the L2 norm.
globalIndex const m_rankOffset
Offset for my MPI rank.
virtual GEOS_HOST_DEVICE void setupL2(localIndex const i, L2StackVariables &stack) const
Setup the residual L2 normal calculations.
arrayView1d< real64 const > const m_localResidual
View on the local residual.
static constexpr integer numNorm
Compile time value for the number of norms to compute.
virtual GEOS_HOST_DEVICE void computeLinf(localIndex const i, LinfStackVariables &stack) const =0
Compute the local values for the Linf norm.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
int MPI_COMM_GEOS
Global MPI communicator used by GEOSX.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
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.
Array< T, 1 > array1d
Alias for 1D array.
static MPI_Op getMpiOp(Reduction const op)
Returns an MPI_Op associated with our strongly typed Reduction enum.
static T max(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MAX operation.
static int allReduce(T const *sendbuf, T *recvbuf, int count, MPI_Op op, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Allreduce.
static T sum(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_SUM operation.
Kernel variables located on the stack for L2 norm.
real64 localNormalizer[numNorm]
Normalizer value for the element/node/face.
Kernel variables located on the stack for Linf norm.
localIndex localRow
Index of the local row in the residual vector.
real64 localValue[numNorm]
Normalized residual value for the element/node/face.