FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_test_utils.hpp
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #ifndef _fei_test_utils_hpp_
10 #define _fei_test_utils_hpp_
11 
12 #include <fei_macros.hpp>
13 
14 #include <fei_mpi.h>
15 
16 #include <fei_fwd.hpp>
17 
18 #include <fei_FillableMat.hpp>
19 
20 #include <vector>
21 #include <string>
22 
25 namespace fei_test_utils {
26 
33  std::string construct_filename(int argc, char** argv);
34 
41  int initialize_mpi(int argc, char** argv,
42  int& localProc, int& numProcs);
43 
53  bool bool_arg(const char* flag, int argc, char** argv,
54  bool default_result=false);
55 
62  std::string get_arg_value(const char* flag, int argc, char** argv);
63 
68  void broadcast_string(MPI_Comm comm, int root, std::string& strg);
69 
77  int get_filename_and_read_input(int argc, char** argv,
78  MPI_Comm comm, int localProc,
79  std::vector<std::string>& stdstrings);
80 
84  void read_file_lines_into_strings(const char* filename,
85  std::vector<std::string>& file_contents);
86 
94  void read_input_file(const char* filename, MPI_Comm comm,
95  std::vector<std::string>& file_contents);
96 
102  double get_file_benchmark(const char* filename,
103  const char* testname);
104 
112  bool within_percentage_margin(double value1,
113  double value2,
114  unsigned margin);
115 
116  bool check_and_cout_test_result(std::string testname,
117  double value,
118  double file_value,
119  unsigned margin);
120 
121  std::string check_test_result(double value,
122  double goldvalue,
123  unsigned margin);
124 
125  int compare_with_file_benchmark(const char* name,
126  double benchmark,
127  const char* filename);
128 
129  int whichArg(int argc, const char*const* argv, const char* findarg);
130 
131  int dirname(const char* name, char*& dir);
132 
133  void print_args(int argc, char** argv);
134 
135  int compareMatrices(fei::FillableMat& mat1, fei::FillableMat& mat2, double tol=1.e-15);
136 
137  int readMatrix(const char* baseName, int np, fei::FillableMat& matrix);
138 
139  int readMatrix(const char* fileName, fei::FillableMat& matrix);
140 
141  int writeMatrix(const char* fileName, fei::FillableMat& matrix);
142 
143  int copy_feiMatrix_to_FillableMat(fei::Matrix& feimat, fei::FillableMat& ssmat);
144 
145 }//namespace fei_test_utils
146 
147 #endif
148 
std::string construct_filename(int argc, char **argv)
void read_file_lines_into_strings(const char *filename, std::vector< std::string > &file_contents)
bool bool_arg(const char *flag, int argc, char **argv, bool default_result)
double get_file_benchmark(const char *filename, const char *testname)
int get_filename_and_read_input(int argc, char **argv, MPI_Comm comm, int localProc, std::vector< std::string > &stdstrings)
int initialize_mpi(int argc, char **argv, int &localProc, int &numProcs)
void read_input_file(const char *filename, MPI_Comm comm, std::vector< std::string > &file_contents)
void broadcast_string(MPI_Comm comm, int root, std::string &strg)
bool within_percentage_margin(double value1, double value2, unsigned margin)
std::string get_arg_value(const char *flag, int argc, char **argv)