[petsc-users] Questions about the PetscDSSetResidual and Nedelec element.

Matthew Knepley knepley at gmail.com
Wed Apr 5 10:28:34 CDT 2023


On Wed, Apr 5, 2023 at 11:23 AM neil liu <liufield at gmail.com> wrote:

> Thanks a lot, Matt. I indeed did some research using Hcurl Nedelec element
> to solve 3D maxwell equations. I didn't consider too much math related to
> Nedelec element (P and P minus). That is why I would like some references
> from you.
>
> Could you please direct me the source code defining the Hdiv basis
> functions?
>

This is what I use for RT1-P0 on quadrilaterals, with fields names "phi"
and "q",

  # RT1-P0 on quads
  testset:
    args: -dm_plex_simplex 0 -dm_plex_box_bd periodic,none
-dm_plex_box_faces 3,1 \
          -dm_plex_box_lower 0,-1 -dm_plex_box_upper 6.283185307179586,1\
          -phi_petscspace_degree 0 \
          -phi_petscdualspace_lagrange_use_moments \
          -phi_petscdualspace_lagrange_moment_order 2 \
          -q_petscfe_default_quadrature_order 1 \
          -q_petscspace_type sum \
          -q_petscspace_variables 2 \
          -q_petscspace_components 2 \
          -q_petscspace_sum_spaces 2 \
          -q_petscspace_sum_concatenate true \
          -q_sumcomp_0_petscspace_variables 2 \
          -q_sumcomp_0_petscspace_type tensor \
          -q_sumcomp_0_petscspace_tensor_spaces 2 \
          -q_sumcomp_0_petscspace_tensor_uniform false \
          -q_sumcomp_0_tensorcomp_0_petscspace_degree 1 \
          -q_sumcomp_0_tensorcomp_1_petscspace_degree 0 \
          -q_sumcomp_1_petscspace_variables 2 \
          -q_sumcomp_1_petscspace_type tensor \
          -q_sumcomp_1_petscspace_tensor_spaces 2 \
          -q_sumcomp_1_petscspace_tensor_uniform false \
          -q_sumcomp_1_tensorcomp_0_petscspace_degree 0 \
          -q_sumcomp_1_tensorcomp_1_petscspace_degree 1 \
          -q_petscdualspace_form_degree -1 \
          -q_petscdualspace_order 1 \
          -q_petscdualspace_lagrange_trimmed true \

  Thanks,

     Matt


> Thanks,
>
> On Wed, Apr 5, 2023 at 11:16 AM Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Wed, Apr 5, 2023 at 10:36 AM neil liu <liufield at gmail.com> wrote:
>>
>>> Thanks, Matt.
>>> When you said "P and P minus space" , do you have some references about
>>> this terminology to build the Hdiv and Hcurl for triangles or tetrahedra?
>>>
>>
>> The canonical reference is
>> https://www-users.cse.umn.edu/~arnold//papers/acta.pdf but that was hard
>> to understand for me. There must
>> be a better reference but I do not know it.
>>
>>   Thanks,
>>
>>      Matt
>>
>>
>>> On Wed, Apr 5, 2023 at 10:12 AM Matthew Knepley <knepley at gmail.com>
>>> wrote:
>>>
>>>> On Wed, Apr 5, 2023 at 10:00 AM neil liu <liufield at gmail.com> wrote:
>>>>
>>>>> Thanks, Matt.
>>>>> 1) You mentioned that "PETSc calculates u_x, given the PetscFE and the
>>>>> coefficients (and the geometry).".
>>>>> Could you please direct me the source code that calculates u_x ?
>>>>>
>>>>
>>>>
>>>> https://gitlab.com/petsc/petsc/-/blob/main/src/dm/dt/fe/interface/fe.c#L2124
>>>>
>>>>
>>>>> 2) Yes. Raviart-Thomas is one type of Nedelec element (Hdiv also
>>>>> called divergence conforming). Do you support Hcurl (curl conforming)
>>>>> Nedelec element ?
>>>>>
>>>>
>>>> Yes, you make them in the same way using the P and P^- spaces.
>>>>
>>>>   Thanks,
>>>>
>>>>       Matt
>>>>
>>>>
>>>>> On Tue, Apr 4, 2023 at 10:59 AM Matthew Knepley <knepley at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> On Tue, Apr 4, 2023 at 10:45 AM neil liu <liufield at gmail.com> wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I am learning this case,
>>>>>>> https://petsc.org/release/src/snes/tutorials/ex62.c.html
>>>>>>> . And try to make myself familiar with the FEM (PetscFE) there.
>>>>>>> Then I have several questions.
>>>>>>> 1)  PetscDSSetResidual
>>>>>>> <https://petsc.org/release/manualpages/DT/PetscDSSetResidual/>,
>>>>>>> For example, line 291,  PetscCall
>>>>>>> <https://petsc.org/release/manualpages/Sys/PetscCall/>(
>>>>>>> PetscDSSetResidual
>>>>>>> <https://petsc.org/release/manualpages/DT/PetscDSSetResidual/>(ds,
>>>>>>> 0, f0_quadratic_u, f1_u)), here, f0_quadratic_u and f1_u is
>>>>>>> function pointers. Where have the input parameter for these functions been
>>>>>>> calculated, e.g., u_x.
>>>>>>>
>>>>>>
>>>>>> Line 291 sets callback functions. These functions are actually called
>>>>>> in the loop over the mesh which calculates the residual.
>>>>>> PETSc calculates u_x, given the PetscFE and the coefficients (and the
>>>>>> geometry).
>>>>>>
>>>>>>
>>>>>>> If I want to check the values of these parameters before line 291,
>>>>>>> how to print that ?
>>>>>>>
>>>>>>
>>>>>> I output many thing with -dm_plex_print_fem 5, but I am not sure if I
>>>>>> print out the field jet. It would be easy to add.
>>>>>>
>>>>>>
>>>>>>> 2) Does PetscFE support Nedelec element? Will it be painful to add
>>>>>>> these modules myself ?
>>>>>>>
>>>>>>
>>>>>> What kind? I think we support them, but have no tests. Take a look at
>>>>>> our support for Raviart-Thomas
>>>>>>
>>>>>>
>>>>>> https://gitlab.com/petsc/petsc/-/blob/main/src/dm/dt/dualspace/impls/lagrange/tutorials/ex1.c#L78
>>>>>>
>>>>>> and see a use case here
>>>>>>
>>>>>>
>>>>>> https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex24.c
>>>>>>
>>>>>>   Thanks,
>>>>>>
>>>>>>      Matt
>>>>>>
>>>>>>
>>>>>>> Thanks ,
>>>>>>>
>>>>>>> Xiaodong
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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/>
>>>>>>
>>>>>
>>>>
>>>> --
>>>> 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/>
>>>>
>>>
>>
>> --
>> 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/>
>>
>

-- 
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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230405/42dd75f1/attachment-0001.html>


More information about the petsc-users mailing list