20 #ifndef GEOS_COMMON_FIELDSPECIFICATIONOPS_HPP
21 #define GEOS_COMMON_FIELDSPECIFICATIONOPS_HPP
23 #include "codingUtilities/traits.hpp"
25 #include "common/GEOS_RAJA_Interface.hpp"
42 template<
typename T,
typename U >
44 void apply( T & lhs, U
const & rhs )
46 lhs =
static_cast< T
>( rhs );
62 template<
typename T,
typename U >
64 void apply( T & lhs, U
const & rhs )
66 lhs +=
static_cast< T
>( rhs );
73 template<
typename OP >
90 template<
typename T >
92 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
99 OP::template apply( field( index ), value );
114 template<
typename T >
116 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
122 OP::template apply( field( index )[component], value );
136 template<
typename T >
138 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
145 OP::template apply( value, field( index ) );
159 template<
typename T >
161 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
167 OP::template apply( value, field( index )[component] );
182 template<
typename T,
int USD >
184 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
192 OP::template apply( field( index, component ), value );
196 for(
localIndex a = 0; a < field.size( 1 ); ++a )
198 OP::template apply( field( index, a ), value );
216 template<
typename T,
int USD >
218 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
226 for(
localIndex a = 0; a < field.size( 1 ); ++a )
228 OP::template apply( field( index, a )[component], value );
233 for(
localIndex a = 0; a < field.size( 1 ); ++a )
237 OP::template apply( field( index, a )[c], value );
255 template<
typename T,
int USD >
257 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
264 OP::template apply( value, field( index, component ) );
277 template<
typename T,
int USD >
279 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
289 GEOS_ERROR(
"readFieldValue: unsupported operation" );
304 template<
typename T,
int USD >
306 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
314 for(
localIndex a = 0; a < field.size( 1 ); ++a )
316 OP::template apply( field( index, a, component ), value );
321 for(
localIndex a = 0; a < field.size( 1 ); ++a )
323 for(
localIndex b = 0; b < field.size( 2 ); ++b )
325 OP::template apply( field( index, a, b ), value );
344 template<
typename T,
int USD >
346 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
354 for(
localIndex a = 0; a < field.size( 1 ); ++a )
356 for(
localIndex b = 0; b < field.size( 2 ); ++b )
358 OP::template apply( field( index, a, b )[component], value );
364 for(
localIndex a = 0; a < field.size( 1 ); ++a )
366 for(
localIndex b = 0; b < field.size( 2 ); ++b )
370 OP::template apply( field( index, a, b )[c], value );
386 template<
typename T,
int USD >
398 GEOS_ERROR(
"readFieldValue: unsupported operation" );
413 template<
typename T,
int USD >
415 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
423 for(
localIndex a = 0; a < field.size( 1 ); ++a )
425 for(
localIndex b = 0; b < field.size( 2 ); ++b )
427 OP::template apply( field( index, a, b, component ), value );
433 for(
localIndex a = 0; a < field.size( 1 ); ++a )
435 for(
localIndex b = 0; b < field.size( 2 ); ++b )
437 for(
localIndex c = 0; c < field.size( 3 ); ++c )
439 OP::template apply( field( index, a, b, c ), value );
459 template<
typename T,
int USD >
461 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
469 for(
localIndex a = 0; a < field.size( 1 ); ++a )
471 for(
localIndex b = 0; b < field.size( 2 ); ++b )
473 for(
localIndex c = 0; c < field.size( 3 ); ++c )
475 OP::template apply( field( index, a, b, c )[component], value );
482 for(
localIndex a = 0; a < field.size( 1 ); ++a )
484 for(
localIndex b = 0; b < field.size( 2 ); ++b )
486 for(
localIndex c = 0; c < field.size( 3 ); ++c )
490 OP::template apply( field( index, a, b, c )[d], value );
507 template<
typename T,
int USD >
519 GEOS_ERROR(
"readFieldValue: unsupported operation" );
563 if( localRow >= 0 && localRow < matrix.numRows() )
567 localIndex const numEntries = matrix.numNonZeros( localRow );
570 real64 const minDiagonal = 1e-15;
573 if( columns[ j ] == dof )
576 if( entries[j] >= 0 && entries[j] < minDiagonal )
578 entries[ j ] = minDiagonal;
580 else if( entries[j] < 0 && entries[j] > -minDiagonal )
582 entries[ j ] = -minDiagonal;
584 diagonal = entries[j];
587 { entries[ j ] = 0; }
590 rhs = -diagonal * (bcValue - fieldValue);
606 template<
typename POLICY >
615 globalIndex const localRow = dof[ a ] - dofRankOffset;
616 if( localRow >= 0 && localRow < rhs.size() )
617 { rhs[ localRow ] = values[ a ]; }
667 template<
typename POLICY >
676 globalIndex const localRow = dof[ a ] - dofRankOffset;
677 if( localRow >= 0 && localRow < rhs.size() )
678 { rhs[ localRow ] += values[ a ]; }
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
#define GEOS_ASSERT(EXP)
Assert a condition in debug builds.
#define GEOS_ASSERT_EQ(lhs, rhs)
Assert that two values compare equal in debug builds.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix 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).
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
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.
static GEOS_HOST_DEVICE void SpecifyFieldValue(globalIndex const dof, globalIndex const dofRankOffset, CRSMatrixView< real64, globalIndex const > const &matrix, real64 &rhs, real64 const bcValue, real64 const fieldValue)
Function to apply a value to a vector field for a single dof.
static void prescribeRhsValues(arrayView1d< real64 > const &rhs, arrayView1d< globalIndex const > const &dof, globalIndex const dofRankOffset, arrayView1d< real64 const > const &values)
Function to add some values of a vector.
static void prescribeRhsValues(arrayView1d< real64 > const &rhs, arrayView1d< globalIndex const > const &dof, globalIndex const dofRankOffset, arrayView1d< real64 const > const &values)
Function to add some values of a vector.
static GEOS_HOST_DEVICE void SpecifyFieldValue(globalIndex const dof, globalIndex const dofRankOffset, CRSMatrixView< real64, globalIndex const > const &matrix, real64 &rhs, real64 const bcValue, real64 const fieldValue)
Function to apply a Dirichlet like boundary condition to a single dof in a system of equations.
OP OpType
Alias for OP, the operator.
static GEOS_HOST_DEVICE void readFieldValue(arrayView3d< T const, USD > const &field, localIndex const index, integer const component, real64 &value)
This function is not meaningful. It exists for generic purposes, but will result in an error if calle...
static GEOS_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView1d< T > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field.
static GEOS_HOST_DEVICE std::enable_if< traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView1d< T > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of value to a field variable.
static GEOS_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type readFieldValue(arrayView2d< T const, USD > const &field, localIndex const index, integer const component, real64 &value)
Read value from a 2d field.
static GEOS_HOST_DEVICE void readFieldValue(arrayView4d< T const, USD > const &field, localIndex const index, integer const component, real64 &value)
This function is not meaningful. It exists for generic purposes, but will result in an error if calle...
static GEOS_HOST_DEVICE std::enable_if< traits::is_tensorT< T >, void >::type readFieldValue(arrayView2d< T const, USD > const &field, localIndex const index, integer const component, real64 &value)
This function is not meaningful. It exists for generic purposes, but will result in an error if calle...
static GEOS_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView3d< T, USD > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field variable.
static GEOS_HOST_DEVICE std::enable_if< traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView2d< T, USD > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field variable.
static GEOS_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView4d< T, USD > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field variable.
static GEOS_HOST_DEVICE std::enable_if< traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView3d< T, USD > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field variable.
static GEOS_HOST_DEVICE std::enable_if< traits::is_tensorT< T >, void >::type readFieldValue(arrayView1d< T const > const &field, localIndex const index, integer const component, real64 &value)
Read a field value.
static GEOS_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type readFieldValue(arrayView1d< T const > const &field, localIndex const index, integer const component, real64 &value)
Read a field value.
static GEOS_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView2d< T, USD > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field variable.
static GEOS_HOST_DEVICE std::enable_if< traits::is_tensorT< T >, void >::type SpecifyFieldValue(arrayView4d< T, USD > const &field, localIndex const index, integer const component, real64 const value)
Pointwise application of a value to a field variable.
OpAdd Operator that adds a value.
static GEOS_HOST_DEVICE void apply(T &lhs, U const &rhs)
Pointwise update of a value.
OpEqual Operator that sets a value.
static GEOS_HOST_DEVICE void apply(T &lhs, U const &rhs)
Pointwise set of a value.