26 #include <queso/InterpolationSurrogateData.h>
29 #include <queso/GslVector.h>
30 #include <queso/GslMatrix.h>
37 template<
class V,
class M>
39 const std::vector<unsigned int>& n_points )
50 template<
class V,
class M>
53 if( this->
dim() != this->m_n_points.size() )
55 std::stringstream vspace_dim;
56 vspace_dim << this->m_domain.vectorSpace().dimGlobal();
58 std::stringstream n_points_dim;
59 n_points_dim << this->m_n_points.size();
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";
69 template<
class V,
class M>
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 )
76 n_total_points *= *
it;
79 this->m_values.resize(n_total_points);
82 template<
class V,
class M>
87 this->m_values = values;
90 template<
class V,
class M>
95 this->m_values[n] = value;
98 template<
class V,
class M>
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);
105 return (x_max-x_min)/n_intervals;
108 template<
class V,
class M>
111 double x_min = this->x_min(dim);
112 double spacing = this->spacing(dim);
114 return x_min + spacing*index;
117 template<
class V,
class M>
120 MpiComm full_comm = this->m_domain.env().fullComm();
122 full_comm.
Bcast( &this->m_values[0], this->n_values(),
124 "InterpolationSurrogateData::sync_values()",
125 "MpiComm::Bcast() failed!" );
void set_value(unsigned int n, double value)
#define queso_assert_equal_to(expr1, expr2)
InterpolationSurrogateData()
#define queso_error_msg(msg)
The QUESO MPI Communicator Class.
double spacing(unsigned int dim) const
Spacing between points along dimension dim.
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.
const std::vector< unsigned int > & m_n_points
vector to store number of points in each coordinate direction
double get_x(unsigned int dim, unsigned int index) const
Get spatial coordinate value at the node index along coordinate direction dim.
#define queso_assert_less(expr1, expr2)
Class representing a subset of a vector space shaped like a hypercube.
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.
void set_values(std::vector< double > &values)
Set all values. Dimension must be consistent with internal m_values.
that you receive source code or can get it if you want it
void sync_values(unsigned int root)
Sync values across all processors from root processor.