[Dune] Creating a Grid

Jö Fahlke jorrit at jorrit.de
Mon Dec 27 12:21:54 CET 2010


Am Mon, 27. Dec 2010, 10:32:39 +0000 schrieb Andreas Dedner:
> Perhaps if you encounter an error like the one below you should have
> a look what
> the standard C++ shared_ptr is all about because your problem is in
> this case not
> understanding dune but understanding standard c++.

While Andreas' statement is correct and points in the right direction, it is
not very specific, so let me narrow that down a bit:

> On 12/27/2010 07:49 AM, Alex Evanovic wrote:
> >Also, when I try to create a structured UGGrid, I am able to
> >create it, but when I try to visualize it with the lines,
> >
> >VTKWriter<GridType::LeafGridView> vtkWriter(grid.leafView());
> >vtkWriter.write("my_filename");
> >
> >I get the following error.
> >
> >*error: ‘class std::shared_ptr<Dune::UGGrid<3> >’ has no member
> >named ‘leafView’*

The problem is, that the variable "grid" is not actually the grid but a
pointer to the grid.  To access the grid you have to dereference it first,
like this: "*grid".  To access the member, you can then use the "." operator:
"(*grid).leafView()".  Since this is pretty common, there is also a shorthand
notation: "grid->leafView()".

> >How can I resolve the above error? Also, I need help to create an
> >*unstructured* UGGrid, that is, without the StructuredGridFactory
> >class. Can someone please help me out with this?

Well, you'll have to use some other tool to actually create the mesh, Dune
cannot do that for you.  And I'm sorry, but I don't actually know of any mesh
generator for cubic meshes -- you'll have to google yourself.  Make sure the
mesh generator can produce one of the file formats understood by Dune -- that
is either .dgf (Dune Grid Format -- you are unlikely to find such a thing) or
.msh (the file format of gmsh -- I'm not sure wether cubes are supported in
the dune-reader for that format, however).  You'll have to use either the
DGFParser (note that the name of the class is GridPtr), or the GmshReader.
Look in the class documentation at
<http://www.dune-project.org/doc/doxygen.html> for the includes you need.

If you cannot find a mesh generator that can export to a file format
understood by dune, you can try to write a conversion program.  Mesh file
formats are often text-based and usually pretty simple, so this should not be
too difficult.  Or you can try to write a file reader for Dune using the
GridFactory.

Bye,
Jö.

-- 
Der Horizont vieler Menschen ist ein Kreis mit Radius Null - und das
nennen sie ihren Standpunkt.
-- A. Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20101227/c308d8f6/attachment.sig>


More information about the Dune mailing list