queso-0.53.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 38 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.

40  : m_domain(domain),
41  m_n_points(n_points)
42  {
43  // This checks that the dimension of n_points and the domain are consistent
44  this->check_dim_consistency();
45 
46  // Size m_values
47  this->init_values(this->m_n_points);
48  }
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
void init_values(const std::vector< unsigned int > &n_points)
Helper function for sizing m_values.
void check_dim_consistency() const
Helper function for constructor.
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 51 of file InterpolationSurrogateData.C.

References dim, and queso_error_msg.

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

52  {
53  if( this->dim() != this->m_n_points.size() )
54  {
55  std::stringstream vspace_dim;
56  vspace_dim << this->m_domain.vectorSpace().dimGlobal();
57 
58  std::stringstream n_points_dim;
59  n_points_dim << this->m_n_points.size();
60 
61  std::string error = "ERROR: Mismatch between dimension of parameter space and number of points\n.";
62  error += " domain dimension = " + vspace_dim.str() + "\n";
63  error += " points dimension = " + n_points_dim.str() + "\n";
64 
65  queso_error_msg(error);
66  }
67  }
unsigned int dim() const
Dimension of parameter space.
#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
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]; };
#define queso_assert_less(expr1, expr2)
Definition: asserts.h:155
std::vector< double > m_values
vector to store values to be interpolated
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 109 of file InterpolationSurrogateData.C.

110  {
111  double x_min = this->x_min(dim);
112  double spacing = this->spacing(dim);
113 
114  return x_min + spacing*index;
115  }
unsigned int dim() const
Dimension of parameter space.
double x_min(unsigned int dim) const
Lower bound of domain along dimension dim.
double spacing(unsigned int dim) const
Spacing between points along dimension dim.
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 70 of file InterpolationSurrogateData.C.

References it.

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

71  {
72  unsigned int n_total_points = 1.0;
73  for( std::vector<unsigned int>::const_iterator it = n_points.begin();
74  it != n_points.end(); ++it )
75  {
76  n_total_points *= *it;
77  }
78 
79  this->m_values.resize(n_total_points);
80  }
that you receive source code or can get it if you want it
Definition: License.txt:41
std::vector< double > m_values
vector to store values to be interpolated
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 91 of file InterpolationSurrogateData.C.

References queso_assert_less.

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

92  {
93  queso_assert_less( n, m_values.size() );
94 
95  this->m_values[n] = value;
96  }
#define queso_assert_less(expr1, expr2)
Definition: asserts.h:155
std::vector< double > m_values
vector to store values to be interpolated
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 83 of file InterpolationSurrogateData.C.

References queso_assert_equal_to.

84  {
85  queso_assert_equal_to( values.size(), m_values.size() );
86 
87  this->m_values = values;
88  }
#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 99 of file InterpolationSurrogateData.C.

References dim.

100  {
101  unsigned int n_intervals = this->m_n_points[dim]-1;
102  double x_min = this->x_min(dim);
103  double x_max = this->x_max(dim);
104 
105  return (x_max-x_min)/n_intervals;
106  }
unsigned int dim() const
Dimension of parameter space.
double x_min(unsigned int dim) const
Lower bound of domain along dimension dim.
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
double x_max(unsigned int dim) const
Upper bound of domain along dimension dim.
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 118 of file InterpolationSurrogateData.C.

References QUESO::MpiComm::Bcast().

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

119  {
120  MpiComm full_comm = this->m_domain.env().fullComm();
121 
122  full_comm.Bcast( &this->m_values[0], this->n_values(),
123  MPI_DOUBLE, root,
124  "InterpolationSurrogateData::sync_values()",
125  "MpiComm::Bcast() failed!" );
126  }
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
std::vector< double > m_values
vector to store values to be interpolated
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]; };
unsigned int dim() const
Dimension of parameter space.
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.
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]; };
unsigned int dim() const
Dimension of parameter space.
const BoxSubset< V, M > & m_domain
Parameter domain over which we use surrogate.

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 Thu Jun 11 2015 13:52:36 for queso-0.53.0 by  doxygen 1.8.5