Exemple #1
0
void COutput::SetSU2_MeshASCII(CConfig *config, CGeometry *geometry) {
  
  char cstr[MAX_STRING_SIZE], out_file[MAX_STRING_SIZE];
  unsigned long iElem, iPoint, iElem_Bound, nElem_Bound_, vnodes_edge[2], vnodes_triangle[3], vnodes_quad[4], iNode, nElem;
  unsigned short iMarker, iDim, nDim = geometry->GetnDim(), iChar, iPeriodic, nPeriodic = 0, VTK_Type, nMarker_;
  su2double *center, *angles, *transl;
  ofstream output_file;
  ifstream input_file;
  string Grid_Marker, text_line, Marker_Tag, str;
  string::size_type position;

  /*--- Read the name of the output and input file ---*/
  
  str = config->GetMesh_Out_FileName();
  strcpy (out_file, str.c_str());
  strcpy (cstr, out_file);
  output_file.precision(15);
  output_file.open(cstr, ios::out);
  
  /*--- Write dimensions data. ---*/

  output_file << "NDIME= " << nDim << endl;
  
  /*--- Write connectivity data. ---*/
  
  nElem = nGlobal_Tria+nGlobal_Quad+nGlobal_Tetr+nGlobal_Hexa+nGlobal_Pris+nGlobal_Pyra;
  
  output_file << "NELEM= " << nElem<< endl;
  
  nElem = 0;
  
  for (iElem = 0; iElem < nGlobal_Tria; iElem++) {
    iNode = iElem*N_POINTS_TRIANGLE;
    output_file << "5\t";
    output_file << Conn_Tria[iNode+0]-1 << "\t"; output_file << Conn_Tria[iNode+1]-1 << "\t";
    output_file << Conn_Tria[iNode+2]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Quad; iElem++) {
    iNode = iElem*N_POINTS_QUADRILATERAL;
    output_file << "9\t";
    output_file << Conn_Quad[iNode+0]-1 << "\t"; output_file << Conn_Quad[iNode+1]-1 << "\t";
    output_file << Conn_Quad[iNode+2]-1 << "\t"; output_file << Conn_Quad[iNode+3]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Tetr; iElem++) {
    iNode = iElem*N_POINTS_TETRAHEDRON;
    output_file << "10\t";
    output_file << Conn_Tetr[iNode+0]-1 << "\t" << Conn_Tetr[iNode+1]-1 << "\t";
    output_file << Conn_Tetr[iNode+2]-1 << "\t" << Conn_Tetr[iNode+3]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Hexa; iElem++) {
    iNode = iElem*N_POINTS_HEXAHEDRON;
    output_file << "12\t";
    output_file << Conn_Hexa[iNode+0]-1 << "\t" << Conn_Hexa[iNode+1]-1 << "\t";
    output_file << Conn_Hexa[iNode+2]-1 << "\t" << Conn_Hexa[iNode+3]-1 << "\t";
    output_file << Conn_Hexa[iNode+4]-1 << "\t" << Conn_Hexa[iNode+5]-1 << "\t";
    output_file << Conn_Hexa[iNode+6]-1 << "\t" << Conn_Hexa[iNode+7]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Pris; iElem++) {
    iNode = iElem*N_POINTS_PRISM;
    output_file << "13\t";
    output_file << Conn_Pris[iNode+0]-1 << "\t" << Conn_Pris[iNode+1]-1 << "\t";
    output_file << Conn_Pris[iNode+2]-1 << "\t" << Conn_Pris[iNode+3]-1 << "\t";
    output_file << Conn_Pris[iNode+4]-1 << "\t" << Conn_Pris[iNode+5]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Pyra; iElem++) {
    iNode = iElem*N_POINTS_PYRAMID;
    output_file << "14\t";
    output_file << Conn_Pyra[iNode+0]-1 << "\t" << Conn_Pyra[iNode+1]-1 << "\t";
    output_file << Conn_Pyra[iNode+2]-1 << "\t" << Conn_Pyra[iNode+3]-1 << "\t";
    output_file << Conn_Pyra[iNode+4]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  /*--- Write the node coordinates ---*/
  
  output_file << "NPOIN= " << nGlobal_Poin<< endl;

  for (iPoint = 0; iPoint < nGlobal_Poin; iPoint++) {
     for (iDim = 0; iDim < nDim; iDim++)
      output_file << scientific << Coords[iDim][iPoint] << "\t";
    output_file << iPoint << endl;
  }
  
  /*--- Read the boundary information ---*/
  
  input_file.open("boundary.su2", ios::out);
  
  /*--- Read grid file with format SU2 ---*/
  
  while (getline (input_file, text_line)) {

    /*--- Write the physical boundaries ---*/
    
    position = text_line.find ("NMARK=",0);
    if (position != string::npos) {
      
      text_line.erase (0,6); nMarker_ = atoi(text_line.c_str());
      output_file << "NMARK= " << nMarker_ << endl;
      
      for (iMarker = 0 ; iMarker < nMarker_; iMarker++) {
        
        getline (input_file, text_line);
        text_line.erase (0,11);
        string::size_type position;
        for (iChar = 0; iChar < 20; iChar++) {
          position = text_line.find( " ", 0 );
          if (position != string::npos) text_line.erase (position,1);
          position = text_line.find( "\r", 0 );
          if (position != string::npos) text_line.erase (position,1);
          position = text_line.find( "\n", 0 );
          if (position != string::npos) text_line.erase (position,1);
        }
        Marker_Tag = text_line.c_str();
        
        /*--- Standart physical boundary ---*/
        
          getline (input_file, text_line);
          
          text_line.erase (0,13); nElem_Bound_ = atoi(text_line.c_str());
          output_file << "MARKER_TAG= " << Marker_Tag << endl;
          output_file << "MARKER_ELEMS= " << nElem_Bound_<< endl;
          
          for (iElem_Bound = 0; iElem_Bound < nElem_Bound_; iElem_Bound++) {
            
            getline(input_file, text_line);
            istringstream bound_line(text_line);
            
            bound_line >> VTK_Type;
            output_file << VTK_Type;
            
            switch(VTK_Type) {
              case LINE:
                bound_line >> vnodes_edge[0]; bound_line >> vnodes_edge[1];
                output_file << "\t" << vnodes_edge[0] << "\t" << vnodes_edge[1] << endl;
                break;
              case TRIANGLE:
                bound_line >> vnodes_triangle[0]; bound_line >> vnodes_triangle[1]; bound_line >> vnodes_triangle[2];
                output_file << "\t" << vnodes_triangle[0] << "\t" << vnodes_triangle[1] << "\t" << vnodes_triangle[2] << endl;
                break;
              case QUADRILATERAL:
                bound_line >> vnodes_quad[0]; bound_line >> vnodes_quad[1]; bound_line >> vnodes_quad[2]; bound_line >> vnodes_quad[3];
                output_file << "\t" << vnodes_quad[0] << "\t" << vnodes_quad[1] << "\t" << vnodes_quad[2] << "\t" << vnodes_quad[3] << endl;
                break;
            }
          }
      }
    }
    
  }
Exemple #2
0
void COutput::SetSU2_MeshASCII(CConfig *config, CGeometry *geometry, unsigned short val_iZone, ofstream& output_file) {
  
  unsigned long iElem, iPoint, iElem_Bound, nElem_Bound_, vnodes_edge[2], vnodes_triangle[3], vnodes_quad[4], iNode, nElem;
  unsigned short iMarker, iDim, nDim = geometry->GetnDim(), iChar, iPeriodic, nPeriodic = 0, VTK_Type, nMarker_;
  short SendTo;
  su2double *center, *angles, *transl;
  ifstream input_file;
  string Grid_Marker, text_line, Marker_Tag, str;
  string::size_type position;

  if (config->GetnZone() > 1){
    output_file << "IZONE= " << val_iZone+1 << endl;
  }

  /*--- Write dimensions data. ---*/

  output_file << "NDIME= " << nDim << endl;
  
  /*--- Write the angle of attack offset. ---*/
  
  output_file << "AOA_OFFSET= " << config->GetAoA_Offset() << endl;
  
  /*--- Write the angle of attack offset. ---*/
  
  output_file << "AOS_OFFSET= " << config->GetAoS_Offset() << endl;

  /*--- Write connectivity data. ---*/
  
  nElem = nGlobal_Tria+nGlobal_Quad+nGlobal_Tetr+nGlobal_Hexa+nGlobal_Pris+nGlobal_Pyra;
  
  output_file << "NELEM= " << nElem<< endl;
  
  nElem = 0;
  
  for (iElem = 0; iElem < nGlobal_Tria; iElem++) {
    iNode = iElem*N_POINTS_TRIANGLE;
    output_file << "5\t";
    output_file << Conn_Tria[iNode+0]-1 << "\t"; output_file << Conn_Tria[iNode+1]-1 << "\t";
    output_file << Conn_Tria[iNode+2]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Quad; iElem++) {
    iNode = iElem*N_POINTS_QUADRILATERAL;
    output_file << "9\t";
    output_file << Conn_Quad[iNode+0]-1 << "\t"; output_file << Conn_Quad[iNode+1]-1 << "\t";
    output_file << Conn_Quad[iNode+2]-1 << "\t"; output_file << Conn_Quad[iNode+3]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Tetr; iElem++) {
    iNode = iElem*N_POINTS_TETRAHEDRON;
    output_file << "10\t";
    output_file << Conn_Tetr[iNode+0]-1 << "\t" << Conn_Tetr[iNode+1]-1 << "\t";
    output_file << Conn_Tetr[iNode+2]-1 << "\t" << Conn_Tetr[iNode+3]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Hexa; iElem++) {
    iNode = iElem*N_POINTS_HEXAHEDRON;
    output_file << "12\t";
    output_file << Conn_Hexa[iNode+0]-1 << "\t" << Conn_Hexa[iNode+1]-1 << "\t";
    output_file << Conn_Hexa[iNode+2]-1 << "\t" << Conn_Hexa[iNode+3]-1 << "\t";
    output_file << Conn_Hexa[iNode+4]-1 << "\t" << Conn_Hexa[iNode+5]-1 << "\t";
    output_file << Conn_Hexa[iNode+6]-1 << "\t" << Conn_Hexa[iNode+7]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Pris; iElem++) {
    iNode = iElem*N_POINTS_PRISM;
    output_file << "13\t";
    output_file << Conn_Pris[iNode+0]-1 << "\t" << Conn_Pris[iNode+1]-1 << "\t";
    output_file << Conn_Pris[iNode+2]-1 << "\t" << Conn_Pris[iNode+3]-1 << "\t";
    output_file << Conn_Pris[iNode+4]-1 << "\t" << Conn_Pris[iNode+5]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  for (iElem = 0; iElem < nGlobal_Pyra; iElem++) {
    iNode = iElem*N_POINTS_PYRAMID;
    output_file << "14\t";
    output_file << Conn_Pyra[iNode+0]-1 << "\t" << Conn_Pyra[iNode+1]-1 << "\t";
    output_file << Conn_Pyra[iNode+2]-1 << "\t" << Conn_Pyra[iNode+3]-1 << "\t";
    output_file << Conn_Pyra[iNode+4]-1 << "\t";
    output_file << nElem << "\n"; nElem++;
  }
  
  /*--- Write the node coordinates ---*/
  
  output_file << "NPOIN= " << nGlobal_Doma;
  if (geometry->GetGlobal_nPointDomain() != nGlobal_Doma)
    output_file << "\t" << geometry->GetGlobal_nPointDomain();
  output_file << endl;

  for (iPoint = 0; iPoint < nGlobal_Doma; iPoint++) {
     for (iDim = 0; iDim < nDim; iDim++)
      output_file << scientific << Coords[iDim][iPoint] << "\t";
    output_file << iPoint << endl;
  }
  
  /*--- Read the boundary information ---*/

  str = "boundary.dat";

  str = config->GetMultizone_FileName(str, val_iZone);

  input_file.open(str.c_str(), ios::out);
  
  /*--- Read grid file with format SU2 ---*/
  
  while (getline (input_file, text_line)) {

    /*--- Write the physical boundaries ---*/
    
    position = text_line.find ("NMARK=",0);
    if (position != string::npos) {
      
      text_line.erase (0,6); nMarker_ = atoi(text_line.c_str());
      output_file << "NMARK= " << nMarker_ << endl;
      
      for (iMarker = 0 ; iMarker < nMarker_; iMarker++) {
        
        getline (input_file, text_line);
        text_line.erase (0,11);
        string::size_type position;
        for (iChar = 0; iChar < 20; iChar++) {
          position = text_line.find( " ", 0 );
          if (position != string::npos) text_line.erase (position,1);
          position = text_line.find( "\r", 0 );
          if (position != string::npos) text_line.erase (position,1);
          position = text_line.find( "\n", 0 );
          if (position != string::npos) text_line.erase (position,1);
        }
        Marker_Tag = text_line.c_str();
        
        /*--- Standart physical boundary ---*/
        
          getline (input_file, text_line);
          
          text_line.erase (0,13); nElem_Bound_ = atoi(text_line.c_str());
          output_file << "MARKER_TAG= " << Marker_Tag << endl;
          output_file << "MARKER_ELEMS= " << nElem_Bound_<< endl;
          getline (input_file, text_line);

          text_line.erase (0,8); SendTo = atoi(text_line.c_str());

          if (Marker_Tag == "SEND_RECEIVE"){
            output_file << "SEND_TO= " << SendTo << endl;
          }
          for (iElem_Bound = 0; iElem_Bound < nElem_Bound_; iElem_Bound++) {
            
            getline(input_file, text_line);
            istringstream bound_line(text_line);
            
            bound_line >> VTK_Type;
            output_file << VTK_Type;
            
            switch(VTK_Type) {
              case LINE:
                bound_line >> vnodes_edge[0]; bound_line >> vnodes_edge[1];
                output_file << "\t" << vnodes_edge[0] << "\t" << vnodes_edge[1] << endl;
                break;
              case TRIANGLE:
                bound_line >> vnodes_triangle[0]; bound_line >> vnodes_triangle[1]; bound_line >> vnodes_triangle[2];
                output_file << "\t" << vnodes_triangle[0] << "\t" << vnodes_triangle[1] << "\t" << vnodes_triangle[2] << endl;
                break;
              case QUADRILATERAL:
                bound_line >> vnodes_quad[0]; bound_line >> vnodes_quad[1]; bound_line >> vnodes_quad[2]; bound_line >> vnodes_quad[3];
                output_file << "\t" << vnodes_quad[0] << "\t" << vnodes_quad[1] << "\t" << vnodes_quad[2] << "\t" << vnodes_quad[3] << endl;
                break;
              case VERTEX:
                bound_line >> vnodes_edge[0]; bound_line >> vnodes_edge[1];
                output_file << "\t" << vnodes_edge[0] <<  "\t" << vnodes_edge[1] <<endl;
                break;
            }
          }
      }
    }
    
  }