FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test_utils
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
12
#include <
test_utils/test_EqnCommMgr.hpp
>
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
24
test_EqnCommMgr::test_EqnCommMgr
(
MPI_Comm
comm)
25
:
tester
(comm)
26
{
27
}
28
29
test_EqnCommMgr::~test_EqnCommMgr
()
30
{
31
}
32
33
int
test_EqnCommMgr::runtests
()
34
{
35
CHK_ERR
(
test1
() );
36
CHK_ERR
(
test2
() );
37
CHK_ERR
(
test3
() );
38
CHK_ERR
(
test4
() );
39
return
(0);
40
}
41
42
int
test_EqnCommMgr::test1
()
43
{
44
EqnCommMgr
* eqnCommMgr =
new
EqnCommMgr
(
comm_
);
45
46
int
numProcs =
fei::numProcs
(
comm_
);
47
int
localProc =
fei::localProc
(
comm_
);
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
109
int
test_EqnCommMgr::test2
()
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
138
int
test_EqnCommMgr::test3
()
139
{
140
return
(0);
141
}
142
143
int
test_EqnCommMgr::test4
()
144
{
145
return
(0);
146
}
EqnCommMgr
Definition
fei_EqnCommMgr.hpp:104
EqnCommMgr::exchangeIndices
int exchangeIndices(std::ostream *dbgOut=NULL)
Definition
fei_EqnCommMgr.cpp:168
EqnCommMgr::setNumRHSs
void setNumRHSs(int numRHSs)
Definition
fei_EqnCommMgr.cpp:906
EqnCommMgr::addLocalEqn
void addLocalEqn(int eqnNumber, int srcProc)
Definition
fei_EqnCommMgr.cpp:131
EqnCommMgr::addSolnValues
void addSolnValues(int *eqnNumbers, double *values, int num)
Definition
fei_EqnCommMgr.cpp:147
EqnCommMgr::deepCopy
EqnCommMgr * deepCopy()
Definition
fei_EqnCommMgr.cpp:118
EqnCommMgr::resetCoefs
void resetCoefs()
Definition
fei_EqnCommMgr.cpp:942
EqnCommMgr::localEqnNumbers
std::vector< int > & localEqnNumbers()
Definition
fei_EqnCommMgr.hpp:197
EqnCommMgr::exchangeSoln
void exchangeSoln()
Definition
fei_EqnCommMgr.cpp:663
EqnCommMgr::addRemoteIndices
void addRemoteIndices(int eqnNumber, int destProc, int *indices, int num)
Definition
fei_EqnCommMgr.cpp:928
ProcEqns
Definition
fei_ProcEqns.hpp:27
ProcEqns::deepCopy
ProcEqns * deepCopy()
Definition
fei_ProcEqns.cpp:30
ProcEqns::addEqn
void addEqn(int eqnNumber, int proc)
Definition
fei_ProcEqns.cpp:65
ProcEqns::eqnsPerProcPtr
std::vector< int > & eqnsPerProcPtr()
Definition
fei_ProcEqns.hpp:48
test_EqnCommMgr::test1
int test1()
Definition
test_EqnCommMgr.cpp:42
test_EqnCommMgr::test_EqnCommMgr
test_EqnCommMgr(MPI_Comm comm)
Definition
test_EqnCommMgr.cpp:24
test_EqnCommMgr::test4
int test4()
Definition
test_EqnCommMgr.cpp:143
test_EqnCommMgr::runtests
int runtests()
Definition
test_EqnCommMgr.cpp:33
test_EqnCommMgr::~test_EqnCommMgr
virtual ~test_EqnCommMgr()
Definition
test_EqnCommMgr.cpp:29
test_EqnCommMgr::test2
int test2()
Definition
test_EqnCommMgr.cpp:109
test_EqnCommMgr::test3
int test3()
Definition
test_EqnCommMgr.cpp:138
tester::tester
tester(MPI_Comm comm)
Definition
tester.cpp:17
tester::comm_
MPI_Comm comm_
Definition
tester.hpp:37
tester::localProc_
int localProc_
Definition
tester.hpp:38
fei_CommUtils.hpp
fei_EqnBuffer.hpp
fei_EqnCommMgr.hpp
fei_ErrMacros.hpp
ERReturn
#define ERReturn(a)
Definition
fei_ErrMacros.hpp:37
CHK_ERR
#define CHK_ERR(a)
Definition
fei_ErrMacros.hpp:26
fei_ProcEqns.hpp
fei_defs.h
FEI_ENDL
#define FEI_ENDL
Definition
fei_iostream.hpp:34
FEI_COUT
#define FEI_COUT
Definition
fei_iostream.hpp:33
fei_macros.hpp
MPI_Comm
#define MPI_Comm
Definition
fei_mpi.h:56
fei::localProc
int localProc(MPI_Comm comm)
Definition
fei_CommUtils.cpp:13
fei::numProcs
int numProcs(MPI_Comm comm)
Definition
fei_CommUtils.cpp:25
test_EqnCommMgr.hpp
Generated by
1.17.0