26 #include <queso/InterpolationSurrogateData.h>
29 #include <queso/MpiComm.h>
30 #include <queso/GslVector.h>
31 #include <queso/GslMatrix.h>
32 #include <queso/math_macros.h>
39 template<
class V,
class M>
41 const std::vector<unsigned int>& n_points )
55 template<
class V,
class M>
58 if( this->
dim() != this->m_n_points.size() )
60 std::stringstream vspace_dim;
61 vspace_dim << this->m_domain.vectorSpace().dimGlobal();
63 std::stringstream n_points_dim;
64 n_points_dim << this->m_n_points.size();
66 std::string error =
"ERROR: Mismatch between dimension of parameter space and number of points\n.";
67 error +=
" domain dimension = " + vspace_dim.str() +
"\n";
68 error +=
" points dimension = " + n_points_dim.str() +
"\n";
70 queso_error_msg(error);
74 template<
class V,
class M>
77 unsigned int n_total_points = 1.0;
78 for( std::vector<unsigned int>::const_iterator it = n_points.begin();
79 it != n_points.end(); ++it )
81 n_total_points *= *it;
84 this->m_values.resize(n_total_points);
87 template<
class V,
class M>
90 for (
unsigned int i = 0; i < m_domain.vectorSpace().dimLocal(); i++) {
92 "Interpolation with an unbounded domain is unsupported");
94 "Interpolation with an unbounded domain is unsupported");
98 template<
class V,
class M>
101 queso_assert_equal_to( values.size(), m_values.size() );
103 this->m_values = values;
106 template<
class V,
class M>
109 queso_assert_less( n, m_values.size() );
111 this->m_values[n] = value;
114 template<
class V,
class M>
117 unsigned int n_intervals = this->m_n_points[
dim]-1;
118 double x_min = this->x_min(dim);
119 double x_max = this->x_max(dim);
121 return (x_max-x_min)/n_intervals;
124 template<
class V,
class M>
127 double x_min = this->x_min(dim);
128 double spacing = this->spacing(dim);
130 return x_min + spacing*index;
133 template<
class V,
class M>
136 MpiComm full_comm = this->m_domain.env().fullComm();
138 full_comm.
Bcast( &this->m_values[0], this->n_values(),
139 RawValue_MPI_DOUBLE, root,
140 "InterpolationSurrogateData::sync_values()",
141 "MpiComm::Bcast() failed!" );
bool queso_isfinite(T arg)
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
InterpolationSurrogateData()
double spacing(unsigned int dim) const
Spacing between points along dimension dim.
void set_value(unsigned int n, double value)
Class representing a subset of a vector space shaped like a hypercube.
void check_domain_bounds() const
Helper function for checking domain extent.
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.
double get_x(unsigned int dim, unsigned int index) const
Get spatial coordinate value at the node index along coordinate direction dim.
The QUESO MPI Communicator Class.
void set_values(std::vector< double > &values)
Set all values. Dimension must be consistent with internal m_values.
void sync_values(unsigned int root)
Sync values across all processors from root processor.
void Bcast(void *buffer, int count, RawType_MPI_Datatype datatype, int root, const char *whereMsg, const char *whatMsg) const
Broadcast values from the root process to the slave processes.