Welcome to the Bug Tracking System for the DUNE project.
Due to increasing spam attacks, we had to disable the feature of anonymous bug reports. You will have to register before you are able to report a new bug.
In case you experience any problems, let us know at http://www.dune-project.org/mailinglists.html .
Due to increasing spam attacks, we had to disable the feature of anonymous bug reports. You will have to register before you are able to report a new bug.
In case you experience any problems, let us know at http://www.dune-project.org/mailinglists.html .
FS#658 - Cannot get GeometryGrid with DiscreteCoordFunction to work
Attached to Project:
Dune
Opened by Oliver Sander (sander) - Wednesday, 11 November 2009, 16:23 GMT+2
Last edited by Martin Nolte (nolte) - Wednesday, 21 April 2010, 08:26 GMT+2
Opened by Oliver Sander (sander) - Wednesday, 11 November 2009, 16:23 GMT+2
Last edited by Martin Nolte (nolte) - Wednesday, 21 April 2010, 08:26 GMT+2
|
DetailsI am not sure whether this is a bug or whether I am not understanding the GeometryGrid documentation right.
I am trying to deform a grid with a vector given the new position for each vertex. In the documentation it says that the deformation function must derive from either AnalyticalCoordFunction or from DiscreteCoordFunction. Well, my function is not analytic, so I try the second one. No example code is given but I try my best and produce the following deformation function template <class GridView> class DeformationFunction : public Dune :: DiscreteCoordFunction< double, dim, DeformationFunction<GridView> > { typedef DeformationFunction<GridView> This; typedef Dune :: DiscreteCoordFunction< double, dim, This > Base; public: DeformationFunction(const GridView& gridView, const double* deformedPosition) : gridView_(gridView), deformedPosition_(deformedPosition) {} template< class HostEntity > void evaluate ( const HostEntity &hostEntity, unsigned int corner, Dune::FieldVector<double,dim> &y ) const { const typename GridView::IndexSet& indexSet = gridView_.indexSet(); int idx = indexSet.subIndex(hostEntity, corner,dim); for (int i=0; i<dim; i++) y[i] = deformedPosition_[idx*dim + i]; } private: GridView gridView_; const double* deformedPosition_; }; Unfortunately, the code won't compile if I ask for a vertex position directly std::cout << deformedGrid.leafbegin<dim>()->geometry().corner(0); because then HostEntity apparently is a Codim<dim> entity for which subIndex is not declared. On the other hand, if I only query elements I can compile this, and the 'corner' parameter really takes on different values. That means the 'corner' parameter is not superfluous and I cannot use 'index' instead of 'subIndex'. I tried to read and understand the code, but it is completely undocumented... Full testcase attached, thank you for your help. |
This task depends upon
semi_lagrangian_inner_product...
Thanks,
Oliver
As to your problem: You're completely right, the subIndex method is what you intend, yet it cannot be called for arbitrary entities. There are 2 workarounds that I know of:
a) Use AlbertaGrid as host grid (it supports the method subIndex for all codimension entities -- if I didn't forget to commit this).
b) Try using YaspGrid or UGGrid (they only provide elements and vertices) and specialize the method for the 2 types of entities that might appear.
Actually this problem is what I meant when I asked for the extended subIndex method on the December 2008 developer meeting in Heidelberg.
You can also take a look at the CachedCoordFunction (which wraps an analytical function into a discrete one by caching the corner values).
I hope this helps you understand a bit better. As I said, demo implementations will follow as soon as possible.
Yours,
Martin
I hope this helps you understand the possibilities a bit better.
Thanks for the quick reply. I know that a) is no use, because my actual code uses Alberta. I just switched to SGrid for a concise test case. The problem is that you need to go through the interface class, which has subIndex only for codim==0. b) specializing sounds more feasible. I am only using vertices and elements anyways.
An example for CachedCoordFunction would be highly appreciated to, even though it will not help in my current problem (my deformation really is vertex-based).
I still have a question: how do store vertex data on an index set, anyway? As far as I see it, you need to index the entire hierarchy. So, if you are using AlbertaGrid and want a simple fix for this problem, use the hierarchic index set (I know it is not standard, but it does both, support your method -- no interface in the way -- and indexes the entire hierarchy). Some holes should not be your problem :-). At least, this is how the CacheCoordFunction does it.
Note: Using level indices for all levels on an AlbertaGrid is currently not a good idea (you will store a vector of the size of the hierarchic index set for each level).
By the way, using IdSets won't help either, since the subId-method you'd need is missing, too (even in AlbertaGrid). To be honest, I don't even know how to write a good example without restricting myself to AlbertaGrid due to this problem.
Do we need to discuss this on the meeting in November? Or can we simply agree that the "extended" sudIndex / subId methods are added to the interface?
Martin
template< int codim >
subId( Codim< codim >::Entity &e, int i, unsigned int subcodim ) const;
Currently, it is not tunnelled through the interface, though.