<div dir="ltr">You can just set the coarse grid matrix/operator instead of using Galerkin.  If you have a shell (matrix free) P then you will need to create and set this yourself.  Our Galerkin requires a matrix P.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 7, 2016 at 9:32 AM, Lukasz Kaczmarczyk <span dir="ltr"><<a href="mailto:Lukasz.Kaczmarczyk@glasgow.ac.uk" target="_blank">Lukasz.Kaczmarczyk@glasgow.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> On 7 Mar 2016, at 14:21, Lawrence Mitchell <<a href="mailto:lawrence.mitchell@imperial.ac.uk">lawrence.mitchell@imperial.ac.uk</a>> wrote:<br>
><br>
> On 07/03/16 14:16, Lukasz Kaczmarczyk wrote:<br>
>><br>
>>> On 7 Mar 2016, at 13:50, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a><br>
>>> <mailto:<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>>> wrote:<br>
>>><br>
>>> On Mon, Mar 7, 2016 at 6:58 AM, Lukasz Kaczmarczyk<br>
>>> <<a href="mailto:Lukasz.Kaczmarczyk@glasgow.ac.uk">Lukasz.Kaczmarczyk@glasgow.ac.uk</a><br>
>>> <mailto:<a href="mailto:Lukasz.Kaczmarczyk@glasgow.ac.uk">Lukasz.Kaczmarczyk@glasgow.ac.uk</a>>> wrote:<br>
>>><br>
>>>    Hello,<br>
>>><br>
>>>    I run multi-grid solver, with adaptivity, works well, however It<br>
>>>    is some space for improving efficiency. I using hierarchical<br>
>>>    approximation basis, for which<br>
>>>    construction of interpolation operators is simple, it is simple<br>
>>>    injection.<br>
>>><br>
>>>    After each refinement level (increase of order of approximation<br>
>>>    on some element) I rebuild multigrid pre-conditioner with<br>
>>>    additional level. It is a way to add dynamically new levels<br>
>>>    without need of rebuilding whole MG pre-conditioner.<br>
>>><br>
>>><br>
>>> That does not currently exist, however it would not be hard to add,<br>
>>> since the MG structure jsut consists of<br>
>>> arrays of pointers.<br>
>>><br>
>>><br>
>>>    Looking at execution profile I noticed that 50%-60% of time is<br>
>>>    spent on MatPtAP function during PCSetUP stage.<br>
>>><br>
>>><br>
>>> Which means you are using a Galerkin projection to define the coarse<br>
>>> operator. Do you have a direct way of defining<br>
>>> this operator (rediscretization)?<br>
>><br>
>> Matt,<br>
>><br>
>><br>
>> Thanks for swift response. You are right, I using Galerkin projection.<br>
>><br>
>> Yes, I have a way to get directly coarse operator, it is some sub<br>
>> matrix of whole matrix. I taking advantage here form hierarchical<br>
>> approximation.<br>
>><br>
>> I could reimplement PCSetUp_MG to set the MG structure directly, but<br>
>> this probably not good approach, since my implementation which will<br>
>> work with current petsc version could be incompatible which  future<br>
>> changes in native MG data structures. The alternative option is to<br>
>> hack MatPtAP itself, and until petsc MG will use this, whatever<br>
>> changes you will make in MG in the future my code will work.<br>
><br>
> Why not provide a shell DM to the KSP that knows how to compute the<br>
> operators (and how to refine/coarsen and therefore<br>
> restrict/interpolate).  Then there's no need to use Galerkin coarse<br>
> grid operators, and the KSP will just call back to your code to create<br>
> the appropriate matrices.<br>
<br>
</div></div>Hello Lawrence,<br>
<br>
Thanks, it is good advice.<br>
I have already my DM shell, however I have not looked yet how make it in the context of MG. Now is probably time to do that.<br>
<br>
DM shell<br>
<a href="http://userweb.eng.gla.ac.uk/lukasz.kaczmarczyk/MoFem/html/group__dm.html" rel="noreferrer" target="_blank">http://userweb.eng.gla.ac.uk/lukasz.kaczmarczyk/MoFem/html/group__dm.html</a><br>
<br>
<br>
Regards,<br>
Lukasz</blockquote></div><br></div>