19 #ifndef GEOS_COMMON_FIELDSPECIFICATIONOPS_HPP
20 #define GEOS_COMMON_FIELDSPECIFICATIONOPS_HPP
22 #include "codingUtilities/traits.hpp"
24 #include "common/GEOS_RAJA_Interface.hpp"
41 template<
typename T,
typename U >
43 void apply( T & lhs, U
const & rhs )
45 lhs =
static_cast< T
>( rhs );
61 template<
typename T,
typename U >
63 void apply( T & lhs, U
const & rhs )
65 lhs +=
static_cast< T
>( rhs );
72 template<
typename OP >
89 template<
typename T >
91 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
98 OP::template apply( field( index ), value );
113 template<
typename T >
115 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
121 OP::template apply( field( index )[component], value );
135 template<
typename T >
137 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
144 OP::template apply( value, field( index ) );
158 template<
typename T >
160 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
166 OP::template apply( value, field( index )[component] );
181 template<
typename T,
int USD >
183 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
191 OP::template apply( field( index, component ), value );
195 for(
localIndex a = 0; a < field.size( 1 ); ++a )
197 OP::template apply( field( index, a ), value );
215 template<
typename T,
int USD >
217 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
225 for(
localIndex a = 0; a < field.size( 1 ); ++a )
227 OP::template apply( field( index, a )[component], value );
232 for(
localIndex a = 0; a < field.size( 1 ); ++a )
236 OP::template apply( field( index, a )[c], value );
254 template<
typename T,
int USD >
256 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
263 OP::template apply( value, field( index, component ) );
276 template<
typename T,
int USD >
278 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
288 GEOS_ERROR(
"readFieldValue: unsupported operation" );
303 template<
typename T,
int USD >
305 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
313 for(
localIndex a = 0; a < field.size( 1 ); ++a )
315 OP::template apply( field( index, a, component ), value );
320 for(
localIndex a = 0; a < field.size( 1 ); ++a )
322 for(
localIndex b = 0; b < field.size( 2 ); ++b )
324 OP::template apply( field( index, a, b ), value );
343 template<
typename T,
int USD >
345 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
353 for(
localIndex a = 0; a < field.size( 1 ); ++a )
355 for(
localIndex b = 0; b < field.size( 2 ); ++b )
357 OP::template apply( field( index, a, b )[component], value );
363 for(
localIndex a = 0; a < field.size( 1 ); ++a )
365 for(
localIndex b = 0; b < field.size( 2 ); ++b )
369 OP::template apply( field( index, a, b )[c], value );
385 template<
typename T,
int USD >
397 GEOS_ERROR(
"readFieldValue: unsupported operation" );
412 template<
typename T,
int USD >
414 static inline typename std::enable_if< !traits::is_tensorT< T >,
void >::type
422 for(
localIndex a = 0; a < field.size( 1 ); ++a )
424 for(
localIndex b = 0; b < field.size( 2 ); ++b )
426 OP::template apply( field( index, a, b, component ), value );
432 for(
localIndex a = 0; a < field.size( 1 ); ++a )
434 for(
localIndex b = 0; b < field.size( 2 ); ++b )
436 for(
localIndex c = 0; c < field.size( 3 ); ++c )
438 OP::template apply( field( index, a, b, c ), value );
458 template<
typename T,
int USD >
460 static inline typename std::enable_if< traits::is_tensorT< T >,
void >::type
468 for(
localIndex a = 0; a < field.size( 1 ); ++a )
470 for(
localIndex b = 0; b < field.size( 2 ); ++b )
472 for(
localIndex c = 0; c < field.size( 3 ); ++c )
474 OP::template apply( field( index, a, b, c )[component], value );
481 for(
localIndex a = 0; a < field.size( 1 ); ++a )
483 for(
localIndex b = 0; b < field.size( 2 ); ++b )
485 for(
localIndex c = 0; c < field.size( 3 ); ++c )
489 OP::template apply( field( index, a, b, c )[d], value );
506 template<
typename T,
int USD >
518 GEOS_ERROR(
"readFieldValue: unsupported operation" );
562 if( localRow >= 0 && localRow < matrix.numRows() )
566 localIndex const numEntries = matrix.numNonZeros( localRow );
569 real64 const minDiagonal = 1e-15;
572 if( columns[ j ] == dof )
575 if( entries[j] >= 0 && entries[j] < minDiagonal )
577 entries[ j ] = minDiagonal;
579 else if( entries[j] < 0 && entries[j] > -minDiagonal )
581 entries[ j ] = -minDiagonal;
583 diagonal = entries[j];
586 { entries[ j ] = 0; }
589 rhs = -diagonal * (bcValue - fieldValue);
605 template<
typename POLICY >
614 globalIndex const localRow = dof[ a ] - dofRankOffset;
615 if( localRow >= 0 && localRow < rhs.size() )
616 { rhs[ localRow ] = values[ a ]; }
666 template<
typename POLICY >
675 globalIndex const localRow = dof[ a ] - dofRankOffset;
676 if( localRow >= 0 && localRow < rhs.size() )
677 { 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.
double real64
64-bit floating point type.
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
std::int32_t integer
Signed integer type.
GEOSX_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
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.