20 #ifndef GEOS_FUNCTIONS_FUNCTIONBASE_HPP_
21 #define GEOS_FUNCTIONS_FUNCTIONBASE_HPP_
26 #include "common/GEOS_RAJA_Interface.hpp"
31 namespace dataRepository
151 template<
typename LEAF,
typename POLICY = serialPolicy >
161 template<
typename LEAF,
typename POLICY >
173 for(
integer varIndex = 0; varIndex < numVars; ++varIndex )
177 if( varName ==
"time" )
179 inputPtrs[varIndex] = &time;
180 varSize[varIndex] = 1;
190 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
192 view.move( hostMemorySpace,
false );
193 for(
int dim = 0; dim < ArrayType::NDIM; ++dim )
195 varStride[varIndex][dim] = view.strides()[dim];
197 inputPtrs[varIndex] = view.data();
200 totalVarSize += varSize[varIndex];
209 getDataContext() <<
": To apply a function to a set, the size of the result and set must match" );
213 localIndex const index = set[i];
214 real64 input[MAX_VARS]{};
216 for(
integer varIndex = 0; varIndex < numVars; ++varIndex )
218 for( localIndex compIndex = 0; compIndex < varSize[varIndex]; ++compIndex )
220 input[offset++] = inputPtrs[varIndex][index * varStride[varIndex][0] + compIndex * varStride[varIndex][1]];
223 result[i] =
static_cast< LEAF
const *
>( this )->evaluate( input );
string const inputVarNames("inputVarNames")
The key for inputVarNames.
#define GEOS_ERROR_IF_GT_MSG(lhs, rhs, msg)
Raise a hard error if one value compares greater than the other.
#define GEOS_ERROR_IF_NE_MSG(lhs, rhs, msg)
Raise a hard error if two values are not equal.
static string const & getOutputDirectory()
Get the output directory for function output.
void evaluateT(dataRepository::Group const &group, real64 const time, SortedArrayView< localIndex const > const &set, arrayView1d< real64 > const &result) const
Method to apply an function with an arbitrary type of output.
virtual ~FunctionBase() override=default
destructor
real64_array evaluateStats(dataRepository::Group const &group, real64 const time, SortedArray< localIndex > const &set) const
This generates statistics by applying a function to an object.
FunctionBase(const string &name, dataRepository::Group *const parent)
Constructor.
static void setOutputDirectory(string const &outputDir)
Set the output directory for function output.
static constexpr int MAX_VARS
Maximum total number of independent variables (including components of multidimensional variables)
static CatalogInterface::CatalogType & getCatalog()
return the catalog entry for the function
string_array m_inputVarNames
names for the input variables
virtual void initializeFunction()=0
Function initialization.
void setInputVarNames(string_array inputVarNames)
Set the input variable names.
virtual void postInputInitialization() override
integer isFunctionOfTime() const
Test to see if the function is a 1D function of time.
virtual real64 evaluate(real64 const *const input) const =0
Method to evaluate a function.
virtual void evaluate(dataRepository::Group const &group, real64 const time, SortedArrayView< localIndex const > const &set, arrayView1d< real64 > const &result) const =0
Method to evaluate a function on a target object.
This class provides the base class/interface for the catalog value objects.
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...
DataContext const & getDataContext() const
WrapperBase const & getWrapperBase(KEY const &key) const
Return a reference to a WrapperBase stored in this group.
Base class for all wrappers containing common operations.
virtual localIndex numArrayComp() const =0
Return the number of components in a multidimensional array.
static Wrapper & cast(WrapperBase &wrapper)
Downcast base to a typed wrapper.
T & reference()
Accessor for m_data.
DimsRange< 1, N > DimsUpTo
Generate a list of types representing array dimensionalities up to (and including) 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.
array1d< string > string_array
A 1-dimensional array of geos::string types.
std::set< T > set
A set of local indices.
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.
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.