int main( int argc, char ** argv )
{
   debug::enterTestMode();

   auto mpiManager = MPIManager::instance();
   mpiManager->initializeMPI( &argc, &argv );

   using blockforest::createUniformBlockGrid;
   auto blocks = createUniformBlockGrid(confBlockCount[0],confBlockCount[1],confBlockCount[2], //blocks
                                        confCells[0],confCells[1],confCells[2],    //cells
                                        real_c(0.7),                                       //dx
                                        false,                                      //one block per process
                                        false,false,false );                       //periodicity


   BlockDataID scalarFieldID = field::addToStorage<GhostLayerField<real_t,1> > ( blocks, "ScalarField" );

   // Geometry Initialization from config file
   using namespace geometry::initializer;

   auto geometryInitializationManager = shared_ptr<InitializationManager> ( new InitializationManager( blocks->getBlockStorage() ) );
   auto freeSurfaceInitializer        = shared_ptr<ScalarFieldFromGrayScaleImage> ( new ScalarFieldFromGrayScaleImage( *blocks, scalarFieldID ) );

   geometryInitializationManager->registerInitializer( "FreeSurfaceImage", freeSurfaceInitializer );

   {
      std::ofstream configFile ( "sampleImage.dat" );
      configFile << "Geometry  {   FreeSurfaceImage   {  \n";

      configFile << "file test.png; \n";
      configFile << "extrusionCoordinate 0;";
      configFile << "lowerExtrusionLimit 5;";
      configFile << "upperExtrusionLimit 10;";
      configFile << "xOffset 5; ";
      configFile << "yOffset -5; ";

      configFile << "}  } \n";
   }
   Config cfg;
   cfg.readParameterFile( "sampleImage.dat" );
   geometryInitializationManager->init( cfg.getBlock("Geometry") );


   if ( useGui )
   {
      SweepTimeloop timeloop ( blocks, 100 );
      GUI gui ( timeloop, blocks, argc, argv );
      gui.run();
   }

}
Ejemplo n.º 2
0
int main(int argc, char ** argv )
{
   walberla::Environment env ( argc, argv );
   debug::enterTestMode();

   try {

   auto mpiManager = MPIManager::instance();



   using blockforest::createUniformBlockGrid;


   WALBERLA_CHECK_EQUAL( mpiManager->numProcesses(), 4 );
   auto  blocks = createUniformBlockGrid( 4, 2, 1,       // blocks in x,y,z
                                          10u, 10u, 10u, // nr of cells per block
                                          1.0,           // dx
                                          uint_t(4), uint_t(1), uint_t(1)    // nr of processes in x,y,z
                                          );
   /*
   auto blocks = createUniformBlockGrid( 4,2,1,
                                         10u,10u,10u,
                                         1.0,
                                         false,              // one block per process
                                         false,false,false,  // periodicity
                                         false );
   */

   BlockDataID fieldID = blocks->addStructuredBlockData<ScalarField>( &createField, "MyField" );


   using namespace gather;


   typedef CellGatherPackInfo<ScalarField, CellInterval > CellGatherPI;

   // PackInfo across process P0 and P1
   CellInterval lowerLeftLine (   5, 5, 5,
                                 14, 5, 5 );
   auto dp1 = make_shared<CheckingDataProcessor>( lowerLeftLine );
   auto lowerLeftPI = make_shared<CellGatherPI> ( blocks, fieldID, lowerLeftLine, dp1 );


   // PackInfo across process P1 and P2
   CellInterval upperRightLine ( 15,15, 5,
                                 24,15, 5 );
   auto dp2 = make_shared<CheckingDataProcessor>( upperRightLine );
   auto upperRightPI = make_shared<CellGatherPI> ( blocks, fieldID, upperRightLine, dp2 );



   // Test MPI Gather
   MPIGatherScheme mpiGatherScheme( blocks->getBlockStorage() );
   mpiGatherScheme.addPackInfo( lowerLeftPI  );
   mpiGatherScheme.addPackInfo( upperRightPI );

   for(int i=0; i< 10; ++i )
      mpiGatherScheme();


   // Test File Gather
   FileGatherScheme fileGatherScheme( blocks->getBlockStorage() );
   fileGatherScheme.addPackInfo( lowerLeftPI  );
   fileGatherScheme.addPackInfo( upperRightPI );

   for(int i=0; i< 10; ++i )
      fileGatherScheme();

   }
   catch( std::exception & e )
   {
      std::cout<<  "Caught Exception: " <<std::endl;
      std::cout<<  e.what() <<std::endl;
      std::cout<<  "Description end.. rethrowing..." <<std::endl;
      throw e;
   }
   return 0;
}