10 #ifndef ROL_USERINPUTGENERATOR_HPP
11 #define ROL_USERINPUTGENERATOR_HPP
14 #include "ROL_ParameterList.hpp"
22 template<
typename Real>
27 void sample(std::string file_pt, std::string file_wt,
32 std::fstream input_pt, input_wt;
33 input_pt.open(file_pt.c_str(),std::ios::in);
34 input_wt.open(file_wt.c_str(),std::ios::in);
35 if ( !input_pt.is_open() || !input_wt.is_open() ) {
36 if ( !input_pt.is_open() ) {
37 if ( bman->batchID() == 0 ) {
38 std::cout <<
"CANNOT OPEN " << file_pt.c_str() << std::endl;
41 if ( !input_wt.is_open() ) {
42 if ( bman->batchID() == 0 ) {
43 std::cout <<
"CANNOT OPEN " << file_wt.c_str() << std::endl;
48 std::vector<std::vector<Real>> pt(n);
49 std::vector<Real> wt(n,0.0);
50 std::vector<Real> point(dim,0.0);;
51 for (
int i = 0; i < n; i++) {
52 for (
int j = 0; j <
dim; j++) {
59 int rank = bman->batchID();
60 int nProc = bman->numBatches();
65 if ( rank < rem ) N++;
66 std::vector<std::vector<Real>> my_pt(N);
67 std::vector<Real> my_wt(N,0.0);
69 for (
int i = 0; i < N; i++) {
70 index = i*nProc + rank;
85 ROL::ParameterList &list
86 = parlist.sublist(
"SOL").sublist(
"Sample Generator").sublist(
"User Input");
87 if ( list.isParameter(
"Points File") &&
88 list.isParameter(
"Weights File") &&
89 list.isParameter(
"Number of Samples") &&
90 list.isParameter(
"Dimension") ) {
91 std::string file_pt = list.get(
"Points File Name",
"points.txt");
92 std::string file_wt = list.get(
"Weights File Name",
"weights.txt");
93 int n = list.get(
"Number of Samples",100);
94 int dim = list.get(
"Dimension",4);
95 sample(file_pt,file_wt,n,dim,bman);
98 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
99 ">>> (ROL::UserInputGenerator): ParameterList does not contain sufficient information.");
109 sample(file_pt,file_wt,n,dim,bman);
void setPoints(std::vector< std::vector< Real > > &p)
void setWeights(std::vector< Real > &w)