[Dune] Local Refinement in a DUNE Grid

Carsten Gräser graeser at math.fu-berlin.de
Wed Dec 29 22:43:56 CET 2010


Am 29.12.2010 11:47, schrieb S. Swayamjyoti:
> If you don't mind, can you please send me a demo code snippet on how to do
> the successive refinement? How do I access the leaf descendants after I have
> marked and refined once, I find difficulty in constructing the correct loop.
> My current code looks like this:
> 
> *for (ElementLeafIterator it = leafView.template begin<0>();
> it!=leafView.template end<0>(); ++it)
> {
> int indexi = mapper.map(*it);
>   if(indexi>135 && indexi<142) grid.mark(1,*it)
> }
>         grid.preAdapt();
>         grid.adapt();
>         grid.postAdapt();*
> 
> How do I assign ids to the leaf descendants of 135 < indexi < 142 elements,
> and how do I mark/refine them again?
You can not assign id's to elements. The grid provides local and global ids
by its Local- and GlobalIdSet. Suppose you have a leaf element e that you
want to refine twice. Then you can store its local or global id, mark it
and refine the grid.

In general the element e will not be a leaf element after refinement. Hence
you must iterate over all grids levels to find it. For each such element
you can use the HierarchicIterator to iterate over all descendents. If you've
found the leaf descendents you can mark them for the next refinement cycle.

For more details consider the class documentation of Grid, Entity<0,...>,
HierarchicIterator, and IdSet.

Best,
Carsten


> *
> *
> 
> On Wed, Dec 29, 2010 at 12:31 AM, Carsten Gräser
> <graeser at math.fu-berlin.de>wrote:
> 
>> Dear Swayam,
>>
>>
>> Am 29.12.2010 00:23, schrieb S. Swayamjyoti:
>>> If I know that a certain element can be refined n (n>1) times uniformly,
>> I
>>> can also tell that to* grid.mark( )* by calling *
>>> grid.mark(n, element). *
>>>
>>> Now, does this not hold true for UGGrid? Because when I try to mark my
>> grid
>>> by grid.mark(4, *it), I get an error while execution (not during
>>> compilation) saying,
>>>
>>> *DUNE ERROR: GridError: UGGrid only supports refCount values -1, 0, and 1
>>> for mark( )!
>>> *
>>> Is it not implemented for UGGrid or is there a work-a-round?
>> it is as the error message says: No, it's not supported by UGGrid.
>>
>> *The workaround is to do several refinement successive refinements
>> of the grid. You could e.g. store ids of the elements you want to
>> refine more then once, refine the grid and then mark all leaf
>> descendants of the elements the these ids and refine again.*
>>
>> Best,
>> Carsten




More information about the Dune mailing list