FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_EqnCommMgr.cpp
Go to the documentation of this file.
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 
10 #include <fei_macros.hpp>
11 
13 #include <fei_CommUtils.hpp>
14 #include <fei_defs.h>
15 
16 #include <fei_ProcEqns.hpp>
17 #include <fei_EqnBuffer.hpp>
18 #include <fei_EqnCommMgr.hpp>
19 
20 #undef fei_file
21 #define fei_file "test_EqnCommMgr.cpp"
22 #include <fei_ErrMacros.hpp>
23 
25  : tester(comm)
26 {
27 }
28 
30 {
31 }
32 
34 {
35  CHK_ERR( test1() );
36  CHK_ERR( test2() );
37  CHK_ERR( test3() );
38  CHK_ERR( test4() );
39  return(0);
40 }
41 
43 {
44  EqnCommMgr* eqnCommMgr = new EqnCommMgr(comm_);
45 
48 
49 // int numGlobalEqns = numProcs*5;
50  int numLocalEqns = 5;
51  int firstLocalEqn = localProc*numLocalEqns;
52 // int lastLocalEqn = (localProc+1)*numLocalEqns - 1;
53 
54  if (numProcs > 1) {
55  for(int p=0; p<numProcs; p++) {
56  if (p == localProc) continue;
57 
58  for(int i=0; i<numLocalEqns; i++) {
59  if (p != 2) eqnCommMgr->addLocalEqn(firstLocalEqn+i, p);
60  }
61  }
62  }
63 
64  eqnCommMgr->setNumRHSs(1);
65 
66  int p;
67  for(p=0; p<numProcs; p++) {
68  if (p == localProc) continue;
69 
70  for(int i=0; i<numLocalEqns; i++) {
71  int eqn = p*numLocalEqns + i;
72 
73  eqnCommMgr->addRemoteIndices(eqn, p, &eqn, 1);
74  }
75  }
76 
77  CHK_ERR( eqnCommMgr->exchangeIndices() );
78 
79  double zero = 0.0;
80  for(p=0; p<numProcs; p++) {
81  if (p == localProc) continue;
82 
83  for(int i=0; i<numLocalEqns; i++) {
84  int eqn = p*numLocalEqns + i;
85 
86  eqnCommMgr->addSolnValues(&eqn, &zero, 1);
87  }
88  }
89 
90  EqnCommMgr* eCopy = eqnCommMgr->deepCopy();
91 
92  std::vector<int>& localEqns = eqnCommMgr->localEqnNumbers();
93  std::vector<int>& localEqnsCopy = eCopy->localEqnNumbers();
94 
95  if (localEqns != localEqnsCopy) {
96  ERReturn(-1);
97  }
98 
99  eqnCommMgr->exchangeSoln();
100 
101  eqnCommMgr->resetCoefs();
102 
103  delete eqnCommMgr;
104  delete eCopy;
105 
106  return(0);
107 }
108 
110 {
111  FEI_COUT << "testing ProcEqns...";
112 
113  ProcEqns procEqns;
114 
115  procEqns.addEqn(0, localProc_);
116  procEqns.addEqn(1, localProc_);
117  procEqns.addEqn(2, localProc_);
118 
119  procEqns.addEqn(3, 2, localProc_+1);
120  procEqns.addEqn(4, 2, localProc_+1);
121  procEqns.addEqn(5, 2, localProc_+1);
122 
123  ProcEqns* pCopy = procEqns.deepCopy();
124 
125  std::vector<int>& eqnsPerProc = procEqns.eqnsPerProcPtr();
126  std::vector<int>& eqnsPerProcCopy = pCopy->eqnsPerProcPtr();
127 
128  if (eqnsPerProc != eqnsPerProcCopy) {
129  ERReturn(-1);
130  }
131 
132  delete pCopy;
133 
134  FEI_COUT << FEI_ENDL;
135  return(0);
136 }
137 
139 {
140  return(0);
141 }
142 
144 {
145  return(0);
146 }
std::vector< int > & localEqnNumbers()
#define FEI_COUT
MPI_Comm comm_
Definition: tester.hpp:37
std::vector< int > & eqnsPerProcPtr()
void addEqn(int eqnNumber, int proc)
int localProc_
Definition: tester.hpp:38
#define MPI_Comm
Definition: fei_mpi.h:56
virtual ~test_EqnCommMgr()
void addLocalEqn(int eqnNumber, int srcProc)
int exchangeIndices(std::ostream *dbgOut=NULL)
void addRemoteIndices(int eqnNumber, int destProc, int *indices, int num)
#define ERReturn(a)
#define FEI_ENDL
EqnCommMgr * deepCopy()
test_EqnCommMgr(MPI_Comm comm)
int localProc(MPI_Comm comm)
void setNumRHSs(int numRHSs)
ProcEqns * deepCopy()
#define CHK_ERR(a)
void addSolnValues(int *eqnNumbers, double *values, int num)
int numProcs(MPI_Comm comm)
void exchangeSoln()