10 #include <fei_macros.hpp>
11 #include <fei_sstream.hpp>
13 #include <test_utils/test_FEI_Impl.hpp>
15 #include <fei_FEI_Impl.hpp>
16 #ifdef HAVE_FEI_AZTECOO
17 #include <fei_Aztec_LinSysCore.hpp>
19 #include <test_utils/FEData.hpp>
20 #include <fei_LibraryWrapper.hpp>
22 #include <test_utils/testData.hpp>
25 #define fei_file "test_FEI_Impl.cpp"
26 #include <fei_ErrMacros.hpp>
28 test_FEI_Impl::test_FEI_Impl(MPI_Comm comm)
33 test_FEI_Impl::~test_FEI_Impl()
37 int test_FEI_Impl::runtests()
40 CHK_ERR( serialtest1() );
50 int test_FEI_Impl::serialtest1()
55 int test_FEI_Impl::compareCoefs(
int n,
56 const double*
const* coefs1,
57 const double*
const* coefs2)
59 for(
int i=0; i<n; ++i) {
60 for(
int j=0; j<n; ++j) {
61 double diff = coefs1[i][j] - coefs2[i][j];
62 if (diff > 1.e-20 || diff < -1.e-20) {
71 int test_FEI_Impl::test1()
76 #ifdef HAVE_FEI_AZTECOO
83 std::string param0(
"name test1");
84 FEI_OSTRINGSTREAM osstr;
85 osstr <<
"debugOutput ";
86 if (path_.empty()) osstr <<
".";
89 std::string param1 = osstr.str();
92 char** params =
new char*[numParams];
93 params[0] =
const_cast<char*
>(param0.c_str());
94 params[1] =
const_cast<char*
>(param1.c_str());
98 CHK_ERR( fei->parameters(1, ¶ms[0]) );
99 CHK_ERR( fei->parameters(1, ¶ms[1]) );
100 CHK_ERR( fei->parameters(2, params) );
104 CHK_ERR( fei->setIDLists(1, &(testdata->ids[0]),
105 1, &(testdata->ids[0])) );
107 CHK_ERR( fei->initFields(testdata->fieldIDs.size(),
108 &(testdata->fieldSizes[0]),
109 &(testdata->fieldIDs[0])) );
111 int numNodesPerElem = testdata->ids.size();
112 std::vector<int> numFieldsPerNode(numNodesPerElem, 1);
113 std::vector<int*>nodalFieldIDs(numNodesPerElem, &(testdata->fieldIDs[0]));
115 CHK_ERR( fei->initElemBlock(0,
118 &numFieldsPerNode[0],
124 CHK_ERR( fei->initElem(0,
126 &(testdata->ids[0])) );
128 std::vector<int*> sharingProcs2D(testdata->sharedIDs.size());
130 for(
int i=0; i<(int)testdata->numSharingProcsPerID.size(); ++i) {
131 sharingProcs2D[i] = &(testdata->sharingProcs[offset]);
132 offset += testdata->numSharingProcsPerID[i];
135 if (testdata->sharedIDs.size() > 0) {
136 CHK_ERR( fei->initSharedNodes(testdata->sharedIDs.size(),
137 &(testdata->sharedIDs[0]),
138 &(testdata->numSharingProcsPerID[0]),
139 &sharingProcs2D[0]) );
142 CHK_ERR( fei->initComplete() );
144 std::vector<double> rhsData(testdata->ids.size(), 1.0);
147 CHK_ERR( fei->setMatScalars(1, &(testdata->ids[0]), &one) );
148 CHK_ERR( fei->setRHSScalars(1, &(testdata->ids[0]), &one) );
150 CHK_ERR( fei->setCurrentMatrix(testdata->ids[0]) );
151 CHK_ERR( fei->setCurrentRHS(testdata->ids[0]) );
153 CHK_ERR( fei->putIntoRHS(FEI_NODE, testdata->fieldIDs[0],
154 testdata->ids.size(),
159 GlobalID* BCNodeIDs = &(testdata->ids[0]);
160 int BCFieldID = testdata->fieldIDs[0];
161 double* values =
new double[numBCNodes];
162 int* offsetsIntoField =
new int[numBCNodes];
163 for(
int ii=0; ii<numBCNodes; ++ii) {
165 offsetsIntoField[ii] = 0;
168 CHK_ERR( fei->loadNodeBCs(numBCNodes, BCNodeIDs, BCFieldID,
169 offsetsIntoField, values) );
171 delete [] offsetsIntoField;
174 CHK_ERR( fei->loadComplete() );
176 int numActiveNodes = 0;
177 CHK_ERR( fei->getNumLocalNodes(numActiveNodes) );
178 if (numActiveNodes != (
int)testdata->ids.size()) {
182 GlobalID* localNodes =
new GlobalID[numActiveNodes];
183 CHK_ERR( fei->getLocalNodeIDList(numActiveNodes, localNodes, numActiveNodes) );
185 int totalFieldSize = 0;
186 for(
int ii=0; ii<(int)testdata->fieldSizes.size(); ++ii) {
187 totalFieldSize += testdata->fieldSizes[ii];
190 double* soln =
new double[numActiveNodes*totalFieldSize];
191 int* offsets =
new int[numActiveNodes+1];
193 CHK_ERR( fei->getNodalSolution(numActiveNodes, localNodes,
197 delete [] localNodes;
199 CHK_ERR( fei->resetInitialGuess() );
202 CHK_ERR( fei->getFieldSize(testdata->fieldIDs[0], fieldSize) );
204 double initTime, loadTime, solveTime, solnReturnTime;
205 CHK_ERR( fei->cumulative_cpu_times(initTime, loadTime, solveTime,
213 int test_FEI_Impl::test2()
220 std::string param0(
"name test1");
221 FEI_OSTRINGSTREAM osstr;
222 osstr <<
"debugOutput ";
223 if (path_.empty()) osstr <<
".";
226 std::string param1 = osstr.str();
229 char** params =
new char*[numParams];
230 params[0] =
const_cast<char*
>(param0.c_str());
231 params[1] =
const_cast<char*
>(param1.c_str());
235 CHK_ERR( fei->parameters(1, ¶ms[0]) );
236 CHK_ERR( fei->parameters(1, ¶ms[1]) );
237 CHK_ERR( fei->parameters(2, params) );
241 CHK_ERR( fei->setIDLists(1, &(testdata->ids[0]),
242 1, &(testdata->ids[0])) );
243 CHK_ERR( fei->initFields(testdata->fieldIDs.size(),
244 &(testdata->fieldSizes[0]),
245 &(testdata->fieldIDs[0])) );
247 int numNodesPerElem = testdata->ids.size();
248 std::vector<int> numFieldsPerNode(numNodesPerElem, 1);
249 std::vector<int*>nodalFieldIDs(numNodesPerElem, &(testdata->fieldIDs[0]));
251 CHK_ERR( fei->initElemBlock(0,
254 &numFieldsPerNode[0],
260 CHK_ERR( fei->initElem(0,
262 &(testdata->ids[0])) );
264 std::vector<int*> sharingProcs2D(testdata->sharedIDs.size());
266 for(i=0; i<(int)testdata->numSharingProcsPerID.size(); ++i) {
267 sharingProcs2D[i] = &(testdata->sharingProcs[offset]);
268 offset += testdata->numSharingProcsPerID[i];
271 if (testdata->sharedIDs.size() > 0) {
272 CHK_ERR( fei->initSharedNodes(testdata->sharedIDs.size(),
273 &(testdata->sharedIDs[0]),
274 &(testdata->numSharingProcsPerID[0]),
275 &sharingProcs2D[0]) );
278 CHK_ERR( fei->initComplete() );
280 std::vector<double> rhsData(testdata->ids.size(), 1.0);
283 CHK_ERR( fei->setMatScalars(1, &(testdata->ids[0]), &one) );
284 CHK_ERR( fei->setRHSScalars(1, &(testdata->ids[0]), &one) );
286 CHK_ERR( fei->setCurrentMatrix(testdata->ids[0]) );
287 CHK_ERR( fei->setCurrentRHS(testdata->ids[0]) );
292 GlobalID* BCNodeIDs = &(testdata->ids[0]);
293 int BCFieldID = testdata->fieldIDs[0];
294 double* values =
new double[numBCNodes];
295 int* offsetsIntoField =
new int[numBCNodes];
296 for(ii=0; ii<numBCNodes; ++ii) {
298 offsetsIntoField[ii] = 0;
301 CHK_ERR( fei->loadNodeBCs(numBCNodes, BCNodeIDs, BCFieldID,
302 offsetsIntoField, values) );
305 delete [] offsetsIntoField;
307 CHK_ERR( fei->loadComplete() );
309 int numActiveNodes = 0;
310 CHK_ERR( fei->getNumLocalNodes(numActiveNodes) );
311 if (numActiveNodes != (
int)testdata->ids.size()) {
315 GlobalID* localNodes =
new GlobalID[numActiveNodes];
316 CHK_ERR( fei->getLocalNodeIDList(numActiveNodes, localNodes, numActiveNodes) );
318 int totalFieldSize = 0;
319 for(ii=0; ii<(int)testdata->fieldSizes.size(); ++ii) {
320 totalFieldSize += testdata->fieldSizes[ii];
323 double* soln =
new double[numActiveNodes*totalFieldSize];
324 int* offsets =
new int[numActiveNodes+1];
326 CHK_ERR( fei->getNodalSolution(numActiveNodes, localNodes,
330 delete [] localNodes;
332 CHK_ERR( fei->resetInitialGuess() );
335 CHK_ERR( fei->getFieldSize(testdata->fieldIDs[0], fieldSize) );
337 double initTime, loadTime, solveTime, solnReturnTime;
338 CHK_ERR( fei->cumulative_cpu_times(initTime, loadTime, solveTime,
344 int test_FEI_Impl::test3()
349 int test_FEI_Impl::test4()