FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
snl_fei_tester.cpp
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 #include <fei_macros.hpp>
10 
11 #include <test_utils/snl_fei_tester.hpp>
12 
13 #include <fei_LinearSystemCore.hpp>
14 #include <fei_ArrayUtils.hpp>
15 #include <test_utils/LibraryFactory.hpp>
16 
17 #include <fei_base.hpp>
18 
19 #ifdef HAVE_FEI_FETI
20 #include <FETI_DP_FiniteElementData.h>
21 #endif
22 
23 #include <test_utils/DataReader.hpp>
24 #include <test_utils/SolnCheck.hpp>
25 
26 #undef fei_file
27 #define fei_file "snl_fei_tester.cpp"
28 #include <fei_ErrMacros.hpp>
29 
30 //----------------------------------------------------------------------------
31 snl_fei_tester::snl_fei_tester(fei::SharedPtr<DataReader> data_reader,
32  MPI_Comm comm, int localProc, int numProcs)
33  : comm_(comm),
34  factory_(),
35  vecSpace_(),
36  matrixGraph_(),
37  A_(),
38  x_(),
39  b_(),
40  linSys_(NULL),
41  linSysCore_(NULL),
42  feData_(NULL),
43  data_(data_reader),
44  idTypes_(),
45  numPatterns_(0),
46  localProc_(localProc),
47  numProcs_(numProcs)
48 {
49 }
50 
51 //----------------------------------------------------------------------------
52 snl_fei_tester::~snl_fei_tester()
53 {
54  delete linSysCore_;
55  delete feData_;
56 }
57 
58 //----------------------------------------------------------------------------
59 int snl_fei_tester::testInitialization()
60 {
61  if (factory_.get() == NULL) {
62  try {
63  factory_ = fei::create_fei_Factory(comm_, data_->solverLibraryName_.c_str());
64  }
65  catch (std::runtime_error& exc) {
66  fei::console_out() << exc.what()<<FEI_ENDL;
67  return(1);
68  }
69  if (factory_.get() == NULL) {
70  ERReturn(-1);
71  }
72  }
73 
74  std::vector<std::string> stdstrings;
75  fei::utils::char_ptrs_to_strings(data_->numParams_, data_->paramStrings_,
76  stdstrings);
77  fei::ParameterSet paramset;
78  fei::utils::parse_strings(stdstrings, " ", paramset);
79 
80  if (!path_.empty()) {
81  paramset.add(fei::Param("debugOutput", path_.c_str()));
82  }
83 
84  factory_->parameters(paramset);
85 
86  vecSpace_ = factory_->createVectorSpace(comm_, NULL);
87 
88  vecSpace_->setParameters(paramset);
89 
90  defineFieldsAndIDTypes();
91 
93  matrixGraph_ = factory_->createMatrixGraph(vecSpace_, dummy, NULL);
94 
95  matrixGraph_->setParameters(paramset);
96 
97  CHK_ERR( initElemBlocks() );
98 
99  CHK_ERR( initConstraints() );
100 
101  int i;
102  for(i=0; i<data_->numSharedNodeSets_; ++i) {
103  CommNodeSet& nodeSet = data_->sharedNodeSets_[i];
104 
105  CHK_ERR( vecSpace_->initSharedIDs(nodeSet.numNodes_,
106  idTypes_[nodeTypeOffset_],
107  nodeSet.nodeIDs_,
108  nodeSet.procsPerNode_,
109  nodeSet.procs_) );
110  }
111 
112  CHK_ERR( matrixGraph_->initComplete() );
113 
114  return(0);
115 }
116 
117 //----------------------------------------------------------------------------
118 void snl_fei_tester::dumpMatrixFiles()
119 {
120  FEI_OSTRINGSTREAM osstr;
121  osstr << "A_" << A_->typeName() << ".np"<<numProcs_;
122  std::string str = osstr.str();
123  A_->writeToFile(str.c_str());
124 }
125 
126 //----------------------------------------------------------------------------
127 void snl_fei_tester::setParameter(const char* param)
128 {
129  std::vector<std::string> stdstrings;
130  fei::utils::char_ptrs_to_strings(1, &param, stdstrings);
131  fei::ParameterSet paramset;
132  fei::utils::parse_strings(stdstrings, " ", paramset);
133  factory_->parameters(paramset);
134  vecSpace_->setParameters(paramset);
135  matrixGraph_->setParameters(paramset);
136 
137  linSys_->parameters(1, &param);
138  A_->parameters(paramset);
139 }
140 
141 //----------------------------------------------------------------------------
142 int snl_fei_tester::testLoading()
143 {
144  linSys_ = factory_->createLinearSystem(matrixGraph_);
145 
146  A_ = factory_->createMatrix(matrixGraph_);
147  x_ = factory_->createVector(matrixGraph_, true);
148  b_ = factory_->createVector(matrixGraph_);
149 
150  matrixGraph_->setIndicesMode(fei::MatrixGraph::POINT_ENTRY_GRAPH);
151 
152  CHK_ERR( linSys_->parameters(data_->numParams_, data_->paramStrings_) );
153 
154  std::vector<std::string> stdstrings;
155  fei::utils::char_ptrs_to_strings(data_->numParams_, data_->paramStrings_, stdstrings);
156  fei::ParameterSet paramset;
157  fei::utils::parse_strings(stdstrings, " ", paramset);
158  CHK_ERR( A_->parameters(paramset) );
159 
160  linSys_->setMatrix(A_);
161  linSys_->setRHS(b_);
162  linSys_->setSolutionVector(x_);
163 
164  CHK_ERR( A_->putScalar(0.0) );
165  CHK_ERR( b_->putScalar(0.0) );
166 
167  matrixGraph_->createSlaveMatrices();
168 
169  CHK_ERR( loadElemBlocks() );
170 
171  CHK_ERR( loadConstraints() );
172 
173  int i;
174  for(i=0; i<data_->numBCNodeSets_; ++i) {
175  BCNodeSet& bcSet = data_->bcNodeSets_[i];
176  int fieldSize = data_->getFieldSize(bcSet.fieldID_);
177  if (fieldSize < 1) {
178  continue;
179  }
180 
181  CHK_ERR( linSys_->loadEssentialBCs(bcSet.numNodes_,
182  bcSet.nodeIDs_,
183  idTypes_[nodeTypeOffset_],
184  bcSet.fieldID_,
185  bcSet.offsetsIntoField_,
186  bcSet.prescribed_values_) );
187  }
188 
189  CHK_ERR( linSys_->loadComplete() );
190 
191  return(0);
192 }
193 
194 //----------------------------------------------------------------------------
195 int snl_fei_tester::testSolve()
196 {
197  fei::SharedPtr<fei::Solver> solver = factory_->createSolver();
198 
199  std::vector<std::string> stdstrings;
200  fei::utils::char_ptrs_to_strings(data_->numParams_, data_->paramStrings_, stdstrings);
201  fei::ParameterSet paramset;
202  fei::utils::parse_strings(stdstrings," ",paramset);
203 
204  int status, itersTaken = 0;
205  CHK_ERR( solver->solve(linSys_.get(),
206  NULL, //preconditioningMatrix
207  paramset, itersTaken, status) );
208 
209  CHK_ERR( x_->scatterToOverlap() );
210 
211  return(0);
212 }
213 
214 //----------------------------------------------------------------------------
215 int snl_fei_tester::testCheckResult()
216 {
217  CHK_ERR( save_block_node_soln(*data_, x_.get(), data_->solnFileName_.c_str(),
218  numProcs_, localProc_, 1));
219 
220  CHK_ERR( save_block_elem_soln(*data_, x_.get(), data_->solnFileName_.c_str(),
221  numProcs_, localProc_, 1));
222 
223  CHK_ERR( save_multiplier_soln(*data_, x_.get(), data_->solnFileName_.c_str(),
224  numProcs_, localProc_, 1));
225 
226  int err = SolnCheck::checkSolution(localProc_, numProcs_, data_->solnFileName_.c_str(),
227  data_->checkFileName_.c_str(), "node", 1);
228 
229  err += SolnCheck::checkSolution(localProc_, numProcs_, data_->solnFileName_.c_str(),
230  data_->checkFileName_.c_str(), "elem", 1);
231 
232  err += SolnCheck::checkSolution(localProc_, numProcs_, data_->solnFileName_.c_str(),
233  data_->checkFileName_.c_str(), "mult", 1);
234  int globalErr = err;
235 #ifndef FEI_SER
236  if (MPI_SUCCESS != MPI_Allreduce(&err, &globalErr, 1, MPI_INT, MPI_SUM,
237  comm_)) return(-1);
238 #endif
239  if (globalErr != 0) return(-1);
240  return(0);
241 }
242 
243 //----------------------------------------------------------------------------
244 void snl_fei_tester::defineFieldsAndIDTypes()
245 {
246  vecSpace_->defineFields(data_->numFields_, data_->fieldIDs_, data_->fieldSizes_);
247 
248  //nodeIDType == 0
249  idTypes_.push_back(0);
250 
251  //constraintIDType == 1
252  idTypes_.push_back(1);
253 
254  //elemDofIDType == 2
255  idTypes_.push_back(2);
256 
257  vecSpace_->defineIDTypes(idTypes_.size(), &idTypes_[0] );
258 
259  nodeTypeOffset_ = 0;
260  constraintTypeOffset_ = 1;
261  elemTypeOffset_ = 2;
262 }
263 
264 //----------------------------------------------------------------------------
265 int snl_fei_tester::initElemBlocks()
266 {
267  for(int i=0; i<data_->numElemBlocks_; ++i) {
268  ElemBlock& eb = data_->elemBlocks_[i];
269 
270  int patternID;
271  definePattern(eb, patternID);
272 
273  CHK_ERR( matrixGraph_->initConnectivityBlock(eb.blockID_,
274  eb.numElements_,
275  patternID) );
276 
277  for(int j=0; j<eb.numElements_; ++j) {
278  std::vector<int> conn(eb.numNodesPerElement_);
279  for(int ii=0; ii<eb.numNodesPerElement_; ++ii) {
280  conn[ii] = eb.elemConn_[j][ii];
281  }
282 
283  CHK_ERR( matrixGraph_->initConnectivity(eb.blockID_,
284  eb.elemIDs_[j],
285  &conn[0]) );
286  }
287  }
288 
289  return(0);
290 }
291 
292 //----------------------------------------------------------------------------
293 int snl_fei_tester::loadElemBlocks()
294 {
295  int i;
296  for(i=0; i<data_->numElemBlocks_; ++i) {
297  ElemBlock& eb = data_->elemBlocks_[i];
298 
299  if (eb.numElements_ < 1) {
300  continue;
301  }
302 
303  int numIndices = matrixGraph_->getConnectivityNumIndices(eb.blockID_);
304 
305  std::vector<int> indices(numIndices);
306 
307  for(int j=0; j<eb.numElements_; ++j) {
308  int checkNum;
309  CHK_ERR( matrixGraph_->getConnectivityIndices(eb.blockID_,
310  eb.elemIDs_[j],
311  numIndices,
312  &indices[0],
313  checkNum) );
314  if (numIndices != checkNum) {
315  ERReturn(-1);
316  }
317 
318  CHK_ERR( A_->sumIn(eb.blockID_, eb.elemIDs_[j],
319  eb.elemStiff_[j]) );
320 
321  CHK_ERR( b_->sumIn(numIndices, &indices[0],
322  eb.elemLoad_[j], 0) );
323  }
324  }
325 
326  return(0);
327 }
328 
329 //----------------------------------------------------------------------------
330 int snl_fei_tester::initConstraints()
331 {
332  std::vector<int> idTypes;
333  int constraintID = localProc_*100000;
334  int i;
335  for(i=0; i<data_->numCRMultSets_; ++i) {
336  CRSet& crSet = data_->crMultSets_[i];
337 
338  for(int j=0; j<1; ++j) {
339  idTypes.assign(crSet.numNodes_, idTypes_[nodeTypeOffset_]);
340 
341  crSet.crID_ = constraintID++;
342  int constraintIDType = idTypes_[constraintTypeOffset_];
343  CHK_ERR( matrixGraph_->initLagrangeConstraint(crSet.crID_,
344  constraintIDType,
345  crSet.numNodes_,
346  &idTypes[0],
347  crSet.nodeIDs_[j],
348  crSet.fieldIDs_) );
349  }
350  }
351 
352  for(i=0; i<data_->numCRPenSets_; ++i) {
353  CRSet& crSet = data_->crPenSets_[i];
354 
355  for(int j=0; j<1; ++j) {
356  idTypes.assign(crSet.numNodes_, idTypes_[nodeTypeOffset_]);
357 
358  crSet.crID_ = constraintID++;
359  int constraintIDType = idTypes_[constraintTypeOffset_];
360  CHK_ERR( matrixGraph_->initPenaltyConstraint(crSet.crID_,
361  constraintIDType,
362  crSet.numNodes_,
363  &idTypes[0],
364  crSet.nodeIDs_[j],
365  crSet.fieldIDs_) );
366  }
367  }
368 
369  std::map<int,int> fieldDB;
370  for(i=0; i<data_->numFields_; ++i) {
371  fieldDB.insert(std::pair<int,int>(data_->fieldIDs_[i], data_->fieldSizes_[i]));
372  }
373 
374  std::vector<int> nodeIDs;
375  std::vector<int> fieldIDs;
376  std::vector<double> weights;
377 
378  for(i=0; i<data_->numSlaveVars_; i++) {
379  int ii;
380  CRSet& crSet = data_->slaveVars_[i];
381 
382  nodeIDs.resize(crSet.numNodes_+1);
383  nodeIDs[0] = crSet.slaveNodeID_;
384  fieldIDs.resize(0);
385  fieldIDs.push_back(crSet.slaveFieldID_);
386 
387  for(ii=0; ii<crSet.numNodes_; ++ii) {
388  nodeIDs[ii+1] = crSet.nodeIDs_[0][ii];
389  fieldIDs.push_back(crSet.fieldIDs_[ii]);
390  }
391 
392  idTypes.assign(crSet.numNodes_+1, idTypes_[nodeTypeOffset_]);
393 
394  int fieldSize = fieldDB[crSet.slaveFieldID_];
395  weights.resize(0);
396  for(ii=0; ii<fieldSize; ++ii) weights.push_back(0.0);
397  weights[crSet.slaveOffset_] = -1.0;
398  int offset = 0;
399  for(ii=0; ii<crSet.numNodes_; ++ii) {
400  fieldSize = fieldDB[crSet.fieldIDs_[ii]];
401  for(int jj=0; jj<fieldSize; ++jj) {
402  weights.push_back(crSet.weights_[offset++]);
403  }
404  }
405 
406  CHK_ERR( matrixGraph_->initSlaveConstraint(crSet.numNodes_+1,
407  &idTypes[0],
408  &nodeIDs[0],
409  &fieldIDs[0],
410  0,
411  crSet.slaveOffset_,
412  &weights[0],
413  crSet.values_[0]));
414  }
415 
416  return(0);
417 }
418 
419 //----------------------------------------------------------------------------
420 int snl_fei_tester::loadConstraints()
421 {
422  int i;
423  for(i=0; i<data_->numCRMultSets_; ++i) {
424  CRSet& crSet = data_->crMultSets_[i];
425 
426  for(int j=0; j<1; ++j) {
427  CHK_ERR( linSys_->loadLagrangeConstraint(crSet.crID_,
428  crSet.weights_,
429  crSet.values_[j]) );
430  }
431  }
432 
433  for(i=0; i<data_->numCRPenSets_; ++i) {
434  CRSet& crSet = data_->crPenSets_[i];
435 
436  for(int j=0; j<1; ++j) {
437  CHK_ERR( linSys_->loadPenaltyConstraint(crSet.crID_,
438  crSet.weights_,
439  crSet.penValues_[j],
440  crSet.values_[j]) );
441  }
442  }
443 
444  return(0);
445 }
446 
447 //----------------------------------------------------------------------------
448 void snl_fei_tester::definePattern(ElemBlock& eb, int& patternID)
449 {
450  int i, j, numIDTypes = 1;
451  numIDTypes += eb.numElemDOF_>0 ? 1 : 0;
452 
453  //find out how many nodal fields there are, total.
454  std::vector<int> nodalFieldIDs;
455  std::vector<int> flatFieldIDsArray;
456  for(i=0; i<eb.numNodesPerElement_; ++i) {
457  for(j=0; j<eb.numFieldsPerNode_[i]; ++j) {
458  fei::sortedListInsert(eb.nodalFieldIDs_[i][j], nodalFieldIDs);
459  flatFieldIDsArray.push_back(eb.nodalFieldIDs_[i][j]);
460  }
461  }
462 
463  patternID = numPatterns_++;
464 
465  if (numIDTypes == 1 && nodalFieldIDs.size() == 1) {
466  //This is a very simple pattern
467  patternID = matrixGraph_->definePattern(eb.numNodesPerElement_,
468  idTypes_[nodeTypeOffset_],
469  nodalFieldIDs[0]);
470  }
471  else if (numIDTypes == 1) {
472  std::vector<int> numFieldsPerID(eb.numNodesPerElement_);
473 
474  patternID = matrixGraph_->definePattern(eb.numNodesPerElement_,
475  idTypes_[nodeTypeOffset_],
476  eb.numFieldsPerNode_,
477  &flatFieldIDsArray[0]);
478  }
479  else {
480  std::vector<int> idTypes(eb.numNodesPerElement_+1, idTypes_[nodeTypeOffset_]);
481  idTypes[idTypes.size()-1] = idTypes_[elemTypeOffset_];
482  std::vector<int> numFieldsPerID(idTypes.size());
483  std::vector<int> fieldIDs;
484  for(i=0; i<eb.numNodesPerElement_; ++i) {
485  numFieldsPerID[i] = eb.numFieldsPerNode_[i];
486  for(j=0; j<eb.numFieldsPerNode_[i]; ++j) {
487  fieldIDs.push_back(eb.nodalFieldIDs_[i][j]);
488  }
489  }
490  numFieldsPerID[idTypes.size()-1] = eb.numElemDOF_;
491  for(i=0; i<eb.numElemDOF_; ++i) {
492  fieldIDs.push_back(eb.elemDOFFieldIDs_[i]);
493  }
494 
495  patternID = matrixGraph_->definePattern(idTypes.size(),
496  &idTypes[0],
497  &numFieldsPerID[0],
498  &fieldIDs[0]);
499  }
500 }
501 
502 //----------------------------------------------------------------------------
503 int snl_fei_tester::save_block_node_soln(DataReader& data, fei::Vector* vec,
504  const char* solnFileName, int numProcs,
505  int localProc, int solveCounter)
506 {
507  (void)solveCounter;
508 
509  int numLocalNodes = vecSpace_->getNumOwnedAndSharedIDs(idTypes_[nodeTypeOffset_]);
510 
511  int* nodeList = new int[numLocalNodes];
512 
513  int checkNum = 0;
514  int err = vecSpace_->getOwnedAndSharedIDs(idTypes_[nodeTypeOffset_],
515  numLocalNodes, nodeList, checkNum);
516  if (err != 0) {
517  ERReturn(-1);
518  }
519 
520  FEI_OSTRINGSTREAM fileName;
521  fileName<< solnFileName<<".node."<<solveCounter<<"."<<numProcs<<"."<<localProc;
522  std::string str = fileName.str();
523  FEI_OFSTREAM outfile(str.c_str());
524 
525  if (!outfile || outfile.bad()) {
526  fei::console_out() << "ERROR opening solution output file " << fileName.str() << FEI_ENDL;
527  return(-1);
528  }
529 
530  outfile.setf(IOS_SCIENTIFIC, IOS_FLOATFIELD);
531 
532  std::vector<double> solnData;
533  std::vector<int> fieldList;
534 
535  int totalSize = 0;
536 
537  for(int i=0; i<numLocalNodes; i++) {
538  int idType = idTypes_[nodeTypeOffset_];
539  int ID = nodeList[i];
540 
541  int numDOF = vecSpace_->getNumDegreesOfFreedom(idType, ID);
542  int numFields = vecSpace_->getNumFields(idType, ID);
543  solnData.resize(numDOF);
544  vecSpace_->getFields(idType, ID, fieldList);
545 
546  outfile << ID << " " << numDOF << FEI_ENDL;
547  for(int j=0; j<numFields; ++j) {
548  int fieldSize = vecSpace_->getFieldSize(fieldList[j]);
549  totalSize += fieldSize;
550 
551  CHK_ERR( vec->copyOutFieldData(fieldList[j], idType,
552  1, &ID, &solnData[0]) );
553 
554  for(int k=0; k<fieldSize; ++k) {
555  outfile << solnData[k] << " ";
556  }
557  }
558  outfile << FEI_ENDL;
559  }
560 
561  FEI_COUT << "save-node-soln: wrote " << totalSize << " entries for " << numLocalNodes << " nodes to " << str << FEI_ENDL;
562 
563  delete [] nodeList;
564 
565  outfile.close();
566  return(0);
567 }
568 
569 //----------------------------------------------------------------------------
570 int snl_fei_tester::save_block_elem_soln(DataReader& data, fei::Vector* vec,
571  const char* solnFileName,
572  int numProcs,
573  int localProc, int solveCounter)
574 {
575  (void)solveCounter;
576 
577  int numLocalElems = vecSpace_->getNumOwnedAndSharedIDs(idTypes_[elemTypeOffset_]);
578 
579  int* elemList = new int[numLocalElems];
580 
581  int checkNum = 0;
582  int err = vecSpace_->getOwnedAndSharedIDs(idTypes_[elemTypeOffset_],
583  numLocalElems, elemList, checkNum);
584  if (err != 0) {
585  ERReturn(-1);
586  }
587 
588  FEI_OSTRINGSTREAM fileName;
589  fileName<< solnFileName<<".elem."<<solveCounter<<"."<<numProcs<<"."<<localProc;
590  std::string str = fileName.str();
591  FEI_OFSTREAM outfile(str.c_str());
592 
593  if (!outfile || outfile.bad()) {
594  fei::console_out() << "ERROR opening solution output file " << fileName.str() << FEI_ENDL;
595  return(-1);
596  }
597 
598  std::vector<double> solnData;
599  std::vector<int> fieldList;
600 
601  for(int i=0; i<numLocalElems; i++) {
602  int idType = idTypes_[elemTypeOffset_];
603  int ID = elemList[i];
604 
605  int numDOF = vecSpace_->getNumDegreesOfFreedom(idType, ID);
606  int numFields = vecSpace_->getNumFields(idType, ID);
607  solnData.resize(numDOF);
608  vecSpace_->getFields(idType, ID, fieldList);
609 
610  outfile << ID << " " << numDOF << FEI_ENDL;
611  for(int j=0; j<numFields; ++j) {
612  int fieldSize = vecSpace_->getFieldSize(fieldList[j]);
613 
614  CHK_ERR( vec->copyOutFieldData(fieldList[j], idType,
615  1, &ID, &solnData[0]) );
616 
617  for(int k=0; k<fieldSize; ++k) {
618  outfile << solnData[k] << " ";
619  }
620  }
621  outfile << FEI_ENDL;
622  }
623 
624  delete [] elemList;
625 
626  outfile.close();
627  return(0);
628 }
629 
630 //----------------------------------------------------------------------------
631 int snl_fei_tester::save_multiplier_soln(DataReader& data, fei::Vector* vec,
632  const char* solnFileName,
633  int numProcs, int localProc,
634  int solveCounter)
635 {
636  (void)solveCounter;
637 
638  int numLocalCRs = vecSpace_->getNumOwnedAndSharedIDs(idTypes_[constraintTypeOffset_]);
639 
640  int* globalNumCRs = new int[numProcs];
641 #ifndef FEI_SER
642  if (MPI_Allgather(&numLocalCRs, 1, MPI_INT, globalNumCRs, 1, MPI_INT,
643  comm_) != MPI_SUCCESS) {
644  ERReturn(-1);
645  }
646 #endif
647 
648  int localCRStart = 0;
649 #ifndef FEI_SER
650  for(int p=0; p<localProc; p++) localCRStart += globalNumCRs[p];
651 #endif
652 
653  delete [] globalNumCRs;
654 
655  std::vector<int> crList(numLocalCRs);
656 
657  int checkNum = 0;
658  int err = vecSpace_->getOwnedAndSharedIDs(
659  idTypes_[constraintTypeOffset_], numLocalCRs,
660  numLocalCRs ? &crList[0] : 0, checkNum);
661  if (err != 0) {
662  ERReturn(-1);
663  }
664 
665  FEI_OSTRINGSTREAM fileName;
666  fileName<< solnFileName<<".mult."<<solveCounter<<"."<<numProcs<<"."<<localProc;
667  std::string str = fileName.str();
668  FEI_OFSTREAM outfile(str.c_str());
669 
670  if (!outfile || outfile.bad()) {
671  fei::console_out() << "ERROR opening solution output file " << fileName.str() << FEI_ENDL;
672  return(-1);
673  }
674 
675  std::vector<double> solnData;
676  std::vector<int> fieldList;
677 
678  for(int i=0; i<numLocalCRs; i++) {
679  int idType = idTypes_[constraintTypeOffset_];
680  int ID = crList[i];
681 
682  solnData.resize(1);
683 
684  outfile << localCRStart++ << " " << 1 << FEI_ENDL;
685  for(int j=0; j<1; ++j) {
686  int globalIndex = -1;
687  CHK_ERR( vecSpace_->getGlobalIndex(idType, ID, globalIndex) );
688 
689  CHK_ERR( vec->copyOut(1, &globalIndex, &solnData[0]) );
690 
691  for(int k=0; k<1; ++k) {
692  outfile << solnData[k] << " ";
693  }
694  }
695  outfile << FEI_ENDL;
696  }
697 
698  outfile.close();
699  return(0);
700 }
int sortedListInsert(const T &item, std::vector< T > &list)
void char_ptrs_to_strings(int numStrings, const char *const *charstrings, std::vector< std::string > &stdstrings)
Definition: fei_utils.cpp:164
Definition: CRSet.hpp:25
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
virtual int copyOutFieldData(int fieldID, int idType, int numIDs, const int *IDs, double *data, int vectorIndex=0)=0
GlobalID slaveNodeID_
Definition: CRSet.hpp:45
int slaveOffset_
Definition: CRSet.hpp:53
void setParameters(const fei::ParameterSet &paramset)
int crID_
Definition: CRSet.hpp:37
void add(const Param &param, bool maintain_unique_keys=true)
int numNodes_
Definition: CRSet.hpp:40
std::ostream & console_out()
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet &paramset)
Definition: fei_utils.cpp:191
virtual int solve(fei::LinearSystem *linearSystem, fei::Matrix *preconditioningMatrix, const fei::ParameterSet &parameterSet, int &iterationsTaken, int &status)
Definition: fei_Solver.cpp:65
int slaveFieldID_
Definition: CRSet.hpp:48
virtual int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const =0