[Dune] ANN and parameters

Dragan Vidovic vitkecar at gmail.com
Thu Nov 19 10:07:34 CET 2009


Dear all,

I have deployed the Approximate Nearest Neighbor library
(http://www.cs.umd.edu/~mount/ANN/) to make use of grid parameters
associated with elements trough a DGF file, as suggested in
http://www.dune-project.org/doc/doxygen/dune-grid-html/group__DuneGridFormatParser.html#PARAMETERS.
I would like to share this solution and I am sending you the patch for
dgfparser.hh.

To conserve memory and save time, I reorder the elParam vector during
the GridPtr construction process so that elParam[mapper(*it)] gives
the right parameters for the element *it, and then I delete the ANN
search structures. The parameters can be accessed trough the new
method

const std::vector< double > & elParameters (const unsigned int e) const

of GridPtr, where e is an array index returned by a
LeafMultipleCodimMultipleGeomTypeMapper.

As far as I can see, this operation does not invalidate anything in
dgfparser, and the old parameters method can still be used.

Several issues still exist. First, if the grid is modified, elParam is
not valid any more for the purpose of the elParameters method, and
should be interpolated by a piecewise constant interpolation in a
similar manner user arrays are treated. My code does not refine the
grid so I leave this unfinished. The old parameters method can still
be used after the refinement but it is very slow (and it should
probably be declared const).

Second, elParam is a vector of pairs of cell centres and parameters
vectors. I think that the cell centers are needed only for the nearest
neighbor search. Once elParam is reordered, these cell centres are
just taking up space, unless the old linear search is going to be
used. I didn't touch it because I didn't want to invalidate the old
parameters method, which won't be necessary once the first issue is
solved.

Third, to use this you need to install the ANN library and you need to
make it visible for Dune, and as I am not an expert in Autotools or in
Dune build system, i leave this to you.

Fourth, I use LeafMultipleCodimMultipleGeomTypeMapper in the GridPtr
construction process, while I guess the grid has only one level, so
maybe some other mapper would be more efficient? It seems to work fine
as it is.

Finally, I understand that array indices are used only for user arrays
in Dune, and that I should probably supply Entity instead, but this
solution is simple and it works for me. I hope someone else will also
find it useful.

Please feel free to do whatever you like with the patch - modify it or whatever.

Regards,

Dragan Vidovic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dgfparser.hh.ann.patch
Type: text/x-patch
Size: 3507 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20091119/9ae35cc7/attachment.bin>


More information about the Dune mailing list