diff --git a/misc/examples/sizes.cc b/misc/examples/sizes.cc index 5d5d7c701dfd1fe043400f2bda846e01070e1d17..7fb864dae234b5880501209cce0e0b3249f30894 100644 --- a/misc/examples/sizes.cc +++ b/misc/examples/sizes.cc @@ -178,115 +178,117 @@ int main (int argc, char ** argv, const char ** envp) else filename = argv[ 1 ]; - int rank = 0; -#ifdef PARALLEL - MpAccessMPI mpa (MPI_COMM_WORLD); - rank = mpa.myrank(); -#endif - - if (argc < 3) - { - if( rank == 0 ) - cout << "Default level = "<< mxl << " choosen! \n"; - } - else - mxl = atoi(argv[2]); - - std::string macroname( filename ); - - if( rank == 0 ) - { - cout << "\n-----------------------------------------------\n"; - cout << "read macro grid from < " << macroname << " > !" << endl; - cout << "-----------------------------------------------\n"; - } - { + int rank = 0; #ifdef PARALLEL - GitterDunePll grid(macroname.c_str(),mpa); - grid.duneLoadBalance(); -#else - GitterDuneImpl grid(macroname.c_str()); + MpAccessMPI mpa (MPI_COMM_WORLD); + rank = mpa.myrank(); #endif - - //cout << "P[ " << rank << " ] : Grid generated! \n"; - grid.printsize(); - cout << "---------------------------------------------\n"; - - grid.printMemUsage(); - //int bla; - // cin >> bla; - for( int i = 0; i <= mxl; ++i ) + if (argc < 3) { - std::ostringstream ss; - ss << "out-" << ZeroPadNumber(i) << ".vtu"; - grid.tovtk( ss.str().c_str() ); - if( i < mxl ) - globalRefine(grid, 1); + if( rank == 0 ) + cout << "Default level = "<< mxl << " choosen! \n"; } - -#if 0 - checkRefinements( grid ); + else + mxl = atoi(argv[2]); - std::ofstream file( "file.out" ); - grid.duneBackup( file ); - file.close(); + std::string macroname( filename ); - /* + if( rank == 0 ) { - ObjectStream os ; - grid.duneBackup( os ); - - char* buffer = ObjectStream ::allocateBuffer( os.size() ); - os.read( buffer, os.size() ); - - std::ofstream obj( "obj.out" ); - const size_t size = os.size(); - obj.write( (const char *) &size, sizeof( size_t ) ); - obj.write( buffer, size ); - ObjectStream :: freeBuffer( buffer ); + cout << "\n-----------------------------------------------\n"; + cout << "read macro grid from < " << macroname << " > !" << endl; + cout << "-----------------------------------------------\n"; } - globalRefine(grid, mxl); - { - size_t size = 0; +#ifdef PARALLEL + GitterDunePll grid(macroname.c_str(),mpa); + grid.duneLoadBalance(); +#else + GitterDuneImpl grid(macroname.c_str()); +#endif - std::ifstream obj( "obj.out" ); - obj.read( (char *) &size, sizeof( size_t ) ); - char * buffer = ObjectStream ::allocateBuffer( size ); - obj.read( buffer, size ); - //ObjectStream :: freeBuffer( buffer ); + + //cout << "P[ " << rank << " ] : Grid generated! \n"; + grid.printsize(); + cout << "---------------------------------------------\n"; + + grid.printMemUsage(); + //int bla; + // cin >> bla; + for( int i = 0; i <= mxl; ++i ) + { + std::ostringstream ss; + ss << "out-" << ZeroPadNumber(i) << ".vtu"; + grid.tovtk( ss.str().c_str() ); + if( i < mxl ) + globalRefine(grid, 1); + } + +#if 0 + checkRefinements( grid ); - ObjectStream is; - is.clear(); - is.write( buffer, size ); + std::ofstream file( "file.out" ); + grid.duneBackup( file ); + file.close(); + /* { - ObjectStream copy( is ); - std::ofstream obj( "check.out" ); - const size_t size = copy.size(); + ObjectStream os ; + grid.duneBackup( os ); + + char* buffer = ObjectStream ::allocateBuffer( os.size() ); + os.read( buffer, os.size() ); + + std::ofstream obj( "obj.out" ); + const size_t size = os.size(); + obj.write( (const char *) &size, sizeof( size_t ) ); obj.write( buffer, size ); - //ObjectStream :: freeBuffer( buffer ); + ObjectStream :: freeBuffer( buffer ); } - }*/ - { - std::ifstream file( "file.out" ); + globalRefine(grid, mxl); + + { + size_t size = 0; + + std::ifstream obj( "obj.out" ); + obj.read( (char *) &size, sizeof( size_t ) ); + char * buffer = ObjectStream ::allocateBuffer( size ); + obj.read( buffer, size ); + //ObjectStream :: freeBuffer( buffer ); + + ObjectStream is; + is.clear(); + is.write( buffer, size ); + + { + ObjectStream copy( is ); + std::ofstream obj( "check.out" ); + const size_t size = copy.size(); + obj.write( buffer, size ); + //ObjectStream :: freeBuffer( buffer ); + } + }*/ + + { + std::ifstream file( "file.out" ); #ifdef PARALLEL - MpAccessMPI a (MPI_COMM_WORLD); - GitterDunePll grid2( file, a); + MpAccessMPI a (MPI_COMM_WORLD); + GitterDunePll grid2( file, a); #else - GitterDuneImpl grid2( file ); + GitterDuneImpl grid2( file ); #endif - grid2.printsize(); - } - //levelwalk(grid, mxl); - // globalCoarsening(grid, mxl); - //grid.printMemUsage(); - //cin.get(); + grid2.printsize(); + } + //levelwalk(grid, mxl); + // globalCoarsening(grid, mxl); + //grid.printMemUsage(); + //cin.get(); #endif + } } MPI_Finalize();