test_Factory_helper.cpp

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 #include <fei_macros.hpp>
00010 
00011 #include <test_utils/test_Factory_helper.hpp>
00012 
00013 #include <test_utils/LibraryFactory.hpp>
00014 
00015 #include <fei_Factory_Trilinos.hpp>
00016 
00017 #include <snl_fei_Factory.hpp>
00018 
00019 #include <fei_Vector_Impl.hpp>
00020 
00021 #include <fei_Matrix_Impl.hpp>
00022 
00023 #undef fei_file
00024 #define fei_file "test_Factory_helper.cpp"
00025 #include <fei_ErrMacros.hpp>
00026 
00027 int test_Factory_helper::dyncastMatrix(fei::Matrix* matrix,
00028                const char* libname)
00029 {
00030   std::string sname(libname);
00031 
00032   if (sname == "TEST_LSC") {
00033 
00034     fei::Matrix_Impl<LinearSystemCore>* smatrix2 =
00035       dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matrix);
00036     if (smatrix2 == NULL) {
00037       FEI_CERR << "dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00038       ERReturn(-1);
00039     }
00040   }
00041 
00042   if (sname == "Aztec") {
00043 #ifdef HAVE_FEI_AZTECOO
00044     fei::Matrix_Impl<LinearSystemCore>* smatrix =
00045       dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matrix);
00046     if (smatrix == NULL) {
00047       FEI_CERR << "dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00048       ERReturn(-1);
00049     }
00050 #else
00051     FEI_CERR << "libname==Aztec but HAVE_FEI_AZTECOO not defined."<<FEI_ENDL;
00052     ERReturn(-1);
00053 #endif
00054   }
00055 
00056   if (sname == "Trilinos") {
00057 #ifdef HAVE_FEI_EPETRA
00058     fei::Matrix_Impl<Epetra_CrsMatrix>* smatrix =
00059       dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*>(matrix);
00060     if (smatrix == NULL) {
00061       FEI_CERR << "dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*> failed"<<FEI_ENDL;
00062       ERReturn(-1);
00063     }
00064 #else
00065     FEI_CERR << "libname==Trilinos but HAVE_FEI_EPETRA not defined."<<FEI_ENDL;
00066     ERReturn(-1);
00067 #endif
00068   }
00069 
00070   return(0);
00071 }
00072 
00073 int test_Factory_helper::dyncastVector(fei::Vector* vector,
00074                const char* libname)
00075 {
00076   std::string sname(libname);
00077   if (sname == "TEST_LSC") {
00078     fei::Vector_Impl<LinearSystemCore>* svector =
00079       dynamic_cast<fei::Vector_Impl<LinearSystemCore>*>(vector);
00080     if (svector == NULL) {
00081       FEI_CERR << "dynamic_cast<fei::Vector_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00082       ERReturn(-1);
00083     }
00084   }
00085 
00086   if (sname == "Aztec") {
00087 #ifdef HAVE_FEI_AZTECOO
00088     fei::Vector_Impl<LinearSystemCore>* svector =
00089       dynamic_cast<fei::Vector_Impl<LinearSystemCore>*>(vector);
00090     if (svector == NULL) {
00091       FEI_CERR << "dynamic_cast<fei::Vector_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00092       ERReturn(-1);
00093     }
00094 #else
00095     FEI_CERR << "libname==Aztec but HAVE_FEI_AZTECOO not defined."<<FEI_ENDL;
00096     ERReturn(-1);
00097 #endif
00098   }
00099 
00100   if (sname == "Trilinos") {
00101 #ifdef HAVE_FEI_EPETRA
00102     fei::Vector_Impl<Epetra_MultiVector>* svector =
00103       dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>*>(vector);
00104     if (svector == NULL) {
00105       FEI_CERR << "dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>*> failed"<<FEI_ENDL;
00106       ERReturn(-1);
00107     }
00108 #else
00109     FEI_CERR << "libname==Trilinos but HAVE_FEI_EPETRA not defined."<<FEI_ENDL;
00110     ERReturn(-1);
00111 #endif
00112   }
00113 
00114   return(0);
00115 }

Generated on Wed May 12 21:30:42 2010 for FEI by  doxygen 1.4.7