9 #include <fei_iostream.hpp>
10 #include <fei_sstream.hpp>
11 #include <fei_fstream.hpp>
13 #include <test_utils/fei_test_utils.hpp>
15 #include <test_utils/SolnCheck.hpp>
18 int SolnCheck::readSoln(
const char* baseName,
int np, fei::FillableMat& solution)
20 for(
int i=0; i<np; i++) {
21 FEI_OSTRINGSTREAM osstr;
22 osstr << baseName <<
"." << np <<
"." << i;
23 FEI_IFSTREAM infile(osstr.str().c_str());
24 if (!infile || infile.bad())
return(-1);
29 while(!infile.eof()) {
32 for(
int j=0; j<numDOF; j++) {
34 solution.putCoef(node,j,tmpValue);
44 int SolnCheck::compareSoln(fei::FillableMat& solution1, fei::FillableMat& solution2,
47 return(fei_test_utils::compareMatrices(solution1, solution2, tol) );
51 int SolnCheck::readMatrix(
const char* baseName,
int np, fei::FillableMat& matrix)
53 return( fei_test_utils::readMatrix(baseName, np, matrix) );
57 int SolnCheck::compareMatrices(fei::FillableMat& mat1, fei::FillableMat& mat2)
59 return( fei_test_utils::compareMatrices(mat1, mat2) );
63 int SolnCheck::checkSolution(
int localProc,
int numProcs,
64 const char* solnFileName,
65 const char* checkFileName,
66 const char* extension,
70 fei::FillableMat soln, correctSoln;
71 FEI_OSTRINGSTREAM fullSolnFileName;
72 FEI_OSTRINGSTREAM fullCheckFileName;
74 fullSolnFileName << solnFileName<<
"."<<extension<<
"."<<solveCounter;
75 fullCheckFileName<< checkFileName<<
"."<<extension<<
".correct."<<solveCounter;
77 std::string fullCheck_str = fullCheckFileName.str();
78 const char* check_c_str = fullCheck_str.c_str();
79 int err = SolnCheck::readSoln(check_c_str, 1, correctSoln);
89 std::string fullSoln_str = fullSolnFileName.str();
90 const char* soln_c_str = fullSoln_str.c_str();
91 err = SolnCheck::readSoln(soln_c_str, numProcs, soln);
92 if (err != 0)
return(err);
94 FEI_COUT <<
"FEI_tester:checkSolution: checking '"<<extension<<
"' solution...";
95 int solnCheckCode = SolnCheck::compareSoln(soln, correctSoln);
97 if (solnCheckCode != 0) {
98 FEI_COUT <<
"soln file-name: " << soln_c_str << FEI_ENDL;
99 FEI_COUT <<
"soln-check failed, checkFileName="<<checkFileName<<FEI_ENDL;
100 FEI_COUT <<
"soln: " << FEI_ENDL;
102 FEI_COUT <<
"correctSoln file-name: " << check_c_str << FEI_ENDL;
103 FEI_COUT <<
"correctSoln: " << FEI_ENDL;
107 FEI_COUT <<
" ok"<<FEI_ENDL;
void print(std::ostream &os, const FillableMat &mat)