Skip to content
Snippets Groups Projects
Select Git revision
  • a7b6b646670fb928dacecc51505beb0a22e63855
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

Callbacks.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    PViewDataGModelIO.cpp 17.86 KiB
    // Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to <gmsh@geuz.org>.
    
    #include "GmshConfig.h"
    #include "GmshMessage.h"
    #include "PViewDataGModel.h"
    #include "MVertex.h"
    #include "MElement.h"
    #include "Numeric.h"
    #include "StringUtils.h"
    
    bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> > &data,
                                  int step, double time, int partition)
    {
      if(data.empty()) return false;
    
      int numComp = 9;
      for(std::map<int, std::vector<double> >::iterator it = data.begin(); 
          it != data.end(); it++)
        numComp = std::min(numComp, (int)it->second.size());
    
      while(step >= (int)_steps.size())
        _steps.push_back(new stepData<double>(model, numComp));
      
      _steps[step]->setTime(time);
      
      int numEnt = (_type == NodeData) ? model->getNumMeshVertices() : 
        model->getNumMeshElements();
      _steps[step]->resizeData(numEnt);
      
      for(std::map<int, std::vector<double> >::iterator it = data.begin(); 
          it != data.end(); it++){
        double *d  = _steps[step]->getData(it->first, true);
        for(int j = 0; j < numComp; j++)
          d[j] = it->second[j];
      }
      _partitions.insert(partition);
      finalize();
      return true;
    }
    
    bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
                                  bool binary, bool swap, int step, double time, 
                                  int partition, int numComp, int numEnt)
    {
      Msg::Info("Reading step %d (time %g) partition %d: %d records", 
          step, time, partition, numEnt);
    
      while(step >= (int)_steps.size())
        _steps.push_back(new stepData<double>(GModel::current(), numComp));
      
      _steps[step]->setFileName(fileName);
      _steps[step]->setFileIndex(fileIndex);
      _steps[step]->setTime(time);
    
      // if we already have maxSteps for this view, return
      int numSteps = 0, maxSteps = 1000000000;
      for(unsigned int i = 0; i < _steps.size(); i++)
        numSteps += _steps[i]->getNumData() ? 1 : 0;
      if(numSteps > maxSteps) return true;
    
      _steps[step]->resizeData(numEnt);
    
      Msg::ResetProgressMeter();
      for(int i = 0; i < numEnt; i++){
        int num;
        if(binary){
          if(fread(&num, sizeof(int), 1, fp) != 1) return false;