FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test_utils
test_SNL_FEI_Structure.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
#include <
fei_mpi.h
>
12
13
#include <
test_utils/test_SNL_FEI_Structure.hpp
>
14
15
#include <
SNL_FEI_Structure.hpp
>
16
17
#include <
test_utils/testData.hpp
>
18
19
#undef fei_file
20
#define fei_file "test_SNL_FEI_Structure.cpp"
21
#include <
fei_ErrMacros.hpp
>
22
23
test_SNL_FEI_Structure::test_SNL_FEI_Structure
(
MPI_Comm
comm)
24
:
tester
(comm)
25
{
26
}
27
28
test_SNL_FEI_Structure::~test_SNL_FEI_Structure
()
29
{
30
}
31
32
int
test_SNL_FEI_Structure::runtests
()
33
{
34
CHK_ERR
(
test1
() );
35
CHK_ERR
(
test2
() );
36
CHK_ERR
(
test3
() );
37
CHK_ERR
(
test4
() );
38
return
(0);
39
}
40
41
int
test_SNL_FEI_Structure::test1
()
42
{
43
testData
* testdata =
new
testData
(
localProc_
,
numProcs_
);
44
45
SNL_FEI_Structure
structure(
comm_
);
46
47
CHK_ERR
( structure.
initFields
(testdata->
fieldIDs
.size(),
48
&(testdata->
fieldSizes
[0]),
49
&(testdata->
fieldIDs
[0])) );
50
51
int
numNodesPerElem = testdata->
ids
.size();
52
std::vector<int> numFieldsPerNode(numNodesPerElem, 1);
53
std::vector<int*>nodalFieldIDs(numNodesPerElem, &(testdata->
fieldIDs
[0]));
54
55
CHK_ERR
( structure.
initElemBlock
(0,
//blockID
56
1,
//numElements
57
numNodesPerElem,
58
&numFieldsPerNode[0],
59
&nodalFieldIDs[0],
60
0,
//numElemDofFieldsPerElement
61
NULL,
//elemDofFieldIDs
62
0));
//interleaveStrategy
63
64
CHK_ERR
( structure.
initElem
(0,
//blockID
65
0,
//elemID
66
&(testdata->
ids
[0])) );
67
68
std::vector<int*> sharingProcs2D(testdata->
sharedIDs
.size());
69
int
i, offset = 0;
70
for
(i=0; i<(int)testdata->
numSharingProcsPerID
.size(); ++i) {
71
sharingProcs2D[i] = &(testdata->
sharingProcs
[offset]);
72
offset += testdata->
numSharingProcsPerID
[i];
73
}
74
75
if
(testdata->
sharedIDs
.size() > 0) {
76
CHK_ERR
( structure.
initSharedNodes
(testdata->
sharedIDs
.size(),
77
testdata->
sharedIDs
.size() ? &(testdata->
sharedIDs
[0]) : 0,
78
testdata->
numSharingProcsPerID
.size() ? &(testdata->
numSharingProcsPerID
[0]) : 0,
79
&sharingProcs2D[0]) );
80
}
81
82
CHK_ERR
( structure.
initComplete
() );
83
84
int
numActiveNodes = structure.
getNumActiveNodes
();
85
if
(numActiveNodes != (
int
)testdata->
ids
.size()) {
86
ERReturn
(-1);
87
}
88
89
int
fieldSize = structure.
getFieldSize
(testdata->
fieldIDs
[0]);
90
91
int
numLocalEqns = fieldSize*2;
92
if
(
localProc_
== 0) numLocalEqns += 2;
93
int
checkNumLocalEqns = structure.
getNumLocalEqns
();
94
if
(numLocalEqns != checkNumLocalEqns) {
95
ERReturn
(-1);
96
}
97
98
int
numGlobalEqns = fieldSize*(
numProcs_
*2 + 2);
99
int
checkNumGlobalEqns = structure.
getNumGlobalEqns
();
100
if
(checkNumGlobalEqns != numGlobalEqns) {
101
ERReturn
(-1);
102
}
103
104
std::vector<int> rowLengths;
105
CHK_ERR
( structure.
getMatrixRowLengths
(rowLengths) );
106
107
int
numNonzeros = 0;
108
for
(
size_t
j=0; j<rowLengths.size(); ++j) {
109
numNonzeros += rowLengths[j];
110
}
111
112
std::vector<int> colIndices_1d(numNonzeros);
113
std::vector<int*> colIndPtrs(rowLengths.size());
114
115
offset = 0;
116
for
(
size_t
j=0; j<rowLengths.size(); ++j) {
117
colIndPtrs[j] = &(colIndices_1d[offset]);
118
offset += rowLengths[j];
119
}
120
121
CHK_ERR
( structure.
getMatrixStructure
(&colIndPtrs[0],
122
rowLengths) );
123
124
delete
testdata;
125
126
return
(0);
127
}
128
129
int
test_SNL_FEI_Structure::test2
()
130
{
131
testData
* testdata =
new
testData
(
localProc_
,
numProcs_
);
132
133
SNL_FEI_Structure
structure(
comm_
);
134
135
CHK_ERR
( structure.
initFields
(testdata->
fieldIDs
.size(),
136
&(testdata->
fieldSizes
[0]),
137
&(testdata->
fieldIDs
[0])) );
138
139
int
numNodesPerElem = testdata->
ids
.size();
140
std::vector<int> numFieldsPerNode(numNodesPerElem, testdata->
fieldIDs
.size());
141
std::vector<int*>nodalFieldIDs(numNodesPerElem, &(testdata->
fieldIDs
[0]));
142
std::vector<int> elemDofFieldIDs = testdata->
fieldIDs
;
143
144
CHK_ERR
( structure.
initElemBlock
(0,
//blockID
145
1,
//numElements
146
numNodesPerElem,
147
&numFieldsPerNode[0],
148
&nodalFieldIDs[0],
149
elemDofFieldIDs.size(),
150
&elemDofFieldIDs[0],
151
0));
//interleaveStrategy
152
153
CHK_ERR
( structure.
initElem
(0,
//blockID
154
0,
//elemID
155
&(testdata->
ids
[0])) );
156
157
std::vector<int*> sharingProcs2D(testdata->
sharedIDs
.size());
158
int
i, offset = 0;
159
for
(i=0; i<(int)testdata->
numSharingProcsPerID
.size(); ++i) {
160
sharingProcs2D[i] = &(testdata->
sharingProcs
[offset]);
161
offset += testdata->
numSharingProcsPerID
[i];
162
}
163
164
if
(testdata->
sharedIDs
.size() > 0) {
165
CHK_ERR
( structure.
initSharedNodes
(testdata->
sharedIDs
.size(),
166
testdata->
sharedIDs
.size() ? &(testdata->
sharedIDs
[0]) : 0,
167
testdata->
numSharingProcsPerID
.size() ? &(testdata->
numSharingProcsPerID
[0]) : 0,
168
&sharingProcs2D[0]) );
169
}
170
171
CHK_ERR
( structure.
initComplete
() );
172
173
int
numActiveNodes = structure.
getNumActiveNodes
();
174
if
(numActiveNodes != (
int
)testdata->
ids
.size()) {
175
ERReturn
(-1);
176
}
177
178
int
numEqnsPerNode = 0;
179
for
(i=0; i<(int)testdata->
fieldSizes
.size(); ++i) {
180
numEqnsPerNode += testdata->
fieldSizes
[i];
181
}
182
183
int
numLocalEqns = 3*numEqnsPerNode;
//2 nodes + elem-dofs
184
185
if
(
localProc_
== 0) numLocalEqns += 2*numEqnsPerNode;
186
int
checkNumLocalEqns = structure.
getNumLocalEqns
();
187
if
(numLocalEqns != checkNumLocalEqns) {
188
ERReturn
(-1);
189
}
190
191
int
numGlobalEqns = (
numProcs_
*3+2)*numEqnsPerNode;
192
int
checkNumGlobalEqns = structure.
getNumGlobalEqns
();
193
if
(checkNumGlobalEqns != numGlobalEqns) {
194
ERReturn
(-1);
195
}
196
197
std::vector<int> rowLengths;
198
CHK_ERR
( structure.
getMatrixRowLengths
(rowLengths) );
199
200
int
numNonzeros = 0;
201
for
(
size_t
j=0; j<rowLengths.size(); ++j) {
202
numNonzeros += rowLengths[j];
203
}
204
205
std::vector<int> colIndices_1d(numNonzeros);
206
std::vector<int*> colIndPtrs(rowLengths.size());
207
208
offset = 0;
209
for
(
size_t
j=0; j<rowLengths.size(); ++j) {
210
colIndPtrs[j] = &(colIndices_1d[offset]);
211
offset += rowLengths[j];
212
}
213
214
CHK_ERR
( structure.
getMatrixStructure
(&colIndPtrs[0],
215
rowLengths) );
216
217
delete
testdata;
218
219
return
(0);
220
}
221
222
int
test_SNL_FEI_Structure::test3
()
223
{
224
return
(0);
225
}
226
227
int
test_SNL_FEI_Structure::test4
()
228
{
229
return
(0);
230
}
SNL_FEI_Structure.hpp
SNL_FEI_Structure
Definition
SNL_FEI_Structure.hpp:43
SNL_FEI_Structure::initFields
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
Definition
SNL_FEI_Structure.cpp:361
SNL_FEI_Structure::initElem
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
Definition
SNL_FEI_Structure.cpp:517
SNL_FEI_Structure::getNumLocalEqns
int getNumLocalEqns()
Definition
SNL_FEI_Structure.hpp:477
SNL_FEI_Structure::initComplete
int initComplete(bool generateGraph=true)
Definition
SNL_FEI_Structure.cpp:845
SNL_FEI_Structure::getFieldSize
int getFieldSize(int fieldID)
Definition
SNL_FEI_Structure.hpp:151
SNL_FEI_Structure::getMatrixRowLengths
int getMatrixRowLengths(std::vector< int > &rowLengths)
Definition
SNL_FEI_Structure.cpp:1200
SNL_FEI_Structure::getMatrixStructure
int getMatrixStructure(int **colIndices, std::vector< int > &rowLengths)
Definition
SNL_FEI_Structure.cpp:1213
SNL_FEI_Structure::getNumGlobalEqns
int getNumGlobalEqns()
Definition
SNL_FEI_Structure.hpp:476
SNL_FEI_Structure::initSharedNodes
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
Definition
SNL_FEI_Structure.cpp:668
SNL_FEI_Structure::initElemBlock
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDofFieldIDs, int interleaveStrategy)
Definition
SNL_FEI_Structure.cpp:409
SNL_FEI_Structure::getNumActiveNodes
int getNumActiveNodes()
Definition
SNL_FEI_Structure.hpp:326
testData
Definition
testData.hpp:18
testData::ids
std::vector< int > ids
Definition
testData.hpp:72
testData::fieldIDs
std::vector< int > fieldIDs
Definition
testData.hpp:69
testData::sharedIDs
std::vector< int > sharedIDs
Definition
testData.hpp:73
testData::numSharingProcsPerID
std::vector< int > numSharingProcsPerID
Definition
testData.hpp:74
testData::fieldSizes
std::vector< int > fieldSizes
Definition
testData.hpp:70
testData::sharingProcs
std::vector< int > sharingProcs
Definition
testData.hpp:75
test_SNL_FEI_Structure::test_SNL_FEI_Structure
test_SNL_FEI_Structure(MPI_Comm comm)
Definition
test_SNL_FEI_Structure.cpp:23
test_SNL_FEI_Structure::test3
int test3()
Definition
test_SNL_FEI_Structure.cpp:222
test_SNL_FEI_Structure::test4
int test4()
Definition
test_SNL_FEI_Structure.cpp:227
test_SNL_FEI_Structure::test1
int test1()
Definition
test_SNL_FEI_Structure.cpp:41
test_SNL_FEI_Structure::runtests
int runtests()
Definition
test_SNL_FEI_Structure.cpp:32
test_SNL_FEI_Structure::test2
int test2()
Definition
test_SNL_FEI_Structure.cpp:129
test_SNL_FEI_Structure::~test_SNL_FEI_Structure
virtual ~test_SNL_FEI_Structure()
Definition
test_SNL_FEI_Structure.cpp:28
tester::tester
tester(MPI_Comm comm)
Definition
tester.cpp:17
tester::numProcs_
int numProcs_
Definition
tester.hpp:38
tester::comm_
MPI_Comm comm_
Definition
tester.hpp:37
tester::localProc_
int localProc_
Definition
tester.hpp:38
fei_ErrMacros.hpp
ERReturn
#define ERReturn(a)
Definition
fei_ErrMacros.hpp:37
CHK_ERR
#define CHK_ERR(a)
Definition
fei_ErrMacros.hpp:26
fei_macros.hpp
fei_mpi.h
MPI_Comm
#define MPI_Comm
Definition
fei_mpi.h:56
testData.hpp
test_SNL_FEI_Structure.hpp
Generated by
1.17.0