"Fossies" - the Fresh Open Source Software Archive

Member "dune-grid-howto-2.7.0/gettingstarted.cc" (20 Dec 2019, 1373 Bytes) of package /linux/misc/dune/dune-grid-howto-2.7.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gettingstarted.cc" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.6.0_vs_2.7.0.

    1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
    2 // vi: set et ts=4 sw=2 sts=2:
    3 
    4 #include <config.h>           // file generated by CMake  /*@\label{gs:inc0}@*/
    5 #include <array>
    6 #include <memory>
    7 #include <dune/common/parallel/mpihelper.hh> // include mpi helper class
    8 #include <dune/grid/yaspgrid.hh> // load Yasp grid definition
    9 #include <dune/grid/common/gridinfo.hh> // definition of gridinfo /*@\label{gs:inc1}@*/
   10 
   11 int main(int argc, char **argv)
   12 {
   13   // initialize MPI, finalize is done automatically on exit
   14   Dune::MPIHelper::instance(argc,argv);
   15 
   16   // start try/catch block to get error messages from dune
   17   try{
   18     // make a grid
   19     const int dim=3;                                     /*@\label{gs:dim}@*/
   20     typedef Dune::YaspGrid<dim> GridType;                /*@\label{gs:gridtype}@*/
   21     Dune::FieldVector<double,dim> length(1.0);           /*@\label{gs:par0}@*/
   22     std::array<int,dim> elements;
   23     std::fill(elements.begin(), elements.end(), 4);      /*@\label{gs:par1}@*/
   24     GridType grid(length,elements);                      /*@\label{gs:grid}@*/
   25 
   26     // print some information about the grid
   27     Dune::gridinfo(grid);
   28   }
   29   catch (std::exception & e) {
   30     std::cout << "ERROR: " << e.what() << std::endl;
   31     return 1;
   32   }
   33   catch (...) {
   34     std::cout << "Unknown ERROR" << std::endl;
   35     return 1;
   36   }
   37 
   38   // done
   39   return 0;
   40 }