// create, read simulation parameters

       void Wave1DSimulator::scan()

       {

          // bind our grid handle to a grid of one space dimension

          m_grid.rebind( new gridLattice());

             

          // Initialize our grid and read parameters from command line

          m_grid->scan( CmdLineArgs::read( "-grid","d=1 [0,1000] [1:100]"));                                                 

          cout << (*m_grid) << endl;    

 

          //

          // create new fields, the grid is shared among the fields

          //

 

          // attach a field of values on the grid

          std::get<0>(m_u).rebind( new scalarField( m_grid, "A"));

          std::get<1>(m_u).rebind( new scalarField( m_grid, "Q"));

          m_lambda.rebind( new scalarField( m_grid, "lambda_H"));

         

          // the wave-function can be specified on the command line

          // 1: Gaussian function

          // 2: ...

          int func = CmdLineArgs::read("-func", 1);

 

          // select the appropriate initial functions

          // describing the seabed and surface.

          if (func == 1)

          {

              m_H.rebind( new GaussianBell('H'));

              m_I.rebind( new GaussianBell('U'));

          }

          else

          {

              m_I.rebind( new Flat());   // we consider flat bed bathymetry

              m_H.rebind( new Step1D()); // we set DamBreak step function

          }

 

          // initialize the parameters in the functions.

          m_H->scan();  // water level according to dam-break parameters

          m_I->scan();  // initial surface (bed), which is flat bed

    

          // simulation time parameters

          m_tip.rebind( new TimePrm( 0, 0.,    // initial dt (time step)

          CmdLineArgs::read("-tstop", 22.5))); // fixed time step as default

 

          std::cout << "Finished the scan initialization\n";

       }

 

       // load depth function into lambda's array (that will yield faster

       // code since we then avoid virtual function calls every time we need

       // to evaluate lambda - now we just look the value up in an array):

       void Wave1DSimulator::setH()

       {

          // number of points in x-direction

          const int nx = m_grid->getMaxI(1); // dimension 1

          const double w_xmax = m_grid->xMax(1); // dimension 1

 

         

          // set reference this way we modify the original values

          RealNumArray<real>& w_lambda = m_lambda->values();

          // Remember that we are indexing from 1 and not 0

          for( int i = 1; i <= nx; i++)

          {

              real x = m_grid->getPoint(1,i); // x-coordinate

              // in flat topography water depth is the same as water level (z=0)

              w_lambda(i) = m_H->valuePt(x,0.); // x,y=0.,z=0. as default

          }

#if _DEBUG

              const real* w_data = w_lambda.getPtr();

              std::vector<real> w_dataCheck;

              w_dataCheck.reserve(w_lambda.size());

              std::copy( &w_data[0],w_data+w_lambda.size(),

                     std::ostream_iterator<double>(std::cout,"\n"));

             

              w_lambda.print1D(std::cout);

              std::vector<real> w_checkVec;

              w_lambda.to_stdVector(w_checkVec);

              assert( w_checkVec.size()==m_grid->getMaxI(1));

              std::cout << "Size are equal\n";

#endif

       }