FEI Package Browser (Single Doxygen Collection)
Version of the Day
|
Functions | |
std::string | construct_filename (int argc, char **argv) |
int | initialize_mpi (int argc, char **argv, int &localProc, int &numProcs) |
bool | bool_arg (const char *flag, int argc, char **argv, bool default_result) |
std::string | get_arg_value (const char *flag, int argc, char **argv) |
void | broadcast_string (MPI_Comm comm, int root, std::string &strg) |
void | read_file_lines_into_strings (const char *filename, std::vector< std::string > &file_contents) |
int | get_filename_and_read_input (int argc, char **argv, MPI_Comm comm, int localProc, std::vector< std::string > &stdstrings) |
void | read_input_file (const char *filename, MPI_Comm comm, std::vector< std::string > &file_contents) |
double | get_file_benchmark (const char *filename, const char *testname) |
bool | within_percentage_margin (double value1, double value2, unsigned margin) |
int | whichArg (int argc, const char *const *argv, const char *findarg) |
bool | check_and_cout_test_result (std::string testname, double value, double file_value, unsigned margin) |
std::string | check_test_result (double value, double goldvalue, unsigned margin) |
int | compare_with_file_benchmark (const char *name, double benchmark, const char *filename) |
int | dirname (const char *name, char *&dir) |
void | print_args (int argc, char **argv) |
int | compareMatrices (fei::FillableMat &mat1, fei::FillableMat &mat2, double tol) |
int | readMatrix (const char *baseName, int np, fei::FillableMat &matrix) |
int | readMatrix (const char *fileName, fei::FillableMat &matrix) |
int | writeMatrix (const char *fileName, fei::FillableMat &matrix) |
int | copy_feiMatrix_to_FillableMat (fei::Matrix &feimat, fei::FillableMat &fmat) |
The fei_test_utils namespace contains general test-utility functions.
std::string fei_test_utils::construct_filename | ( | int | argc, |
char ** | argv | ||
) |
Look through argv for a '-i' argument which names an input file, and a '-d' argument which names the directory in which the input file is to be found. If the '-i' argument is present but the '-d' argument is not present, then the path to the input file will be assumed to be ".".
Definition at line 26 of file fei_test_utils.cpp.
References fei::console_out(), FEI_ENDL, FEI_OSTRINGSTREAM, filename, and whichArg().
Referenced by get_filename_and_read_input(), and main().
int fei_test_utils::initialize_mpi | ( | int | argc, |
char ** | argv, | ||
int & | localProc, | ||
int & | numProcs | ||
) |
If the macro FEI_SER is not defined, call MPI_Init and then call MPI_Comm_rank to set localProc and MPI_Comm_size to set numProcs.
If the macro FEI_SER is defined, then simply set localProc = 0 and set numProcs = 1.
Definition at line 65 of file fei_test_utils.cpp.
References ERReturn, MPI_COMM_WORLD, and MPI_SUCCESS.
Referenced by main().
bool fei_test_utils::bool_arg | ( | const char * | flag, |
int | argc, | ||
char ** | argv, | ||
bool | default_result = false |
||
) |
If flag is in the specified command-line arguments, and it is accompanied by either "yes" or "true" (case insensitive), then return true. If it is accompanied by "no" or "false", return false. If flag is not in the specified command-line arguments, return false unless the optional parameter 'default_result' is set to true.
(e.g., return true if some argv[i] == flag and argv[i+1] == "yes".)
Definition at line 78 of file fei_test_utils.cpp.
References whichArg().
std::string fei_test_utils::get_arg_value | ( | const char * | flag, |
int | argc, | ||
char ** | argv | ||
) |
Return argument string corresponding to flag from the command-line arguments. Example: if command-line arguments include some argv[i]="-d" and argv[i+1] = "path", and this function is called with flag=="-d", then the returned string value will be "path".
Definition at line 103 of file fei_test_utils.cpp.
References whichArg().
Referenced by execute_named_test(), main(), and read_input_and_execute_fullsystem_tests().
void fei_test_utils::broadcast_string | ( | MPI_Comm | comm, |
int | root, | ||
std::string & | strg | ||
) |
Broadcast string from 'root' processor so that on exit, the string has the same contents on all processors. Does nothing if num-procs==1 or if the compile-time macro FEI_SER is defined.
Definition at line 118 of file fei_test_utils.cpp.
References MPI_COMM_WORLD.
Referenced by execute_named_test(), main(), and read_input_and_execute_fullsystem_tests().
void fei_test_utils::read_file_lines_into_strings | ( | const char * | filename, |
std::vector< std::string > & | file_contents | ||
) |
read contents of file line by line into a vector of strings. This is a purely serial operation.
Definition at line 150 of file fei_test_utils.cpp.
References FEI_IFSTREAM, and FEI_OSTRINGSTREAM.
Referenced by get_file_benchmark(), and read_input_file().
int fei_test_utils::get_filename_and_read_input | ( | int | argc, |
char ** | argv, | ||
MPI_Comm | comm, | ||
int | localProc, | ||
std::vector< std::string > & | stdstrings | ||
) |
Check command-line arguments for an input-file specified by '-i', and optionally a path specified by '-d', and then read the contents of the input-file into the user-provided parameter-strings.
Filename is constructed on proc 0, file is read on proc 0, and contents are returned on all processors.
Definition at line 174 of file fei_test_utils.cpp.
References fei::console_out(), construct_filename(), ERReturn, FEI_ENDL, filename, and read_input_file().
Referenced by beam_main(), beam_oldfei_main(), feiDriver_main(), main(), poisson3_main(), and poisson_main().
void fei_test_utils::read_input_file | ( | const char * | filename, |
MPI_Comm | comm, | ||
std::vector< std::string > & | file_contents | ||
) |
This function reads the contents of filename on processor 0, and broadcasts those contents (strings) to all processors. All processors return the file contents in the file_contents argument.
If the file is not found, or can't be opened, an std::runtime_error will be thrown.
Definition at line 194 of file fei_test_utils.cpp.
References fei::localProc(), fei::numProcs(), and read_file_lines_into_strings().
Referenced by get_filename_and_read_input(), test_FEI::get_test_parameters(), read_input_and_execute_fullsystem_tests(), and test_FEI::test1().
double fei_test_utils::get_file_benchmark | ( | const char * | filename, |
const char * | testname | ||
) |
Given a file-name and test-name, return the named benchmark value.
If anything goes wrong, such as the file can't be read, or the specified testname doesn't appear in the file, throw an std::runtime_error.
Definition at line 243 of file fei_test_utils.cpp.
References snl_fei::getDoubleParamValue(), and read_file_lines_into_strings().
Referenced by beam_main(), beam_oldfei_main(), compare_with_file_benchmark(), main(), poisson3_main(), test_benchmarks::test1(), and test_benchmarks::test2().
bool fei_test_utils::within_percentage_margin | ( | double | value1, |
double | value2, | ||
unsigned | margin | ||
) |
Given two values determine whether the values are within 'margin' percentage points of each other. i.e., return true if 100*abs(value1 - value2)/max(abs(value1),abs(value2)) <= margin
Note: if max(abs(value1),abs(value2)) < 1.e-14, return true
Definition at line 260 of file fei_test_utils.cpp.
Referenced by check_and_cout_test_result(), check_test_result(), and test_misc::serialtest1().
int fei_test_utils::whichArg | ( | int | argc, |
const char *const * | argv, | ||
const char * | findarg | ||
) |
Definition at line 276 of file fei_test_utils.cpp.
Referenced by bool_arg(), construct_filename(), get_arg_value(), and poisson_main().
bool fei_test_utils::check_and_cout_test_result | ( | std::string | testname, |
double | value, | ||
double | file_value, | ||
unsigned | margin | ||
) |
Definition at line 286 of file fei_test_utils.cpp.
References FEI_COUT, FEI_ENDL, and within_percentage_margin().
Referenced by beam_main(), beam_oldfei_main(), compare_with_file_benchmark(), main(), and poisson3_main().
std::string fei_test_utils::check_test_result | ( | double | value, |
double | goldvalue, | ||
unsigned | margin | ||
) |
Definition at line 307 of file fei_test_utils.cpp.
References within_percentage_margin().
Referenced by test_benchmarks::test1(), and test_benchmarks::test2().
int fei_test_utils::compare_with_file_benchmark | ( | const char * | name, |
double | benchmark, | ||
const char * | filename | ||
) |
Definition at line 315 of file fei_test_utils.cpp.
References check_and_cout_test_result(), FEI_COUT, FEI_ENDL, FEI_OSTRINGSTREAM, and get_file_benchmark().
int fei_test_utils::dirname | ( | const char * | name, |
char *& | dir | ||
) |
Definition at line 354 of file fei_test_utils.cpp.
Referenced by FEI_tester::lsc_matrix_check().
void fei_test_utils::print_args | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 385 of file fei_test_utils.cpp.
References FEI_COUT, and FEI_ENDL.
Referenced by main(), poisson3_main(), and poisson_main().
int fei_test_utils::compareMatrices | ( | fei::FillableMat & | mat1, |
fei::FillableMat & | mat2, | ||
double | tol | ||
) |
Definition at line 396 of file fei_test_utils.cpp.
References FEI_COUT, and FEI_ENDL.
Referenced by SolnCheck::compareMatrices(), and SolnCheck::compareSoln().
int fei_test_utils::readMatrix | ( | const char * | baseName, |
int | np, | ||
fei::FillableMat & | matrix | ||
) |
Definition at line 403 of file fei_test_utils.cpp.
References FEI_IFSTREAM, FEI_OSTRINGSTREAM, IOS_FLOATFIELD, IOS_SCIENTIFIC, fei::FillableMat::putCoef(), and readMatrix().
Referenced by FEI_tester::lsc_matrix_check(), and SolnCheck::readMatrix().
int fei_test_utils::readMatrix | ( | const char * | fileName, |
fei::FillableMat & | matrix | ||
) |
Definition at line 432 of file fei_test_utils.cpp.
References fei::FillableMat::clear(), FEI_COUT, FEI_ENDL, FEI_IFSTREAM, IOS_FLOATFIELD, IOS_SCIENTIFIC, and fei::FillableMat::putCoef().
int fei_test_utils::writeMatrix | ( | const char * | fileName, |
fei::FillableMat & | matrix | ||
) |
Definition at line 463 of file fei_test_utils.cpp.
References FEI_COUT, FEI_ENDL, FEI_OFSTREAM, IOS_FLOATFIELD, and IOS_SCIENTIFIC.
Referenced by test_Matrix_unit2().
int fei_test_utils::copy_feiMatrix_to_FillableMat | ( | fei::Matrix & | feimat, |
fei::FillableMat & | fmat | ||
) |
Definition at line 478 of file fei_test_utils.cpp.
References fei::FillableMat::clear(), fei::Matrix::copyOutRow(), fei::VectorSpace::getCommunicator(), fei::VectorSpace::getGlobalIndexOffsets(), fei::Matrix::getMatrixGraph(), fei::Matrix::getRowLength(), fei::MatrixGraph::getRowSpace(), fei::localProc(), MPI_Comm, and fei::FillableMat::putRow().
Referenced by test_Matrix_unit2().