FEI Version of the Day
test_Factory_helper.cpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 #include <fei_macros.hpp>
00044 
00045 #include <test_utils/test_Factory_helper.hpp>
00046 
00047 #include <test_utils/LibraryFactory.hpp>
00048 
00049 #include <fei_Factory_Trilinos.hpp>
00050 
00051 #include <snl_fei_Factory.hpp>
00052 
00053 #include <fei_Vector_Impl.hpp>
00054 
00055 #include <fei_Matrix_Impl.hpp>
00056 
00057 #undef fei_file
00058 #define fei_file "test_Factory_helper.cpp"
00059 #include <fei_ErrMacros.hpp>
00060 
00061 int test_Factory_helper::dyncastMatrix(fei::Matrix* matrix,
00062                const char* libname)
00063 {
00064   std::string sname(libname);
00065 
00066   if (sname == "TEST_LSC") {
00067 
00068     fei::Matrix_Impl<LinearSystemCore>* smatrix2 =
00069       dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matrix);
00070     if (smatrix2 == NULL) {
00071       fei::console_out() << "dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00072       ERReturn(-1);
00073     }
00074   }
00075 
00076   if (sname == "Aztec") {
00077 #ifdef HAVE_FEI_AZTECOO
00078     fei::Matrix_Impl<LinearSystemCore>* smatrix =
00079       dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matrix);
00080     if (smatrix == NULL) {
00081       fei::console_out() << "dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00082       ERReturn(-1);
00083     }
00084 #else
00085     fei::console_out() << "libname==Aztec but HAVE_FEI_AZTECOO not defined."<<FEI_ENDL;
00086     ERReturn(-1);
00087 #endif
00088   }
00089 
00090   if (sname == "Trilinos") {
00091 #ifdef HAVE_FEI_EPETRA
00092     fei::Matrix_Impl<Epetra_CrsMatrix>* smatrix =
00093       dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*>(matrix);
00094     if (smatrix == NULL) {
00095       fei::console_out() << "dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*> failed"<<FEI_ENDL;
00096       ERReturn(-1);
00097     }
00098 #else
00099     fei::console_out() << "libname==Trilinos but HAVE_FEI_EPETRA not defined."<<FEI_ENDL;
00100     ERReturn(-1);
00101 #endif
00102   }
00103 
00104   return(0);
00105 }
00106 
00107 int test_Factory_helper::dyncastVector(fei::Vector* vector,
00108                const char* libname)
00109 {
00110   std::string sname(libname);
00111   if (sname == "TEST_LSC") {
00112     fei::Vector_Impl<LinearSystemCore>* svector =
00113       dynamic_cast<fei::Vector_Impl<LinearSystemCore>*>(vector);
00114     if (svector == NULL) {
00115       fei::console_out() << "dynamic_cast<fei::Vector_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00116       ERReturn(-1);
00117     }
00118   }
00119 
00120   if (sname == "Aztec") {
00121 #ifdef HAVE_FEI_AZTECOO
00122     fei::Vector_Impl<LinearSystemCore>* svector =
00123       dynamic_cast<fei::Vector_Impl<LinearSystemCore>*>(vector);
00124     if (svector == NULL) {
00125       fei::console_out() << "dynamic_cast<fei::Vector_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
00126       ERReturn(-1);
00127     }
00128 #else
00129     fei::console_out() << "libname==Aztec but HAVE_FEI_AZTECOO not defined."<<FEI_ENDL;
00130     ERReturn(-1);
00131 #endif
00132   }
00133 
00134   if (sname == "Trilinos") {
00135 #ifdef HAVE_FEI_EPETRA
00136     fei::Vector_Impl<Epetra_MultiVector>* svector =
00137       dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>*>(vector);
00138     if (svector == NULL) {
00139       fei::console_out() << "dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>*> failed"<<FEI_ENDL;
00140       ERReturn(-1);
00141     }
00142 #else
00143     fei::console_out() << "libname==Trilinos but HAVE_FEI_EPETRA not defined."<<FEI_ENDL;
00144     ERReturn(-1);
00145 #endif
00146   }
00147 
00148   return(0);
00149 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends