Hi Peter,

I just used your PR as a patch in my candi-deal-ii setup, and I am happy to 
report that indeed the bug was solved, thanks a lot for your reactivity! If 
you want to further simplify the new test in your PR, I think the 
AffineConstraints object is not needed.

Now I just need to investigate why I get terrible performance (in terms of 
solver iteration) with my multigrid preconditioner when there is periodic 
BCs, probably an implementation problem on my side.

Step-75 uses hp-adaptivity, right? I am really not familiar with this, I 
think I will already try first to make things work correctly with adaptive 
mesh. But definitely, I am already extremely impressed with Matrix-Free 
performance: back in 2016 I wrote a code using matrix-based minimization of 
a simpler version of my free energy functional (unit-normed 3D solution 
field, I think I have two papers listed in the dealii publication list), 
and my new (and more complex) matrix-free code is actually much faster than 
the old one, even without multigrid (the old one was using AMG, so maybe 
not optimal)! 

Best

Guilhem

On Friday, 3 September 2021 at 10:29:46 UTC+2 peterrum wrote:

> Hi Guilhem,
>
> Thanks for reporting the bug and providing a failing test. I have opened a 
> PR (hopefully) fixing the issue (
> https://github.com/dealii/dealii/pull/12738) and simplified your code a 
> bit (since the issue was not related to MatrixFree). Maybe you could verify 
> that it indeed works for you!?
>
> Looking forward to your result you will obtain with MatrixFree! If you 
> want you can also checkout the new global-coarsening multigrid 
> infrastructure as shown in step-75.
>
> PM
>
> On Thursday, 2 September 2021 at 18:14:23 UTC+2 [email protected] wrote:
>
>> Dear deal-ii users and developers, 
>>
>> I am currently implementing a code that minimizes an energy functional 
>> depending on a traceless symmetric tensor (5D solution) for liquid crystal 
>> physics. The physics details matters not, I will just mention that I am 
>> using a combination of trust-region Newton iterations with a Truncated 
>> Conjugate Gradient (TCG) solver and matrix-free approach with multigrid 
>> preconditioning. This works exceedingly well for simple problems with 
>> Dirichlet boundary conditions, and I must say I am very impressed by the 
>> quality and efficiency of the dealii library and the excellent 
>> documentation, so a big thanks to all the developers! 
>>
>> However, I have a problem when I want to use periodic boundary conditions 
>> together with matrix-free multigrid preconditioning (it works fine with 
>> matrix-free but no preconditioner). Specifically, the problem arises when I 
>> try to use the method MGTransferMatrixFree::interpolate_to_mg, that allows 
>> me to transfer the solution of my problem at each level of the 
>> triangulation (where it is further used in the calculation of the system 
>> matrix at this level, which in my case corresponds to the hessian of the 
>> free energy functional, but I think that it is irrelevant for the problem I 
>> have).
>>
>> Basically, this method tries to access an element of a distributed vector 
>> that is not stored on the current MPI process, so I get an exception raised 
>> by LinearAlgebra::distributed::Vector. If I use Dirichlet BCs instead of 
>> periodic ones, the problem goes away. So it seems to be a problem with the 
>> way that the vectors of my problem are partitioned when I include periodic 
>> BCs. To illustrate this problem, I am attaching a MWE that shows how I 
>> setup matrix-free and multigrid objects with periodic BCs, and raises the 
>> same error as in my main code. I am using deal.II v9.3 on an archlinux 
>> distribution.
>>
>> I have looked at all the tutorials related to matrix-free and multigrid 
>> objects (this is how I wrote the base program in the first place), but was 
>> not able to find a solution on my own. I have tried various way of 
>> specifying the AffineConstraints objects for the level matrix-free objects, 
>> but none worked out. I also tried dummy AffineConstraints like in step 59 
>> which uses periodic faces, but this does not work, so I guess this is is 
>> specific to FE_DGQ (whereas I am using FE_Q spaces). I must do something 
>> wrong because it works so well without periodic BCs, so if anyone has an 
>> idea this would be great :) I am happy to provide any additional details 
>> that you would deem important.
>>
>> Best regards,
>>
>> Guilhem
>>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/899f6079-2bd8-4856-9725-f00512f36a7en%40googlegroups.com.

Reply via email to