10 #include <fei_macros.hpp>
13 #include <test_utils/test_SNL_FEI_Structure.hpp>
15 #include <SNL_FEI_Structure.hpp>
17 #include <test_utils/testData.hpp>
20 #define fei_file "test_SNL_FEI_Structure.cpp"
21 #include <fei_ErrMacros.hpp>
23 test_SNL_FEI_Structure::test_SNL_FEI_Structure(MPI_Comm comm)
28 test_SNL_FEI_Structure::~test_SNL_FEI_Structure()
32 int test_SNL_FEI_Structure::runtests()
41 int test_SNL_FEI_Structure::test1()
47 CHK_ERR( structure.initFields(testdata->fieldIDs.size(),
48 &(testdata->fieldSizes[0]),
49 &(testdata->fieldIDs[0])) );
51 int numNodesPerElem = testdata->ids.size();
52 std::vector<int> numFieldsPerNode(numNodesPerElem, 1);
53 std::vector<int*>nodalFieldIDs(numNodesPerElem, &(testdata->fieldIDs[0]));
55 CHK_ERR( structure.initElemBlock(0,
64 CHK_ERR( structure.initElem(0,
66 &(testdata->ids[0])) );
68 std::vector<int*> sharingProcs2D(testdata->sharedIDs.size());
70 for(i=0; i<(int)testdata->numSharingProcsPerID.size(); ++i) {
71 sharingProcs2D[i] = &(testdata->sharingProcs[offset]);
72 offset += testdata->numSharingProcsPerID[i];
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]) );
82 CHK_ERR( structure.initComplete() );
84 int numActiveNodes = structure.getNumActiveNodes();
85 if (numActiveNodes != (
int)testdata->ids.size()) {
89 int fieldSize = structure.getFieldSize(testdata->fieldIDs[0]);
91 int numLocalEqns = fieldSize*2;
92 if (localProc_ == 0) numLocalEqns += 2;
93 int checkNumLocalEqns = structure.getNumLocalEqns();
94 if (numLocalEqns != checkNumLocalEqns) {
98 int numGlobalEqns = fieldSize*(numProcs_*2 + 2);
99 int checkNumGlobalEqns = structure.getNumGlobalEqns();
100 if (checkNumGlobalEqns != numGlobalEqns) {
104 std::vector<int> rowLengths;
105 CHK_ERR( structure.getMatrixRowLengths(rowLengths) );
108 for(
size_t j=0; j<rowLengths.size(); ++j) {
109 numNonzeros += rowLengths[j];
112 std::vector<int> colIndices_1d(numNonzeros);
113 std::vector<int*> colIndPtrs(rowLengths.size());
116 for(
size_t j=0; j<rowLengths.size(); ++j) {
117 colIndPtrs[j] = &(colIndices_1d[offset]);
118 offset += rowLengths[j];
121 CHK_ERR( structure.getMatrixStructure(&colIndPtrs[0],
129 int test_SNL_FEI_Structure::test2()
135 CHK_ERR( structure.initFields(testdata->fieldIDs.size(),
136 &(testdata->fieldSizes[0]),
137 &(testdata->fieldIDs[0])) );
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;
144 CHK_ERR( structure.initElemBlock(0,
147 &numFieldsPerNode[0],
149 elemDofFieldIDs.size(),
153 CHK_ERR( structure.initElem(0,
155 &(testdata->ids[0])) );
157 std::vector<int*> sharingProcs2D(testdata->sharedIDs.size());
159 for(i=0; i<(int)testdata->numSharingProcsPerID.size(); ++i) {
160 sharingProcs2D[i] = &(testdata->sharingProcs[offset]);
161 offset += testdata->numSharingProcsPerID[i];
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]) );
171 CHK_ERR( structure.initComplete() );
173 int numActiveNodes = structure.getNumActiveNodes();
174 if (numActiveNodes != (
int)testdata->ids.size()) {
178 int numEqnsPerNode = 0;
179 for(i=0; i<(int)testdata->fieldSizes.size(); ++i) {
180 numEqnsPerNode += testdata->fieldSizes[i];
183 int numLocalEqns = 3*numEqnsPerNode;
185 if (localProc_ == 0) numLocalEqns += 2*numEqnsPerNode;
186 int checkNumLocalEqns = structure.getNumLocalEqns();
187 if (numLocalEqns != checkNumLocalEqns) {
191 int numGlobalEqns = (numProcs_*3+2)*numEqnsPerNode;
192 int checkNumGlobalEqns = structure.getNumGlobalEqns();
193 if (checkNumGlobalEqns != numGlobalEqns) {
197 std::vector<int> rowLengths;
198 CHK_ERR( structure.getMatrixRowLengths(rowLengths) );
201 for(
size_t j=0; j<rowLengths.size(); ++j) {
202 numNonzeros += rowLengths[j];
205 std::vector<int> colIndices_1d(numNonzeros);
206 std::vector<int*> colIndPtrs(rowLengths.size());
209 for(
size_t j=0; j<rowLengths.size(); ++j) {
210 colIndPtrs[j] = &(colIndices_1d[offset]);
211 offset += rowLengths[j];
214 CHK_ERR( structure.getMatrixStructure(&colIndPtrs[0],
222 int test_SNL_FEI_Structure::test3()
227 int test_SNL_FEI_Structure::test4()