queso-0.55.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QUESO::InterpolationSurrogateData< V, M > Class Template Reference

#include <InterpolationSurrogateBase.h>

Public Member Functions

 InterpolationSurrogateData (const BoxSubset< V, M > &domain, const std::vector< unsigned int > &n_points)
 
 ~InterpolationSurrogateData ()
 
const BoxSubset< V, M > & get_paramDomain () const
 
const std::vector< unsigned int > & get_n_points () const
 
const std::vector< double > & get_values () const
 
std::vector< double > & get_values ()
 
double get_value (unsigned int n) const
 
unsigned int n_values () const
 
void set_values (std::vector< double > &values)
 Set all values. Dimension must be consistent with internal m_values. More...
 
void set_value (unsigned int n, double value)
 
unsigned int dim () const
 Dimension of parameter space. More...
 
double x_min (unsigned int dim) const
 Lower bound of domain along dimension dim. More...
 
double x_max (unsigned int dim) const
 Upper bound of domain along dimension dim. More...
 
double spacing (unsigned int dim) const
 Spacing between points along dimension dim. More...
 
double get_x (unsigned int dim, unsigned int index) const
 Get spatial coordinate value at the node index along coordinate direction dim. More...
 
void sync_values (unsigned int root)
 Sync values across all processors from root processor. More...
 

Private Member Functions

 InterpolationSurrogateData ()
 
void check_dim_consistency () const
 Helper function for constructor. More...
 
void init_values (const std::vector< unsigned int > &n_points)
 Helper function for sizing m_values. More...
 

Private Attributes

const BoxSubset< V, M > & m_domain
 Parameter domain over which we use surrogate. More...
 
const std::vector< unsigned int > & m_n_points
 vector to store number of points in each coordinate direction More...
 
std::vector< double > m_values
 vector to store values to be interpolated More...
 

Detailed Description

template<typename V, typename M>
class QUESO::InterpolationSurrogateData< V, M >

Definition at line 34 of file InterpolationSurrogateBase.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::InterpolationSurrogateData< V, M >::InterpolationSurrogateData ( const BoxSubset< V, M > &  domain,
const std::vector< unsigned int > &  n_points 
)

Definition at line 39 of file InterpolationSurrogateData.C.

References QUESO::InterpolationSurrogateData< V, M >::check_dim_consistency(), QUESO::InterpolationSurrogateData< V, M >::init_values(), and QUESO::InterpolationSurrogateData< V, M >::m_n_points.

41  : m_domain(domain),
42  m_n_points(n_points)
43  {
44  // This checks that the dimension of n_points and the domain are consistent
45  this->check_dim_consistency();
46 
47  // Size m_values
48  this->init_values(this->m_n_points);
49  }
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
void check_dim_consistency() const
Helper function for constructor.
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
void init_values(const std::vector< unsigned int > &n_points)
Helper function for sizing m_values.
template<typename V, typename M>
QUESO::InterpolationSurrogateData< V, M >::~InterpolationSurrogateData ( )
inline

Definition at line 43 of file InterpolationSurrogateData.h.

43 {};
template<typename V, typename M>
QUESO::InterpolationSurrogateData< V, M >::InterpolationSurrogateData ( )
private

Member Function Documentation

template<class V , class M >
void QUESO::InterpolationSurrogateData< V, M >::check_dim_consistency ( ) const
private

Helper function for constructor.

Definition at line 52 of file InterpolationSurrogateData.C.

References dim, and queso_error_msg.

Referenced by QUESO::InterpolationSurrogateData< V, M >::InterpolationSurrogateData().

53  {
54  if( this->dim() != this->m_n_points.size() )
55  {
56  std::stringstream vspace_dim;
57  vspace_dim << this->m_domain.vectorSpace().dimGlobal();
58 
59  std::stringstream n_points_dim;
60  n_points_dim << this->m_n_points.size();
61 
62  std::string error = "ERROR: Mismatch between dimension of parameter space and number of points\n.";
63  error += " domain dimension = " + vspace_dim.str() + "\n";
64  error += " points dimension = " + n_points_dim.str() + "\n";
65 
66  queso_error_msg(error);
67  }
68  }
#define queso_error_msg(msg)
Definition: asserts.h:47
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
unsigned int dim() const
Dimension of parameter space.
template<typename V, typename M>
unsigned int QUESO::InterpolationSurrogateData< V, M >::dim ( ) const
inline

Dimension of parameter space.

Definition at line 72 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_domain.

Referenced by QUESO::InterpolationSurrogateData< V, M >::x_max(), and QUESO::InterpolationSurrogateData< V, M >::x_min().

73  { return this->m_domain.vectorSpace().dimGlobal(); };
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
template<typename V, typename M>
const std::vector<unsigned int>& QUESO::InterpolationSurrogateData< V, M >::get_n_points ( ) const
inline

Definition at line 48 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_n_points.

Referenced by QUESO::InterpolationSurrogateIOASCII< V, M >::write().

49  { return this->m_n_points; };
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
template<typename V, typename M>
const BoxSubset<V,M>& QUESO::InterpolationSurrogateData< V, M >::get_paramDomain ( ) const
inline

Definition at line 45 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_domain.

Referenced by QUESO::InterpolationSurrogateBuilder< V, M >::sync_data(), and QUESO::InterpolationSurrogateIOASCII< V, M >::write().

46  { return this->m_domain; };
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
template<typename V, typename M>
double QUESO::InterpolationSurrogateData< V, M >::get_value ( unsigned int  n) const
inline

Definition at line 57 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_values, and queso_assert_less.

Referenced by QUESO::InterpolationSurrogateIOASCII< V, M >::write().

58  { queso_assert_less(n,this->m_values.size());
59  return this->m_values[n]; };
std::vector< double > m_values
vector to store values to be interpolated
#define queso_assert_less(expr1, expr2)
Definition: asserts.h:155
template<typename V, typename M>
const std::vector<double>& QUESO::InterpolationSurrogateData< V, M >::get_values ( ) const
inline

Definition at line 51 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_values.

52  { return this->m_values; };
std::vector< double > m_values
vector to store values to be interpolated
template<typename V, typename M>
std::vector<double>& QUESO::InterpolationSurrogateData< V, M >::get_values ( )
inline

Definition at line 54 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_values.

55  { return this->m_values; };
std::vector< double > m_values
vector to store values to be interpolated
template<class V , class M >
double QUESO::InterpolationSurrogateData< V, M >::get_x ( unsigned int  dim,
unsigned int  index 
) const

Get spatial coordinate value at the node index along coordinate direction dim.

Definition at line 110 of file InterpolationSurrogateData.C.

111  {
112  double x_min = this->x_min(dim);
113  double spacing = this->spacing(dim);
114 
115  return x_min + spacing*index;
116  }
double spacing(unsigned int dim) const
Spacing between points along dimension dim.
double x_min(unsigned int dim) const
Lower bound of domain along dimension dim.
unsigned int dim() const
Dimension of parameter space.
template<class V , class M >
void QUESO::InterpolationSurrogateData< V, M >::init_values ( const std::vector< unsigned int > &  n_points)
private

Helper function for sizing m_values.

Definition at line 71 of file InterpolationSurrogateData.C.

References it.

Referenced by QUESO::InterpolationSurrogateData< V, M >::InterpolationSurrogateData().

72  {
73  unsigned int n_total_points = 1.0;
74  for( std::vector<unsigned int>::const_iterator it = n_points.begin();
75  it != n_points.end(); ++it )
76  {
77  n_total_points *= *it;
78  }
79 
80  this->m_values.resize(n_total_points);
81  }
std::vector< double > m_values
vector to store values to be interpolated
that you receive source code or can get it if you want it
Definition: License.txt:41
template<typename V, typename M>
unsigned int QUESO::InterpolationSurrogateData< V, M >::n_values ( ) const
inline

Definition at line 61 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::m_values.

Referenced by QUESO::InterpolationSurrogateBuilder< V, M >::sync_data(), and QUESO::InterpolationSurrogateIOASCII< V, M >::write().

62  { return this->m_values.size(); };
std::vector< double > m_values
vector to store values to be interpolated
template<class V , class M >
void QUESO::InterpolationSurrogateData< V, M >::set_value ( unsigned int  n,
double  value 
)

Definition at line 92 of file InterpolationSurrogateData.C.

References queso_assert_less.

Referenced by QUESO::InterpolationSurrogateBuilder< V, M >::sync_data().

93  {
94  queso_assert_less( n, m_values.size() );
95 
96  this->m_values[n] = value;
97  }
std::vector< double > m_values
vector to store values to be interpolated
#define queso_assert_less(expr1, expr2)
Definition: asserts.h:155
template<class V , class M >
void QUESO::InterpolationSurrogateData< V, M >::set_values ( std::vector< double > &  values)

Set all values. Dimension must be consistent with internal m_values.

This does a full copy of the values vector. This is mainly for testing, users are encouraged to use the InterpolationSurrogateBuilder.

Definition at line 84 of file InterpolationSurrogateData.C.

References queso_assert_equal_to.

85  {
86  queso_assert_equal_to( values.size(), m_values.size() );
87 
88  this->m_values = values;
89  }
#define queso_assert_equal_to(expr1, expr2)
Definition: asserts.h:149
std::vector< double > m_values
vector to store values to be interpolated
template<class V , class M >
double QUESO::InterpolationSurrogateData< V, M >::spacing ( unsigned int  dim) const

Spacing between points along dimension dim.

Definition at line 100 of file InterpolationSurrogateData.C.

References dim.

101  {
102  unsigned int n_intervals = this->m_n_points[dim]-1;
103  double x_min = this->x_min(dim);
104  double x_max = this->x_max(dim);
105 
106  return (x_max-x_min)/n_intervals;
107  }
double x_min(unsigned int dim) const
Lower bound of domain along dimension dim.
double x_max(unsigned int dim) const
Upper bound of domain along dimension dim.
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
unsigned int dim() const
Dimension of parameter space.
template<class V , class M >
void QUESO::InterpolationSurrogateData< V, M >::sync_values ( unsigned int  root)

Sync values across all processors from root processor.

m_values may only be set on one processor, so this method is used for MPI_Bcast'ing those values to all processors. This calls MPI_Bcast, which is collective, so this MUST be called from all processors in env.fullComm().

Definition at line 119 of file InterpolationSurrogateData.C.

References QUESO::MpiComm::Bcast(), and RawValue_MPI_DOUBLE.

Referenced by QUESO::InterpolationSurrogateBuilder< V, M >::sync_data().

120  {
121  MpiComm full_comm = this->m_domain.env().fullComm();
122 
123  full_comm.Bcast( &this->m_values[0], this->n_values(),
124  RawValue_MPI_DOUBLE, root,
125  "InterpolationSurrogateData::sync_values()",
126  "MpiComm::Bcast() failed!" );
127  }
std::vector< double > m_values
vector to store values to be interpolated
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:67
template<typename V, typename M>
double QUESO::InterpolationSurrogateData< V, M >::x_max ( unsigned int  dim) const
inline

Upper bound of domain along dimension dim.

Definition at line 80 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::dim(), and QUESO::InterpolationSurrogateData< V, M >::m_domain.

Referenced by QUESO::InterpolationSurrogateIOASCII< V, M >::write().

81  { return this->m_domain.maxValues()[dim]; };
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
unsigned int dim() const
Dimension of parameter space.
template<typename V, typename M>
double QUESO::InterpolationSurrogateData< V, M >::x_min ( unsigned int  dim) const
inline

Lower bound of domain along dimension dim.

Definition at line 76 of file InterpolationSurrogateData.h.

References QUESO::InterpolationSurrogateData< V, M >::dim(), and QUESO::InterpolationSurrogateData< V, M >::m_domain.

Referenced by QUESO::InterpolationSurrogateIOASCII< V, M >::write().

77  { return this->m_domain.minValues()[dim]; };
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
unsigned int dim() const
Dimension of parameter space.

Member Data Documentation

template<typename V, typename M>
const BoxSubset<V,M>& QUESO::InterpolationSurrogateData< V, M >::m_domain
private
template<typename V, typename M>
const std::vector<unsigned int>& QUESO::InterpolationSurrogateData< V, M >::m_n_points
private

vector to store number of points in each coordinate direction

We assume that the spacing in each coordinate direction is constant so we only need to know the number of points.

Definition at line 112 of file InterpolationSurrogateData.h.

Referenced by QUESO::InterpolationSurrogateData< V, M >::get_n_points(), and QUESO::InterpolationSurrogateData< V, M >::InterpolationSurrogateData().

template<typename V, typename M>
std::vector<double> QUESO::InterpolationSurrogateData< V, M >::m_values
private

vector to store values to be interpolated

These will be stored in a particular ordering. Helper functions will provide mapping between grid coordinates and a global coordinate; the global coordinate will be used to index into the values.

Todo:
We currently store all values reside on all processes. Generalization would be to partition values across processes allocated for the subenvironment.

Definition at line 120 of file InterpolationSurrogateData.h.

Referenced by QUESO::InterpolationSurrogateData< V, M >::get_value(), QUESO::InterpolationSurrogateData< V, M >::get_values(), and QUESO::InterpolationSurrogateData< V, M >::n_values().


The documentation for this class was generated from the following files:

Generated on Fri Jun 17 2016 14:17:46 for queso-0.55.0 by  doxygen 1.8.5