fei_test_utils.hpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_test_utils_hpp_
00010 #define _fei_test_utils_hpp_
00011 
00012 #include <fei_macros.hpp>
00013 
00014 #include <fei_mpi.h>
00015 
00016 #include <fei_fwd.hpp>
00017 
00018 #include <fei_FillableMat.hpp>
00019 
00020 #include <vector>
00021 #include <string>
00022 
00025 namespace fei_test_utils {
00026 
00033   std::string construct_filename(int argc, char** argv);
00034 
00041   int initialize_mpi(int argc, char** argv,
00042                      int& localProc, int& numProcs);
00043 
00053   bool bool_arg(const char* flag, int argc, char** argv,
00054                 bool default_result=false);
00055 
00062   std::string get_arg_value(const char* flag, int argc, char** argv);
00063 
00068   void broadcast_string(MPI_Comm comm, int root, std::string& strg);
00069 
00077   int get_filename_and_read_input(int argc, char** argv,
00078           MPI_Comm comm, int localProc,
00079           std::vector<std::string>& stdstrings);
00080 
00084   void read_file_lines_into_strings(const char* filename,
00085             std::vector<std::string>& file_contents);
00086 
00094   void read_input_file(const char* filename, MPI_Comm comm,
00095            std::vector<std::string>& file_contents);
00096 
00102   double get_file_benchmark(const char* filename,
00103           const char* testname);
00104 
00112   bool within_percentage_margin(double value1,
00113         double value2,
00114         unsigned margin);
00115 
00116   bool check_and_cout_test_result(std::string testname,
00117           double value,
00118           double file_value,
00119           unsigned margin);
00120 
00121   std::string check_test_result(double value,
00122         double goldvalue,
00123         unsigned margin);
00124 
00125   int compare_with_file_benchmark(const char* name,
00126           double benchmark,
00127           const char* filename);
00128 
00129   int whichArg(int argc, const char*const* argv, const char* findarg);
00130 
00131   int dirname(const char* name, char*& dir);
00132 
00133   void print_args(int argc, char** argv);
00134 
00135   int compareMatrices(fei::FillableMat& mat1, fei::FillableMat& mat2, double tol=1.e-15);
00136 
00137   int readMatrix(const char* baseName, int np, fei::FillableMat& matrix);
00138 
00139   int readMatrix(const char* fileName, fei::FillableMat& matrix);
00140 
00141   int writeMatrix(const char* fileName, fei::FillableMat& matrix);
00142 
00143   int copy_feiMatrix_to_FillableMat(fei::Matrix& feimat, fei::FillableMat& ssmat);
00144 
00145 }//namespace fei_test_utils
00146 
00147 #endif
00148 

Generated on Tue Jul 13 09:27:46 2010 for FEI by  doxygen 1.4.7