Skip to content
Snippets Groups Projects
Select Git revision
  • c478235bdd5506228187843e6aee6f9ed8192f1e
  • 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

Box.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    GModelIO_IR3.cpp 2.32 KiB
    // Gmsh - Copyright (C) 1997-2016 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to the public mailing list <gmsh@onelab.info>.
    
    #include "GModel.h"
    #include "OS.h"
    #include "MElement.h"
    
    int GModel::writeIR3(const std::string &name, int elementTagType,
                         bool saveAll, double scalingFactor)
    {
      FILE *fp = Fopen(name.c_str(), "w");
      if(!fp){
        Msg::Error("Unable to open file '%s'", name.c_str());
        return 0;
      }
    
      if(noPhysicalGroups()) saveAll = true;
    
      int numVertices = indexMeshVertices(saveAll), num2D = 0, num3D = 0;
      for(fiter it = firstFace(); it != lastFace(); ++it)
        if(saveAll || (*it)->physicals.size())
          num2D += (*it)->getNumMeshElements();
      for(riter it = firstRegion(); it != lastRegion(); ++it)
        if(saveAll || (*it)->physicals.size())
          num3D += (*it)->getNumMeshElements();
    
      fprintf(fp,"33\n");
      if(num2D && num3D)
        fprintf(fp,"%d %d %d\n", numVertices, num2D, num3D);
      else
        fprintf(fp,"%d %d\n", numVertices, num2D ? num2D : num3D);
    
      std::vector<GEntity*> entities;
      getEntities(entities);
    
      for(unsigned int i = 0; i < entities.size(); i++)
        for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++)
          if(entities[i]->mesh_vertices[j]->getIndex() >= 0)
            fprintf(fp,"%d %.16g %.16g %.16g\n", entities[i]->mesh_vertices[j]->getIndex(),
                    entities[i]->mesh_vertices[j]->x() * scalingFactor,
                    entities[i]->mesh_vertices[j]->y() * scalingFactor,
                    entities[i]->mesh_vertices[j]->z() * scalingFactor);
    
      int iElement = 1;
      for(fiter it = firstFace(); it != lastFace(); ++it){
        int numPhys = (*it)->physicals.size();
        if(saveAll || numPhys)
          for(unsigned int i = 0; i < (*it)->getNumMeshElements(); i++)
            (*it)->getMeshElement(i)->writeIR3
              (fp, elementTagType, iElement++, (*it)->tag(),
               numPhys ? (*it)->physicals[0] : 0);
      }
    
      iElement = 1;
      for(riter it = firstRegion(); it != lastRegion(); ++it){
        int numPhys = (*it)->physicals.size();
        if(saveAll || numPhys)
          for(unsigned int i = 0; i < (*it)->getNumMeshElements(); i++)
            (*it)->getMeshElement(i)->writeIR3
              (fp, elementTagType, iElement++, (*it)->tag(),
               numPhys ? (*it)->physicals[0] : 0);
      }
    
      fclose(fp);
      return 1;
    }