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

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

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

revision 2885 by jfenwick, Thu Jan 28 02:03:15 2010 UTC revision 2886 by caltinay, Thu Jan 28 05:39:23 2010 UTC
# Line 463  bool DataVar::reorderSamples() Line 463  bool DataVar::reorderSamples()
463      return true;      return true;
464  }  }
465    
466    //
467    //
468    //
469    void DataVar::sampleToStream(ostream& os, int index)
470    {
471        if (rank == 0) {
472            os << dataArray[0][index];
473        } else if (rank == 1) {
474            if (shape[0] < 3)
475                os << dataArray[0][index] << " " << dataArray[1][index]
476                    << " " << 0.;
477            else
478                os << dataArray[0][index] << " " << dataArray[1][index]
479                    << " " << dataArray[2][index];
480        } else if (rank == 2) {
481            if (shape[1] < 3) {
482                os << dataArray[0][index] << " " << dataArray[1][index]
483                    << " " << 0. << " ";
484                os << dataArray[2][index] << " " << dataArray[3][index]
485                    << " " << 0. << " ";
486                os << 0. << " " << 0. << " " << 0.;
487            } else {
488                os << dataArray[0][index] << " " << dataArray[1][index]
489                    << " " << dataArray[2][index] << " ";
490                os << dataArray[3][index] << " " << dataArray[4][index]
491                    << " " << dataArray[5][index] << " ";
492                os << dataArray[6][index] << " " << dataArray[7][index]
493                    << " " << dataArray[8][index];
494            }
495        }
496        os << endl;
497    }
498    
499    //
500    //
501    //
502    void DataVar::writeToVTK(ostream& os, int ownIndex)
503    {
504        if (numSamples == 0)
505            return;
506    
507        if (isNodeCentered()) {
508            // data was reordered in reorderSamples() but for VTK we write the
509            // original node mesh and thus need the original ordering...
510            const IntVec& requiredIDs = finleyMesh->getNodes()->getNodeIDs();
511            const IntVec& nodeGNI = finleyMesh->getNodes()->getGlobalNodeIndices();
512            const IntVec& nodeDist = finleyMesh->getNodes()->getNodeDistribution();
513            int firstId = nodeDist[ownIndex];
514            int lastId = nodeDist[ownIndex+1];
515            IndexMap sampleID2idx = buildIndexMap();
516            for (int i=0; i<nodeGNI.size(); i++) {
517                if (firstId <= nodeGNI[i] && nodeGNI[i] < lastId) {
518                    int idx = sampleID2idx[requiredIDs[i]];
519                    sampleToStream(os, idx);
520                }
521            }
522        } else {
523            // cell data: ghost cells have been removed so do not write ghost
524            // samples (which are the last elements in the arrays)
525            int toWrite =
526                finleyMesh->getElementsByName(meshName)->getNumElements();
527            for (int i=0; i<toWrite; i++) {
528                sampleToStream(os, i);
529            }
530        }
531    }
532    
533  ///////////////////////////////  ///////////////////////////////
534  // SILO related methods follow  // SILO related methods follow
535  ///////////////////////////////  ///////////////////////////////

Legend:
Removed from v.2885  
changed lines
  Added in v.2886

  ViewVC Help
Powered by ViewVC 1.1.26