GEOSX
TableFunction.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_MANAGERS_FUNCTIONS_TABLEFUNCTION_HPP_
20 #define GEOSX_MANAGERS_FUNCTIONS_TABLEFUNCTION_HPP_
21 
22 #include "common/EnumStrings.hpp"
24 
25 namespace geosx
26 {
27 
34 {
35 public:
41  TableFunction( const std::string & name,
42  dataRepository::Group * const parent );
43 
47  virtual ~TableFunction() override;
48 
53  static string CatalogName() { return "TableFunction"; }
54 
63  template< typename T >
64  void parse_file( array1d< T > & target, string const & filename, char delimiter );
65 
69  virtual void InitializeFunction() override;
70 
74  void reInitializeFunction();
75 
83  virtual void Evaluate( dataRepository::Group const * const group,
84  real64 const time,
86  real64_array & result ) const override final
87  {
88  FunctionBase::EvaluateT< TableFunction >( group, time, set, result );
89  }
90 
96  virtual real64 Evaluate( real64 const * const input ) const override final;
97 
102  array1d< real64_array > const & getCoordinates() const { return m_coordinates; }
103 
107  array1d< real64_array > & getCoordinates() { return m_coordinates; }
108 
113  array1d< real64 > const & getValues() const { return m_values; }
114 
118  array1d< real64 > & getValues() { return m_values; }
119 
122  {
123  Linear,
124  Nearest,
125  Upper,
126  Lower
127  };
128 
133  void setInterpolationMethod( InterpolationType const method ) { m_interpolationMethod = method; }
134 
139  void setTableCoordinates( array1d< real64_array > coordinates ) { m_coordinates = coordinates; }
140 
145  void setTableValues( real64_array values ) { m_values = values; }
146 
147 private:
149  real64_array m_tableCoordinates1D;
150 
152  path_array m_coordinateFiles;
153 
155  Path m_voxelFile;
156 
158  InterpolationType m_interpolationMethod;
159 
161  array1d< real64_array > m_coordinates;
162 
164  real64_array m_values;
165 
167  static localIndex constexpr m_maxDimensions = 4;
168 
170  localIndex m_dimensions;
171 
173  localIndex_array m_size;
174 
176  localIndex_array m_indexIncrement;
177 
182  localIndex m_corners[m_maxDimensions][16];
183 
185  localIndex m_numCorners;
186 };
187 
188 ENUM_STRINGS( TableFunction::InterpolationType, "linear", "nearest", "upper", "lower" )
189 
190 
191 } /* namespace geosx */
192 
193 #endif /* GEOSX_MANAGERS_FUNCTIONS_TABLEFUNCTION_HPP_ */
InterpolationType
Enumerator of available interpolation types.
Class describing a file Path.
Definition: Path.hpp:30
TableFunction(const std::string &name, dataRepository::Group *const parent)
The constructor.
virtual void Evaluate(dataRepository::Group const *const group, real64 const time, SortedArrayView< localIndex const > const &set, real64_array &result) const override final
Method to evaluate a function on a target object.
void setTableCoordinates(array1d< real64_array > coordinates)
Set the table coordinates.
array1d< real64 > const & getValues() const
Get the table values.
#define ENUM_STRINGS(ENUM,...)
Associate a list of string names with enumeration values.
Definition: EnumStrings.hpp:69
void parse_file(array1d< T > &target, string const &filename, char delimiter)
Parse a table file.
virtual void InitializeFunction() override
Initialize the table function.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
void setInterpolationMethod(InterpolationType const method)
Set the interpolation method.
array1d< real64_array > & getCoordinates()
Get the table axes definitions.
virtual ~TableFunction() override
The destructor.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
array1d< real64_array > const & getCoordinates() const
Get the table axes definitions.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
void reInitializeFunction()
Build the maps used to evaluate the table function.
void setTableValues(real64_array values)
Set the table values.
std::string string
String type.
Definition: DataTypes.hpp:131
array1d< real64 > & getValues()
Get the table values.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
static string CatalogName()
The catalog name interface.