FEI Version of the Day
test_Tables.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_Tables.hpp>
00046 
00047 #include <snl_fei_RaggedTable.hpp>
00048 #include <fei_ProcEqns.hpp>
00049 #include <fei_ctg_set.hpp>
00050 #include <map>
00051 #undef fei_file
00052 #define fei_file "test_Tables.cpp"
00053 #include <fei_ErrMacros.hpp>
00054 
00055 test_Tables::test_Tables(MPI_Comm comm)
00056  : tester(comm)
00057 {
00058 }
00059 
00060 test_Tables::~test_Tables()
00061 {
00062 }
00063 
00064 int test_Tables::runtests()
00065 {
00066   //This class doesn't have any parallel tests. The Table objects are
00067   //purely serial objects, so only run tests if numProcs_==1.
00068   if (numProcs_ > 1) {
00069     return(0);
00070   }
00071 
00072   CHK_ERR( test1() );
00073   CHK_ERR( test2() );
00074   CHK_ERR( test3() );
00075   CHK_ERR( test4() );
00076   return(0);
00077 }
00078 
00079 int test_Tables::test1()
00080 {
00081   int len = 100;
00082 
00083   snl_fei::RaggedTable<std::map<int,fei::ctg_set<int>*>,fei::ctg_set<int> > ordTable(0,1);
00084   snl_fei::RaggedTable<std::map<int,fei::ctg_set<int>*>,fei::ctg_set<int> > ordTable2(0,1);
00085 
00086   std::vector<int> keys(len), values(len);
00087   int i;
00088   for(i=0; i<len; ++i) {
00089     keys[i] = i;
00090     values[i] = i;
00091 
00092     ordTable.addIndices(i, 1, &i);
00093   }
00094 
00095   keys.push_back(len);
00096   values.push_back(len);
00097   ++len;
00098 
00099   ordTable.addIndices(len, &keys[0], len, &values[0] );
00100 
00101   bool same = ordTable.equal(ordTable2, true);
00102   if (same) {
00103     return(-1);
00104   }
00105 
00106   for(i=0; i<len; ++i) {
00107     keys[i] = i;
00108     values[i] = i;
00109 
00110     ordTable2.addIndices(i, 1, &i);
00111   }
00112 
00113   same = ordTable.equal(ordTable2, true);
00114 
00115   ordTable2.addIndices(len, &keys[0], len, &values[0] );
00116 
00117   same = ordTable.equal(ordTable2, false);
00118   if (!same) {
00119     return(-2);
00120   }
00121 
00122   return(0);
00123 }
00124 
00125 int test_Tables::test2()
00126 {
00127   return(0);
00128 }
00129 
00130 int test_Tables::test3()
00131 {
00132   int len = 100;
00133 
00134   ProcEqns peqns;
00135 
00136   std::vector<int> keys(len), values(len);
00137   for(int i=0; i<len; ++i) {
00138     keys[i] = i;
00139     values[i] = i;
00140 
00141     peqns.addEqn(i, i);
00142     peqns.addEqn(i, i, len-i);
00143   }
00144 
00145   return(0);
00146 }
00147 
00148 int test_Tables::test4()
00149 {
00150   return(0);
00151 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends