26 #include <queso/InterpolationSurrogateData.h>
29 #include <queso/MpiComm.h>
30 #include <queso/GslVector.h>
31 #include <queso/GslMatrix.h>
38 template<
class V,
class M>
40 const std::vector<unsigned int>& n_points )
51 template<
class V,
class M>
54 if( this->
dim() != this->m_n_points.size() )
56 std::stringstream vspace_dim;
57 vspace_dim << this->m_domain.vectorSpace().dimGlobal();
59 std::stringstream n_points_dim;
60 n_points_dim << this->m_n_points.size();
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";
70 template<
class V,
class M>
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 )
77 n_total_points *= *
it;
80 this->m_values.resize(n_total_points);
83 template<
class V,
class M>
88 this->m_values = values;
91 template<
class V,
class M>
96 this->m_values[n] = value;
99 template<
class V,
class M>
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);
106 return (x_max-x_min)/n_intervals;
109 template<
class V,
class M>
112 double x_min = this->x_min(dim);
113 double spacing = this->spacing(dim);
115 return x_min + spacing*index;
118 template<
class V,
class M>
121 MpiComm full_comm = this->m_domain.env().fullComm();
123 full_comm.
Bcast( &this->m_values[0], this->n_values(),
125 "InterpolationSurrogateData::sync_values()",
126 "MpiComm::Bcast() failed!" );
#define queso_error_msg(msg)
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.
#define queso_assert_equal_to(expr1, expr2)
that you receive source code or can get it if you want it
double spacing(unsigned int dim) const
Spacing between points along dimension dim.
#define queso_assert_less(expr1, expr2)
InterpolationSurrogateData()
double get_x(unsigned int dim, unsigned int index) const
Get spatial coordinate value at the node index along coordinate direction dim.
void check_dim_consistency() const
Helper function for constructor.
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.
Class representing a subset of a vector space shaped like a hypercube.
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
The QUESO MPI Communicator Class.
void set_value(unsigned int n, double value)
void init_values(const std::vector< unsigned int > &n_points)
Helper function for sizing m_values.
#define RawValue_MPI_DOUBLE