20 #ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONIMPL_HPP
21 #define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONIMPL_HPP
32 #include "common/GEOS_RAJA_Interface.hpp"
58 template<
typename OBJECT_TYPE,
typename BC_TYPE = FieldSpecification,
typename LAMBDA >
59 static void apply( BC_TYPE
const & fs,
MeshLevel & mesh, LAMBDA && lambda );
83 template<
typename OBJECT_TYPE,
typename BC_TYPE = FieldSpecification,
typename LAMBDA >
84 static void apply( BC_TYPE
const & fs,
88 string const & fieldName );
101 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
120 template<
typename FIELD_OP,
typename POLICY=parallelHostPolicy >
125 string const & fieldName );
150 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
183 template<
typename FIELD_OP,
typename POLICY >
189 string const & fieldName,
190 string const & dofMapName,
218 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
254 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
303 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
328 template<
typename POLICY >
336 template<
typename OBJECT_TYPE,
typename BC_TYPE,
typename LAMBDA >
343 [&] ( OBJECT_TYPE & object )
348 for(
auto & setName : setNames )
354 lambda( fs, setName, targetSet,
object, fs.getFieldName() );
361 template<
typename OBJECT_TYPE,
typename BC_TYPE,
typename LAMBDA >
366 string const & fieldName )
368 integer const isInitialCondition = fs.initialCondition();
369 if( ( isInitialCondition && fieldName==
"") ||
370 ( !isInitialCondition && time >= fs.getStartTime()
371 && time < fs.getEndTime()
372 && fieldName == fs.getFieldName() ) )
374 FieldSpecificationImpl::apply< OBJECT_TYPE >( fs, mesh, std::forward< LAMBDA >( lambda ) );
378 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
391 if( functionName.empty() )
397 FIELD_OP::SpecifyFieldValue( field, a, component, value );
408 catch( std::exception
const & e )
410 string const errorMsg = GEOS_FMT(
"Error while reading {}:\n",
413 functionNameString() ) );
423 if(
function.isFunctionOfTime()==2 )
429 FIELD_OP::SpecifyFieldValue( field, a, component, value );
435 function.evaluate( dataGroup, time, targetSet, result );
441 FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] );
447 template<
typename FIELD_OP,
typename POLICY >
454 string const & fieldName )
466 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
468 applyFieldValueKernel< FIELD_OP, POLICY >( fs,
469 wrapperT.reference().toView(),
476 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
490 applyBoundaryConditionToSystem< FIELD_OP, POLICY >( fs,
506 template<
typename FIELD_OP,
typename POLICY >
513 string const & fieldName,
514 string const & dofMapName,
526 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
528 applyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( fs,
536 wrapperT.reference() );
540 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
553 return applyBoundaryConditionToSystem< FIELD_OP, POLICY >( fs,
562 std::forward< LAMBDA >( lambda ) );
565 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
585 computeRhsContribution< FIELD_OP, POLICY, LAMBDA >( fs,
595 std::forward< LAMBDA >( lambda ) );
597 FIELD_OP::template prescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution );
600 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
623 if( functionName.empty() ||
627 if( !functionName.empty() )
630 value *=
function.evaluate( &time );
633 forAll< POLICY >( targetSet.size(),
645 dof[ i ] = dofMap[ a ] + component;
646 FIELD_OP::SpecifyFieldValue( dof[ i ],
649 rhsContribution[ i ],
659 function.evaluate( dataGroup, time, targetSet, resultsArray );
663 forAll< POLICY >( targetSet.size(),
676 dof[ i ] = dofMap[ a ] + component;
677 FIELD_OP::SpecifyFieldValue( dof[ i ],
680 rhsContribution[ i ],
681 value * results[ i ],
687 template<
typename POLICY >
696 forAll< POLICY >( targetSet.size(),
703 localIndex const numEntries = matrix.numNonZeros( dof );
#define GEOS_HOST_DEVICE
Marks a host-device function.
DiagnosticMsgBuilder & addContextInfo(Args &&... args)
Adds one or more context elements to the error.
DiagnosticMsgBuilder & addToMsg(std::exception const &e, bool toEnd=false)
Append exception text to the message.
DiagnosticMsgBuilder modifyCurrentExceptionMessage()
Modify/Continue building the current exception message.
static GEOS_HOST ErrorLogger & global()
string const & getFunctionName() const
virtual int getComponent() const
Methods to apply field specifications.
static void applyBoundaryConditionToSystemKernel(FieldSpecification const &fs, SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group const &dataGroup, arrayView1d< globalIndex const > const &dofMap, globalIndex const dofRankOffset, CRSMatrixView< real64, globalIndex const > const &matrix, arrayView1d< real64 > const &rhs, ArrayView< T const, NDIM, USD > const &fieldView)
Apply a boundary condition to a system of equations.
static void applyFieldValue(FieldSpecification const &fs, SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group &dataGroup, string const &fieldName)
static void apply(BC_TYPE const &fs, MeshLevel &mesh, LAMBDA &&lambda)
Apply this field specification to the discretization.
static void applyBoundaryConditionToSystem(FieldSpecification const &fs, SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group const &dataGroup, string const &fieldName, string const &dofMapName, globalIndex const dofRankOffset, CRSMatrixView< real64, globalIndex const > const &matrix, arrayView1d< real64 > const &rhs)
Apply a boundary condition to a system of equations.
static void computeRhsContribution(FieldSpecification const &fs, SortedArrayView< localIndex const > const &targetSet, real64 const time, real64 const dt, dataRepository::Group const &dataGroup, arrayView1d< globalIndex const > const &dofMap, globalIndex const dofRankOffset, CRSMatrixView< real64, globalIndex const > const &matrix, arrayView1d< globalIndex > const &dof, arrayView1d< real64 > const &rhsContribution, LAMBDA &&lambda)
Compute the contributions that will be added/enforced to the right-hand side, and collect the corresp...
static void applyFieldValueKernel(FieldSpecification const &fs, ArrayView< T, N, USD > const &field, SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group &dataGroup)
static void zeroSystemRowsForBoundaryCondition(FieldSpecification const &fs, SortedArrayView< localIndex const > const &targetSet, arrayView1d< globalIndex const > const &dofMap, CRSMatrixView< real64, globalIndex const > const &matrix)
Function to zero matrix rows to apply boundary conditions.
integer isFunctionOfTime() const
Test to see if the function is a 1D function of time.
static FunctionManager & getInstance()
Class facilitating the representation of a multi-level discretization of a MeshBody.
Class to hold the path to a collection of mesh objects.
void forObjectsInPath(dataRepository::Group &meshBodies, FUNC &&func) const
LLoop over objects in the path and execute a callback function.
virtual ErrorContext getContextInfo() const =0
Returns contextual information, including the file name and the line number.
bool hasWrapper(LOOKUP_TYPE const &lookup) const
Check if a wrapper exists.
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
WrapperBase const & getWrapperBase(KEY const &key) const
Return a reference to a WrapperBase stored in this group.
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
DataContext const & getWrapperDataContext(KEY key) const
Base class for all wrappers containing common operations.
static Wrapper & cast(WrapperBase &wrapper)
Downcast base to a typed wrapper.
internal::Apply< internal::ArrayType, camp::cartesian_product< TYPES, internal::AddLayouts< NDIMS > > > ArrayTypes
Construct a list of GEOSX multidimensional array types (geos::Array), containing all value types in t...
DimsRange< N, N > DimsSingle
Generate a list of types representing array dimensionality exactly N.
bool dispatch(LIST const combinations, LAMBDA &&lambda, Ts &&... objects)
Dispatch a generic worker function lambda based on runtime type.
internal::Apply< camp::list, LIST > ListofTypeList
Construct a list of list type.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
stdVector< string > string_array
A 1-dimensional array of geos::string types.
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.
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
array1d< real64 > real64_array
A 1-dimensional array of geos::real64 types.
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
int integer
Signed integer type.
Array< T, 1 > array1d
Alias for 1D array.
LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer > ArrayView
Multidimensional array view type. See LvArray:ArrayView for details.
ErrorContext & setPriority(integer priority)
Set the priority value of the current error context information. This way the different context infor...
constexpr static char const * functionNameString()
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 constexpr char const * setsString()