19 #ifndef GEOSX_MANAGERS_FUNCTIONS_FUNCTIONBASE_HPP_ 20 #define GEOSX_MANAGERS_FUNCTIONS_FUNCTIONBASE_HPP_ 23 #include "rajaInterface/GEOS_RAJA_Interface.hpp" 28 namespace dataRepository
75 integer isFunctionOfTime()
const;
94 virtual real64 Evaluate(
real64 const *
const input )
const = 0;
139 template<
typename LEAF >
149 template<
typename LEAF >
155 real64 const * input_ptrs[4];
157 int timeVar[4] = {1, 1, 1, 1};
160 localIndex const numVars = LvArray::integerConversion< localIndex >( inputVarNames.
size());
163 for(
auto varIndex=0; varIndex<numVars; ++varIndex )
165 string const & varName = inputVarNames[varIndex];
167 if( varName==
"time" )
169 input_ptrs[varIndex] = &time;
170 varSize[varIndex] = 1;
171 timeVar[varIndex] = 0;
174 else if( groupSize > 0 )
178 input_ptrs[ varIndex ] =
reinterpret_cast< double const *
>( wrapper->
voidPointer() );
180 localIndex wrapperSize = LvArray::integerConversion< localIndex >( wrapper->
size());
181 varSize[varIndex] = wrapperSize / groupSize;
182 totalVarSize += varSize[varIndex];
187 GEOSX_ERROR_IF( totalVarSize > 4,
"Function input size is: " << totalVarSize );
190 GEOSX_ERROR_IF( result.
size() !=
set.size(),
"To apply a function to a set, the size of the result and set must match" );
193 forAll< serialPolicy >(
set.size(), [&,
set](
localIndex const i )
198 for(
int a=0; a<numVars; ++a )
200 for(
int b=0; b<varSize[a]; ++b )
202 input[c] = input_ptrs[a][(index*varSize[a]+b)*timeVar[a]];
208 result[i] =
static_cast< LEAF
const *
>(
this)->Evaluate( input );
virtual void const * voidPointer() const =0
INDEX_TYPE size() const noexcept
virtual void InitializeFunction()
Function initialization.
This class serves to provide a "view" of a multidimensional array.
double real64
64-bit floating point type.
Base class for all wrappers containing common operations.
void setInputVarNames(string_array inputVarNames)
Set the input variable names.
string_array m_inputVarNames
names for the input variables
virtual void PostProcessInput() override
static CatalogInterface::CatalogType & GetCatalog()
return the catalog entry for the function
std::int32_t integer
Signed integer type.
This class provides the base class/interface for the catalog value objects.
virtual localIndex size() const =0
Calls T::size()
void EvaluateT(dataRepository::Group const *const group, real64 const time, SortedArrayView< localIndex const > const &set, real64_array &result) const
Method to apply an function with an arbitrary type of output.
string const inputVarNames("inputVarNames")
The key for inputVarNames.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers...
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
static string CatalogName()
Static Factory Catalog Functions.
std::string string
String type.
#define GEOSX_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
WrapperBase const * getWrapperBase(indexType const index) const
Retrieve a WrapperBase stored in this group.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
This is the type that will be used for the catalog. The catalog is actually instantiated in the BASET...