[petsc-users] Configure nested PCFIELDSPLIT with general index sets

Matthew Knepley knepley at gmail.com
Thu May 4 10:07:59 CDT 2017


On Thu, May 4, 2017 at 9:17 AM, Natacha BEREUX <natacha.bereux at gmail.com>
wrote:

> Dear Matt,
> I re-checked the master branch. To be precise, I downloaded the nightly
> tarball this morning (from http://ftp.mcs.anl.gov/pub/
> petsc/petsc-master.tar.gz)
> I am sure that the Fortran interface of DMSellSetCreateFieldDecomposition
> is missing.
> And it is quite tricky to add it. I have tried to write something in
> src/dm/impls/shell/ftn-custom/zdmshellf.c but I am not familiar with
> callbacks.
> Any help would be greatly appreciated!
>

I added PetscObjectCompose() to Fortran, so you could compose IS objects
when needed. Setting function pointers from Fortran is indeed
complicated and I do not yet know how to do it. Could you submit and Issue (
https://bitbucket.org/petsc/petsc/issues?status=new&status=open)
and someone will add this as soon as we have time?

In the meantime, it would not be hard to create the DMShell in C and have a
small C wrapper for your Fortran function to create the decomposition.

  Thanks,

    Matt


> Best regards
> Natacha
>
> On Fri, Apr 28, 2017 at 8:11 PM, Matthew Knepley <knepley at gmail.com>
> wrote:
>
>> On Fri, Apr 28, 2017 at 1:09 PM, Matthew Knepley <knepley at gmail.com>
>> wrote:
>>
>>> On Fri, Apr 28, 2017 at 11:48 AM, Natacha BEREUX <
>>> natacha.bereux at gmail.com> wrote:
>>>
>>>> Dear Matt,
>>>> Sorry for my (very) late reply.
>>>> I was not able to find the Fortran interface of
>>>> DMSellSetCreateFieldDecomposition in the late petsc-3.7.6 fortran (and
>>>> my code still fails to link).
>>>> I have the feeling that it is missing in the master branch.
>>>> And I was not able to get it on bitbucket either.
>>>> Is there a branch from which I can pull your commit  ?
>>>>
>>>
>>> I would either:
>>>
>>>   a) Use the 'next' branch
>>>
>>> or
>>>
>>>   b) wait until Monday for me to merge to 'master'
>>>
>>> This merge has been held up, but can now go forward.
>>>
>>
>> I just checked master. It was already merged. Please recheck your master.
>>
>>   Thanks,
>>
>>      Matt
>>
>>
>>>   Thanks,
>>>
>>>      Matt
>>>
>>>
>>>> Thans a lot for your help,
>>>> Natacha
>>>>
>>>> On Thu, Mar 30, 2017 at 9:25 PM, Matthew Knepley <knepley at gmail.com>
>>>> wrote:
>>>>
>>>>> On Wed, Mar 22, 2017 at 1:45 PM, Natacha BEREUX <
>>>>> natacha.bereux at gmail.com> wrote:
>>>>>
>>>>>> Hello Matt,
>>>>>> Thanks a lot for your answers.
>>>>>> Since I am working on a large FEM Fortran code, I have to stick to
>>>>>> Fortran.
>>>>>> Do you know if  someone plans to add this Fortran interface? Or may
>>>>>> be I could do it myself ? Is this particular interface very hard to add ?
>>>>>> Perhaps could  I mimic some other interface ?
>>>>>> What would you advise ?
>>>>>>
>>>>>
>>>>> I have added the interface in branch knepley/feature-fortran-compose.
>>>>> I also put this in the 'next' branch. It
>>>>> should make it to master soon. There is a test in
>>>>> sys/examples/tests/ex13f
>>>>>
>>>>>   Thanks,
>>>>>
>>>>>     Matt
>>>>>
>>>>>
>>>>>> Best regards,
>>>>>> Natacha
>>>>>>
>>>>>> On Wed, Mar 22, 2017 at 12:33 PM, Matthew Knepley <knepley at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> On Wed, Mar 22, 2017 at 10:03 AM, Natacha BEREUX <
>>>>>>> natacha.bereux at gmail.com> wrote:
>>>>>>>
>>>>>>>> Hello,
>>>>>>>> if my understanding is correct, the approach proposed by Matt and
>>>>>>>> Lawrence is the following :
>>>>>>>> - create a DMShell (DMShellCreate)
>>>>>>>> - define my own CreateFieldDecomposition to return the index sets I
>>>>>>>> need (for displacement, pressure and temperature degrees of freedom) :
>>>>>>>> myCreateFieldDecomposition(... )
>>>>>>>> - set it in the DMShell ( DMShellSetCreateFieldDecomposition)
>>>>>>>> - then sets  the DM in KSP context  (KSPSetDM)
>>>>>>>>
>>>>>>>> I  have some more questions
>>>>>>>> - I did not succeed in setting my own CreateFieldDecomposition in
>>>>>>>> the DMShell : link  fails with " unknown reference to «
>>>>>>>> dmshellsetcreatefielddecomposition_ ». Could it be a Fortran
>>>>>>>> problem (I am using Fortran)?  Is this routine available in PETSc  Fortran
>>>>>>>> interface ? \
>>>>>>>>
>>>>>>>
>>>>>>> Yes, exactly. The Fortran interface for passing function pointers is
>>>>>>> complex, and no one has added this function yet.
>>>>>>>
>>>>>>>
>>>>>>>> - CreateFieldDecomposition is supposed to return an array of dms
>>>>>>>> (to define the fields). I am not able to return such datas.  Do I return a
>>>>>>>> PETSC_NULL_OBJECT instead ?
>>>>>>>>
>>>>>>>
>>>>>>> Yes.
>>>>>>>
>>>>>>>
>>>>>>>> - do I have to provide something else to define the DMShell ?
>>>>>>>>
>>>>>>>
>>>>>>> I think you will have to return local and global vectors, but this
>>>>>>> just means creating a vector of the correct size and distribution.
>>>>>>>
>>>>>>>   Thanks,
>>>>>>>
>>>>>>>      Matt
>>>>>>>
>>>>>>>
>>>>>>>> Thanks a lot for your help
>>>>>>>> Natacha
>>>>>>>>
>>>>>>>> On Tue, Mar 21, 2017 at 2:44 PM, Natacha BEREUX <
>>>>>>>> natacha.bereux at gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Thanks for your quick answers. To be honest, I am not familiar at
>>>>>>>>> all with DMShells and DMPlexes. But since it is what I need, I am going to
>>>>>>>>> try it.
>>>>>>>>> Thanks again  for your advices,
>>>>>>>>> Natacha
>>>>>>>>>
>>>>>>>>> On Tue, Mar 21, 2017 at 2:27 PM, Lawrence Mitchell <
>>>>>>>>> lawrence.mitchell at imperial.ac.uk> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> > On 21 Mar 2017, at 13:24, Matthew Knepley <knepley at gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>> >
>>>>>>>>>> > I think the remedy is as easy as specifying a DMShell that has
>>>>>>>>>> a PetscSection (DMSetDefaultSection) with your ordering, and
>>>>>>>>>> > I think this is how Firedrake (http://www.firedrakeproject.org/)
>>>>>>>>>> does it.
>>>>>>>>>>
>>>>>>>>>> We actually don't use a section, but we do provide
>>>>>>>>>> DMCreateFieldDecomposition_Shell.
>>>>>>>>>>
>>>>>>>>>> If you have a section that describes all the fields, then I think
>>>>>>>>>> if the DMShell knows about it, you effectively get the same behaviour as
>>>>>>>>>> DMPlex (which does the decomposition in the same manner?).
>>>>>>>>>>
>>>>>>>>>> > However, I usually use a DMPlex which knows about my
>>>>>>>>>> > mesh, so I am not sure if this strategy has any holes.
>>>>>>>>>>
>>>>>>>>>> I haven't noticed anything yet.
>>>>>>>>>>
>>>>>>>>>> Lawrence
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> What most experimenters take for granted before they begin their
>>>>>>> experiments is infinitely more interesting than any results to which their
>>>>>>> experiments lead.
>>>>>>> -- Norbert Wiener
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> What most experimenters take for granted before they begin their
>>>>> experiments is infinitely more interesting than any results to which their
>>>>> experiments lead.
>>>>> -- Norbert Wiener
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> What most experimenters take for granted before they begin their
>>> experiments is infinitely more interesting than any results to which their
>>> experiments lead.
>>> -- Norbert Wiener
>>>
>>
>>
>>
>> --
>> What most experimenters take for granted before they begin their
>> experiments is infinitely more interesting than any results to which their
>> experiments lead.
>> -- Norbert Wiener
>>
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170504/ef5d42ff/attachment-0001.html>


More information about the petsc-users mailing list