/[escript]/trunk/weipa/src/DataVar.cpp
ViewVC logotype

Diff of /trunk/weipa/src/DataVar.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3397 by caltinay, Wed Nov 17 06:21:37 2010 UTC revision 3398 by caltinay, Mon Dec 6 00:02:33 2010 UTC
# Line 481  float* DataVar::getDataFlat() const Line 481  float* DataVar::getDataFlat() const
481  //  //
482  void DataVar::sampleToStream(ostream& os, int index)  void DataVar::sampleToStream(ostream& os, int index)
483  {  {
484        // index is -1 for dummy samples, i.e. if writing the full mesh but
485        // only a reduced number of samples is required
486      if (rank == 0) {      if (rank == 0) {
487          os << dataArray[0][index];          if (index < 0) {
488                os << 0.;
489            } else {
490                os << dataArray[0][index];
491            }
492      } else if (rank == 1) {      } else if (rank == 1) {
493          if (shape[0] < 3)          if (index < 0) {
494                os << 0. << " " << 0.  << " " << 0.;
495            } else if (shape[0] < 3) {
496              os << dataArray[0][index] << " " << dataArray[1][index]              os << dataArray[0][index] << " " << dataArray[1][index]
497                  << " " << 0.;                  << " " << 0.;
498          else          } else {
499              os << dataArray[0][index] << " " << dataArray[1][index]              os << dataArray[0][index] << " " << dataArray[1][index]
500                  << " " << dataArray[2][index];                  << " " << dataArray[2][index];
501            }
502      } else if (rank == 2) {      } else if (rank == 2) {
503          if (shape[1] < 3) {          if (index < 0) {
504                os << 0. << " " << 0. << " " << 0. << " ";
505                os << 0. << " " << 0. << " " << 0. << " ";
506                os << 0. << " " << 0. << " " << 0.;
507            } else if (shape[1] < 3) {
508              os << dataArray[0][index] << " " << dataArray[1][index]              os << dataArray[0][index] << " " << dataArray[1][index]
509                  << " " << 0. << " ";                  << " " << 0. << " ";
510              os << dataArray[2][index] << " " << dataArray[3][index]              os << dataArray[2][index] << " " << dataArray[3][index]
# Line 519  void DataVar::writeToVTK(ostream& os, in Line 532  void DataVar::writeToVTK(ostream& os, in
532    
533      if (isNodeCentered()) {      if (isNodeCentered()) {
534          // data was reordered in reorderSamples() but for VTK we write the          // data was reordered in reorderSamples() but for VTK we write the
535          // original node mesh and thus need the original ordering...          // original node mesh and thus need the original ordering.
536            // Note, that this also means we may not have samples for all nodes
537            // in which case we set idx to -1 and write a dummy sample
538          const IntVec& requiredIDs = domain->getNodes()->getNodeIDs();          const IntVec& requiredIDs = domain->getNodes()->getNodeIDs();
539          const IntVec& nodeGNI = domain->getNodes()->getGlobalNodeIndices();          const IntVec& nodeGNI = domain->getNodes()->getGlobalNodeIndices();
540          const IntVec& nodeDist = domain->getNodes()->getNodeDistribution();          const IntVec& nodeDist = domain->getNodes()->getNodeDistribution();
# Line 528  void DataVar::writeToVTK(ostream& os, in Line 543  void DataVar::writeToVTK(ostream& os, in
543          IndexMap sampleID2idx = buildIndexMap();          IndexMap sampleID2idx = buildIndexMap();
544          for (int i=0; i<nodeGNI.size(); i++) {          for (int i=0; i<nodeGNI.size(); i++) {
545              if (firstId <= nodeGNI[i] && nodeGNI[i] < lastId) {              if (firstId <= nodeGNI[i] && nodeGNI[i] < lastId) {
546                  int idx = sampleID2idx[requiredIDs[i]];                  IndexMap::const_iterator it = sampleID2idx.find(requiredIDs[i]);
547                    int idx = (it==sampleID2idx.end() ? -1 : (int)it->second);
548                  sampleToStream(os, idx);                  sampleToStream(os, idx);
549              }              }
550          }          }

Legend:
Removed from v.3397  
changed lines
  Added in v.3398

  ViewVC Help
Powered by ViewVC 1.1.26