25 #include "PrimitiveTypes.H"
35 using namespace Rocstar::Rocin::Utilities;
61 std::vector< Mesh::UnstructuredMesh >
meshes;
62 std::vector< std::vector< bool > >
mask;
63 std::vector< SolnMetaData >
smdv;
64 std::vector< std::vector< std::vector< double > > >
solution;
65 std::vector< PaneConnectivity >
pconns;
82 inline std::string getTecplotZoneType( )
85 assert( globalElementList.size( ) > 0 );
88 std::string retString =
"";
90 int maxElementSize = 0;
91 for(
int i=0;
i < globalElementList.size( ); ++
i )
93 if( globalElementList[
i ].size( ) > maxElementSize )
94 maxElementSize = globalElementList[
i ].size( );
97 switch( maxElementSize )
100 retString =
"FEBRICK";
103 retString =
"FETETRAHEDRON";
107 retString =
"FEPOLYHEDRAL";
110 std::cerr <<
"Undefined element size: " << maxElementSize << std::endl;
111 std::cerr <<
"File: " << __FILE__ << std::endl;
112 std::cerr <<
"Line: " << __LINE__ << std::endl;
125 inline DataItemType getDataItemType(
const int metaDataIdx )
128 assert( metaDataIdx >= 0 && metaDataIdx < smdv.size( ) );
131 if( smdv[ metaDataIdx ].loc ==
'e' )
133 else if( smdv[ metaDataIdx ].loc ==
'n' )
136 std::cerr <<
"Undefined location: " << smdv[ metaDataIdx ].loc << std::endl;
137 std::cerr <<
"File: " << __FILE__ << std::endl;
138 std::cerr <<
"Line: " << __LINE__ << std::endl;
151 inline bool isNodeShared(
const int meshidx,
const int pointidx )
154 assert( meshidx >= 0 && meshidx < numberOfPanes );
155 assert( pointidx >= 0 && pointidx < meshes[ meshidx ].nc.Size( ) );
157 return mask[ meshidx ][ pointidx ];
168 inline int getPaneIndex(
const int paneId )
171 assert( hasPane( paneId ) );
174 int idx = paneIds2index[ paneId ];
177 assert( idx >= 0 && idx < numberOfPanes );
188 inline bool hasPane(
const int paneId )
190 if( paneIds2index.find( paneId ) != paneIds2index.end( ) )
205 assert( meshIndex >= 0 && meshIndex < meshes.size( ) );
206 assert( meshes.size( ) == pconns.size( ) );
208 return( &pconns[ meshIndex ] );
214 inline void loadModules( )
223 inline void unloadModules( )
233 inline void printInfo( )
236 std::cout <<
"Program: " << prgmname << std::endl;
237 std::cout <<
"Date: " << __DATE__ << std::endl;
238 if( readControlFile )
240 std::cout <<
"Read control file: yes\n";
241 std::cout <<
"Control file: " << cntrlfile << std::endl;
245 std::cout <<
"Read control file: no\n";
246 std::cout <<
"File(s): " << fileregx << std::endl;
249 std::cout <<
"Use ghost nodes: ";
250 (
withGhost)? std::cout <<
"yes\n" : std::cout <<
"no\n";
252 if( outputfile ==
"" )
253 std::cout <<
"Output file: standard out\n";
255 std::cout <<
"Output file: " << outputfile << std::endl;
320 void writeVtkFiles( std::vector< Mesh::UnstructuredMesh > &m );
368 int addToGlobalNodeList(
const double x,
const double y,
const double z, std::vector< double > &nodelist );
402 void printVtk( std::vector< double > &vlist, std::vector< std::vector< int > > &elist );
412 int main(
int argc,
char **argv )
429 std::cout <<
"Read window: " << windowname << std::endl;
430 std::cout <<
"Number of panes: " <<
Program.numberOfPanes << std::endl;
461 std::cout <<
"Writing TECPLOT file...";
465 assert(
Program.globalNodeList.size( ) > 0 );
466 assert(
Program.globalElementList.size( ) > 0 );
467 assert(
Program.smdv.size( ) > 0 );
476 if( !ofs.is_open( ) )
478 std::cerr <<
"Cannot write TECPLOT file: " <<
Program.
outputfile+
".vtk" << std::endl;
479 std::cerr <<
"File: " << __FILE__ << std::endl;
480 std::cerr <<
"Line: " << __LINE__ << std::endl;
488 int variableCount = 3;
489 std::vector< int > ecenteredidx;
491 ofs <<
"VARIABLES= \"X\", \"Y\", \"Z\"";
500 for(
int component=0; component <
Program.smdv[
i ].ncomp; ++component )
503 ofs << component+1 <<
"-" <<
Program.smdv[
i ].name;
508 ecenteredidx.push_back( variableCount );
513 ofs <<
", \"" <<
Program.smdv[
i ].name <<
"\"";
516 ecenteredidx.push_back( variableCount );
525 ofs <<
"ZONE " <<
"NODES=" <<
Program.globalNodeList.size( )/3 <<
" ";
526 ofs <<
"ELEMENTS=" <<
Program.globalElementList.size( ) <<
" ";
527 ofs <<
"ZONETYPE=" <<
Program.getTecplotZoneType( ) <<
" ";
528 ofs <<
"DATAPACKING=BLOCK ";
530 if( !ecenteredidx.empty( ) )
532 ofs <<
"VARLOCATION=([";
533 ofs << ecenteredidx[ 0 ];
534 for(
int i=1;
i < ecenteredidx.size( ); ++
i )
535 ofs <<
"," << ecenteredidx[
i ];
536 ofs <<
"]=CELLCENTERED)";
542 for(
int i=0;
i < 3; ++
i )
547 ofs <<
"# Begin X\n";
550 ofs <<
"# Begin Y\n";
553 ofs <<
"# Begin Z\n";
556 std::cerr <<
"Error: Code should not reach here!\n";
557 std::cerr <<
"File: " << __FILE__ << std::endl;
558 std::cerr <<
"Line: " << __LINE__ << std::endl;
559 std::cerr <<
"core dumping...\n";
577 for(
int i=0;
i <
Program.globalSolution.size( ); ++
i )
583 for(
int component=0; component <
Program.smdv[
i ].ncomp; ++component )
585 ofs <<
"\n# Begin " << component+1 <<
"-" <<
Program.smdv[
i ].name << std::endl;
587 int stride =
Program.smdv[
i ].ncomp;
588 int NumItems =
Program.globalSolution[
i ].size( )/stride;
589 for(
int dataidx=0; dataidx < NumItems; ++dataidx )
591 ofs <<
Program.globalSolution[
i ][ dataidx*stride+component ] <<
" ";
592 if( dataidx % 10 == 9 )
600 ofs <<
"\n# Begin " <<
Program.smdv[
i ].name << std::endl;
601 for(
int dataidx=0; dataidx <
Program.globalSolution[
i ].size( ); ++dataidx )
603 ofs <<
Program.globalSolution[
i ][ dataidx ] <<
" ";
604 if( dataidx % 10 == 9 )
618 ofs << std::endl <<
"# Begin Element Connectivity\n";
619 for(
int i=0;
i <
Program.globalElementList.size( ); ++
i )
621 for(
int j=0;
j <
Program.globalElementList[
i ].size( ); ++
j )
623 ofs <<
Program.globalElementList[
i ][
j ]+1 <<
" ";
631 std::cout <<
"[DONE]\n";
648 std::cout <<
"Writing VTK data...";
652 assert(
Program.globalNodeList.size( ) > 0 );
653 assert(
Program.globalElementList.size( ) > 0 );
654 assert(
Program.smdv.size( ) > 0 );
663 if( !ofs.is_open( ) )
665 std::cerr <<
"Cannot write VTK file: " <<
Program.
outputfile+
".vtk" << std::endl;
666 std::cerr <<
"File: " << __FILE__ << std::endl;
667 std::cerr <<
"Line: " << __LINE__ << std::endl;
672 ofs <<
"# vtk DataFile Version 3.0\n";
673 ofs <<
"Global Mesh Output" << std::endl;
675 ofs <<
"DATASET UNSTRUCTURED_GRID\n";
676 ofs <<
"POINTS " <<
Program.globalNodeList.size( )/3 <<
" double\n";
679 for(
int i=0;
i <
Program.globalNodeList.size( )/3; ++
i )
681 ofs <<
Program.globalNodeList[
i*3 ] <<
" ";
682 ofs <<
Program.globalNodeList[
i*3+1 ] <<
" ";
683 ofs <<
Program.globalNodeList[
i*3+2 ] << std::endl;
688 for(
int i=0;
i <
Program.globalElementList.size( ); ++
i )
690 if( maxnodes <
Program.globalElementList[
i ].size( ) )
691 maxnodes =
Program.globalElementList[
i ].size( );
695 ofs <<
"CELLS " <<
Program.globalElementList.size( ) <<
" " <<
Program.globalElementList.size( )*( maxnodes+1) <<
"\n";
696 for(
int i=0;
i <
Program.globalElementList.size( ); ++
i )
698 ofs <<
Program.globalElementList[
i ].size( ) <<
" ";
699 for(
int j=0;
j <
Program.globalElementList[
i ].size( ); ++
j )
700 ofs <<
Program.globalElementList[
i ][
j ]<<
" ";
705 ofs <<
"CELL_TYPES " <<
Program.globalElementList.size( ) << std::endl;
706 for(
int i=0;
i <
Program.globalElementList.size( ); ++
i )
709 if(
Program.globalElementList[
i ].size( ) == 8 )
711 else if(
Program.globalElementList[
i ].size( ) == 4 )
714 std::cerr <<
"Undefined element type!\n";
715 std::cerr <<
"File: " << __FILE__ << std::endl;
716 std::cerr <<
"Line: " << __LINE__ << std::endl;
722 bool wroteHeader =
false;
723 for(
int i=0;
i <
Program.globalSolution.size( ); ++
i )
729 int N =
Program.globalNodeList.size( )/3;
734 ofs <<
"POINT_DATA " << N << std::endl;
740 ofs <<
"SCALARS " <<
Program.smdv[
i ].name <<
" double" << std::endl;
741 ofs <<
"LOOKUP_TABLE default\n";
745 ofs <<
"VECTORS " <<
Program.smdv[
i ].name <<
" double" << std::endl;
749 ofs <<
"TENSORS " <<
Program.smdv[
i ].name <<
" double" << std::endl;
752 for(
int j=0;
j < N; ++
j )
754 for(
int component=0; component < NC; ++component )
756 ofs <<
Program.globalSolution[
i ][
j*NC+component ] <<
" ";
768 for(
int i=0;
i <
Program.globalSolution.size( ); ++
i )
774 int N =
Program.globalElementList.size();
779 ofs <<
"CELL_DATA " << N << std::endl;
785 ofs <<
"SCALARS " <<
Program.smdv[
i ].name <<
" double" << std::endl;
786 ofs <<
"LOOKUP_TABLE default\n";
790 ofs <<
"VECTORS " <<
Program.smdv[
i ].name <<
" double" << std::endl;
794 ofs <<
"TENSORS " <<
Program.smdv[
i ].name <<
" double" << std::endl;
797 for(
int j=0;
j < N; ++
j )
799 for(
int component=0; component < NC; ++component )
801 ofs <<
Program.globalSolution[
i ][
j*NC+component ] <<
" ";
812 std::cout <<
"[DONE]\n";
822 void printVtk( std::vector< double > &vlist, std::vector< std::vector< int > > &elist )
825 ofs.open( std::string(
"global_mesh.vtk" ).c_str( ) );
827 if( !ofs.is_open( ) )
829 std::cerr <<
"Cannot write global VTK file! " << std::endl;
830 std::cerr <<
"File: " << __FILE__ << std::endl;
831 std::cerr <<
"Line: " << __LINE__ << std::endl;
835 ofs <<
"# vtk DataFile Version 3.0\n";
836 ofs <<
"Global Mesh Output" << std::endl;
838 ofs <<
"DATASET UNSTRUCTURED_GRID\n";
839 ofs <<
"POINTS " << vlist.size( )/3 <<
" double\n";
841 for(
int i=0;
i < vlist.size( )/3; ++
i )
843 ofs << vlist[
i*3 ] <<
" ";
844 ofs << vlist[
i*3+1 ] <<
" ";
845 ofs << vlist[
i*3+2 ] <<
"\n";
849 for(
int i=0;
i < elist.size( ); ++
i )
851 if( maxnodes < elist[
i ].size( ) )
852 maxnodes = elist[
i ].size( );
855 ofs <<
"CELLS " << elist.size( ) <<
" " << elist.size( )*( maxnodes+1) <<
"\n";
856 for(
int i=0;
i < elist.size( ); ++
i )
858 ofs << elist[
i ].size( ) <<
" ";
859 for(
int j=0;
j < elist[
i ].size( ); ++
j )
860 ofs << elist[
i ][
j ]<<
" ";
864 ofs <<
"CELL_TYPES " << elist.size( ) << std::endl;
865 for(
int i=0;
i < elist.size( ); ++
i )
868 if( elist[
i ].size( ) == 8 )
870 else if( elist[
i ].size( ) == 4 )
873 std::cerr <<
"Undefined element type!\n";
874 std::cerr <<
"File: " << __FILE__ << std::endl;
875 std::cerr <<
"Line: " << __LINE__ << std::endl;
897 assert(
Program.hasPane( meshPaneId ) );
898 assert( pointId >= 0 && pointId <
Program.meshes[
Program.getPaneIndex( meshPaneId ) ].nc.Size( ) );
899 assert( globalId >= 0 );
900 assert( hash != NULL );
903 hash ->
insert( meshPaneId, pointId, globalId );
905 int idx =
Program.getPaneIndex( meshPaneId );
908 assert( idx >= 0 && idx <
Program.numberOfPanes );
911 std::vector< std::pair< int, int > > connections;
912 Program.getPaneConnectivity( idx ) ->getPointConnectionPairs( pointId, connections );
914 for(
int i=0;
i < connections.size( ); ++
i )
917 int remotePaneId = connections[
i ].first;
918 int nodeIndex = connections[
i ].second;
921 assert(
Program.hasPane( remotePaneId ) );
924 int remotePoint =
Program.getPaneConnectivity(
Program.getPaneIndex( remotePaneId ) )->getSharedPointIdAt( meshPaneId, nodeIndex );
925 std::pair< int, int >
key = std::make_pair( remotePaneId, remotePoint );
929 assert( remotePoint >= 0 && remotePoint <
Program.meshes[
Program.getPaneIndex( remotePaneId ) ].nc.Size( ) );
930 assert(
Program.isNodeShared(
Program.getPaneIndex( remotePaneId ), remotePoint ) ==
true );
933 if( !hash ->exists( remotePaneId, remotePoint ) )
934 hash ->
insert( remotePaneId, remotePoint, globalId );
953 nodelist.push_back( x );
954 nodelist.push_back( y );
955 nodelist.push_back( z );
957 return( (nodelist.size( )/3)-1 );
976 std::cout <<
"Stitching the solution...";
980 assert( hash != NULL && ehash != NULL );
981 assert(
Program.globalNodeList.size( ) > 0 );
982 assert(
Program.globalElementList.size( ) > 0 );
983 assert( hash ->size( ) > 0 && ehash ->size( ) > 0 );
991 for(
int i=0;
i <
Program.globalSolution.size( ); ++
i )
998 std::cerr <<
"Code should not reach here!\n";
999 std::cerr <<
"File: " << __FILE__ << std::endl;
1000 std::cerr <<
"Line: " << __LINE__ << std::endl;
1006 for(
int paneidx=0; paneidx <
Program.numberOfPanes; ++paneidx )
1008 int paneId =
Program.paneIds[ paneidx ];
1011 assert(
Program.solution[ paneidx ].size( ) ==
Program.smdv.size( ) );
1014 for(
int dataidx=0; dataidx <
Program.solution[ paneidx].size( ); ++dataidx )
1018 assert( dataidx >= 0 && dataidx <
Program.solution[paneidx].size( ) );
1024 if(
Program.solution[ paneidx ][ dataidx ].size( ) == 0 )
1026 Program.solutionignore[ dataidx ] =
true;
1027 Program.globalSolution[ dataidx ].resize( 0 );
1032 int N =
Program.smdv[ dataidx ].ncomp;
1033 int NumNodes =
Program.meshes[ paneidx ].nc.Size( );
1036 assert(
Program.meshes[ paneidx ].nc.Size( )*N ==
Program.solution[ paneidx ][ dataidx ].size( ) );
1039 for(
int localNodeId=0; localNodeId < NumNodes; ++localNodeId )
1043 assert( hash ->exists( paneId, localNodeId ) );
1046 int globalId = hash ->
getGlobalId( paneId, localNodeId );
1047 for(
int component=0; component < N; ++component )
1049 int gidx = globalId*N+component;
1050 int lidx = localNodeId*N+component;
1053 assert( gidx >= 0 && gidx <
Program.globalSolution[ dataidx ].size( ) );
1054 assert( lidx >= 0 && lidx <
Program.solution[ paneidx ][ dataidx ].size( ) );
1057 Program.globalSolution[ dataidx ][ gidx ] =
Program.solution[ paneidx ][ dataidx ][ lidx ];
1068 if(
Program.solution[ paneidx ][ dataidx ].size( ) == 0 )
1070 Program.solutionignore[ dataidx ] =
true;
1071 Program.globalSolution[ dataidx ].resize( 0 );
1076 int N =
Program.smdv[ dataidx ].ncomp;
1077 int NumElements =
Program.meshes[ paneidx ].con.Nelem( );
1080 assert(
Program.meshes[ paneidx ].con.Nelem( )*N ==
Program.solution[ paneidx ][ dataidx ].size( ) );
1083 for(
int localElement=0; localElement < NumElements; ++ localElement )
1086 assert( ehash ->exists( paneId, localElement ) );
1089 int globalId = ehash ->
getGlobalId( paneId, localElement );
1090 for(
int component=0; component < N; ++component )
1092 int gidx = globalId*N+component;
1093 int lidx = localElement*N+component;
1096 assert( gidx >= 0 && gidx <
Program.globalSolution[ dataidx ].size( ) );
1097 assert( lidx >= 0 && lidx <
Program.solution[ paneidx ][ dataidx ].size( ) );
1100 Program.globalSolution[ dataidx ][ gidx ] =
Program.solution[ paneidx ][ dataidx ][ lidx ];
1111 std::cerr <<
"Code should not reach here!\n";
1112 std::cerr <<
"File: " << __FILE__ << std::endl;
1113 std::cerr <<
"Line: " << __LINE__ << std::endl;
1121 std::cout <<
"[DONE]\n";
1133 std::cout <<
"Stitching grids...";
1145 for(
int i=0;
i <
Program.meshes.size( ); ++
i )
1147 int meshPaneId =
Program.paneIds[
i ];
1151 assert( mesh != NULL );
1166 assert( ! hash.exists( meshPaneId,
node ) );
1169 hash.insert( meshPaneId,
node, globalId );
1172 else if( !hash.exists( meshPaneId,
node ) )
1185 for(
int element=0; element < mesh ->
con.
Nelem( ); ++element )
1187 int size = mesh ->
con.
Esize( element+1 );
1189 std::vector< int > elt;
1192 for(
int i=0;
i < size; ++
i )
1194 int localId = mesh ->
con.
Node( element+1,
i+1 )-1;
1197 assert( hash.exists( meshPaneId, localId ) );
1200 int globalId = hash.getGlobalId( meshPaneId, localId );
1201 elt[
i ] = globalId;
1204 Program.globalElementList.push_back( elt );
1205 int globalElementId =
Program.globalElementList.size( )-1;
1206 ehash.
insert( meshPaneId, element, globalElementId );
1212 std::cout <<
"[DONE]\n";
1214 std::cout <<
"Total number of nodes: " << (
Program.globalNodeList.size( )/3) << std::endl;
1215 std::cout <<
"Total number of elements: " <<
Program.globalElementList.size( ) << std::endl;
1238 assert(
Program.mask.size( ) == 0 );
1239 assert(
Program.numberOfPanes >= 1 );
1245 for(
int pane=0; pane <
Program.numberOfPanes; ++pane )
1248 Program.mask[ pane ].resize(
Program.meshes[ pane ].nc.Size( ),false );
1254 assert( pconPtr != NULL );
1258 std::vector< int > remotePaneIds;
1262 assert( pconPtr ->getNumberOfConnections( ) == remotePaneIds.size( ) );
1266 for(
int rmtPane=0; rmtPane < remotePaneIds.size( ); ++rmtPane )
1272 int id = remotePaneIds[ rmtPane ];
1279 for(
int i=0;
i < nodeList.size( ); ++
i )
1281 int nodeId = nodeList[
i ];
1284 assert( nodeId >= 0 && nodeId <
Program.mask[ pane ].size( ) );
1287 Program.mask[ pane ][ nodeId ] =
true;
1306 std::cout <<
"Getting the pane connectivity...";
1314 for(
int i=0;
i <
Program.numberOfPanes; ++
i )
1324 assert( pconn != NULL );
1335 assert( size >= 0 );
1339 Program.pconns[
i ].constructPaneConnectivityFromArray( pconn, size );
1344 std::cout <<
"[DONE]\n";
1358 for(
int m=0; m < meshes.size( ); ++m )
1361 std::ostringstream oss; oss.clear( );
1365 ofs.open( oss.str( ).c_str( ) );
1367 if( !ofs.is_open( ) )
1369 std::cerr <<
"Cannot write VTK file: " << oss.str( ) << std::endl;
1370 std::cerr <<
"File: " << __FILE__ << std::endl;
1371 std::cerr <<
"Line: " << __LINE__ << std::endl;
1375 ofs <<
"# vtk DataFile Version 3.0\n";
1376 ofs << oss.str( ) << std::endl;
1378 ofs <<
"DATASET UNSTRUCTURED_GRID\n";
1379 ofs <<
"POINTS " << meshes[ m ].nc.Size( ) <<
" double\n";
1381 for(
int i=1;
i <= meshes[ m ].nc.Size( ); ++
i )
1383 ofs << meshes[ m ].nc.x(
i ) <<
" ";
1384 ofs << meshes[ m ].nc.y(
i ) <<
" ";
1385 ofs << meshes[ m ].nc.z(
i ) <<
"\n";
1388 ofs <<
"CELLS " << meshes[ m ].con.Nelem( ) <<
" " << meshes[ m ].con.Nelem( )*9 <<
"\n";
1389 for(
int e=1; e <= meshes[ m ].con.Nelem( ); ++e )
1392 for(
int j=1;
j <= 8; ++
j )
1393 ofs << meshes[ m ].con.Node( e,
j )-1<<
" ";
1397 ofs <<
"CELL_TYPES " << meshes[ m ].con.Nelem( ) << std::endl;
1398 for(
int e=1; e <= meshes[ m ].con.Nelem( ); ++ e )
1401 ofs <<
"POINT_DATA " <<
Program.mask[ m ].size( ) << std::endl;
1402 ofs <<
"SCALARS SharedNodes double\nLOOKUP_TABLE default\n";
1403 for(
int i=0;
i <
Program.mask[ m ].size( ); ++
i )
1425 std::cout <<
"\n\n\n";
1426 std::cout <<
"Converting window to Unstructured mesh...";
1431 std::cout <<
"[DONE]\n";
1452 std::string newWindow(
"unstructured" );
1455 for(
int i=0;
i <
Program.meshes.size( ); ++
i )
1457 TAIL_UnstructuredMesh2Pane( newWindow,
Program.paneIds[
i ],
1485 std::string window = wName;
1489 std::cout <<
"Converting block-structured grids to unstructured...\n";
1494 std::cout <<
"[DONE]\n";
1500 std::cerr <<
"Unstructured grids are currently not supported!\n";
1501 std::cerr <<
"If your data-set consists of block structured grids make sure the -block-structured argument is supplied at the command line.\n";
1502 std::cerr <<
"File: " << __FILE__ << std::endl;
1503 std::cerr <<
"Line: " << __LINE__ << std::endl;
1504 std::cerr <<
"core dumping...\n";
1514 std::cout <<
"Writting VTK files...";
1516 std::cout <<
"[DONE]\n";
1548 std::string::size_type st = win_in.find_last_of(
'/');
1549 if (st != std::string::npos)
1550 win_in.erase(0, st+1);
1551 st = win_in.find_first_not_of(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
1552 if (st != std::string::npos)
1562 std::cout <<
"Reading by control file " <<
Program.
cntrlfile <<
" into window " << win_in <<
"...";
1565 win_in.c_str(),NULL,timeStr,&len );
1566 std::cout <<
"[DONE]\n";
1571 std::cout <<
"Reading HDF file(s) " <<
Program.
fileregx <<
" into window " << win_in <<
"...";
1574 win_in.c_str(),NULL,NULL,timeStr,&len );
1575 std::cout <<
"[DONE]\n";
1580 std::string win_out(
"win_out" );
1590 int *paneids = NULL;
1595 for(
int i=0;
i <
Program.numberOfPanes; ++
i )
1601 Program.paneIds2index.end( ) );
1607 delete [] paneids; paneids = NULL;
1610 assert(
Program.paneIds2index.size( ) ==
Program.numberOfPanes );
1624 Program.prgmname = std::string( argv[ 0 ] );
1633 for(
int i=1;
i < argc; ++
i )
1636 if( std::strcmp( argv[
i ],
"-g" ) == 0 )
1640 else if( std::strcmp( argv[ i ],
"-c" ) == 0 )
1645 else if( std::strcmp( argv[ i ],
"-o" ) == 0 )
1649 else if( std::strcmp( argv[ i ],
"-regex") == 0 )
1653 else if( std::strcmp( argv[ i ],
"-block-structured") == 0 )
1657 else if( std::strcmp( argv[ i ],
"-vtk" ) == 0 )
1661 else if( std::strcmp( argv[ i ],
"-h") == 0 )
1671 std::cerr <<
"Error parsing command line input!\n";
1684 std::cout <<
"HDF2PLT OPTIONS:\n";
1685 std::cout <<
"-regex \"{somestring}*.hdf\" : Specifies a set of hdf files\n";
1686 std::cout <<
"-g : Enables ghost node inclusion in the output file\n";
1687 std::cout <<
"-c {cntrlfile} : Specifies a control file to use\n";
1688 std::cout <<
"-block-structured: Indicates the the input files are block-structured grids which must be converted to unstructured format\n";
1689 std::cout <<
"-o {outputfile} : Specifies output file name. Note, do not append a file extension. A file extension will be automatically appended.\n";
1690 std::cout <<
"-vtk : Enables printing of VTK files as well.\n";
1691 std::cout <<
"-h : Prints this help menu.\n";
1692 std::cout <<
"Examples:\n";
1693 std::cout <<
"\thdf2plt -g -regex \"fluid*.hdf\" -block-structured -o output\n";
std::vector< Mesh::UnstructuredMesh > meshes
The list of grids to write.
void printVtk(std::vector< double > &vlist, std::vector< std::vector< int > > &elist)
This method prints the global grid in VTK file format.
int addToGlobalNodeList(const double x, const double y, const double z, std::vector< double > &nodelist)
This method adds the vertex with the given x,y,z coordinates to the global node list and returns the ...
std::map< int, int > paneIds2index
Maps the pane ids to the index in the corresponding vectors.
void parseArguments(int argc, char **argv)
Parses the command line arguments.
void COM_delete_window(const char *wname)
void int int REAL REAL * y
void updateHash(const int meshPaneId, const int pointId, const int globalId, MeshPointIdToGlobalIdMap *hash)
This method updates a MeshPointIdToGlobalIdMap hash with the mesh panes and point IDs mapping to the ...
This file contains the prototypes for Roccom API.
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
DataItemType
The data item type.
std::vector< PaneConnectivity > pconns
Inter-zone (pane) connectivity information.
The MeshPointIdToGlobalIdMap provides the functionality for mapping a pair consisting of (mesh_pane_i...
int getNumberOfNodesSharedWithRemotePane(const int remotePane)
Returns the number of nodes shared with a particular remote pane.
int COM_get_attribute_handle(const char *waname)
void COM_delete_attribute(const char *wa_str)
Delete an existing attribute.
std::vector< int > & getNodesSharedWithRemotePane(const int remotePane)
Returns a reference to the list of nodes shared with the remotePane.
std::string fileregx
File regular expression.
void getPaneConnectivity(const std::string &wName)
Computes the pane connectivity using Rocmap.
std::vector< SolnMetaData > smdv
The solution Metadata.
std::string cntrlfile
Control file string.
int getGlobalId(const int meshPaneId, const int meshPointId)
Returns the assigned global id to meshPointId of the mesh associated with the provided meshPaneId...
void insert(const int meshPaneId, const int meshPointId, const int globalId)
This method constructs a new key-pair for the meshPaneId and meshPointId which maps into globalId and...
std::string outputfile
The filename of the output file.
void stitchGrids()
This method will stitch the grids into a single, global grid.
std::vector< double > globalNodeList
The global node list.
void writeVtkFiles(std::vector< Mesh::UnstructuredMesh > &m)
Writes the set of meshes into separate VTK files that can be visualized with Paraview.
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
double & z(IndexType n=1)
void maskPoints()
This method is called from getPaneConnectivity() to mask the flag the mesh points that are shared on ...
void int int int REAL REAL REAL * z
int numberOfPanes
The number of panes, aka number of sub-domains.
IndexType & Node(IndexType e, IndexType n)
IndexType Esize(IndexType n) const
bool vtk
Writes vtk files.
std::vector< std::vector< std::vector< double > > > solution
The solution data.
std::string outputfile
Output file to write the file.
std::string cntrlfile
Filename of the control file.
bool readControlFile
Data is read from the control file.
std::string prgmname
The program name.
void COM_window_init_done(const char *w_str, int pane_changed=true)
void showUsage()
Prints usage and examples to STDOUT.
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
bool withGhost
A flag that specifies that ghost nodes need to be included.
void COM_clone_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Clone the subset of panes of another window of which the given pane attribute has value val...
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_call_function(const int wf, int argc,...)
bool blocks
Input data is block-structured grid.
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
int main(int argc, char *argv[])
void getPaneConnnectivity(const std::string &wname)
This method calls Rocmap to query the pane connectivity information for the given window...
std::vector< std::vector< int > > globalElementList
The global element list.
void writePlotFile()
Generates a single zone plot file from the stitched mesh.
bool readControlFile
A flag that specifies that a control file needs to be read.
The PaneConnectivity object holds the inter-zone connectivity of each grid.
void COM_init(int *argc, char ***argv)
void writeVtkData()
Writes the merged grid and its data in VTK UNSTRUCTURED_GRID file format.
std::string fileregx
Regular expression that describes the files that need to be read.
void printWindow(const std::string &windowName)
Prints the window with the given name.
void getRemotePaneIds(std::vector< int > &rmtpanes)
Returns the remote pane ids that are connected to this instance.
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
bool withGhost
Ghost nodes will be used.
std::vector< bool > solutionignore
Masks the data to be ignored.
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
std::string convertWindow(const std::string &wname)
Converts the window from block-structured format to unstructured format.
int COM_get_function_handle(const char *wfname)
std::string getWindow()
Loads the set of HDF files into a single window.
void stitchSolutionData(MeshPointIdToGlobalIdMap *hash)
This method will stitch the partitioned solution for the single grid.
double & y(IndexType n=1)
std::vector< std::vector< double > > globalSolution
Contains the global solution.
#define COM_EXTERN_MODULE(moduleName)
std::vector< int > paneIds
Array of paneIds.