10 #include <fei_sstream.hpp>
11 #include <snl_fei_Utils.hpp>
12 #include <test_utils/test_FEI.hpp>
14 #include <test_utils/fei_test_utils.hpp>
15 #include <test_utils/LibraryFactory.hpp>
17 #include <fei_ParameterSet.hpp>
18 #include <fei_utils.hpp>
19 #include <test_utils/DataReader.hpp>
20 #include <test_utils/FEI_tester.hpp>
21 #include <test_utils/snl_fei_tester.hpp>
24 #define fei_file "test_FEI.cpp"
25 #include <fei_ErrMacros.hpp>
27 test_FEI::test_FEI(MPI_Comm comm)
37 int test_FEI::runtests()
39 if (fileName_.empty())
return(-1);
54 std::string solverName;
57 throw std::runtime_error(
".input file doesn't contain 'SOLVER_LIBRARY'");
63 throw std::runtime_error(
".input file doesn't contain 'WHICH_FEI'");
66 std::string inputFileName;
69 throw std::runtime_error(
".input file doesn't contain 'INPUT_FILE'");
72 std::string paramFile;
75 throw std::runtime_error(
".input file doesn't contain 'PARAM_FILE'");
81 throw std::runtime_error(
".input file doesn't contain 'SOLN_FILE'");
84 std::string checkFile;
87 throw std::runtime_error(
".input file doesn't contain 'CHECK_FILE'");
90 std::string readerType;
95 FEI_OSTRINGSTREAM fullName;
96 std::string fullInputFileName = fully_qualified_name(inputFileName);
97 fullName<< fullInputFileName<<
"."<< numProcs_<<
"."<< localProc_;
99 std::string fullName_str = fullName.str();
100 const char* fullName_c_str = fullName_str.c_str();
105 CHK_ERR( data_reader->readData(fullName_c_str));
108 std::string fullParamFileName = fully_qualified_name(paramFile);
109 const char* paramFile_c_str = fullParamFileName.c_str();
111 std::vector<std::string> param_file_contents;
113 param_file_contents);
115 data_reader->numParams_ = param_file_contents.size();
116 data_reader->paramStrings_ =
new char*[data_reader->numParams_];
118 for(
unsigned i=0; i<param_file_contents.size(); ++i) {
119 std::string& str = param_file_contents[i];
120 data_reader->paramStrings_[i] =
new char[str.size()+1];
121 for(
unsigned j=0; j<str.size(); ++j) {
122 data_reader->paramStrings_[i][j] = str[j];
124 data_reader->paramStrings_[i][str.size()] =
'\0';
127 data_reader->solverLibraryName_ = solverName;
129 std::string fullSolnFile = fully_qualified_name(solnFile);
130 data_reader->solnFileName_ = fullSolnFile;
132 std::string fullCheckFile = fully_qualified_name(checkFile);
133 data_reader->checkFileName_ = fullCheckFile;
138 if (whichFEI ==
"OLDFEI") {
139 fei_tester.
reset(
new FEI_tester(data_reader, comm_, localProc_, numProcs_));
141 if (whichFEI ==
"fei::FEI_Impl") {
142 bool useNewFEI =
true;
143 fei_tester.
reset(
new FEI_tester(data_reader, comm_, localProc_, numProcs_,
146 else if (whichFEI ==
"new_fei") {
147 fei_tester.
reset(
new snl_fei_tester(data_reader, comm_, localProc_, numProcs_));
150 if (fei_tester.
get() == NULL) {
154 fei_tester->setPath(path_);
156 int errCode = fei_tester->testInitialization();
161 FEI_COUT <<
"library " << solverName <<
" not available."<<FEI_ENDL;
165 for(
int solveCounter=1; solveCounter<=numSolves; solveCounter++) {
167 CHK_ERR( fei_tester->testLoading() );
176 CHK_ERR( fei_tester->testSolve() );
178 CHK_ERR( fei_tester->testCheckResult() );
186 test_FEI::get_test_parameters()
188 std::vector<std::string> inputFileStrings;
190 FEI_OSTRINGSTREAM filename;
193 std::size_t length = path_.size();
195 if (path_[length-1] !=
'/') filename<<
"/";
198 filename << fileName_;
200 std::string filename_str = filename.str();
201 const char* filename_c_str = filename_str.c_str();
210 std::string test_FEI::fully_qualified_name(
const std::string& fileName)
212 FEI_OSTRINGSTREAM osstr;
215 std::size_t length = path_.size();
217 if (path_[length-1] !=
'/') osstr<<
"/";
int getStringParamValue(const char *name, std::string ¶mValue) const
void read_input_file(const char *filename, MPI_Comm comm, std::vector< std::string > &file_contents)
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
int getIntParamValue(const char *name, int ¶mValue) const