# [petsc-users] different periodicity per dof in DMDA?

Matthew Knepley knepley at gmail.com
Mon May 2 11:28:54 CDT 2022

```On Mon, May 2, 2022 at 12:23 PM Matteo Semplice <
matteo.semplice at uninsubria.it> wrote:

> Thanks!
>
> On 02/05/2022 18:07, Matthew Knepley wrote:
>
> On Mon, May 2, 2022 at 11:25 AM Matteo Semplice <
> matteo.semplice at uninsubria.it> wrote:
>
>> Hi.
>>
>> I am facing a PDE with 2 dofs per node in which one dof has periodic
>> b.c. in the x direction and the other one periodic b.c. in the y
>> direction. Is there a (possibly quick-and-dirty) solution to represent
>> this in a DM (not necessarily a DMDA)?
>>
>
> I am trying to understand what this means.
>
> It comes from a toy model for more complicated quantum field theory model
> that's hard for me to understand.
>
> Usually we think of periodicity as arising from the domain, not the field.
>
> I think it would be easiest to:
>
>   a) Use two different DMDA for the fields that "match up" where needed
>
> This is kind of what I was thinking at. So I would create two DMDA, then a
> DMComposite with the two and finally create Vecs and Matrices from the
> DMComposite?
>
> Yes. The drawback here is that DMDA will not help you make the proper
Jacobian. I'm not sure how important this is to you.

> If so, then how do I assemble matrices for linear systems? If I extract
> submatrices, I could use MatSetValuesStencil on diagonal blocks, but how
> about the off-diagonal ones? These latter would have rows/cols indexed by
> different DMDAs.
>
> Yes, you would need to manage it. Here is an example doing this:
https://petsc.org/main/src/snes/tutorials/ex28.c.html
I have never loved it, but sometimes it makes the most sense.

As a third option, you could manually construct the local to global map.
Periodicity is encoded here. However, this is pretty
intrusive.

Thanks,

Matt

> Matteo
>
>
> or
>
>   b) Use a DMStag since it sounds like these should live on horizontal and
> vertical edges
>
>   Thanks,
>
>      Matt
>
>
>> I understand the request it's strange, but I should add that we are
>> experimenting numerically with this toy model, so in fact the b.c. may
>> change in the future... just to stress once more that I am not after a
>> perfect solution, but anything that would at least allow parallel runs
>> with few processors would do for now.
>>
>>
>>      Matteo
>>
>>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
>
> --
> Prof. Matteo Semplice
> Università degli Studi dell’Insubria
> Dipartimento di Scienza e Alta Tecnologia – DiSAT
> Professore Associato
> Via Valleggio, 11 – 22100 Como (CO) – Italia
> tel.: +39 031 2386316
>
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their