10 #include <fei_fstream.hpp>
15 #include <snl_fei_Utils.hpp>
16 #include <test_utils/DataReader.hpp>
18 #include <test_utils/driverData.hpp>
25 #define CHK_ERR(a) {int chkerr; if ((chkerr = a) != 0) { \
26 fei::console_out() << "file " << __FILE__ << ", line " << __LINE__ \
27 << ", err " << chkerr << FEI_ENDL; \
30 driverData::driverData()
35 initFields_fieldSizes_(NULL),
36 initFields_fieldIDs_(NULL),
37 initElemBlock_ints_(NULL),
38 initElemBlock_fieldsPerNode_(NULL),
39 initElemBlock_fieldIDs_(NULL),
40 initElemBlock_elemDofFieldIDs_(NULL),
46 sumInElemMatrixCounter_(0),
48 sumInElemRHSCounter_(0),
50 loadNodeBCsCounter_(0),
52 initCRMultCounter_(0),
54 loadCRMultCounter_(0),
56 initSharedNodesCounter_(0),
58 parametersCounter_(0),
60 setIDListsCounter_(0),
62 setCurrentMatrixCounter_(0),
64 setCurrentRHSCounter_(0),
65 putBlockFieldNodeSolution_(),
66 putBlockFieldNodeSolutionCounter_(0)
69 temp_ =
new char[tempLen_];
72 driverData::~driverData()
77 for(
size_t i=0; i<methodNames.size(); i++) {
78 delete [] methodNames[i];
81 delete [] initFields_fieldSizes_;
82 delete [] initFields_fieldIDs_;
84 if (initElemBlock_numInts_ > 0 && initElemBlock_ints_ != NULL) {
85 int len = initElemBlock_ints_[2];
86 for(
int j=0; j<len; ++j)
delete [] initElemBlock_fieldIDs_[j];
87 delete [] initElemBlock_fieldIDs_;
88 delete [] initElemBlock_fieldsPerNode_;
89 delete [] initElemBlock_ints_;
90 initElemBlock_ints_ = NULL;
93 for(
size_t i=0; i<initElems_.size(); ++i)
delete initElems_[i];
94 for(
size_t i=0; i<sumInElems_.size(); ++i)
delete sumInElems_[i];
95 for(
size_t i=0; i<sumInElemMatrix_.size(); ++i)
delete sumInElemMatrix_[i];
96 for(
size_t i=0; i<sumInElemRHS_.size(); ++i)
delete sumInElemRHS_[i];
97 for(
size_t i=0; i<loadNodeBCs_.size(); ++i)
delete loadNodeBCs_[i];
98 for(
size_t i=0; i<initCRMult_.size(); ++i)
delete initCRMult_[i];
99 for(
size_t i=0; i<loadCRMult_.size(); ++i)
delete loadCRMult_[i];
100 for(
size_t i=0; i<initSharedNodes_.size(); ++i)
delete initSharedNodes_[i];
101 for(
size_t i=0; i<parameters_.size(); ++i)
delete parameters_[i];
102 for(
size_t i=0; i<setIDLists_.size(); ++i)
delete setIDLists_[i];
105 int driverData::readData(
const char* fileName)
107 FEI_IFSTREAM* instr = NULL;
108 instr =
new FEI_IFSTREAM(fileName);
111 fei::console_out() <<
"driverData::readData: ERROR opening " << fileName << FEI_ENDL;
114 FEI_COUT <<
"driverData reading from " << fileName << FEI_ENDL;
115 char* keyword = NULL;
117 int err = getKeyword(instr, keyword);
118 while (!instr->eof() && !err) {
119 FEI_COUT <<
"driverData read keyword: " << keyword << FEI_ENDL;
120 err = readData(instr, keyword);
122 fei::console_out() <<
"driverData: ERROR reading data for keyword: " << keyword << FEI_ENDL;
126 err = getKeyword(instr, keyword);
134 int driverData::call_fei_method(
const char* method,
FEI* fei)
136 if (!std::strcmp(
"setSolveType", method)) {
140 if (!std::strcmp(
"setIDLists", method)) {
141 if (setIDListsCounter_ >= (
int)setIDLists_.size()) {
142 fei::console_out() <<
"driverData ERROR, can't call setIDLists again" << FEI_ENDL;
146 setIDLists* sidl = setIDLists_[setIDListsCounter_++];
148 return( fei->
setIDLists(sidl->numMatrices, sidl->matrixIDs,
149 sidl->numRHSs, sidl->rhsIDs) );
152 if (!std::strcmp(
"setCurrentMatrix", method)) {
153 if (setCurrentMatrixCounter_ >= (
int)setCurrentMatrix_.size()) {
154 fei::console_out() <<
"driverData ERROR, can't call setCurrentMatrix again" << FEI_ENDL;
158 int matID = setCurrentMatrix_[setCurrentMatrixCounter_++];
163 if (!std::strcmp(
"setCurrentRHS", method)) {
164 if (setCurrentRHSCounter_ >= (
int)setCurrentRHS_.size()) {
165 fei::console_out() <<
"driverData ERROR, can't call setCurrentRHS again" << FEI_ENDL;
169 int rhsID = setCurrentRHS_[setCurrentRHSCounter_++];
174 if (!std::strcmp(
"initFields", method)) {
175 return( fei->
initFields(initFields_numFields_,
176 initFields_fieldSizes_,
177 initFields_fieldIDs_) );
180 if (!std::strcmp(
"initElemBlock", method)) {
182 initElemBlock_ints_[1],
183 initElemBlock_ints_[2],
184 initElemBlock_fieldsPerNode_,
185 initElemBlock_fieldIDs_,
186 initElemBlock_ints_[3],
187 initElemBlock_elemDofFieldIDs_,
188 initElemBlock_ints_[4]) );
192 if (!std::strcmp(
"parameters", method)) {
193 if (parametersCounter_ >= (
int)parameters_.size()) {
194 fei::console_out() <<
"driverData ERROR, can't call parameters again" << FEI_ENDL;
198 parameters* param = parameters_[parametersCounter_++];
200 return( fei->
parameters(param->paramList.size(),
201 ¶m->paramList[0]) );
204 if (!std::strcmp(
"initCRMult", method)) {
205 if (initCRMultCounter_ >= (
int)initCRMult_.size()) {
206 fei::console_out() <<
"driverData ERROR, can't call initCRMult again" << FEI_ENDL;
210 initCR* icr = initCRMult_[initCRMultCounter_++];
212 return( fei->
initCRMult(icr->numNodes, icr->nodeIDs,
213 icr->fieldIDs, icr->CRID) );
216 if (!std::strcmp(
"initSharedNodes", method)) {
217 if (initSharedNodesCounter_ >= (
int)initSharedNodes_.size()) {
218 fei::console_out() <<
"driverData ERROR, can't call initSharedNodes again" << FEI_ENDL;
222 sharedNodes* sn = initSharedNodes_[initSharedNodesCounter_++];
225 sn->numProcsPerNode, sn->sharedProcIDs) );
228 if (!std::strcmp(
"loadCRMult", method)) {
229 if (loadCRMultCounter_ >= (
int)loadCRMult_.size()) {
230 fei::console_out() <<
"driverData ERROR, can't call loadCRMult again" << FEI_ENDL;
234 loadCR* lcr = loadCRMult_[loadCRMultCounter_++];
236 return( fei->
loadCRMult(lcr->CRID, lcr->numNodes, lcr->nodeIDs,
237 lcr->fieldIDs, lcr->weights, lcr->CRValue) );
240 if (!std::strcmp(
"deleteMultCRs", method)) {
244 if (!std::strcmp(
"initElem", method)) {
245 if (initElemCounter_ >= (
int)initElems_.size()) {
246 fei::console_out() <<
"driverData ERROR, can't call initElem again" << FEI_ENDL;
250 initElem* ie = initElems_[initElemCounter_++];
252 return( fei->
initElem(ie->elemBlockID, ie->elemID, ie->nodeIDs) );
255 if (!std::strcmp(
"initComplete", method)) {
259 if (!std::strcmp(
"resetSystem", method)) {
263 if (!std::strcmp(
"resetMatrix", method)) {
267 if (!std::strcmp(
"resetRHSVector", method)) {
271 if (!std::strcmp(
"resetInitialGuess", method)) {
275 if (!std::strcmp(
"sumInElem", method)) {
276 if (sumInElemCounter_ >= (
int)sumInElems_.size()) {
277 fei::console_out() <<
"driverData ERROR, can't call sumInElem again" << FEI_ENDL;
281 sumInElem* sie = sumInElems_[sumInElemCounter_++];
283 return( fei->
sumInElem(sie->elemBlockID, sie->elemID, sie->nodeIDs,
284 sie->stiffness, sie->load, sie->elemFormat) );
287 if (!std::strcmp(
"sumInElemMatrix", method)) {
288 if (sumInElemMatrixCounter_ >= (
int)sumInElemMatrix_.size()) {
289 fei::console_out() <<
"driverData ERROR, can't call sumInElemMatrix again" << FEI_ENDL;
293 sumInElem* sie = sumInElemMatrix_[sumInElemMatrixCounter_++];
295 return( fei->
sumInElemMatrix(sie->elemBlockID, sie->elemID, sie->nodeIDs,
296 sie->stiffness, sie->elemFormat) );
299 if (!std::strcmp(
"sumInElemRHS", method)) {
300 if (sumInElemRHSCounter_ >= (
int)sumInElemRHS_.size()) {
301 fei::console_out() <<
"driverData ERROR, can't call sumInElemRHS again" << FEI_ENDL;
305 sumInElem* sie = sumInElemRHS_[sumInElemRHSCounter_++];
307 return( fei->
sumInElemRHS(sie->elemBlockID, sie->elemID, sie->nodeIDs,
311 if (!std::strcmp(
"putBlockFieldNodeSolution", method)) {
312 if (putBlockFieldNodeSolutionCounter_ >=
313 (
int)putBlockFieldNodeSolution_.size()) {
314 fei::console_out() <<
"driverData ERROR, can't call putBlockFieldNodeSolution again"
319 putBlockFieldNodeSolution* pbfns =
320 putBlockFieldNodeSolution_[putBlockFieldNodeSolutionCounter_++];
329 if (!std::strcmp(
"loadNodeBCs", method)) {
330 if (loadNodeBCsCounter_ >= (
int)loadNodeBCs_.size()) {
331 fei::console_out() <<
"driverData ERROR, can't call loadNodeBCs again" << FEI_ENDL;
335 fei::console_out() <<
"driverData: ERROR, loadNodeBCs needs to be re-examined..." << FEI_ENDL;
339 if (!std::strcmp(
"loadComplete", method)) {
343 if (!std::strcmp(
"solve", method)) {
345 return( fei->
solve(status) );
348 if (!std::strcmp(
"getBlockNodeIDList", method) ||
349 !std::strcmp(
"residualNorm", method) ||
350 !std::strcmp(
"getBlockFieldNodeSolution", method)) {
354 fei::console_out() <<
"driverData: ERROR unrecognized method name '" << method <<
"'"<<FEI_ENDL;
358 int driverData::readData(FEI_ISTREAM* instr,
char* keyword)
360 if (!std::strcmp(
"setSolveType", keyword)) {
361 CHK_ERR( appendName(keyword) );
362 return(readData(instr, solveType_));
365 if (!std::strcmp(
"setIDLists", keyword)) {
367 CHK_ERR( readData(instr, numMatrices) );
368 setIDLists* sidl =
new setIDLists;
369 sidl->numMatrices = numMatrices;
370 sidl->matrixIDs =
new int[numMatrices];
372 for(i=0; i<numMatrices; ++i) {
373 CHK_ERR( readData(instr, sidl->matrixIDs[i]) );
376 CHK_ERR( readData(instr, numRHSs) );
377 sidl->numRHSs = numRHSs;
378 sidl->rhsIDs =
new int[numRHSs];
379 for(i=0; i<numRHSs; ++i) {
380 CHK_ERR( readData(instr, sidl->rhsIDs[i]) );
383 setIDLists_.push_back(sidl);
384 return( appendName(keyword) );
387 if (!std::strcmp(
"setCurrentMatrix", keyword)) {
389 CHK_ERR( readData(instr, matID) );
390 setCurrentMatrix_.push_back(matID);
391 return( appendName(keyword) );
394 if (!std::strcmp(
"setCurrentRHS", keyword)) {
396 CHK_ERR( readData(instr, rhsID) );
397 setCurrentRHS_.push_back(rhsID);
398 return( appendName(keyword) );
401 if (!std::strcmp(
"initFields", keyword)) {
403 CHK_ERR( readData(instr, initFields_numFields_) );
404 initFields_fieldSizes_ =
new int[initFields_numFields_];
405 initFields_fieldIDs_ =
new int[initFields_numFields_];
407 for(i=0; i<initFields_numFields_; ++i) {
408 CHK_ERR( readData(instr, initFields_fieldSizes_[i]) );
410 for(i=0; i<initFields_numFields_; ++i) {
411 CHK_ERR( readData(instr, initFields_fieldIDs_[i]) );
414 return( appendName(keyword) );
417 if (!std::strcmp(
"parameters", keyword)) {
419 CHK_ERR( readData(instr, numParams) );
420 parameters* param =
new parameters;
421 param->paramList.resize(numParams);
422 CHK_ERR( skipWhite(instr) );
423 for(
int i=0; i<numParams; ++i) {
424 char* line =
new char[512];
425 instr->getline(line, 512);
426 param->paramList[i] = line;
428 parameters_.push_back(param);
429 return( appendName(keyword) );
432 if (!std::strcmp(
"initElemBlock", keyword)) {
433 initElemBlock_numInts_ = 5;
434 int i, intOffset = 0;
435 initElemBlock_ints_ =
new int[initElemBlock_numInts_];
437 CHK_ERR( readData(instr, initElemBlock_ints_[intOffset++]) );
439 CHK_ERR( readData(instr, initElemBlock_ints_[intOffset++]) );
441 CHK_ERR( readData(instr, initElemBlock_ints_[intOffset++]) );
443 int len = initElemBlock_ints_[intOffset-1];
444 initElemBlock_fieldsPerNode_ =
new int[len];
445 initElemBlock_fieldIDs_ =
new int*[len];
446 for(i=0; i<len; ++i) {
447 CHK_ERR( readData(instr, initElemBlock_fieldsPerNode_[i]) );
450 for(i=0; i<len; ++i) {
451 int len2 = initElemBlock_fieldsPerNode_[i];
452 initElemBlock_fieldIDs_[i] =
new int[len2];
453 for(
int ii=0; ii<len2; ++ii) {
454 CHK_ERR( readData(instr, initElemBlock_fieldIDs_[i][ii]) );
458 CHK_ERR( readData(instr, initElemBlock_ints_[intOffset++]) );
460 len = initElemBlock_ints_[intOffset-1];
462 initElemBlock_elemDofFieldIDs_ =
new int[len];
463 for(i=0; i<len; ++i) {
464 CHK_ERR( readData(instr, initElemBlock_elemDofFieldIDs_[i]) );
468 CHK_ERR( readData(instr, initElemBlock_ints_[intOffset++]) );
469 return( appendName(keyword) );
472 if (!std::strcmp(
"initElem", keyword) ) {
473 initElem* ie =
new initElem;
475 CHK_ERR( readData(instr, tmp) );
476 ie->elemBlockID = (GlobalID)tmp;
477 CHK_ERR( readData(instr, tmp) );
478 ie->elemID = (GlobalID)tmp;
479 CHK_ERR( readData(instr, tmp) );
480 ie->nodeIDs =
new GlobalID[tmp];
482 for(
int i=0; i<ie->numNodes; ++i) {
483 CHK_ERR( readData(instr, tmp) );
484 ie->nodeIDs[i] = (GlobalID)tmp;
486 initElems_.push_back(ie);
487 return( appendName(keyword) );
490 if (!std::strcmp(
"initCRMult", keyword) ) {
491 initCR* icr =
new initCR;
492 CHK_ERR( readData(instr, icr->numNodes) );
493 if (icr->numNodes > 0) {
494 icr->nodeIDs =
new GlobalID[icr->numNodes];
495 icr->fieldIDs =
new int[icr->numNodes];
498 for(i=0; i<icr->numNodes; ++i) {
499 CHK_ERR( readData(instr, tmp) ); icr->nodeIDs[i] = (GlobalID)tmp;
502 for(i=0; i<icr->numNodes; ++i) {
503 CHK_ERR( readData(instr, icr->fieldIDs[i]) );
507 CHK_ERR( readData(instr, icr->CRID) );
509 initCRMult_.push_back(icr);
510 return( appendName(keyword) );
513 if (!std::strcmp(
"loadCRMult", keyword) ) {
514 loadCR* lcr =
new loadCR;
515 CHK_ERR( readData(instr, lcr->numNodes) );
516 if (lcr->numNodes > 0) {
517 lcr->nodeIDs =
new GlobalID[lcr->numNodes];
518 lcr->fieldIDs =
new int[lcr->numNodes];
519 lcr->fieldSizes =
new int[lcr->numNodes];
522 for(i=0; i<lcr->numNodes; ++i) {
523 CHK_ERR( readData(instr, tmp) ); lcr->nodeIDs[i] = (GlobalID)tmp;
526 for(i=0; i<lcr->numNodes; ++i) {
527 CHK_ERR( readData(instr, lcr->fieldIDs[i]) );
531 for(i=0; i<lcr->numNodes; ++i) {
532 CHK_ERR( readData(instr, lcr->fieldSizes[i]) );
533 tmp += lcr->fieldSizes[i];
536 lcr->weights =
new double[tmp];
538 for(i=0; i<lcr->numNodes; ++i) {
539 int size = lcr->fieldSizes[i];
540 for(
int j=0; j<size; ++j) {
541 CHK_ERR( readData(instr, lcr->weights[offset++]) );
545 CHK_ERR( readData(instr, lcr->CRValue) );
548 CHK_ERR( readData(instr, lcr->CRID) );
550 loadCRMult_.push_back(lcr);
551 return( appendName(keyword) );
554 if (!std::strcmp(
"deleteMultCRs", keyword) ) {
555 return( appendName(keyword) );
558 if (!std::strcmp(
"initSharedNodes", keyword) ) {
559 sharedNodes* sn =
new sharedNodes;
560 CHK_ERR( readData(instr, sn->numNodes) );
561 if (sn->numNodes > 0) {
562 sn->nodeIDs =
new GlobalID[sn->numNodes];
563 sn->numProcsPerNode =
new int[sn->numNodes];
564 sn->sharedProcIDs =
new int*[sn->numNodes];
567 for(i=0; i<sn->numNodes; ++i) {
568 CHK_ERR( readData(instr, sn->numProcsPerNode[i]) );
569 sn->sharedProcIDs[i] =
new int[sn->numProcsPerNode[i]];
572 for(i=0; i<sn->numNodes; ++i) {
573 CHK_ERR( readData(instr, tmp) ); sn->nodeIDs[i] = (GlobalID)tmp;
574 for(
int j=0; j<sn->numProcsPerNode[i]; ++j) {
575 CHK_ERR( readData(instr, sn->sharedProcIDs[i][j]) );
580 initSharedNodes_.push_back(sn);
581 return( appendName(keyword) );
584 if (!std::strcmp(
"initComplete", keyword) ) {
585 return( appendName(keyword) );
588 if (!std::strcmp(
"sumInElem", keyword) ) {
589 sumInElem* sie =
new sumInElem;
592 CHK_ERR( readData(instr, tmp) );
593 sie->elemBlockID = (GlobalID)tmp;
594 CHK_ERR( readData(instr, tmp) );
595 sie->elemID = (GlobalID)tmp;
596 CHK_ERR( readData(instr, tmp) );
597 sie->nodeIDs =
new GlobalID[tmp];
600 for(i=0; i<sie->numNodes; ++i) {
601 CHK_ERR( readData(instr, tmp) );
602 sie->nodeIDs[i] = (GlobalID)tmp;
605 CHK_ERR( readData(instr, tmp) );
607 sie->stiff1D =
new double[tmp*tmp];
608 sie->load =
new double[tmp];
609 sie->stiffness =
new double*[tmp];
611 for(i=0; i<sie->numRows; ++i) {
612 for(
int j=0; j<sie->numRows; ++j) {
613 CHK_ERR( readData(instr, dtmp) );
614 sie->stiff1D[offset++] = dtmp;
616 sie->stiffness[i] = &(sie->stiff1D[i*sie->numRows]);
619 for(
int j=0; j<sie->numRows; ++j) {
620 CHK_ERR( readData(instr, dtmp) );
624 CHK_ERR( readData(instr, tmp) );
625 sie->elemFormat = tmp;
627 sumInElems_.push_back(sie);
628 return( appendName(keyword) );
631 if (!std::strcmp(
"sumInElemMatrix", keyword) ) {
632 sumInElem* sie =
new sumInElem;
635 CHK_ERR( readData(instr, tmp) );
636 sie->elemBlockID = (GlobalID)tmp;
637 CHK_ERR( readData(instr, tmp) );
638 sie->elemID = (GlobalID)tmp;
639 CHK_ERR( readData(instr, tmp) );
640 sie->nodeIDs =
new GlobalID[tmp];
643 for(i=0; i<sie->numNodes; ++i) {
644 CHK_ERR( readData(instr, tmp) );
645 sie->nodeIDs[i] = (GlobalID)tmp;
648 CHK_ERR( readData(instr, tmp) );
650 sie->stiff1D =
new double[tmp*tmp];
651 sie->load =
new double[tmp];
652 sie->stiffness =
new double*[tmp];
654 for(i=0; i<sie->numRows; ++i) {
655 for(
int j=0; j<sie->numRows; ++j) {
656 CHK_ERR( readData(instr, dtmp) );
657 sie->stiff1D[offset++] = dtmp;
659 sie->stiffness[i] = &(sie->stiff1D[i*sie->numRows]);
662 CHK_ERR( readData(instr, tmp) );
663 sie->elemFormat = tmp;
665 sumInElemMatrix_.push_back(sie);
666 return( appendName(keyword) );
669 if (!std::strcmp(
"sumInElemRHS", keyword) ) {
670 sumInElem* sie =
new sumInElem;
673 CHK_ERR( readData(instr, tmp) );
674 sie->elemBlockID = (GlobalID)tmp;
675 CHK_ERR( readData(instr, tmp) );
676 sie->elemID = (GlobalID)tmp;
677 CHK_ERR( readData(instr, tmp) );
678 sie->nodeIDs =
new GlobalID[tmp];
680 for(
int i=0; i<sie->numNodes; ++i) {
681 CHK_ERR( readData(instr, tmp) );
682 sie->nodeIDs[i] = (GlobalID)tmp;
685 CHK_ERR( readData(instr, tmp) );
688 sie->load =
new double[sie->numRows];
689 for(
int j=0; j<sie->numRows; ++j) {
690 CHK_ERR( readData(instr, dtmp) );
694 sumInElemRHS_.push_back(sie);
695 return( appendName(keyword) );
698 if (!std::strcmp(
"resetSystem", keyword) ) {
699 CHK_ERR( readData(instr, resetSystem_) );
700 return( appendName(keyword) );
703 if (!std::strcmp(
"resetMatrix", keyword) ) {
704 CHK_ERR( readData(instr, resetMatrix_) );
705 return( appendName(keyword) );
708 if (!std::strcmp(
"resetRHSVector", keyword) ) {
709 CHK_ERR( readData(instr, resetRHSVector_) );
710 return( appendName(keyword) );
713 if (!std::strcmp(
"resetInitialGuess", keyword) ) {
714 CHK_ERR( readData(instr, resetInitialGuess_) );
715 return( appendName(keyword) );
718 if (!std::strcmp(
"putBlockFieldNodeSolution", keyword) ) {
719 putBlockFieldNodeSolution* pbfns =
new putBlockFieldNodeSolution;
720 CHK_ERR( readData(instr, pbfns->elemBlockID) );
721 CHK_ERR( readData(instr, pbfns->fieldID) );
722 CHK_ERR( readData(instr, pbfns->fieldSize) );
723 CHK_ERR( readData(instr, pbfns->numNodes) );
724 if (pbfns->numNodes > 0) {
725 pbfns->nodeIDs =
new GlobalID[pbfns->numNodes];
728 for(i=0; i<pbfns->numNodes; ++i) {
729 CHK_ERR( readData(instr, pbfns->nodeIDs[i]) );
731 int len = pbfns->numNodes * pbfns->fieldSize;
732 pbfns->estimates =
new double[len];
734 for(i=0; i<pbfns->numNodes * pbfns->fieldSize; ++i) {
735 CHK_ERR( readData(instr, pbfns->estimates[i]) );
739 putBlockFieldNodeSolution_.push_back(pbfns);
740 return( appendName(keyword) );
743 if (!std::strcmp(
"loadNodeBCs", keyword) ) {
744 nodeBC* nbc =
new nodeBC;
745 CHK_ERR( readData(instr, nbc->numNodes) );
746 CHK_ERR( readData(instr, nbc->fieldID) );
747 CHK_ERR( readData(instr, nbc->fieldSize) );
749 if (nbc->numNodes > 0) {
750 nbc->nodeIDs =
new GlobalID[nbc->numNodes];
751 nbc->alpha =
new double*[nbc->numNodes];
752 nbc->beta =
new double*[nbc->numNodes];
753 nbc->gamma =
new double*[nbc->numNodes];
756 for(i=0; i<nbc->numNodes; ++i) {
757 nbc->alpha[i] =
new double[nbc->fieldSize];
758 nbc->beta[i] =
new double[nbc->fieldSize];
759 nbc->gamma[i] =
new double[nbc->fieldSize];
761 CHK_ERR( readData(instr, tmp) );
762 nbc->nodeIDs[i] = (GlobalID)tmp;
764 for(j=0; j<nbc->fieldSize; ++j) {
765 CHK_ERR( readData(instr, nbc->alpha[i][j]));
767 for(j=0; j<nbc->fieldSize; ++j) {
768 CHK_ERR( readData(instr, nbc->beta[i][j]));
770 for(j=0; j<nbc->fieldSize; ++j) {
771 CHK_ERR( readData(instr, nbc->gamma[i][j]));
776 loadNodeBCs_.push_back(nbc);
777 return( appendName(keyword) );
780 if (!std::strcmp(
"loadComplete", keyword) ||
781 !std::strcmp(
"solve", keyword) ||
782 !std::strcmp(
"destructor", keyword) ||
783 !std::strcmp(
"getBlockNodeIDList", keyword) ||
784 !std::strcmp(
"getBlockFieldNodeSolution", keyword) ||
785 !std::strcmp(
"residualNorm", keyword)) {
786 return( appendName(keyword) );
792 int driverData::appendName(
const char* name)
794 if (name == NULL)
return(-1);
795 char* str =
new char[strlen(name)+1];
797 methodNames.push_back(str);
801 int driverData::getKeyword(FEI_ISTREAM* instr,
char*& keyword)
803 int err = skipWhite(instr);
804 if (err)
return(err);
806 for(
int i=0; i<tempLen_; i++) temp_[i] =
'\0';
809 instr->getline(temp_, tempLen_);
810 }
while ((strlen(temp_) == 0) && (!instr->eof()));
812 if (instr->eof() || strlen(temp_) == 0)
return(-1);
814 keyword =
new char[strlen(temp_)+1];
815 const char* temp2 = snl_fei::getParamValue(
"FEI:", 1, &temp_);
818 strcpy(keyword, temp2);
826 int driverData::is_reg_char(
char c) {
828 if (i<1 || i>126)
return(0);
834 int driverData::skipWhite(FEI_ISTREAM* instr) {
838 if (!is_reg_char(c)) {
842 while(c ==
'#' || c ==
'\n' || c ==
' ') {
844 char* buf =
new char[128];
845 for(
int i=0; i<128; i++) buf[i] =
'\0';
846 instr->getline(buf, 128);
852 if (instr->eof())
return(1);
853 if ((
int)c == EOF)
return(1);
855 if (!is_reg_char(c)) {
865 int driverData::readData(FEI_ISTREAM* instr,
int& n) {
866 int err = skipWhite(instr);
867 if (err)
return(err);
873 int driverData::readData(FEI_ISTREAM* instr,
double& val) {
874 int err = skipWhite(instr);
875 if (err)
return(err);
virtual int sumInElemMatrix(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, int elemFormat)=0
virtual int parameters(int numParams, const char *const *paramStrings)=0
virtual int initComplete()=0
virtual int solve(int &status)=0
virtual int loadCRMult(int CRMultID, int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, const double *CRWeights, double CRValue)=0
virtual int initCRMult(int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, int &CRID)=0
virtual int deleteMultCRs()=0
virtual int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)=0
virtual int resetInitialGuess(double s)=0
virtual int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)=0
virtual int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)=0
virtual int setSolveType(int solveType)=0
virtual int resetMatrix(double s=0.0)=0
std::ostream & console_out()
virtual int loadComplete(bool applyBCs=true, bool globalAssemble=true)=0
virtual int resetSystem(double s=0.0)=0
virtual int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)=0
virtual int resetRHSVector(double s=0.0)=0
virtual int setIDLists(int numMatrices, const int *matrixIDs, int numRHSs, const int *rhsIDs)=0
virtual int setCurrentMatrix(int matrixID)=0
virtual int sumInElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, const double *elemLoad, int elemFormat)=0
virtual int putBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, const double *estimates)=0
virtual int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)=0