[petsc-users] petsc4py/Plex createSection

Nicolas Barral nicolas.barral at math.u-bordeaux.fr
Sat Mar 28 12:06:27 CDT 2020


Thanks Matt!

with your explanation I realized it was actually one line above in the 
test. It seems that you can just specify the number of fields with:
self.plex.setNumFields(1)

Thanks,

-- 
Nicolas

On 28/03/2020 17:15, Matthew Knepley wrote:
> On Sat, Mar 28, 2020 at 10:04 AM Nicolas Barral 
> <nicolas.barral at math.u-bordeaux.fr 
> <mailto:nicolas.barral at math.u-bordeaux.fr>> wrote:
> 
>     All,
> 
>     I hope you're all safe and fine.
> 
>     My question may be due to me being rusty with dmplex, please forgive me
> 
> 
> Hi Nicolas! I hope everything is good Bordeaux despite the lockdown.
> 
> I think I know this one. I put in support for having fields that extend 
> over only part of the mesh, which some
> users really needed. This means that the DM has a description of fields 
> independent from the DS and Section.
> Thus we have to ask the DM how many fields it has when creating the 
> Section automatically now. I think you
> can fix this by first telling the DM that it has one field:
> 
>    field = PETSc.Object()
>    field.setName('potential')
>    dm.addField(field)
>    <createSection>
> 
>    Thanks,
> 
>       Matt
> 
>     if I missed something obvious...
>     In my Firedrake code, I had the following line for a 2D mesh
>      > section = createSection([1], [2, 0, 0], perm=mesh._plex_renumbering)
>     where mesh._plex_renumbering was an IS containing the mesh renumbering.
>     This created a nice section mapping the plex to a P1 field.
> 
>     However, with a recently installed Petsc/petsc4py, this does not work
>     anymore and results in a section pointing all points of the plex to 0.
>     I investigated a bit (although I don't understand the doc for this
>     function), and found a similar construction in petsc4py
>     test/test_dmplex.py in 1D:
>      > DIM = 1
>      > CELLS = [[0, 1], [1, 2]]
>      > COORDS = [[0.], [0.5], [1.]]
>      > COMP = 1
>      > DOFS = [1, 0]
>      >
>      > plex = PETSc.DMPlex().createFromCellList(DIM, CELLS, COORDS)
>      > section = plex.createSection([COMP], [DOFS])
>      > plex.view()
>      > section.view()
> 
>     This also results in an empty section (which makes the test fail when I
>     run it manually):
>      > PetscSection Object: 1 MPI processes
>      >   type not yet set
>      > Process 0:
>      >   (   0) dim  0 offset   0
>      >   (   1) dim  0 offset   0
>      >   (   2) dim  0 offset   0
>      >   (   3) dim  0 offset   0
>      >   (   4) dim  0 offset   0
> 
>     So, what did I miss ?
> 
>     Thanks,
> 
>     -- 
>     Nicolas
> 
> 
> 
> -- 
> 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
> 
> https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>


More information about the petsc-users mailing list