FEI Version of the Day
test_PointBlockMap.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_iostream.hpp>
00044 
00045 #include <test_utils/test_PointBlockMap.hpp>
00046 #include <snl_fei_PointBlockMap.hpp>
00047 
00048 #undef fei_file
00049 #define fei_file "test_PointBlockMap.cpp"
00050 #include <fei_ErrMacros.hpp>
00051 
00052 test_PointBlockMap::test_PointBlockMap(MPI_Comm comm)
00053  : tester(comm)
00054 {
00055 }
00056 
00057 test_PointBlockMap::~test_PointBlockMap()
00058 {
00059 }
00060 
00061 int test_PointBlockMap::runtests()
00062 {
00063   CHK_ERR( test1() );
00064   CHK_ERR( test2() );
00065   CHK_ERR( test3() );
00066   CHK_ERR( test4() );
00067   return(0);
00068 }
00069 
00070 int test_PointBlockMap::test1()
00071 {
00072   snl_fei::PointBlockMap pbMap;
00073 
00074   CHK_ERR( pbMap.setEqn(0, 0) );
00075   CHK_ERR( pbMap.setEqn(1, 0) );
00076   CHK_ERR( pbMap.setEqn(2, 0) );
00077   CHK_ERR( pbMap.setEqn(3, 1) );
00078   CHK_ERR( pbMap.setEqn(4, 1) );
00079   CHK_ERR( pbMap.setEqn(5, 2) );
00080 
00081   CHK_ERR( pbMap.setBlkEqnSize(0, 3) );
00082   CHK_ERR( pbMap.setBlkEqnSize(1, 2) );
00083   CHK_ERR( pbMap.setBlkEqnSize(2, 1) );
00084 
00085   int blkEqnOffset = pbMap.getBlkEqnOffset(1,3);
00086   if (blkEqnOffset != 0) {
00087     ERReturn(-1);
00088   }
00089 
00090   int size = pbMap.getBlkEqnSize(1);
00091   if (size != 2) {
00092     ERReturn(-1);
00093   }
00094 
00095   int blkSize, ptEqn;
00096   CHK_ERR( pbMap.getBlkEqnInfo(1, ptEqn, blkSize) );
00097   if (ptEqn != 3) {
00098     ERReturn(-1);
00099   }
00100   if (blkSize != 2) {
00101     ERReturn(-1);
00102   }
00103 
00104   int blkEqn = pbMap.eqnToBlkEqn(4);
00105   if (blkEqn != 1) {
00106     ERReturn(-1);
00107   }
00108 
00109   if (pbMap.isExactlyBlkEqn(4)) {
00110     ERReturn(-1);
00111   }
00112 
00113   int blkOffset;
00114   CHK_ERR( pbMap.getPtEqnInfo(4, blkEqn, blkOffset) );
00115   if (blkEqn != 1) {
00116     ERReturn(-1);
00117   }
00118 
00119   if (blkOffset != 1) {
00120     ERReturn(-1);
00121   }
00122 
00123   if (!pbMap.isExactlyBlkEqn(3)) {
00124     ERReturn(-1);
00125   }
00126 
00127   int maxBlkSize = pbMap.getMaxBlkEqnSize();
00128   if (maxBlkSize == 0) {
00129     ERReturn(-1);
00130   }
00131 
00132   return(0);
00133 }
00134 
00135 int test_PointBlockMap::test2()
00136 {
00137   snl_fei::PointBlockMap pbMap;
00138 
00139   CHK_ERR( pbMap.setEqn(0, 0) );
00140   CHK_ERR( pbMap.setEqn(1, 0) );
00141   CHK_ERR( pbMap.setEqn(2, 0) );
00142   CHK_ERR( pbMap.setEqn(3, 1) );
00143   CHK_ERR( pbMap.setEqn(4, 1) );
00144   CHK_ERR( pbMap.setEqn(5, 2) );
00145 
00146   CHK_ERR( pbMap.setBlkEqnSize(0, 3) );
00147   CHK_ERR( pbMap.setBlkEqnSize(1, 2) );
00148   CHK_ERR( pbMap.setBlkEqnSize(2, 1) );
00149 
00150   std::map<int,std::pair<int,int> >* blkEqns = pbMap.getBlkEqns();
00151 
00152   std::map<int,std::pair<int,int> >::const_iterator
00153     iter = blkEqns->begin(),
00154     iter_end = blkEqns->end();
00155 
00156   for(; iter != iter_end; ++iter) {
00157     if ((*iter).first < 0) {
00158       CHK_ERR( -1 );
00159     }
00160   }
00161 
00162   return(0);
00163 }
00164 
00165 int test_PointBlockMap::test3()
00166 {
00167   return(0);
00168 }
00169 
00170 int test_PointBlockMap::test4()
00171 {
00172   return(0);
00173 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends