[Dune] Creating a Grid

Oliver Sander sander at mi.fu-berlin.de
Sat Dec 25 09:23:10 CET 2010


Hi Alex!
Great to hear you are using Dune.  A structured cube UGGrid is most easily
created using the StructuredGridFactory class (only available in the svn --
not in dune 2.0).  Here is a code snippet:

    const int dim = 3;
    typedef UGGrid<dim> GridType;

     FieldVector<double,dim> lowerLeft(0);
     FieldVector<double,dim> upperRight(1);
     array<unsigned int, dim> elements;
     std::fill(elements.begin(), elements.end(), 10);

     StructuredGridFactory<GridType> factory;
     shared_ptr<GridType> grid = factory.createSimplexGrid(lowerLeft, 
upperRight, elements);

You can write the grid into a VTK file using the following two lines:

    VTKWriter<GridType::LeafGridView> vtkWriter(grid->leafView());
    vtkWriter.write("my_filename");

BTW, what's your thesis about?

Best,
Oliver




Am 25.12.2010 08:52, schrieb Alex Evanovic:
> Hi,
>
> I am Master's student, new to DUNE. I have just started my Master's 
> Thesis using DUNE. I want to create a 3D grid of cubes using DUNE and 
> then visualize it using Paraview with the VTKWriter. But I have no 
> clue how to go about it. I read through the dune-grid-howto 
> documentation and also went through the DGF Parser and stuff. But I am 
> not sure which is the starting point.
>
> Can someone be kind enough to suggest me how to create and visualize a 
> grid in DUNE. Either by using the DGF Parser or with the UG Grid and 
> then visualize the grid?
>
> Thanks,
> Alex
>
>
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
>    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20101225/42a86a36/attachment.htm>


More information about the Dune mailing list