Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hdf2plt.C File Reference
#include <cstdlib>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include "roccom.h"
Include dependency graph for hdf2plt.C:

Go to the source code of this file.

Classes

struct  AttrInfo
 
struct  ConnInfo
 
struct  Patch
 
struct  Block
 
struct  SGStr
 
struct  globarg
 Holds some global program arguments. More...
 

Namespaces

 HDF2PLT
 

Macros

#define SwitchOnDataType(dType, funcCall)
 

Functions

int getBlockNumber (const int zonenumber, const int NBlocks)
 Gets the block number by parsing the leading significant digits. More...
 
void resolveConnectivity ()
 
void readBlock (std::ifstream &ifs)
 
void readTopFile (const std::string file)
 
template<typename TT >
void PrintStructured (const TT *pData, const int ndims, const int *dims_nodes, int ghost, char loc, std::ostream &out)
 
template<typename TT >
void PrintUnstructured (const TT *pData, int size, bool panel, std::ostream &out)
 
void PrintConn (const int *pConn, const ConnInfo &ci, char type, std::ostream &out)
 
void COM_print_window (const std::string &wName, const std::string &timeStr, std::ostream &out, bool with_ghost, bool useTopFile)
 
 COM_EXTERN_MODULE (Rocin)
 
static void remove_arg (int *argc, char ***argv, int i)
 Remove an argument from the argument list. More...
 
void showUsage ()
 Prints usage and examples to STDOUT. More...
 
void parseArguments (int argc, char **argv)
 Parses the command line arguments. More...
 
int main (int argc, char *argv[])
 Program main. More...
 

Variables

struct HDF2PLT::SGStr StructuredGrid
 
struct globarg Program
 

Macro Definition Documentation

#define SwitchOnDataType (   dType,
  funcCall 
)

Definition at line 45 of file hdf2plt.C.

Referenced by COM_print_window().

Function Documentation

COM_EXTERN_MODULE ( Rocin  )
void COM_print_window ( const std::string &  wName,
const std::string &  timeStr,
std::ostream &  out,
bool  with_ghost,
bool  useTopFile 
)

Definition at line 401 of file hdf2plt.C.

References blocks, SGStr::blocks, COM_free_buffer(), COM_get_attribute(), COM_get_attributes(), COM_get_connectivities(), COM_get_panes(), COM_get_size(), getBlockNumber(), i, paneIds, PrintConn(), PrintStructured(), PrintUnstructured(), resolveConnectivity(), sin, HDF2PLT::StructuredGrid, SwitchOnDataType, and x.

403 {
404 
405  if( useTopFile )
406  {
407  std::cout << "Resolving inter-partition connectivity....";
409  std::cout << "[DONE]\n";
410  }
411 
412  // Obtain the list of panes
413  int nPanes;
414  int* paneIds;
415  COM_get_panes(wName.c_str(), &nPanes, &paneIds);
416 
417  // Obtain the list of attributes
418  int nAttrs; // Number of attributes
419  char* attrStr; // names of attributes separated by spaces
420  COM_get_attributes(wName.c_str(), &nAttrs, &attrStr);
421 
422  // First get the nodal coordinate info.
423  int i;
424  std::string name;
425  std::vector<AttrInfo> attrs(nAttrs+1);
426  attrs[0].m_name = "nc";
427  COM_get_attribute((wName + '.' + attrs[0].m_name).c_str(),
428  &(attrs[0].m_location), &(attrs[0].m_dataType),
429  &(attrs[0].m_numComp), &(attrs[0].m_units));
430 
431  // Then get the basic attribute info.
432  {
433  std::istringstream sin(attrStr);
434  for (i=1; i<nAttrs+1; ++i) {
435  sin >> attrs[i].m_name;
436  COM_get_attribute((wName + '.' + attrs[i].m_name).c_str(),
437  &(attrs[i].m_location), &(attrs[i].m_dataType),
438  &(attrs[i].m_numComp), &(attrs[i].m_units));
439  }
440  }
441 
442  if ( nPanes > 0 )
443  {
444  out << "TITLE=\"" << wName << ". Time: " << timeStr << ".\"" << std::endl;
445  out << "VARIABLES= \"x\", \"y\", \"z\"";
446  }
447 
448  // Eliminate window and pane attributes, note element attributes.
449  // EDIT: pane attributes with one item are used as element data.
450  // We might as well get rid of vectors and tensors, too.
451  std::vector<int> elemCentered;
452  int var = 4;
453  std::vector<AttrInfo>::iterator p = attrs.begin();
454  ++p;
455  while (p != attrs.end()) {
456  if ((*p).m_location == 'w') {
457  p = attrs.erase(p);
458  continue;
459  }
460 
461  if ((*p).m_location == 'p') {
462  bool okay = true;
463  int nItems, nGItems;
464  for (i=0; i<nPanes && okay; ++i) {
465  COM_get_size((wName + '.' + (*p).m_name).c_str(), paneIds[i], &nItems,
466  &nGItems);
467  if (nItems - nGItems != 1)
468  okay = false;
469  }
470  if (!okay) {
471  p = attrs.erase(p);
472  continue;
473  }
474  }
475 
476  if ((*p).m_numComp == 1)
477  {
478  out << ", \"" << (*p).m_name << '"';
479  if ((*p).m_location != 'n')
480  elemCentered.push_back(var);
481  ++var;
482  }
483  else {
484  int x;
485  for (x=1; x<=(*p).m_numComp; ++x) {
486  out << ", \"" << x << '-' << (*p).m_name << '"';
487  if ((*p).m_location != 'n')
488  elemCentered.push_back(var);
489  ++var;
490  }
491  }
492  ++p;
493  }
494  out << std::endl;
495 
496  // Loop through the panes to find the meshes
497  for ( i=0; i < nPanes; ++i )
498  {
499 
500  int nElems, ngElems;
501  name = wName + ".conn";
502  COM_get_size(name.c_str(), paneIds[i], &nElems, &ngElems);
503  if ( with_ghost) ngElems = 0;
504  if ( nElems-ngElems==0) continue; // Skip empty panes
505 
506  out << "ZONE T=\"" << std::setw(5) << std::setfill('0')
507  << paneIds[i] << "\", ";
508 
509  // Obtain the size of nodes
510  int nNodes; // total number of nodes
511  int ghost; // Number of ghost nodes
512  name = wName + ".nc";
513  COM_get_size(name.c_str(), paneIds[i], &nNodes, &ghost);
514  if ( with_ghost) ghost=0;
515 
516  // Obtain pane connectivity
517 // int nPcon; // total number of pane connectivities
518 // name = wName +".pconn";
519 // COM_get_size( name.c_str( ), paneIds[ i ], &nPcon );
520 // // Obtain a reference to the pconn array.
521 // const int* pconnArray = NULL;
522 // COM_get_array_const( pConnName.c_str( ), paneIds[ i ], &pconnArray );
523 
524  // Obtain the connectivity tables
525  int nConn; // Number of connectivity tables
526  char* connNames; // Names of connectivity tables separated by space
527  COM_get_connectivities(wName.c_str(), paneIds[i], &nConn, &connNames);
528 
529  int ndims;
530  const int* dims = NULL;
531  char elemType = '\0';
532  int eTotal = 0;
533  std::vector<ConnInfo> connInfo(nConn);
534  if (nConn == 1 && std::strncmp(connNames, ":st", 3) == 0)
535  {
536  // Structured mesh
537 
538  connInfo.clear();
539 
540  name = wName + '.' + connNames;
541  COM_get_size(name.c_str(), paneIds[i], &ndims, &ghost);
542  if ( with_ghost) ghost=0;
543 
544  // Obtain the dimensions (must be a const array) of the pane
545  COM_get_array_const(name.c_str(), paneIds[i], &dims);
546 
547 // // Obtain the size of the pconn array
548 // std::string pConnName = wName + ".pconn";
549 // int pconnsize;
550 // COM_get_size( pConnName.c_str( ), paneIds[ i ], &pconnsize );
551 //
552 // std::cout << "Here is the pane connectivity size: " << pconnsize << std::endl;
553 // // Obtain a reference to the pconn array.
554 // const int* pconnArray = NULL;
555 // COM_get_array_const( pConnName.c_str( ), paneIds[ i ], &pconnArray );
556 //
557 // for( int panecon=0; panecon < pconnsize; panecon++ )
558 // {
559 // std::cout << pconnArray[ panecon ] << "\n";
560 // }
561 
562  out << "I=" << dims[0] - 2 * ghost;
563  if ( ndims>=2) out << ", J=" << dims[1] - 2 * ghost;
564  if ( ndims>=3) out << ", K=" << dims[2] - 2 * ghost;
565 
566  out << ", ZONETYPE=ORDERED, ";
567 
568  if( useTopFile )
569  {
570  std::cout << "Processing paneId: " << paneIds[ i ] << std::endl;
571  int blockNum = getBlockNumber( paneIds[ i ], HDF2PLT::StructuredGrid.numBlocks );
572  std::cout << "Here is the block number: " << blockNum << std::endl;
573  assert( HDF2PLT::StructuredGrid.blocks.find( blockNum ) != HDF2PLT::StructuredGrid.blocks.end( ) );
575  std::cout << dims[ 0 ] << " == " << HDF2PLT::StructuredGrid.blocks[ blockNum ].Ni+7 << std::endl;
576  std::cout << dims[ 1 ] << " == " << HDF2PLT::StructuredGrid.blocks[ blockNum ].Nj+7 << std::endl;
577  std::cout << dims[ 2 ] << " == " << HDF2PLT::StructuredGrid.blocks[ blockNum ].Nk+7 << std::endl;
578  }
579 
580  }
581  else
582  { // Unstructured mesh
583  // Obtain the sizes of connectivity tables
584  std::istringstream sin(connNames);
585  std::vector<ConnInfo>::iterator c;
586  for (c=connInfo.begin(); c!=connInfo.end(); ++c)
587  {
588  sin >> (*c).m_type;
589  (*c).m_name = wName + '.' + (*c).m_type;
590  (*c).m_type.erase(0, 1);
591  std::string::size_type x = (*c).m_type.find(':', 2);
592  if (x != std::string::npos)
593  (*c).m_type.erase(x);
594 
595  COM_get_size((*c).m_name.c_str(), paneIds[i], &((*c).m_numElements),
596  &((*c).m_numGhost));
597  if ( with_ghost) (*c).m_numGhost = 0;
598  eTotal += (*c).m_numElements - (*c).m_numGhost;
599 
600  // Tecplot can't do mixed elements, so we have to use the biggest
601  // and fudge the rest.
602  if (elemType == '\0' || elemType == 't'
603  || ((elemType == 'q' || elemType == 'T')
604  && (*c).m_type[0] > 'A' && (*c).m_type[0] < 'Z')
605  || (*c).m_type[0] == 'B' || (*c).m_type[0] == 'H')
606  elemType = (*c).m_type[0];
607  }
608  out << "N=" << nNodes - ghost << ", E=" << eTotal << ", ZONETYPE=";
609  switch (elemType) {
610  case 't':
611  out << "FETRIANGLE, ";
612  break;
613 
614  case 'q':
615  out << "FEQUADRILATERAL, ";
616  break;
617 
618  case 'T':
619  out << "FETETRAHEDRON, ";
620  break;
621 
622  case 'P':
623  case 'W':
624  case 'H':
625  elemType = 'B';
626  // Intentional fall-through
627 
628  case 'B':
629  out << "FEBRICK, ";
630  break;
631  }
632 
633  // free the buffer of connNames
634  COM_free_buffer(&connNames);
635  }
636 
637  out << "DATAPACKING=BLOCK";
638  if (!elemCentered.empty()) {
639  std::vector<int>::iterator cv = elemCentered.begin();
640  out << ", VARLOCATION=([" << *cv;
641  ++cv;
642  while (cv != elemCentered.end()) {
643  out << ',' << *cv;
644  ++cv;
645  }
646  out << "]=CELLCENTERED)";
647  }
648  out << std::endl;
649 
650  for (p=attrs.begin(); p!=attrs.end(); ++p)
651  {
652  const void* pArray = NULL;
653  if ((*p).m_numComp == 1)
654  {
655  out << "# Begin " << (*p).m_name << std::endl;
656  COM_get_array_const((wName + '.' + (*p).m_name).c_str(), paneIds[i],
657  &pArray);
658  if (dims != NULL)
659  { // Structured
660  SwitchOnDataType((*p).m_dataType,
661  PrintStructured((TT*)pArray, ndims, dims, ghost,
662  (*p).m_location, out));
663  }
664  else
665  {
666  SwitchOnDataType((*p).m_dataType,
667  PrintUnstructured((TT*)pArray,
668  ((*p).m_location != 'n' ? eTotal
669  : nNodes - ghost),
670  (*p).m_location == 'p', out));
671  }
672 
673  } // End if m_numComp == 1
674  else
675  {
676  int comp;
677  for (comp=1; comp<=(*p).m_numComp; ++comp)
678  {
679  std::ostringstream sout;
680  sout << wName << '.' << comp << '-' << (*p).m_name;
681  out << "# Begin " << comp << '-' << (*p).m_name << std::endl;
682  COM_get_array_const(sout.str().c_str(), paneIds[i], &pArray);
683  if (dims != NULL) { // Structured
684  SwitchOnDataType((*p).m_dataType,
685  PrintStructured((TT*)pArray, ndims, dims, ghost,
686  (*p).m_location, out));
687  }
688  else
689  {
690  SwitchOnDataType((*p).m_dataType,
691  PrintUnstructured((TT*)pArray,
692  ((*p).m_location != 'n' ? eTotal
693  : nNodes - ghost),
694  (*p).m_location == 'p', out));
695  }
696 
697  }// End for comp
698 
699  } // End else
700 
701  } // End for attrs.begin
702 
703  if (!connInfo.empty( ) )
704  {
705  std::vector<ConnInfo>::iterator c = connInfo.begin();
706  while (c != connInfo.end())
707  {
708  const int* pConn = NULL;
709  COM_get_array_const((*c).m_name.c_str(), paneIds[i], &pConn);
710  PrintConn(pConn, *c, elemType, out);
711  ++c;
712  }
713 
714  }
715 
716  } // for all panes
717 
718  // Free buffers for pane ids and attribute names
719  COM_free_buffer(&paneIds);
720  COM_free_buffer(&attrStr);
721 
722 }
std::map< int, Block > blocks
Definition: hdf2plt.C:142
void PrintConn(const int *pConn, const ConnInfo &ci, std::ostream &out)
Definition: cgns2smf.C:232
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
Definition: roccom_c++.h:269
void PrintUnstructured(const TT **pData, int nComp, int size, std::ostream &out)
Definition: cgns2smf.C:221
void PrintStructured(const TT **pData, int nComp, int ndims, const int *dims_nodes, int ghost, char loc, std::ostream &out)
Definition: cgns2smf.C:176
void COM_get_connectivities(const char *wname, int pane_id, int *nc, std::string &names)
Definition: roccom_c++.h:363
void COM_get_attributes(const char *wname, int *na, std::string &names)
Definition: roccom_c++.h:360
int getBlockNumber(const int zonenumber, const int NBlocks)
Gets the block number by parsing the leading significant digits.
Definition: hdf2plt.C:154
NT & sin
#define SwitchOnDataType(dType, funcCall)
Definition: hdf2plt.C:45
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
bool blocks
Input data is block-structured grid.
Definition: hdf2pltV2.C:51
void resolveConnectivity()
Definition: hdf2plt.C:175
struct HDF2PLT::SGStr StructuredGrid
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
std::vector< int > paneIds
Array of paneIds.
Definition: hdf2pltV2.C:60

Here is the call graph for this function:

int getBlockNumber ( const int  zonenumber,
const int  NBlocks 
)
inline

Gets the block number by parsing the leading significant digits.

Parameters
zonenumberthe zone number.
NBlocksthe total number of blocks.
Returns
N the number without the trailing zeros.

Definition at line 154 of file hdf2plt.C.

References s.

Referenced by COM_print_window().

155 {
156  std::stringstream iss;
157  iss << zonenumber;
158  std::string s = iss.str( );
159  bool found = false;
160  int reduceFactor = 4;
161  int B = -1;
162  while( !found )
163  {
164  s.resize( reduceFactor );
165  B = std::atoi( s.c_str( ) );
166  if( B <= NBlocks )
167  {
168  found = true;
169  }
170  --reduceFactor;
171  }
172  return( B );
173 }
double s
Definition: blastest.C:80

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Program main.

Parameters
argcargument counter.
argvargument vector.
Returns
rc return code.
Postcondition
if rc >= 0 program terminated normally.

Definition at line 863 of file hdf2plt.C.

References COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_print_window(), parseArguments(), and readTopFile().

864 {
865  /* Parse the command line arguments */
866  parseArguments( argc, argv );
867 
868  Program.printInfo( );
869 
870  /* Initialize the COM Environment */
871  COM_init(&argc, &argv);
872 
873  /* Load Rocin for reading the HDF files */
875 
876  std::cout << "Reading top file: " << Program.topfile << "...";
877  if( Program.useTopFile )
878  readTopFile( Program.topfile );
879  std::cout << "[DONE]\n";
880 
881  /* Obtain function handle to the obtain attribute function */
882  int IN_obtain = COM_get_function_handle("IN.obtain_attribute");
883 
884  std::string win_in;
885  if( Program.readControlFile )
886  win_in = Program.cntrlfile;
887  else
888  win_in = Program.fileregx;
889 
890  std::string::size_type st = win_in.find_last_of('/');
891  if (st != std::string::npos)
892  win_in.erase(0, st+1);
893  st = win_in.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
894  if (st != std::string::npos)
895  win_in.erase(st);
896 
897  // Initialize an empty time string
898  int len = 15;
899  char timeStr[16];
900  timeStr[0] = '\0';
901 
902  if( Program.readControlFile )
903  {
904  std::cout << "Reading by control file " << Program.cntrlfile << " into window " << win_in << "...";
905 
906  int IN_read = COM_get_function_handle("IN.read_by_control_file");
907  COM_call_function(IN_read,
908  Program.cntrlfile.c_str(),
909  win_in.c_str(),
910  NULL,
911  timeStr,
912  &len);
913 
914  std::cout << "[DONE]\n";
915 
916  }
917  else
918  {
919  std::cout << "Reading HDF file(s) " << Program.fileregx << " into window " << win_in << "...";
920 
921  int IN_read = COM_get_function_handle("IN.read_window");
922  COM_call_function(IN_read,
923  Program.fileregx.c_str(),
924  win_in.c_str(),
925  NULL,
926  NULL,
927  timeStr,
928  &len);
929 
930  std::cout << "[DONE]\n";
931 
932  }
933 
934  std::string win_all(win_in + ".all");
935  int IN_all = COM_get_attribute_handle(win_all.c_str());
936 
937  std::cout << "Obtaining data attributes for window " << win_in << "...";
938  COM_call_function(IN_obtain, &IN_all, &IN_all);
939  std::cout << "[DONE]\n";
940 
941  if( Program.outputfile == "" )
942  {
943  std::cout << "Writing window out to standard output " << "...";
944  COM_print_window(win_in, timeStr, std::cout, Program.withGhost, Program.useTopFile );
945  std::cout << "[DONE]\n";
946  }
947  else
948  {
949  std::cout << "Writing window out to " << Program.outputfile << "...";
950  std::ofstream fout( Program.outputfile.c_str( ) );
951  COM_print_window(win_in, timeStr, fout, Program.withGhost, Program.useTopFile );
952  std::cout << "[DONE]\n";
953  }
954 
955  // COM_UNLOAD_MODULE_STATIC_DYNAMIC(Rocin);
956 
957  COM_finalize();
958  return 0;
959 }
void parseArguments(int argc, char **argv)
Parses the command line arguments.
Definition: hdf2plt.C:805
void readTopFile(const std::string file)
Definition: hdf2plt.C:232
A struct that holds all the global program data.
void COM_print_window(const char *wName, std::ostream &ostr)
Print a terse human-readable description of this window to this ostream.
Definition: printin.C:64
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocin.h:64
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void parseArguments ( int  argc,
char **  argv 
)

Parses the command line arguments.

Parses the user-supplied command line arguments.

Parameters
argcthe argument counter.
argvthe argument vector.
argcthe argument counter
argvthe argument vector

Definition at line 805 of file hdf2plt.C.

References i, and showUsage().

Referenced by main().

806 {
807  Program.useTopFile = false;
808  Program.withGhost = false;
809  Program.readControlFile = false;
810 
811  Program.cntrlfile = "";
812  Program.topfile = "";
813  Program.fileregx = "";
814 
815  for( int i=1; i < argc; ++i )
816  {
817  if( std::strcmp( argv[ i ], "-top" ) == 0 )
818  {
819  Program.useTopFile = true;
820  Program.topfile = std::string( argv[ ++i ] );
821  }
822  else if( std::strcmp( argv[ i ], "-g" ) == 0 )
823  {
824  Program.withGhost = true;
825  }
826  else if( std::strcmp( argv[ i ], "-c" ) == 0 )
827  {
828  Program.readControlFile = true;
829  Program.cntrlfile = std::string( argv[ ++i ] );
830  }
831  else if( std::strcmp( argv[ i ], "-o" ) == 0 )
832  {
833  Program.outputfile = std::string( argv[ ++i ] );
834  }
835  else if( std::strcmp( argv[ i ], "-regex") == 0 )
836  {
837  Program.fileregx = std::string( argv[ ++i ] );
838  }
839  else if( std::strcmp( argv[ i ], "-h") == 0 )
840  {
841  showUsage( );
842  exit( 0 );
843  }
844 
845  }
846 
847  if( Program.cntrlfile == "" && Program.fileregx == "" )
848  {
849  std::cerr << "Error parsing command line input!\n";
850  showUsage( );
851  exit( -1 );
852  }
853 
854 }
A struct that holds all the global program data.
blockLoc i
Definition: read.cpp:79
void showUsage()
Prints usage and examples to STDOUT.
Definition: hdf2plt.C:785

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintConn ( const int *  pConn,
const ConnInfo ci,
char  type,
std::ostream &  out 
)

Definition at line 331 of file hdf2plt.C.

References ConnInfo::m_numElements, ConnInfo::m_numGhost, ConnInfo::m_type, and sin.

333 {
334  int nn;
335  std::istringstream sin(ci.m_type.substr(1));
336  sin >> nn;
337 
338  int elem;
339  for (elem=0; elem<ci.m_numElements-ci.m_numGhost; ++elem) {
340  switch (type) {
341  case 't': // The overall type is 't', so all the tables must be 't'
342  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
343  << " " << pConn[elem+2*ci.m_numElements] << std::endl;
344  break;
345 
346  case 'q':
347  if (ci.m_type[0] == 't')
348  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
349  << " " << pConn[elem+2*ci.m_numElements] << " "
350  << pConn[elem+2*ci.m_numElements] << std::endl;
351  else // must be q4, q8 or q9.
352  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
353  << " " << pConn[elem+2*ci.m_numElements] << " "
354  << pConn[elem+3*ci.m_numElements] << std::endl;
355  break;
356 
357  case 'T': // The overall type is 'T', so all the tables must be 'T'
358  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
359  << " " << pConn[elem+2*ci.m_numElements] << " "
360  << pConn[elem+3*ci.m_numElements] << std::endl;
361  break;
362 
363  case 'B':
364  if (ci.m_type[0] == 'T')
365  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
366  << " " << pConn[elem+2*ci.m_numElements] << " "
367  << pConn[elem+2*ci.m_numElements] << " "
368  << pConn[elem+3*ci.m_numElements] << " "
369  << pConn[elem+3*ci.m_numElements] << " "
370  << pConn[elem+3*ci.m_numElements] << " "
371  << pConn[elem+3*ci.m_numElements] << std::endl;
372  else if (ci.m_type == "P5")
373  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
374  << " " << pConn[elem+2*ci.m_numElements] << " "
375  << pConn[elem+3*ci.m_numElements] << " "
376  << pConn[elem+4*ci.m_numElements] << " "
377  << pConn[elem+4*ci.m_numElements] << " "
378  << pConn[elem+4*ci.m_numElements] << " "
379  << pConn[elem+4*ci.m_numElements] << std::endl;
380  else if (ci.m_type == "P6" || ci.m_type == "W6")
381  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
382  << " " << pConn[elem+2*ci.m_numElements] << " "
383  << pConn[elem+2*ci.m_numElements] << " "
384  << pConn[elem+3*ci.m_numElements] << " "
385  << pConn[elem+4*ci.m_numElements] << " "
386  << pConn[elem+5*ci.m_numElements] << " "
387  << pConn[elem+5*ci.m_numElements] << std::endl;
388  else
389  out << " " << pConn[elem] << " " << pConn[elem+ci.m_numElements]
390  << " " << pConn[elem+2*ci.m_numElements] << " "
391  << pConn[elem+3*ci.m_numElements] << " "
392  << pConn[elem+4*ci.m_numElements] << " "
393  << pConn[elem+5*ci.m_numElements] << " "
394  << pConn[elem+6*ci.m_numElements] << " "
395  << pConn[elem+7*ci.m_numElements] << std::endl;
396  break;
397  }
398  }
399 }
int m_numGhost
Definition: cgns2smf.C:140
std::string m_type
Definition: cgns2smf.C:138
NT & sin
int m_numElements
Definition: cgns2smf.C:139
void PrintStructured ( const TT *  pData,
const int  ndims,
const int *  dims_nodes,
int  ghost,
char  loc,
std::ostream &  out 
)

Definition at line 263 of file hdf2plt.C.

References i, j, and k.

265 {
266  const int dims[3] = { dims_nodes[0] - (loc!='n'),
267  ndims>=2 ? dims_nodes[1] - (loc!='n') : 0,
268  ndims>=3 ? dims_nodes[2] - (loc!='n') : 0};
269 
270  const int last[3] = { dims[0] - ghost,
271  ndims>=2 ? dims[1] - ghost : 0,
272  ndims>=3 ? dims[2] - ghost : 0};
273  int count = 0;
274 
275  if ( ndims==3)
276  {
277  for (int k=ghost; k<last[2]; ++k)
278  {
279  for (int j=ghost; j<last[1]; ++j)
280  {
281  for (int i=ghost; i<last[0]; ++i,++count)
282  {
283  out << " " << std::scientific
284  << (!pData ? (TT)-987654321
285  : (loc=='p' ? pData[0]
286  : pData[i+j*dims[0]+k*dims[0]*dims[1]]));
287  if (count % 10 == 9) out << std::endl;
288  }
289  }
290  }
291  }
292  else if (ndims==2)
293  {
294  for (int j=ghost; j<last[1]; ++j)
295  {
296  for (int i=ghost; i<last[0]; ++i,++count)
297  {
298  out << " " << std::scientific
299  << (!pData ? (TT)-987654321
300  : (loc=='p' ? pData[0] : pData[i+j*dims[0]]));
301  if (count % 10 == 9) out << std::endl;
302  }
303  }
304 
305  }
306  else
307  {
308  for (int i=ghost; i<last[0]; ++i,++count)
309  {
310  out << " " << std::scientific << (!pData ? (TT)-987654321 : (loc=='p' ? pData[0] : pData[i]));
311  if (count % 10 == 9)
312  out << std::endl;
313  }
314  }
315  out << std::endl;
316 }
j indices k indices k
Definition: Indexing.h:6
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
void PrintUnstructured ( const TT *  pData,
int  size,
bool  panel,
std::ostream &  out 
)

Definition at line 319 of file hdf2plt.C.

References i.

320 {
321  int i;
322  for (i=0; i<size; ++i) {
323  out << " " << std::scientific << (!pData ? (TT)-987654321
324  : (panel ? pData[0]
325  : pData[i]));
326  if (i % 10 == 9) out << std::endl;
327  }
328  out << std::endl;
329 }
blockLoc i
Definition: read.cpp:79
void readBlock ( std::ifstream &  ifs)
inline

Definition at line 180 of file hdf2plt.C.

References Block::blockNumber, blocks, SGStr::blocks, Patch::boundaryCondition, Patch::coupled, Block::gridLevels, i, Patch::L1BEGIN, Patch::L1END, Patch::L2BEGIN, Patch::L2END, Patch::localBlockFaceNumer, Block::Ni, Block::Nj, Block::Nk, Block::pathces, Patch::remoteBlockFaceNumber, Patch::remoteBlockNumber, Patch::remoteL1BEGIN, Patch::remoteL1END, Patch::remoteL2BEGIN, Patch::remoteL2END, and HDF2PLT::StructuredGrid.

Referenced by readTopFile().

181 {
182  std::string dummyline;
183  int N;
184 
185  if( !ifs.is_open( ) )
186  {
187  std::cerr << "Error opening reading file!"<< std::endl;
188  std::cerr << "FILE: " << __FILE__ << std::endl;
189  std::cerr << "LINE: " << __LINE__ << std::endl;
190  exit( -1 );
191  }
192 
193  HDF2PLT::Block b;
194  ifs >> b.blockNumber >> b.gridLevels;
195 // std::cout << "# " << b.blockNumber << " ";
196 
197  std::getline( ifs, dummyline );
198 
199  ifs >> N >> b.Ni >> b.Nj >> b.Nk;
200 // std::cout << b.Ni << " " << b.Nj << " " << b.Nk << std::endl;
201 
202  std::getline( ifs,dummyline );
203 
204  b.pathces.resize( N );
205  for( int i=0; i < N; ++i )
206  {
207  HDF2PLT::Patch p;
208  ifs >> p.boundaryCondition;
209  ifs >> p.localBlockFaceNumer;
210  ifs >> p.L1BEGIN;
211  ifs >> p.L1END;
212  ifs >> p.L2BEGIN;
213  ifs >> p.L2END;
214  ifs >> p.remoteBlockNumber;
215  ifs >> p.remoteBlockFaceNumber;
216  ifs >> p.remoteL1BEGIN;
217  ifs >> p.remoteL1END;
218  ifs >> p.remoteL2BEGIN;
219  ifs >> p.remoteL2END;
220  ifs >> p.coupled;
221  std::getline( ifs, dummyline );
222  b.pathces[ i ] = p;
223  }
224 
225  assert( HDF2PLT::StructuredGrid.blocks.find( b.blockNumber ) ==
228 
229 
230 }
std::map< int, Block > blocks
Definition: hdf2plt.C:142
int remoteBlockFaceNumber
The remote block face number that is connecting with this block.
Definition: hdf2plt.C:121
int remoteBlockNumber
The remote block number.
Definition: hdf2plt.C:120
int remoteL2BEGIN
The remote block&#39;s patch l2 begin coordinate.
Definition: hdf2plt.C:124
int remoteL2END
The remote block&#39;s patch l2 end coordinate.
Definition: hdf2plt.C:125
int boundaryCondition
Patch boundary condition number.
Definition: hdf2plt.C:114
std::vector< Patch > pathces
Definition: hdf2plt.C:136
int remoteL1BEGIN
The remote block&#39;s patch l1 begin coordinate.
Definition: hdf2plt.C:122
int L2BEGIN
The local patch l2 begin coordinate.
Definition: hdf2plt.C:118
blockLoc i
Definition: read.cpp:79
int L1END
The local patch l1 end coordinate.
Definition: hdf2plt.C:117
int L1BEGIN
The local patch l1 begin coordinate.
Definition: hdf2plt.C:116
int localBlockFaceNumer
The local block face number.
Definition: hdf2plt.C:115
bool blocks
Input data is block-structured grid.
Definition: hdf2pltV2.C:51
int L2END
The local patch l2 end coordinate.
Definition: hdf2plt.C:119
int remoteL1END
The remote block&#39;s patch l1 end coordinate.
Definition: hdf2plt.C:123
struct HDF2PLT::SGStr StructuredGrid
int gridLevels
Definition: hdf2plt.C:132
int coupled
A flag to the external solver.
Definition: hdf2plt.C:126
int blockNumber
Definition: hdf2plt.C:131

Here is the caller graph for this function:

void readTopFile ( const std::string  file)
inline

Definition at line 232 of file hdf2plt.C.

References i, SGStr::numBlocks, readBlock(), and HDF2PLT::StructuredGrid.

Referenced by main().

233 {
234  std::ifstream ifs;
235  std::string dummyline;
236 
237  ifs.open( file.c_str( ) );
238 
239  if( !ifs.is_open( ) )
240  {
241  std::cerr << "Error opening file " << file << std::endl;
242  std::cerr << "FILE: " << __FILE__ << std::endl;
243  std::cerr << "LINE: " << __LINE__ << std::endl;
244  exit( -1 );
245  }
246 
247  std::getline( ifs, dummyline );
248  std::getline( ifs, dummyline );
249 
251 
252  std::getline( ifs, dummyline );
253 
254  int blockId;
255 
256  for( int i=0; i < HDF2PLT::StructuredGrid.numBlocks; ++i )
257  readBlock( ifs );
258 
259  ifs.close( );
260 }
void readBlock(std::ifstream &ifs)
Definition: hdf2plt.C:180
blockLoc i
Definition: read.cpp:79
struct HDF2PLT::SGStr StructuredGrid

Here is the call graph for this function:

Here is the caller graph for this function:

static void remove_arg ( int *  argc,
char ***  argv,
int  i 
)
inlinestatic

Remove an argument from the argument list.

Definition at line 727 of file hdf2plt.C.

References j.

727  {
728  for ( int j=i; j<*argc-1; ++j) (*argv)[j]=(*argv)[j+1];
729  --*argc;
730 }
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
void resolveConnectivity ( )
inline

Definition at line 175 of file hdf2plt.C.

Referenced by COM_print_window().

176 {
177  // TODO: implement this
178 }

Here is the caller graph for this function:

void showUsage ( )

Prints usage and examples to STDOUT.

Definition at line 785 of file hdf2plt.C.

Referenced by main(), parseArguments(), and parseCmdParameters().

786 {
787  std::cout << "HDF2PLT OPTIONS:\n";
788  std::cout << "-regex \"{somestring}*.hdf\" : Specifies a set of hdf files\n";
789  std::cout << "-top {topfile} : Specifies a top file to use to resolve the connectivity\n";
790  std::cout << "-g : Enables ghost node inclusion in the output file\n";
791  std::cout << "-c {cntrlfile} : Specifies a control file to use\n";
792  std::cout << "-o {outputfile} : Specifies output file. Output is printed to STDOUT by default.\n";
793  std::cout << "-h : Prints this help menu.\n";
794  std::cout << "Examples:\n";
795  std::cout << "\thdf2plt -g -regex \"fluid*.hdf\" -o output.plt\n";
796  std::cout << "\thdf2plt -regex \"fluid*.hdf\" -top fluid.top -o output.plt\n";
797  std::cout.flush( );
798 }

Here is the caller graph for this function:

Variable Documentation