44 #ifndef ROL_USERINPUTGENERATOR_HPP 45 #define ROL_USERINPUTGENERATOR_HPP 58 void sample(
const std::string &file_pt,
59 const std::string &file_wt,
64 std::fstream input_pt;
65 input_pt.open(file_pt.c_str(),std::ios::in);
66 std::fstream input_wt;
67 input_wt.open(file_wt.c_str(),std::ios::in);
68 if ( !input_pt.is_open() || !input_wt.is_open() ) {
69 if ( !input_pt.is_open() ) {
70 if ( bman->batchID() == 0 ) {
71 std::cout <<
"CANNOT OPEN " << file_pt.c_str() <<
"\n";
74 if ( !input_wt.is_open() ) {
75 if ( bman->batchID() == 0 ) {
76 std::cout <<
"CANNOT OPEN " << file_wt.c_str() <<
"\n";
81 std::vector<std::vector<Real> > pt(n);
82 std::vector<Real> wt(n,0.0);
83 std::vector<Real> point(dim,0.0);;
84 for (
int i = 0; i < n; i++) {
85 for (
int j = 0; j < dim; j++) {
92 int rank = bman->batchID();
93 int nProc = bman->numBatches();
101 std::vector<std::vector<Real> > my_pt(N);
102 std::vector<Real> my_wt(N,0.0);
104 for (
int i = 0; i < N; i++) {
105 index = i*nProc + rank;
106 my_pt[i] = pt[index];
107 my_wt[i] = wt[index];
120 Teuchos::ParameterList &list
121 = parlist.sublist(
"SOL").sublist(
"Sample Generator").sublist(
"User Input");
122 if ( list.isParameter(
"Points File") &&
123 list.isParameter(
"Weights File") &&
124 list.isParameter(
"Number of Samples") &&
125 list.isParameter(
"Dimension") ) {
126 std::string file_pt = list.get(
"Points File Name",
"points.txt");
127 std::string file_wt = list.get(
"Weights File Name",
"weights.txt");
128 int n = list.get(
"Number of Samples",100);
129 int dim = list.get(
"Dimension",4);
130 sample(file_pt,file_wt,n,dim,bman);
133 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
134 ">>> (ROL::UserInputGenerator): ParameterList does not contain sufficient information.");
139 const std::string file_wt,
144 sample(file_pt,file_wt,n,dim,bman);
void setPoints(std::vector< std::vector< Real > > &p)
void setWeights(std::vector< Real > &w)