test_EqnCommMgr.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 
00010 #include <fei_macros.hpp>
00011 
00012 #include <test_utils/test_EqnCommMgr.hpp>
00013 #include <fei_CommUtils.hpp>
00014 #include <fei_defs.h>
00015 
00016 #include <fei_ProcEqns.hpp>
00017 #include <fei_EqnBuffer.hpp>
00018 #include <fei_EqnCommMgr.hpp>
00019 
00020 #undef fei_file
00021 #define fei_file "test_EqnCommMgr.cpp"
00022 #include <fei_ErrMacros.hpp>
00023 
00024 test_EqnCommMgr::test_EqnCommMgr(MPI_Comm comm)
00025  : tester(comm)
00026 {
00027 }
00028 
00029 test_EqnCommMgr::~test_EqnCommMgr()
00030 {
00031 }
00032 
00033 int test_EqnCommMgr::runtests()
00034 {
00035   CHK_ERR( test1() );
00036   CHK_ERR( test2() );
00037   CHK_ERR( test3() );
00038   CHK_ERR( test4() );
00039   return(0);
00040 }
00041 
00042 int test_EqnCommMgr::test1()
00043 {
00044   EqnCommMgr* eqnCommMgr = new EqnCommMgr(comm_);
00045 
00046   int numProcs = fei::numProcs(comm_);
00047   int localProc = fei::localProc(comm_);
00048 
00049 //  int numGlobalEqns = numProcs*5;
00050   int numLocalEqns = 5;
00051   int firstLocalEqn = localProc*numLocalEqns;
00052 //  int lastLocalEqn = (localProc+1)*numLocalEqns - 1;
00053 
00054   if (numProcs > 1) {
00055     for(int p=0; p<numProcs; p++) {
00056       if (p == localProc) continue;
00057 
00058       for(int i=0; i<numLocalEqns; i++) {
00059   if (p != 2) eqnCommMgr->addLocalEqn(firstLocalEqn+i, p);
00060       }
00061     }
00062   }
00063 
00064   eqnCommMgr->setNumRHSs(1);
00065 
00066   int p;
00067   for(p=0; p<numProcs; p++) {
00068     if (p == localProc) continue;
00069 
00070     for(int i=0; i<numLocalEqns; i++) {
00071       int eqn = p*numLocalEqns + i;
00072 
00073       eqnCommMgr->addRemoteIndices(eqn, p, &eqn, 1);
00074     }
00075   }
00076 
00077   CHK_ERR( eqnCommMgr->exchangeIndices() );
00078 
00079   double zero = 0.0;
00080   for(p=0; p<numProcs; p++) {
00081     if (p == localProc) continue;
00082 
00083     for(int i=0; i<numLocalEqns; i++) {
00084       int eqn = p*numLocalEqns + i;
00085 
00086       eqnCommMgr->addSolnValues(&eqn, &zero, 1);
00087     }
00088   }
00089 
00090   EqnCommMgr* eCopy = eqnCommMgr->deepCopy();
00091 
00092   std::vector<int>& localEqns = eqnCommMgr->localEqnNumbers();
00093   std::vector<int>& localEqnsCopy = eCopy->localEqnNumbers();
00094 
00095   if (localEqns != localEqnsCopy) {
00096     ERReturn(-1);
00097   }
00098 
00099   eqnCommMgr->exchangeSoln();
00100 
00101   eqnCommMgr->resetCoefs();
00102 
00103   delete eqnCommMgr;
00104   delete eCopy;
00105 
00106   return(0);
00107 }
00108 
00109 int test_EqnCommMgr::test2()
00110 {
00111   FEI_COUT << "testing ProcEqns...";
00112 
00113   ProcEqns procEqns;
00114 
00115   procEqns.addEqn(0, localProc_);
00116   procEqns.addEqn(1, localProc_);
00117   procEqns.addEqn(2, localProc_);
00118 
00119   procEqns.addEqn(3, 2, localProc_+1);
00120   procEqns.addEqn(4, 2, localProc_+1);
00121   procEqns.addEqn(5, 2, localProc_+1);
00122 
00123   ProcEqns* pCopy = procEqns.deepCopy();
00124 
00125   std::vector<int>& eqnsPerProc = procEqns.eqnsPerProcPtr();
00126   std::vector<int>& eqnsPerProcCopy = pCopy->eqnsPerProcPtr();
00127 
00128   if (eqnsPerProc != eqnsPerProcCopy) {
00129     ERReturn(-1);
00130   }
00131 
00132   delete pCopy;
00133 
00134   FEI_COUT << FEI_ENDL;
00135   return(0);
00136 }
00137 
00138 int test_EqnCommMgr::test3()
00139 {
00140   return(0);
00141 }
00142 
00143 int test_EqnCommMgr::test4()
00144 {
00145   return(0);
00146 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:25 2011 for FEI by  doxygen 1.6.3